铺货返回抖店类目

20230922-ljl-fixBug
cxxxxxxx详 1 year ago
parent 5545b32c43
commit aa40f4d096

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

@ -1,9 +1,7 @@
package com.ms.api;
import com.alibaba.fastjson.JSON;
import com.doudian.open.api.open_getAuthInfo.OpenGetAuthInfoRequest;
import com.doudian.open.api.open_getAuthInfo.OpenGetAuthInfoResponse;
import com.doudian.open.api.open_getAuthInfo.param.OpenGetAuthInfoParam;
import com.alibaba.fastjson.JSONObject;
import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
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.SPIBaseService;
import com.ms.api.dto.ItemDTO;
import com.ms.api.paas.RedisService;
import com.ms.api.service.MoveProductPublishQueueService;
import com.ms.api.tool.ImageTool;
import com.ms.api.tool.DsJsonRequestTemplate;
import com.ms.api.tool.SecurityTool;
import lombok.extern.slf4j.Slf4j;
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")
@Slf4j
public class TestSpiService extends SPIBaseService implements ExtensionServiceHandler<ItemDTO, String> {
@Autowired
MoveProductPublishQueueService moveProductPublishQueueService;
public class TestSpiService extends SPIBaseService implements ExtensionServiceHandler<ItemDTO, JSONObject> {
@Autowired
RedisService redisFIFOService;
private DsJsonRequestTemplate dsJsonRequestTemplate;
@Override
public BaseResponse<String> handle(BaseRequest<ItemDTO> req) {
try{
public BaseResponse<JSONObject> handle(BaseRequest<ItemDTO> req) {
initHandle(req);
ItemDTO itemDTO = req.getData();
String result = "";
if(itemDTO.getTitle().equals("authInfo")){
OpenGetAuthInfoRequest request = new OpenGetAuthInfoRequest();
OpenGetAuthInfoParam param = request.getParam();
param.setAuthId(shopId + "");
OpenGetAuthInfoResponse response = request.execute();
result = JSON.toJSONString(response);
System.out.println();
}
return R.ok(result);
}catch (Throwable e){
getAuthCode();
String res = null;
HashMap<String, Object> params = new HashMap<>();
params.put("platformItemId", SecurityTool.encodeByAES("3638605009077281167"));
params.put("sourceItemId", "1000090775");
params.put("authCode", authCode);
try {
res = dsJsonRequestTemplate.execute("/micro_move/add_platform_item_to_source_item_relation", params);
log.info("rrrr"+res);
} catch (Exception e) {
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.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -68,24 +65,21 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi
MoveSystemSourceCategory moveSystemSourceCategory = moveSystemSourceCategoryService.selectBySourceCategoryId(sourceCategoryId.toString());
if (!ObjectUtil.isEmpty(moveSystemSourceCategory)) {
Long moveSystemSourceCategoryId = moveSystemSourceCategory.getMoveSystemSourceCategoryId();
product.put("dsCid", moveSystemSourceCategoryId);
PHPSerializer p = new PHPSerializer();
// Map map = (Map) p.unserialize(moveSystemSourceCategory.getMatchCategoryList().getBytes());
// map = sortByKey(map);
// String content = moveSystemSourceCategory.getMatchCategoryList();
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:\"魅力热舞\";}";
// 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:\"童装/婴儿装/亲子装>帽子/围巾/口罩/手套/耳套/脚套>多件套 帽子、围巾、手套等组合\";}}";
log.info("dsCategoryList:::" + content);
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)));
}
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());
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"));
log.info(res);
@ -103,4 +97,20 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi
// ----结果返回----
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