|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.ms.api.spi.move;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.jinritemai.cloud.base.api.BaseRequest;
|
|
|
|
@ -10,9 +11,13 @@ import com.ms.api.common.R;
|
|
|
|
|
import com.ms.api.common.Ret;
|
|
|
|
|
import com.ms.api.common.SPIBaseService;
|
|
|
|
|
import com.ms.api.dto.move.GetProductInfoRequestDTO;
|
|
|
|
|
import com.ms.api.service.MoveSystemSourceCategoryService;
|
|
|
|
|
import com.ms.api.tool.DsJsonRequestTemplate;
|
|
|
|
|
import com.ms.api.common.UniqueKeyMultiValueMap;
|
|
|
|
|
import com.ms.dal.entity.MoveSystemSourceCategory;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.phprpc.util.AssocArray;
|
|
|
|
|
import org.phprpc.util.PHPSerializer;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
|
|
|
|
|
|
@ -37,6 +42,9 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
|
|
|
|
|
@Autowired
|
|
|
|
|
private DsJsonRequestTemplate dsJsonRequestTemplate;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MoveSystemSourceCategoryService moveSystemSourceCategoryService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BaseResponse<Ret> handle(BaseRequest<GetProductInfoRequestDTO> req) {
|
|
|
|
|
initHandle(req);
|
|
|
|
@ -62,6 +70,28 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
|
|
|
|
|
try {
|
|
|
|
|
res = dsJsonRequestTemplate.execute("/micro_move/get_product_info", params);
|
|
|
|
|
resObj = JSON.parseObject(res);
|
|
|
|
|
JSONObject product = resObj.getJSONObject("productInfo");
|
|
|
|
|
Long sourceCategoryId = product.getLong("1688cid");
|
|
|
|
|
log.info("productInfo:::"+sourceCategoryId.toString());
|
|
|
|
|
MoveSystemSourceCategory moveSystemSourceCategory = moveSystemSourceCategoryService.selectBySourceCategoryId(sourceCategoryId.toString());
|
|
|
|
|
if (!ObjectUtil.isEmpty(moveSystemSourceCategory)) {
|
|
|
|
|
Long moveSystemSourceCategoryId = moveSystemSourceCategory.getMoveSystemSourceCategoryId();
|
|
|
|
|
PHPSerializer p = new PHPSerializer();
|
|
|
|
|
String content = moveSystemSourceCategory.getMatchCategoryList();
|
|
|
|
|
AssocArray assocArray = (AssocArray) p.unserialize(content.getBytes());
|
|
|
|
|
Map assocMap = assocArrayToHash(assocArray);
|
|
|
|
|
List<Object> assocMapValues = new ArrayList<>(assocMap.values());
|
|
|
|
|
Map inMap = (Map) assocMapValues.get(assocMapValues.size() - 1);
|
|
|
|
|
List<String> assocMapKeys = new ArrayList<>(assocMap.keySet());
|
|
|
|
|
|
|
|
|
|
log.info("assocArrayToHash" + inMap.get("path"));
|
|
|
|
|
log.info("assocArrayToHash" + assocMapKeys.get(assocMapKeys.size() - 1));
|
|
|
|
|
product.put("ddCid", inMap.get("path"));
|
|
|
|
|
product.put("ddCategoryList", assocMapKeys.get(assocMapKeys.size() - 1));
|
|
|
|
|
} else {
|
|
|
|
|
product.put("ddCid", "");
|
|
|
|
|
product.put("ddCategoryList", "");
|
|
|
|
|
}
|
|
|
|
|
productInfo.add(resObj.getJSONObject("productInfo"));
|
|
|
|
|
log.info(res);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -84,4 +114,19 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
|
|
|
|
|
// ----结果返回----
|
|
|
|
|
return R.ok(Ret.success(result));
|
|
|
|
|
}
|
|
|
|
|
private static Map assocArrayToHash(AssocArray assocArray) {
|
|
|
|
|
HashMap hashMap = assocArray.toHashMap();
|
|
|
|
|
Map result = new HashMap();
|
|
|
|
|
for (Object key : hashMap.keySet()) {
|
|
|
|
|
if(hashMap.get(key) instanceof AssocArray) {
|
|
|
|
|
result.put(key.toString(),assocArrayToHash((AssocArray) hashMap.get(key)));
|
|
|
|
|
}else if(hashMap.get(key) instanceof byte[]) {
|
|
|
|
|
result.put(key.toString(),new String((byte[]) hashMap.get(key)));
|
|
|
|
|
}else {
|
|
|
|
|
result.put(key.toString(),hashMap.get(key));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.info(result + "result");
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|