|
|
|
@ -41,11 +41,16 @@ public class GetRecommendProductListService extends SPIBaseService implements Ex
|
|
|
|
|
getAuthCode();
|
|
|
|
|
|
|
|
|
|
GetRecommendProductListRequestDTO requestDTO = req.getData();
|
|
|
|
|
Integer pageSize = requestDTO.getPageSize();
|
|
|
|
|
if (pageSize == null) {
|
|
|
|
|
pageSize = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONArray productArray = new JSONArray();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 1688类目树
|
|
|
|
|
JSONArray dsCateLeafArray = dsCatService.getDSProductCatTreeLeafArray();
|
|
|
|
|
// 1688类目列表
|
|
|
|
|
JSONArray dsCateLeafArray = dsCatService.getDSProductTopCatArray();
|
|
|
|
|
|
|
|
|
|
// 获取商家抖店类目列表
|
|
|
|
|
List<Category> categoryList = categoryService.getAllLeafProductCatListFromTos(shopId.intValue(), false);
|
|
|
|
@ -53,12 +58,12 @@ public class GetRecommendProductListService extends SPIBaseService implements Ex
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dsCateLeafArray) && ObjectUtil.isNotEmpty(dsCateLeafArray)) {
|
|
|
|
|
final int eachCateProductChooseCount = 3;
|
|
|
|
|
int productCnt = 0;
|
|
|
|
|
int categoryIndex = 0;
|
|
|
|
|
while (productCnt < requestDTO.getPageSize() && categoryIndex < categoryList.size()) {
|
|
|
|
|
HashSet<String> sourceItemIdSet = new HashSet<>();
|
|
|
|
|
while (productArray.size() < pageSize && categoryIndex < categoryList.size()) {
|
|
|
|
|
Category category = categoryList.get(categoryIndex);
|
|
|
|
|
String categoryName = category.getCategoryName();
|
|
|
|
|
|
|
|
|
|
// categoryName="女装";
|
|
|
|
|
double maxPercent = 0;
|
|
|
|
|
String maxPercentName = "";
|
|
|
|
|
String maxPercentCid = "";
|
|
|
|
@ -67,16 +72,19 @@ public class GetRecommendProductListService extends SPIBaseService implements Ex
|
|
|
|
|
String dsCateName = dsCateLeaf.getString("name");
|
|
|
|
|
String dsCateCid = dsCateLeaf.getString("cid");
|
|
|
|
|
double percent = StringUtils.getJaroWinklerDistance(categoryName, dsCateName);
|
|
|
|
|
maxPercent = Math.max(maxPercent, percent);
|
|
|
|
|
if (percent > maxPercent) {
|
|
|
|
|
maxPercent = percent;
|
|
|
|
|
maxPercentName = dsCateName;
|
|
|
|
|
maxPercentCid = dsCateCid;
|
|
|
|
|
}
|
|
|
|
|
log.info(dsCateName + " " + percent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 匹配到的最终类目,每个查询N个
|
|
|
|
|
HashMap<String, Object> params = new HashMap<>();
|
|
|
|
|
// params.put("keyword",fields.getKeyword());
|
|
|
|
|
// params.put("topCid",fields.getTopCid());
|
|
|
|
|
params.put("cid", maxPercentCid);
|
|
|
|
|
params.put("topCid", maxPercentCid);
|
|
|
|
|
// params.put("cid", maxPercentCid);
|
|
|
|
|
params.put("sort", "saleCntDesc");
|
|
|
|
|
// params.put("ruleIds", fields.getRuleIds());
|
|
|
|
|
params.put("isHideMoved", 1);
|
|
|
|
@ -86,15 +94,21 @@ public class GetRecommendProductListService extends SPIBaseService implements Ex
|
|
|
|
|
log.info(params.toString());
|
|
|
|
|
JSONObject resObj = null;
|
|
|
|
|
String res = null;
|
|
|
|
|
List<Object> products = new LinkedList<>();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
res = dsJsonRequestTemplate.execute("/move/search_choiceness_source_item", params);
|
|
|
|
|
resObj = JSON.parseObject(res);
|
|
|
|
|
if (resObj.get("result").equals("success")) {
|
|
|
|
|
JSONArray sourceItems = resObj.getJSONArray("sourceItems");
|
|
|
|
|
productArray.addAll(sourceItems);
|
|
|
|
|
productCnt += sourceItems.size();
|
|
|
|
|
if (ObjectUtil.isNotEmpty(sourceItems)) {
|
|
|
|
|
for (int i = 0; i < sourceItems.size(); ++i) {
|
|
|
|
|
JSONObject sourceItem = sourceItems.getJSONObject(i);
|
|
|
|
|
String sourceItemId = sourceItem.getString("sourceItemId");
|
|
|
|
|
if (!sourceItemIdSet.contains(sourceItemId)) {
|
|
|
|
|
productArray.add(sourceItem);
|
|
|
|
|
sourceItemIdSet.add(sourceItemId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("/move/search_choiceness_source_item request error", e);
|
|
|
|
@ -110,7 +124,7 @@ public class GetRecommendProductListService extends SPIBaseService implements Ex
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map retMap = new HashMap();
|
|
|
|
|
retMap.put("products", productArray);
|
|
|
|
|
retMap.put("products", productArray.subList(0, Math.min(pageSize, productArray.size())));
|
|
|
|
|
return R.ok(Ret.success(retMap));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|