Merge branch 'master' of codeup.aliyun.com:64d9c5feeceb191898f636d7/honor-dd-light-ds-java

20230922-ljl-fixBug
ljl 1 year ago
commit 2d18050d1c

@ -5,7 +5,7 @@ curl --location --request POST 'localhost:8080/base/cloud/spi' \
--data-raw '{ --data-raw '{
"appId":"7264840234423027259", "appId":"7264840234423027259",
"authId":"4463798", "authId":"4463798",
"method":"getProductInfoByProductId", "method":"testSpi",
"data":"{\"productIds\":[1000137090,588529442342]}" "data":"{\"productIds\":[1000137090,588529442342]}"
}' }'

@ -1,9 +1,7 @@
package com.ms.api; package com.ms.api;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.doudian.open.api.open_getAuthInfo.OpenGetAuthInfoRequest; import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.open_getAuthInfo.OpenGetAuthInfoResponse;
import com.doudian.open.api.open_getAuthInfo.param.OpenGetAuthInfoParam;
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;
@ -12,42 +10,39 @@ import com.ms.api.common.R;
import com.ms.api.common.Ret; import com.ms.api.common.Ret;
import com.ms.api.common.SPIBaseService; import com.ms.api.common.SPIBaseService;
import com.ms.api.dto.ItemDTO; import com.ms.api.dto.ItemDTO;
import com.ms.api.paas.RedisService; import com.ms.api.tool.DsJsonRequestTemplate;
import com.ms.api.service.MoveProductPublishQueueService; import com.ms.api.tool.SecurityTool;
import com.ms.api.tool.ImageTool;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
@ExtensionService("testSpi") @ExtensionService("testSpi")
@Slf4j @Slf4j
public class TestSpiService extends SPIBaseService implements ExtensionServiceHandler<ItemDTO, String> { public class TestSpiService extends SPIBaseService implements ExtensionServiceHandler<ItemDTO, JSONObject> {
@Autowired @Autowired
MoveProductPublishQueueService moveProductPublishQueueService; private DsJsonRequestTemplate dsJsonRequestTemplate;
@Autowired
RedisService redisFIFOService;
@Override @Override
public BaseResponse<String> handle(BaseRequest<ItemDTO> req) { public BaseResponse<JSONObject> handle(BaseRequest<ItemDTO> req) {
try{
initHandle(req); initHandle(req);
ItemDTO itemDTO = req.getData(); getAuthCode();
String result = ""; String res = null;
if(itemDTO.getTitle().equals("authInfo")){ HashMap<String, Object> params = new HashMap<>();
OpenGetAuthInfoRequest request = new OpenGetAuthInfoRequest(); params.put("platformItemId", SecurityTool.encodeByAES("3638605009077281167"));
OpenGetAuthInfoParam param = request.getParam(); params.put("sourceItemId", "1000090775");
param.setAuthId(shopId + ""); params.put("authCode", authCode);
OpenGetAuthInfoResponse response = request.execute(); try {
result = JSON.toJSONString(response); res = dsJsonRequestTemplate.execute("/micro_move/add_platform_item_to_source_item_relation", params);
System.out.println(); log.info("rrrr"+res);
} } catch (Exception e) {
return R.ok(result);
}catch (Throwable e){
e.printStackTrace(); e.printStackTrace();
return R.ok(e.getMessage()); log.error(e.getMessage());
} }
return R.ok(JSON.parseObject(res));
} }
} }

@ -19,10 +19,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.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -68,24 +65,21 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi
MoveSystemSourceCategory moveSystemSourceCategory = moveSystemSourceCategoryService.selectBySourceCategoryId(sourceCategoryId.toString()); MoveSystemSourceCategory moveSystemSourceCategory = moveSystemSourceCategoryService.selectBySourceCategoryId(sourceCategoryId.toString());
if (!ObjectUtil.isEmpty(moveSystemSourceCategory)) { if (!ObjectUtil.isEmpty(moveSystemSourceCategory)) {
Long moveSystemSourceCategoryId = moveSystemSourceCategory.getMoveSystemSourceCategoryId(); Long moveSystemSourceCategoryId = moveSystemSourceCategory.getMoveSystemSourceCategoryId();
product.put("dsCid", moveSystemSourceCategoryId);
PHPSerializer p = new PHPSerializer(); PHPSerializer p = new PHPSerializer();
// Map map = (Map) p.unserialize(moveSystemSourceCategory.getMatchCategoryList().getBytes()); String content = moveSystemSourceCategory.getMatchCategoryList();
// map = sortByKey(map); AssocArray assocArray = (AssocArray) p.unserialize(content.getBytes());
// String content = moveSystemSourceCategory.getMatchCategoryList(); Map assocMap = assocArrayToHash(assocArray);
String content ="a:10:{i:0;s:18:\"舞蹈(私教)\";i:1;s:5:\"Zumba\";i:2;s:12:\"完美塑造\";i:3;s:12:\"战斗有氧\";i:4;s:12:\"杠铃雕塑\";i:5;s:12:\"核心特训\";i:6;s:12:\"漫步舞林\";i:7;s:12:\"身体平衡\";i:8;s:12:\"高效冲击\";i:9;s:12:\"魅力热舞\";}"; List<Object> assocMapValues = new ArrayList<>(assocMap.values());
// String content ="a:2:{i:26953;a:2:{s:4:\"type\";s:6:\"manual\";s:4:\"path\";s:32:\"内衣裤袜>女士内衣>抹胸\";}i:24928;a:2:{s:4:\"type\";s:6:\"manual\";s:4:\"path\";s:112:\"童装/婴儿装/亲子装>帽子/围巾/口罩/手套/耳套/脚套>多件套 帽子、围巾、手套等组合\";}}"; Map inMap = (Map) assocMapValues.get(assocMapValues.size() - 1);
log.info("dsCategoryList:::" + content); List<String> assocMapKeys = new ArrayList<>(assocMap.keySet());
Object unserialize = p.unserialize(content.getBytes("utf-8"));//数据转格式
AssocArray array = (AssocArray) unserialize;
log.info("dsCategoryList:::" + array);
List<Object> listResult = new ArrayList<Object>();
for (int s = 0; s < array.size(); s++) {
log.info("arrayList:::" + array.toHashMap());
listResult.add(new String((byte[])array.get(s)));
}
product.put("dsCategoryList", listResult); 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")); productInfo.add(resObj.getJSONObject("productInfo"));
log.info(res); log.info(res);
@ -103,4 +97,20 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi
// ----结果返回---- // ----结果返回----
return R.ok(Ret.success(result)); 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;
}
} }

Loading…
Cancel
Save