|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.ms.api.biz;
|
|
|
|
|
|
|
|
|
|
import java.net.URLDecoder;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
@ -49,6 +50,10 @@ import com.doudian.open.api.product_getProductUpdateRule.data.NormalRule;
|
|
|
|
|
import com.doudian.open.api.product_getProductUpdateRule.data.OptionsItem;
|
|
|
|
|
import com.doudian.open.api.product_getProductUpdateRule.data.ProductGetProductUpdateRuleData;
|
|
|
|
|
import com.doudian.open.api.product_getProductUpdateRule.param.ProductGetProductUpdateRuleParam;
|
|
|
|
|
import com.doudian.open.api.product_qualificationConfig.ProductQualificationConfigRequest;
|
|
|
|
|
import com.doudian.open.api.product_qualificationConfig.ProductQualificationConfigResponse;
|
|
|
|
|
import com.doudian.open.api.product_qualificationConfig.data.ConfigListItem;
|
|
|
|
|
import com.doudian.open.api.product_qualificationConfig.param.ProductQualificationConfigParam;
|
|
|
|
|
import com.jinritemai.cloud.base.core.util.AuthThreadLocalUtil;
|
|
|
|
|
import com.ms.api.bo.MoveProductPublishQueueBO;
|
|
|
|
|
import com.ms.api.bo.MoveShopConfigBO;
|
|
|
|
@ -229,6 +234,7 @@ public class MoveService {
|
|
|
|
|
Long size = getSizeTemplateId(shopId, Long.parseLong(queueMsg.getCid()));
|
|
|
|
|
productDetailBase.put("sizeTemplateId", size);
|
|
|
|
|
}
|
|
|
|
|
productDetailBase.put("qualityList", buildQualityList(queueMsg));
|
|
|
|
|
|
|
|
|
|
// 发货时间
|
|
|
|
|
long deliveryDelayDay = condition.getDeliveryDelayDay();
|
|
|
|
@ -283,6 +289,120 @@ public class MoveService {
|
|
|
|
|
return CommonTool.successResult("productDetailBase", productDetailBase);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<StrObjMap> buildQualityList(MoveProductPublishQueueBO queueMsg) {
|
|
|
|
|
MoveShopSettingBO condition = queueMsg.getCondition();
|
|
|
|
|
Long shopId = queueMsg.getShopId();
|
|
|
|
|
Long cid = Long.parseLong(queueMsg.getCid());
|
|
|
|
|
List<StrObjMap> qualityList = new ArrayList<>();
|
|
|
|
|
// $qualitySettingMap = !empty($queueMsg['quality_map']) ? [$cid => $queueMsg['quality_map']] : null;
|
|
|
|
|
Integer moveShopSettingId = condition.getMoveShopSettingId();
|
|
|
|
|
if (moveShopSettingId < 1 || shopId < 1 || cid < 1) {
|
|
|
|
|
return qualityList;
|
|
|
|
|
}
|
|
|
|
|
AuthThreadLocalUtil.set(queueMsg.getShopId().toString());
|
|
|
|
|
Ret cateQualityListRet = getProductQualityToCidList(cid, false);
|
|
|
|
|
if (CommonTool.isFailRet(cateQualityListRet)) {
|
|
|
|
|
return qualityList;
|
|
|
|
|
}
|
|
|
|
|
Map<String, StrObjMap> cateQualityList = (Map<String, StrObjMap>) cateQualityListRet.getData().get("qualityList");
|
|
|
|
|
if (ObjectUtil.isEmpty(cateQualityList)) {
|
|
|
|
|
return qualityList;
|
|
|
|
|
}
|
|
|
|
|
Map<String, String> qualityMap = (Map<String, String>) cateQualityListRet.getData().get("qualityMap");
|
|
|
|
|
|
|
|
|
|
// TODO: 2023/9/17 没表
|
|
|
|
|
// $qualityMap = $this->moveService->getProductQualityMap();
|
|
|
|
|
// TODO: 2023/9/17 没qualitySettingMap
|
|
|
|
|
// if (!$qualitySettingMap) {
|
|
|
|
|
// $qualitySettingMap = [];
|
|
|
|
|
// $qualitySettingList = $this->moveService->getShopProductQualitySettingList($shopId, $moveShopSettingId, [$cid, 0]);
|
|
|
|
|
//
|
|
|
|
|
// foreach ($qualitySettingList as $qualitySetting) {
|
|
|
|
|
// $settingCid = $qualitySetting['cid'];
|
|
|
|
|
// $settingQualityKey = $qualitySetting['quality_key'];
|
|
|
|
|
// $qualitySettingMap[$settingCid][$settingQualityKey] = $qualitySetting['contents'];
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// foreach ($qualitySettingMap as $settingCid => $qualitySetting) {
|
|
|
|
|
// list($qualitySettingMap[$settingCid], ) = $this->rebuildQualitySetting($qualitySetting, $qualityMap, $cateQualityList);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// TODO: 2023/9/17 没taskQualityMap
|
|
|
|
|
// if ($condition['taskQualityMap']) {
|
|
|
|
|
// if ($qualitySettingMap[0]) { // cid = 0 代表通用类目
|
|
|
|
|
// $qualitySettingMap[0] = array_merge($qualitySettingMap[0], $condition['taskQualityMap']);
|
|
|
|
|
// } else {
|
|
|
|
|
// $qualitySettingMap[0] = $condition['taskQualityMap'];
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
for (Map.Entry<String, StrObjMap> entry : cateQualityList.entrySet()) {
|
|
|
|
|
List<String> imgUrls = new ArrayList();
|
|
|
|
|
List<String> attachments = new ArrayList();
|
|
|
|
|
StrObjMap cateQuality = entry.getValue();
|
|
|
|
|
String qualityKey = (String) cateQuality.get("quality_key");
|
|
|
|
|
|
|
|
|
|
// if ($qualitySettingMap[$cid][$qualityKey]) {
|
|
|
|
|
// // json格式是搬家配置的。数组的是搬家第二步
|
|
|
|
|
// $imgUrls = is_array($qualitySettingMap[$cid][$qualityKey]) ? $qualitySettingMap[$cid][$qualityKey] : json_decode($qualitySettingMap[$cid][$qualityKey], true);
|
|
|
|
|
// } elseif ($qualitySettingMap[0][$qualityKey]) {
|
|
|
|
|
// $imgUrls = is_array($qualitySettingMap[0][$qualityKey]) ? $qualitySettingMap[0][$qualityKey] : json_decode($qualitySettingMap[0][$qualityKey], true);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
imgUrls.removeIf(url -> url == null || !url.matches("^https?://.*$"));
|
|
|
|
|
Set<String> uniqueUrls = new HashSet<>(imgUrls);
|
|
|
|
|
imgUrls.clear();
|
|
|
|
|
imgUrls.addAll(uniqueUrls);
|
|
|
|
|
if (ObjectUtil.isEmpty(imgUrls)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (String url : imgUrls) {
|
|
|
|
|
String decodedUrl = URLDecoder.decode(url);
|
|
|
|
|
Pattern pattern = Pattern.compile("/image_search/src=(.*)&refer=", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
|
|
|
|
|
Matcher matcher = pattern.matcher(decodedUrl);
|
|
|
|
|
if (matcher.find()) {
|
|
|
|
|
url = matcher.group(1);
|
|
|
|
|
}
|
|
|
|
|
attachments.add("{\"media_type\": 1, \"url\": " + url + "}");
|
|
|
|
|
}
|
|
|
|
|
StrObjMap temp = new StrObjMap();
|
|
|
|
|
temp.put("quality_key", qualityKey);
|
|
|
|
|
temp.put("quality_name", qualityMap.get(qualityKey));
|
|
|
|
|
temp.put("text_list", attachments);
|
|
|
|
|
qualityList.add(temp);
|
|
|
|
|
}
|
|
|
|
|
return qualityList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Ret getProductQualityToCidList(Long cid, boolean updateDb) {
|
|
|
|
|
// 不走缓存
|
|
|
|
|
ProductQualificationConfigRequest req = new ProductQualificationConfigRequest();
|
|
|
|
|
ProductQualificationConfigParam param = new ProductQualificationConfigParam();
|
|
|
|
|
param.setCategoryId(cid);
|
|
|
|
|
ProductQualificationConfigResponse response = req.execute();
|
|
|
|
|
if (!CommonTool.checkDdApiRequestIsSuccess(response)) {
|
|
|
|
|
return Ret.fail();
|
|
|
|
|
}
|
|
|
|
|
Map<String, StrObjMap> qualityList = new HashMap<>();
|
|
|
|
|
List<ConfigListItem> configList = response.getData().getConfigList();
|
|
|
|
|
for (ConfigListItem config : configList) {
|
|
|
|
|
StrObjMap temp = new StrObjMap();
|
|
|
|
|
temp.put("is_required", config.getIsRequired());
|
|
|
|
|
temp.put("quality_key", config.getKey());
|
|
|
|
|
temp.put("quality_name", config.getName());
|
|
|
|
|
temp.put("text_list", config.getTextList());
|
|
|
|
|
qualityList.put(config.getKey(), temp);
|
|
|
|
|
}
|
|
|
|
|
if (updateDb) {
|
|
|
|
|
// TODO: 2023/9/17 没表 product_quality
|
|
|
|
|
// $this->insertUpdateProductQuality($quality);
|
|
|
|
|
}
|
|
|
|
|
// $this->setProductQualityCache($cid, $qualityList);
|
|
|
|
|
StrObjMap result = new StrObjMap();
|
|
|
|
|
result.put("qualityList", qualityList);
|
|
|
|
|
result.put("qualityMap", configList.stream().collect(Collectors.toMap(ConfigListItem::getKey, ConfigListItem::getName)));
|
|
|
|
|
return Ret.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double processConditionPrice(MoveShopSettingBO condition, double price) {
|
|
|
|
|
if (price <= 0) {
|
|
|
|
|
return 99999;
|
|
|
|
|