|
|
@ -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");
|
|
|
|