Merge remote-tracking branch 'origin/master'

20230922-ljl-fixBug
qiushengjie 1 year ago
commit c9a98a9d1f

@ -4,6 +4,13 @@ import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.product_GetRecommendCategory.ProductGetRecommendCategoryRequest;
import com.doudian.open.api.product_GetRecommendCategory.ProductGetRecommendCategoryResponse;
import com.doudian.open.api.product_GetRecommendCategory.data.CategoryDetailsItem;
import com.doudian.open.api.product_GetRecommendCategory.param.ProductGetRecommendCategoryParam;
import com.doudian.open.api.shop_getShopCategory.ShopGetShopCategoryRequest;
import com.doudian.open.api.shop_getShopCategory.ShopGetShopCategoryResponse;
import com.doudian.open.api.shop_getShopCategory.param.ShopGetShopCategoryParam;
import com.jinritemai.cloud.base.api.BaseRequest; import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse; import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService; import com.jinritemai.cloud.base.api.ExtensionService;
@ -32,6 +39,7 @@ import org.phprpc.util.AssocArray;
import org.phprpc.util.PHPSerializer; import org.phprpc.util.PHPSerializer;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.lang.annotation.Retention;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -73,6 +81,9 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi
getAuthCode(); getAuthCode();
GetProductInfoRequestDTO fields = req.getData(); GetProductInfoRequestDTO fields = req.getData();
List<String> productIds = fields.getProductIds(); List<String> productIds = fields.getProductIds();
if (productIds.size() > 10) {
return R.ok(Ret.fail("最多支持20个商品"));
}
List<Object> productInfo = new ArrayList<>(); List<Object> productInfo = new ArrayList<>();
List<String> fetchFailIds = new ArrayList<>(); List<String> fetchFailIds = new ArrayList<>();
for (int i = 0; i < productIds.size(); i++) { for (int i = 0; i < productIds.size(); i++) {
@ -108,8 +119,56 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi
product.put("ddCategoryList", pathArr); product.put("ddCategoryList", pathArr);
} }
} else { } else {
product.put("ddCid", ""); ProductGetRecommendCategoryRequest request = new ProductGetRecommendCategoryRequest();
product.put("ddCategoryList", ""); ProductGetRecommendCategoryParam param = request.getParam();
param.setScene("category_infer");
param.setName(product.getString("title"));
ProductGetRecommendCategoryResponse response = request.execute();
List<CategoryDetailsItem> categoryDetails = response.getData().getCategoryDetails();
if (!ObjectUtil.isEmpty(categoryDetails) && categoryDetails.size() > 0) {
log.info(categoryDetails.get(0).toString());
CategoryDetailsItem categoryDetailsItem = categoryDetails.get(0);
List<Long> categoryIds = new ArrayList<>();
List<String> pathArr = new ArrayList<>();
if (categoryDetailsItem.getCategoryDetail().getFirstCid() != 0) {
categoryIds.add(categoryDetailsItem.getCategoryDetail().getFirstCid());
}
if (categoryDetailsItem.getCategoryDetail().getSecondCid() != 0) {
categoryIds.add(categoryDetailsItem.getCategoryDetail().getSecondCid());
}
if (categoryDetailsItem.getCategoryDetail().getFirstCid() != 0) {
categoryIds.add(categoryDetailsItem.getCategoryDetail().getFirstCid());
}
if (categoryDetailsItem.getCategoryDetail().getFourthCid() != 0) {
categoryIds.add(categoryDetailsItem.getCategoryDetail().getFourthCid());
}
if (!categoryDetailsItem.getCategoryDetail().getFirstCname().isEmpty()) {
pathArr.add(categoryDetailsItem.getCategoryDetail().getFirstCname());
}
if (!categoryDetailsItem.getCategoryDetail().getSecondCname().isEmpty()) {
pathArr.add(categoryDetailsItem.getCategoryDetail().getSecondCname());
}
if (!categoryDetailsItem.getCategoryDetail().getThirdCname().isEmpty()) {
pathArr.add(categoryDetailsItem.getCategoryDetail().getThirdCname());
}
if (!categoryDetailsItem.getCategoryDetail().getFourthCname().isEmpty()) {
pathArr.add(categoryDetailsItem.getCategoryDetail().getFourthCname());
}
ShopGetShopCategoryRequest shopRequest = new ShopGetShopCategoryRequest();
ShopGetShopCategoryParam shopParam = shopRequest.getParam();
shopParam.setCid(categoryIds.get(categoryIds.size() - 2));
ShopGetShopCategoryResponse shopReponse = shopRequest.execute();
if (!ObjectUtil.isEmpty(shopReponse.getData())) {
product.put("ddCid", categoryIds);
product.put("ddCategoryList", pathArr);
} else {
product.put("ddCid", "");
product.put("ddCategoryList", "");
}
} else {
product.put("ddCid", "");
product.put("ddCategoryList", "");
}
} }
// 处理价格 // 处理价格
Double price = product.getDoubleValue("jd_price"); Double price = product.getDoubleValue("jd_price");

