|
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.kuaishou.merchant.open.api.KsMerchantApiException;
|
|
@@ -17,6 +18,7 @@ import com.kuaishou.merchant.open.api.response.distribution.OpenDistributionPubl
|
|
|
import com.ruixuan.common.utils.Check;
|
|
|
import com.ruixuan.common.utils.KsHttpUtils;
|
|
|
import com.ruixuan.isc.constants.KuaiShouConstants;
|
|
|
+import com.ruixuan.isc.entity.KuaishouItemCollectSamples;
|
|
|
import com.ruixuan.isc.entity.KuaishouItemList;
|
|
|
import com.ruixuan.isc.entity.KuaishouItemCategory;
|
|
|
import com.ruixuan.isc.mapper.KuaishouItemListMapper;
|
|
@@ -45,7 +47,30 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
|
|
|
|
|
|
@Override
|
|
|
public List<KuaishouItemList> getItemList(Map<String, Object> requestMap) {
|
|
|
- return kuaishouItemListMapper.getItemList(requestMap);
|
|
|
+ List<KuaishouItemList> itemList = kuaishouItemListMapper.getItemList(requestMap);
|
|
|
+ Map<Long, JSONObject> dataMap = new HashMap<>();
|
|
|
+ if (!Check.isNull(itemList)) {
|
|
|
+ Map<Long, Long> map = new HashMap<>();
|
|
|
+ for (KuaishouItemList item : itemList) {
|
|
|
+ map.put(item.getItemId(), item.getItemId());
|
|
|
+ }
|
|
|
+ List<JSONObject> itemInfoList = kuaishouItemListMapper.selectItemInfo(map);
|
|
|
+ for (int i = 0; i < itemInfoList.size(); i++) {
|
|
|
+ JSONObject jsonObject = itemInfoList.get(i);
|
|
|
+ dataMap.put(jsonObject.getLong("itemId"), jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!Check.isNull(itemList)) {
|
|
|
+ for (KuaishouItemList item : itemList) {
|
|
|
+ Long itemId = item.getItemId();
|
|
|
+ JSONObject jsonObject = dataMap.get(itemId);
|
|
|
+ if (!Check.isNull(jsonObject)) {
|
|
|
+ item.setValidAmount(jsonObject.getLong("validAmount"));
|
|
|
+ item.setValidOrderNum(jsonObject.getLong("validOrderNum"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return itemList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -71,7 +96,7 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
|
|
|
if (code == 1 && subCode == 1) {
|
|
|
JSONArray data = json.getJSONArray("data");
|
|
|
if (Check.isNull(data)) {
|
|
|
- returnJson.put("code", -1);
|
|
|
+ returnJson.put("code", 500);
|
|
|
returnJson.put("message", "数据查询失败");
|
|
|
return returnJson;
|
|
|
}
|
|
@@ -99,7 +124,7 @@ public class KuaishouItemListServiceImpl implements IKuaishouItemListService {
|
|
|
} else if (code != 1) { // 商品下线
|
|
|
return invaliItemDetail;
|
|
|
} else {
|
|
|
- returnJson.put("code", -1);
|
|
|
+ returnJson.put("code", 500);
|
|
|
returnJson.put("message", "数据查询失败");
|
|
|
}
|
|
|
log.info("获取商品信息回,活动ID:{},商品ID:{},数据:{}", activityId, itemId, returnJson);
|