@ -3,6 +3,14 @@ package com.ms.api.spi.move;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.product_GetRecommendCategory.ProductGetRecommendCategoryRequest;
import com.doudian.open.api.product_GetRecommendCategory.ProductGetRecommendCategoryResponse;
import com.doudian.open.api.product_GetRecommendCategory.data.CategoryDetail;
import com.doudian.open.api.product_GetRecommendCategory.data.CategoryDetailsItem;
import com.doudian.open.api.product_GetRecommendCategory.param.ProductGetRecommendCategoryParam;
import com.doudian.open.api.shop_getShopCategory.ShopGetShopCategoryRequest;
import com.doudian.open.api.shop_getShopCategory.ShopGetShopCategoryResponse;
import com.doudian.open.api.shop_getShopCategory.param.ShopGetShopCategoryParam;
import com.jinritemai.cloud.base.api.BaseRequest; import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse; import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService; import com.jinritemai.cloud.base.api.ExtensionService;
@ -73,6 +81,9 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
GetProductInfoRequestDTO fields = req.getData(); GetProductInfoRequestDTO fields = req.getData();
// List<String> sourceItemUrls = new ArrayList<>(); // List<String> sourceItemUrls = new ArrayList<>();
List<String> sourceItemUrls = fields.getSourceItemUrls(); List<String> sourceItemUrls = fields.getSourceItemUrls();
if (sourceItemUrls.size() > 10) {
return R.ok(Ret.fail("最多支持20个商品"));
}
// sourceItemUrls.add("https://detail.1688.com/offer/682805686164.html?spm=a2638t.b_90254924.bangdan-list.3.3872436cl59VWf&cosite=baidujj_pz&tracelog=p4p&_p_isad=1&clickid=3906df8adbe74c3faba6eefc496fa074&sessionid=3fa85d5fd57096560a3cfa71088c6e4a"); // sourceItemUrls.add("https://detail.1688.com/offer/682805686164.html?spm=a2638t.b_90254924.bangdan-list.3.3872436cl59VWf&cosite=baidujj_pz&tracelog=p4p&_p_isad=1&clickid=3906df8adbe74c3faba6eefc496fa074&sessionid=3fa85d5fd57096560a3cfa71088c6e4a");
// sourceItemUrls.add("https://detail.1688.com/offer/682805686164.html?spm=a2638t.b_90254924.bangdan-list.3.3872436cl59VWf&cosite=baidujj_pz&tracelog=p4p&_p_isad=1&clickid=3906df8adbe74c3faba6eefc496fa074&sessionid=3fa85d5fd57096560a3cfa71088c6e4a"); // sourceItemUrls.add("https://detail.1688.com/offer/682805686164.html?spm=a2638t.b_90254924.bangdan-list.3.3872436cl59VWf&cosite=baidujj_pz&tracelog=p4p&_p_isad=1&clickid=3906df8adbe74c3faba6eefc496fa074&sessionid=3fa85d5fd57096560a3cfa71088c6e4a");
List<Object> productInfo = new ArrayList<>(); List<Object> productInfo = new ArrayList<>();
@ -113,8 +124,56 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
product.put("ddCategoryList", pathArr); product.put("ddCategoryList", pathArr);
} }
} else { } else {
product.put("ddCid", ""); ProductGetRecommendCategoryRequest request = new ProductGetRecommendCategoryRequest();
product.put("ddCategoryList", ""); ProductGetRecommendCategoryParam param = request.getParam();
param.setScene("category_infer");
param.setName(product.getString("title"));
ProductGetRecommendCategoryResponse response = request.execute();
List<CategoryDetailsItem> categoryDetails = response.getData().getCategoryDetails();
if (!ObjectUtil.isEmpty(categoryDetails) && categoryDetails.size() > 0) {
log.info(categoryDetails.get(0).toString());
CategoryDetailsItem categoryDetailsItem = categoryDetails.get(0);
List<Long> categoryIds = new ArrayList<>();
List<String> pathArr = new ArrayList<>();
if (categoryDetailsItem.getCategoryDetail().getFirstCid() != 0) {
categoryIds.add(categoryDetailsItem.getCategoryDetail().getFirstCid());
}
if (categoryDetailsItem.getCategoryDetail().getSecondCid() != 0) {
categoryIds.add(categoryDetailsItem.getCategoryDetail().getSecondCid());
}
if (categoryDetailsItem.getCategoryDetail().getFirstCid() != 0) {
categoryIds.add(categoryDetailsItem.getCategoryDetail().getFirstCid());
}
if (categoryDetailsItem.getCategoryDetail().getFourthCid() != 0) {
categoryIds.add(categoryDetailsItem.getCategoryDetail().getFourthCid());
}
if (!categoryDetailsItem.getCategoryDetail().getFirstCname().isEmpty()) {
pathArr.add(categoryDetailsItem.getCategoryDetail().getFirstCname());
}
if (!categoryDetailsItem.getCategoryDetail().getSecondCname().isEmpty()) {
pathArr.add(categoryDetailsItem.getCategoryDetail().getSecondCname());
}
if (!categoryDetailsItem.getCategoryDetail().getThirdCname().isEmpty()) {
pathArr.add(categoryDetailsItem.getCategoryDetail().getThirdCname());
}
if (!categoryDetailsItem.getCategoryDetail().getFourthCname().isEmpty()) {
pathArr.add(categoryDetailsItem.getCategoryDetail().getFourthCname());
}
ShopGetShopCategoryRequest shopRequest = new ShopGetShopCategoryRequest();
ShopGetShopCategoryParam shopParam = shopRequest.getParam();
shopParam.setCid(categoryIds.get(categoryIds.size() - 2));
ShopGetShopCategoryResponse shopReponse = shopRequest.execute();
if (!ObjectUtil.isEmpty(shopReponse.getData())) {
product.put("ddCid", categoryIds);
product.put("ddCategoryList", pathArr);
} else {
product.put("ddCid", "");
product.put("ddCategoryList", "");
}
} else {
product.put("ddCid", "");
product.put("ddCategoryList", "");
}
} }
// 处理价格 // 处理价格
JSONObject skuMap = product.getJSONObject("skuMap"); JSONObject skuMap = product.getJSONObject("skuMap");

@ -275,7 +275,7 @@ public class PurchaseOrderUtil {
if (StrUtil.isNotBlank(dto.getDsSourcePlatform())) { if (StrUtil.isNotBlank(dto.getDsSourcePlatform())) {
params.setDsSourcePlatform(PurchaseOrderConst.getPurchasePlatformAndOrderDsTblMap().containsKey(dto.getDsSourcePlatform()) ? dto.getDsSourcePlatform() : PurchaseOrderConst.PURCHASE_PLATFORM1688_D_S); params.setDsSourcePlatform(PurchaseOrderConst.getPurchasePlatformAndOrderDsTblMap().containsKey(dto.getDsSourcePlatform()) ? dto.getDsSourcePlatform() : PurchaseOrderConst.PURCHASE_PLATFORM1688_D_S);
} }
log.info("searchDsOrderFilter params: " + JSONObject.toJSONString(params));
return params; return params;
} }

Loading…
Cancel
Save