wangchaoxu 1 year ago
commit 60f566a114

@ -39,7 +39,7 @@ public class TestRedisService extends SPIBaseService implements ExtensionService
redisFIFOService.pop(RedisKeyConst.MOVE_PRODUCT_PUBLISH_QUEUE);
}
for (long i = 13; i < 30; i++) {
for (long i = 13; i < 100; i++) {
MoveProductPublishQueue data = moveProductPublishQueueService.selectByPrimaryKey(i);
if(data != null && data.getLocked() == 0){
redisFIFOService.push(RedisKeyConst.MOVE_PRODUCT_PUBLISH_QUEUE, String.valueOf(data.getMoveCollectTaskDetailId()));
@ -49,7 +49,7 @@ public class TestRedisService extends SPIBaseService implements ExtensionService
//to pic
if(itemDTO.getTitle().equals("initToPic")){
for (long i = 13; i < 30; i++) {
for (long i = 13; i < 100; i++) {
MoveProductPublishToPicQueue data = moveProductPublishToPicQueueService.selectByPrimaryKey(i);
if (data != null && data.getLocked() == 0) {
redisFIFOService.push(RedisKeyConst.MOVE_PRODUCT_PUBLISH_TO_PIC_QUEUE, String.valueOf(data.getMoveProductPublishToPicQueueId()));

@ -261,6 +261,9 @@ public class SaveBatchMoveTaskBizService extends BizBaseService {
moveCollectTaskDetail.setSourceImgUrl(product.getSourceImgUrl());
moveCollectTaskDetail.setSourceShopName(product.getSourceShopName());
moveCollectTaskDetail.setMoveShopConfigId(moveShopConfigId);
if(product.getCid().equals("716812213765")){ // TODO 测试阶段,后面去掉
moveCollectTaskDetail.setCid("20219");
}
moveCollectTaskDetail.setCid(String.valueOf(product.getCid()));
moveCollectTaskDetail.setStatus(StatusConst.processing);
moveCollectTaskDetail.setGmtCreate(CommonTool.curDate());

@ -169,4 +169,7 @@ public class MoveShopSettingBO {
private Boolean useSourcePresell;
private Integer resetSkuStockNum;
private Integer resetSkuZeroStockNum;
private Integer quantity;
}

@ -48,8 +48,13 @@ public abstract class TaskBaseService implements TaskHandler {
}
public void runTask() {
if(isPoolFull()){ return;}
execute();
try{
if(isPoolFull()){ return;}
execute();
}catch (Throwable e){
e.printStackTrace();
log.info("任务执行失败",e);
}
}
public void runTaskWithTransaction(){
@ -61,6 +66,7 @@ public abstract class TaskBaseService implements TaskHandler {
transactionManager.commit(status);
}catch (Throwable e){
e.printStackTrace();
log.info("任务执行失败",e);
transactionManager.rollback(status);
}
}
@ -77,28 +83,23 @@ public abstract class TaskBaseService implements TaskHandler {
public void execute(){
// 如果需要循环执行这边可以加个while(true), 配合休息策略
// 循环加载try外层这样内部有异常不会影响下次执行
try {
String threadInfo = getThreadPoolInfo();
log.info(threadInfo);
String threadInfo = getThreadPoolInfo();
log.info(threadInfo);
log.info("开始执行任务");
log.info("start get one task");
Object getTaskRet = getTask();
log.info("end get one task");
log.info("开始执行任务");
log.info("start get one task");
Object getTaskRet = getTask();
log.info("end get one task");
log.info("start process one task");
Object processTaskRet = processTask(getTaskRet);
log.info("end process task");
log.info("start process one task");
Object processTaskRet = processTask(getTaskRet);
log.info("end process task");
log.info("start clear one task");
clearTask(processTaskRet);
log.info("end clear one task");
log.info("start clear one task");
clearTask(processTaskRet);
log.info("end clear one task");
log.info("执行任务结束");
} catch (Throwable e) {
e.printStackTrace();
log.error("任务执行失败", e);
}
log.info("执行任务结束");
}
protected abstract Executor getTaskPool();

@ -94,6 +94,12 @@ public class MoveConst {
public static String presellTimeSkuSpecDetailWithin15Days = "15天内发货";
public static String presellTimeSkuSpecDetailWithin45Days = "45天内发货";
public static String presellTimeSkuSpecDetailWithinNew = "现货";
public static Integer basePriceTypeSourcePrice = 0;
public static Integer basePriceTypeCostPrice = 1;
public static String aliPriceTypeSourceOrder = "order";
public static String aliPriceTypeConsign = "consign";
public static String aliPriceTypeConfig = "config";
public static List<String> getSpecialBanWordList() {
List<String> result = new ArrayList<String>();

@ -515,9 +515,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
Long categoryLeafId = productData.getLong("categoryLeafId");
if (!Objects.isNull(categoryLeafId)) {
//TODO 前端没有真实传抖店的类目id这里先写死
param.setCategoryLeafId(20219L);
// param.setCategoryLeafId(categoryLeafId);
param.setCategoryLeafId(categoryLeafId);
}
String title = productData.getString("title");

@ -1,16 +1,20 @@
package com.ms.api.task;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
@ -41,21 +45,61 @@ import com.doudian.open.api.product_getCatePropertyV2.ProductGetCatePropertyV2Re
import com.doudian.open.api.product_getCatePropertyV2.ProductGetCatePropertyV2Response;
import com.doudian.open.api.product_getCatePropertyV2.data.DataItem;
import com.doudian.open.api.product_getCatePropertyV2.data.OptionsItem;
import com.doudian.open.api.product_getCatePropertyV2.data.ProductGetCatePropertyV2Data;
import com.doudian.open.api.product_getCatePropertyV2.param.ProductGetCatePropertyV2Param;
import com.doudian.open.core.AccessToken;
import com.ms.api.biz.MoveService;
import com.ms.api.bo.*;
import com.ms.api.common.*;
import com.ms.api.consts.*;
import com.ms.api.bo.AttributeBO;
import com.ms.api.bo.CateAttributeResultBO;
import com.ms.api.bo.CategoryBO;
import com.ms.api.bo.MoveProductPublishQueueBO;
import com.ms.api.bo.MoveShopSettingBO;
import com.ms.api.common.ApiResult;
import com.ms.api.common.E;
import com.ms.api.common.Ret;
import com.ms.api.common.StrObjMap;
import com.ms.api.common.StrStrMap;
import com.ms.api.common.TaskBaseService;
import com.ms.api.consts.CommonConst;
import com.ms.api.consts.MaterialConst;
import com.ms.api.consts.MoveConst;
import com.ms.api.consts.RedisKeyConst;
import com.ms.api.consts.StatusConst;
import com.ms.api.paas.RedisService;
import com.ms.api.paas.StorageService;
import com.ms.api.service.*;
import com.ms.api.tool.*;
import com.ms.api.service.CategoryShopService;
import com.ms.api.service.MaterialAuditStatusBufferService;
import com.ms.api.service.MaterialBizAuditStatusLogService;
import com.ms.api.service.MaterialBizQueueService;
import com.ms.api.service.MaterialBizToMaterialService;
import com.ms.api.service.MoveCollectTaskDetailService;
import com.ms.api.service.MoveCollectTaskService;
import com.ms.api.service.MoveProductPublishQueueService;
import com.ms.api.service.MoveProductPublishToPicQueueService;
import com.ms.api.service.MoveShopSettingService;
import com.ms.api.service.RsyncCategoryQueueService;
import com.ms.api.service.Shop1688DsAuthService;
import com.ms.api.service.ShopService;
import com.ms.api.tool.CommonTool;
import com.ms.api.tool.DsJsonRequestTemplate;
import com.ms.api.tool.ImageTool;
import com.ms.api.tool.MoveTool;
import com.ms.api.tool.SecurityTool;
import com.ms.api.util.DdRequestUtil;
import com.ms.dal.entity.*;
import com.ms.dal.entity.Category;
import com.ms.dal.entity.CategoryShop;
import com.ms.dal.entity.MaterialAuditStatusBuffer;
import com.ms.dal.entity.MaterialBizAuditStatusLog;
import com.ms.dal.entity.MaterialBizQueue;
import com.ms.dal.entity.MaterialBizToMaterial;
import com.ms.dal.entity.MoveCollectTaskDetail;
import com.ms.dal.entity.MoveProductPublishQueue;
import com.ms.dal.entity.MoveProductPublishToPicQueue;
import com.ms.dal.entity.RsyncCategoryQueue;
import com.ms.dal.entity.Shop;
import com.ms.dal.entity.Shop1688DsAuth;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.tomcat.jni.OS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -63,15 +107,6 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* move_product_publish_queue
*/
@ -545,7 +580,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
JSONObject productDetailBase = (JSONObject) getPostDataRet.getData().get("productDetailBase");
JSONObject moveBaseData = (JSONObject) getPostDataRet.getData().get("moveBaseData");
Ret ret = buildSpec(queueMsg, moveBaseData, productDetailBase, condition.getFilterEmptyColorImg(),false,new ArrayList<>());
Ret ret = buildSpec(queueMsg, moveBaseData, productDetailBase, condition.getFilterEmptyColorImg(), false, new ArrayList<>());
productDetailBase.put("specs", ret.getData().get("specs"));
productDetailBase.put("specName", ret.getData().get("specName"));
productDetailBase.put("specPic", ret.getData().get("specPic"));
@ -557,9 +592,9 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
StrObjMap publishTips = (StrObjMap) ret.getData().get("publishTips");
productDetailBase.put("specPrices", buildSpecPrice(productDetailBase, condition, colorSpecArrCalc, sizeSpecArrCalc, queueMsg, skuPresellChildSkuDetail));
StrObjMap checkHasRepeatSpecMap = checkHasRepeatSpec(colorSpecArrCalc, sizeSpecArrCalc);
if (ObjectUtil.isNotEmpty(checkHasRepeatSpecMap) && checkHasRepeatSpecMap.containsKey("repeatSpecArr")) {
return Ret.fail("规格: ".concat((String) checkHasRepeatSpecMap.get("repeatSpecArr")).concat("重复,请检查是否包含特殊符号或违禁词(").concat(String.join(",", CommonConst.getSpecialBanWordList())).concat(")"));
List<String> repeatSpecArr = checkHasRepeatSpec(colorSpecArrCalc, sizeSpecArrCalc);
if (ObjectUtil.isNotEmpty(repeatSpecArr) ) {
return Ret.fail("规格: ".concat((String) String.join(",",repeatSpecArr)).concat("重复,请检查是否包含特殊符号或违禁词(").concat(String.join(",", CommonConst.getSpecialBanWordList())).concat(")"));
}
productDetailBase = processSpuPriceMaybeOutRange(productDetailBase);
productDetailBase = processSpuMarketPriceMaybeOutRange(productDetailBase, condition);
@ -679,14 +714,32 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return productDetailBase;
}
private StrObjMap checkHasRepeatSpec(StrObjMap colorSpecArrCalc, StrObjMap sizeSpecArrCalc) {
// $uniqueColorSpecArr = array_unique($colorSpecArr);
// $repeatColorSpecArr = array_diff_assoc($colorSpecArr, $uniqueColorSpecArr);
//
// $uniqueSizeSpecArr = array_unique($sizeSpecArr);
// $repeatSizeSpecArr = array_diff_assoc($sizeSpecArr, $uniqueSizeSpecArr);
// return array_merge($repeatColorSpecArr, $repeatSizeSpecArr);
return null;
private List<String> checkHasRepeatSpec(StrObjMap colorSpecArrCalc, StrObjMap sizeSpecArrCalc) {
List<String> repeatSpecArr = new ArrayList<>();
Map<String, Integer> colorSpecCounts = new HashMap<>();
for (String colorSpec : colorSpecArrCalc.keySet()) {
colorSpecCounts.put(colorSpec, colorSpecCounts.getOrDefault(colorSpec, 0) + 1);
}
Map<String, Integer> sizeSpecCounts = new HashMap<>();
for (String sizeSpec : sizeSpecArrCalc.keySet()) {
sizeSpecCounts.put(sizeSpec, sizeSpecCounts.getOrDefault(sizeSpec, 0) + 1);
}
for (String colorSpec : colorSpecCounts.keySet()) {
if (colorSpecCounts.get(colorSpec) > 1) {
repeatSpecArr.add(colorSpec);
}
}
for (String sizeSpec : sizeSpecCounts.keySet()) {
if (sizeSpecCounts.get(sizeSpec) > 1) {
repeatSpecArr.add(sizeSpec);
}
}
return repeatSpecArr;
}
private Ret buildSpec(MoveProductPublishQueueBO queueMsg, JSONObject moveBaseData, JSONObject productDetailBase, String filterEmptyColorImg, boolean filterBanWord, List<String> foundBanWordList) {
@ -781,7 +834,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
String skuSpecStr = getSkuSpecStr(queueMsg, deliveryDelayDay);
log.info("skuSpecStr: " + skuSpecStr);
if (skuSpecStr != null) {
if (StrUtil.isNotBlank(skuSpecStr)) {
spec += "^" + skuSpecStr;
specName += "-" + MoveConst.skuSpecName;
}
@ -793,7 +846,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
if (!specPics.isEmpty()) {
specPics = specPics.stream().map(CommonTool::updateProductImgDomain).collect(Collectors.toList());
}
StrObjMap skuPresellChildSkuDetail = buildSkuPresellChildSkuDetail(queueMsg, skus, skuList, moveBaseData);
// StrObjMap skuPresellChildSkuDetail = buildSkuPresellChildSkuDetail(queueMsg, skus, skuList, moveBaseData);
// skuPresellChildSkuDetail = sortSkuPresellChildSkuDetail(skuPresellChildSkuDetail);
StrObjMap temp = new StrObjMap();
@ -802,7 +855,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
temp.put("specPics", String.join(",", specPics));
temp.put("colorSpecArr", colorSpecArr);
temp.put("sizeSpecArr", sizeSpecArr);
temp.put("skuPresellChildSkuDetail", skuPresellChildSkuDetail);
// temp.put("skuPresellChildSkuDetail", skuPresellChildSkuDetail);
temp.put("ewColorNameAndOldColorNameMap", newColorNameAndOldColorNameMap);
temp.put("newSizeNameAndOldSizeNameMap", newSizeNameAndOldSizeNameMap);
temp.put("publishTips", publishTips);
@ -816,10 +869,9 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return new StrObjMap();
}
int isFastMode = queueMsg.getIsFastMode();
if(isFastMode!=0 && ObjectUtil.isNotNull(queueMsg.getSkuPresellChildSkuDetail())){
if (isFastMode != 0 && ObjectUtil.isNotNull(queueMsg.getSkuPresellChildSkuDetail())) {
// queueMsg.setSkuPresellChildSkuDetail(processSpecialWebSiteSkuKey(queueMsg, skus, queueMsg.getSkuPresellChildSkuDetail()));
// return replaceSkuPresellChildSkuDetailSkuKeyIllegalChars(queueMsg.getSkuPresellChildSkuDetail());
// TODO: 2023/9/12 进度
}
return null;
}
@ -934,7 +986,6 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return new boolean[]{hasColorImg, existEmptyColorImg};
}
private JSONArray buildSpecPrice(JSONObject productDetailBase,
MoveShopSettingBO condition,
StrObjMap colorSpecArrCalc,
@ -1017,7 +1068,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
needSkip = true;
}
StrObjMap diffMap = (StrObjMap)(colorSpecArrCalc.clone());
StrObjMap diffMap = (StrObjMap) (colorSpecArrCalc.clone());
diffMap.remove("默认");
if (ObjectUtil.isEmpty(diffMap) && ObjectUtil.isEmpty(sizeSpecArrCalc) && StrUtil.isEmpty(newColorName) && StrUtil.isEmpty(newSizeName)) {
newColorName = "默认";
@ -1033,7 +1084,6 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
private Ret getCompletePostData(JSONObject moveBaseData, MoveProductPublishQueueBO queueMsg, AccessToken accessToken) {
String cid = queueMsg.getCid();
String brandName = moveBaseData.getString("brandName");
MoveShopSettingBO condition = queueMsg.getCondition();
// TODO
@ -1071,13 +1121,23 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
productDetailBase.put("updateSkuMinPriceInfo", updateSkuMinPriceInfo);
// 品牌
Ret matchBrandRet = searchBrandIdByBrandNameFromDd(cid, brandName, accessToken, true);
if (CommonTool.isFailRet(matchBrandRet)) {
return matchBrandRet;
long brandId = 0L;
String brandName = "";
Ret matchBrandRet = null;
brandName = getSourceAttrBrandName(moveBaseData.getJSONObject("sourceAttrs"));
for (int i = 0; i <= 3; i++) {
matchBrandRet = searchBrandIdByBrandNameFromDd(cid, brandName, accessToken, true);
if (CommonTool.isSuccessRet(matchBrandRet) || !CommonTool.checkIsFrequencyLimitReason(matchBrandRet.getReason())) {
break;
}
CommonTool.randomSleep();
}
String standardBrandId = (String) matchBrandRet.getData().get("brandId");
productDetailBase.put("standardBrandId", standardBrandId);
brandName = (String) (matchBrandRet.getData().get("brandName"));
if (CommonTool.isSuccessRet(matchBrandRet)) {
Map<String, Object> brandRetData = (Map<String, Object>) matchBrandRet.getData();
brandId = (Integer) brandRetData.get("brandId");
brandName = (String) brandRetData.get("brandName");
}
productDetailBase.put("standardBrandId", brandId);
moveBaseData.put("brandName", brandName);
// 从抖店获取的类目属性
@ -1086,10 +1146,11 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return categoryAttrRet;
}
JSONObject sourceAttrs = moveBaseData.getJSONObject("sourceAttrs");
List<DataItem> attributes = (List<DataItem>) categoryAttrRet.getData();
ProductGetCatePropertyV2Data attrRetData = (ProductGetCatePropertyV2Data) categoryAttrRet.getData().get("data");
List<DataItem> attributes = attrRetData.getData();
String title = productDetailBase.getString("title");
List<List<StrObjMap>> productFormatNew = buildProductAttrs(attributes, sourceAttrs, title);
productFormatNew = attachBrand2ProductFormatNew(standardBrandId, brandName, productFormatNew);
Map<Long, List<StrObjMap>> productFormatNew = buildProductAttrs(attributes, sourceAttrs, title);
productFormatNew = attachBrand2ProductFormatNew(brandId, brandName, productFormatNew);
productDetailBase.put("productFormatNew", productFormatNew);
Ret ret = CommonTool.successResult();
@ -1100,6 +1161,17 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return ret;
}
private String getSourceAttrBrandName(JSONObject sourceAttrs) {
String brandName = "";
for (Map.Entry entry : sourceAttrs.entrySet()) {
if (((String) entry.getKey()).contains("品牌")) {
brandName = (String) entry.getValue();
break;
}
}
return brandName;
}
private Ret replaceAndDeleteSkuName(JSONObject moveBaseData, JSONObject condition) {
if (condition.get("skuAliasDelete") == null && condition.get("sku") == null) {
return Ret.success();
@ -1178,24 +1250,25 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return title;
}
private List<List<StrObjMap>> attachBrand2ProductFormatNew(String standardBrandId, String brandName, List<List<StrObjMap>> productFormatNew) {
private Map<Long, List<StrObjMap>> attachBrand2ProductFormatNew(long standardBrandId, String brandName, Map<Long, List<StrObjMap>> productFormatNew) {
StrObjMap brandMap = new StrObjMap();
brandMap.put("name", brandName);
brandMap.put("diy_type", 0);
brandMap.put("value", standardBrandId);
List<StrObjMap> brandList = new ArrayList<>();
brandList.add(brandMap);
productFormatNew.add(1687, brandList);
productFormatNew.put(1687L, brandList);
return productFormatNew;
}
private List<List<StrObjMap>> buildProductAttrs(List<DataItem> attributes, JSONObject sourceAttrs, String title) {
List<List<StrObjMap>> result = new ArrayList<>();
private Map<Long, List<StrObjMap>> buildProductAttrs(List<DataItem> attributes, JSONObject sourceAttrs, String title) {
Map<Long, List<StrObjMap>> matchAttrs = new HashMap<>();
for (DataItem attribute : attributes) {
result.add(matchSourceAttr(attribute, sourceAttrs, title));
long currAid = attribute.getPropertyId();
matchAttrs.put(currAid, matchSourceAttr(attribute, sourceAttrs, title));
}
return result;
return matchAttrs;
}
private Ret getCategoryAttrV2FromDd(String cid, AccessToken accessToken) {
@ -1365,7 +1438,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
boolean isReq = CommonTool.isTrue(attribute.getRequired().intValue());
StrObjMap sourceValueMap = searchSourceValue(sourceAttrs, attribute.getPropertyName());
String sourceValue = (String) sourceValueMap.get("sourceValue");
double matchMaxPercent = (Double) sourceValueMap.get("matchMaxPercent");
double matchMaxPercent = (Double)sourceValueMap.get("matchMaxPercent");
if (!checkInputPropertyMatchPercent(attribute.getPropertyName(), matchMaxPercent)) {
sourceValue = null;
@ -1496,7 +1569,9 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
matchAttr.put("value", matchVid.getValue());
matchAttrList.add(matchAttr);
}
return matchAttrList.subList(0, attribute.getMultiSelectMax().intValue());
int multiSelectMax = attribute.getMultiSelectMax().intValue();
return matchAttrList.subList(0, multiSelectMax > matchAttrList.size() ? matchAttrList.size() : multiSelectMax);
}
private List<String> splitMultiValueList(String sourceValue) {
@ -1523,7 +1598,6 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return Arrays.stream(value.split(delimiter)).map(String::trim).filter(str -> !str.isEmpty()).collect(Collectors.toList());
}
private List<StrObjMap> matchProductAttributesByInput(DataItem attribute, JSONObject sourceAttrs) {
List<Map<String, Object>> matchSourceAttrs = new ArrayList<>();
boolean isReq = CommonTool.isTrue(attribute.getRequired().intValue());
@ -1599,7 +1673,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
}
private String getDefaultValueByAttrName(String propertyName, String sourceValue) {
if (!sourceValue.isEmpty()) {
if (!Objects.isNull(sourceValue) && !sourceValue.isEmpty()) {
return sourceValue;
}
@ -1614,7 +1688,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
}
private boolean checkInputPropertyMatchPercent(String propertyName, double matchMaxPercent) {
int minPercent = 100;
double minPercent = 100D;
String[] needExactMatchArray = {"认证编号"};
for (String text : needExactMatchArray) {
if (propertyName.contains(text) && matchMaxPercent < minPercent) {
@ -1629,7 +1703,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
String sourceValue = sourceAttrs.getString(parName);
if (sourceValue != null && !sourceValue.isEmpty()) {
objMap.put("sourceValue", sourceValue);
objMap.put("matchMaxPercent", 100);
objMap.put("matchMaxPercent", 100D);
return objMap;
}
@ -1640,11 +1714,11 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
sourceValue = sourceAttrs.getString(similarName);
if (sourceValue != null && !sourceValue.isEmpty()) {
objMap.put("sourceValue", sourceValue);
objMap.put("matchMaxPercent", 100);
objMap.put("matchMaxPercent", 100D);
}
}
double maxPercent = -1;
double maxPercent = -1D;
String[] parNames = parName.split("/");
for (String newParName : parNames) {
sourceValue = sourceAttrs.getString(newParName);
@ -1751,8 +1825,9 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
MoveShopSettingBO condition = queueMsg.getCondition();
moveBaseData = rebuildProductSkuMap(moveBaseData, condition);
JSONObject mSkus = moveBaseData.getJSONObject("skus");
JSONObject skuMap = resetSkuStock(condition, mSkus.getJSONObject("skuMap"));
skuMap = resetSkuSalePrice(condition.getPriceMode(), condition.getBasePriceType(), skuMap, condition.getAliPriceType(), moveBaseData.getString("source"));
int isFastMode = condition.getIsFastMode();
JSONObject skuMap = resetSkuStock(condition, mSkus.getJSONObject("skuMap"), isFastMode);
skuMap = resetSkuSalePrice(isFastMode, condition.getPriceMode(), condition.getBasePriceType(), skuMap, condition.getAliPriceType(), moveBaseData.getString("source"),0);
moveBaseData.put("skus", mSkus);
Integer price = moveBaseData.getInteger("price");
if (price == null) {
@ -1773,13 +1848,61 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return result;
}
private JSONObject resetSkuStock(MoveShopSettingBO condition, JSONObject skuMap) {
// TODO
private JSONObject resetSkuStock(MoveShopSettingBO condition, JSONObject skuMap, int isFastMode) {
if (isFastMode == 0) {
return skuMap;
}
Integer resetSkuStockNum = condition.getResetSkuStockNum();
Integer resetSkuZeroStockNum = condition.getResetSkuZeroStockNum();
Integer quantity = condition.getQuantity();
for (String propString : skuMap.keySet()) {
JSONObject skuDetail = skuMap.getJSONObject(propString);
if (resetSkuStockNum > 0 && skuDetail.containsKey("stock") && skuDetail.getInteger("stock") < resetSkuStockNum) {
skuDetail.put("oriStock", skuDetail.get("stock"));
skuDetail.put("stock", 0);
}
if (resetSkuZeroStockNum > 0 && skuDetail.containsKey("oriStock") && skuDetail.getInteger("oriStock") == 0) {
skuDetail.put("stock", resetSkuZeroStockNum);
}
if ((ObjectUtil.isNotNull(resetSkuZeroStockNum) && resetSkuZeroStockNum > 0) && skuDetail.containsKey("stock") && skuDetail.getInteger("stock") == 0) {
skuDetail.put("stock", resetSkuZeroStockNum);
}
if (quantity > 0) {
skuDetail.put("stock", quantity);
}
}
return skuMap;
}
private JSONObject resetSkuSalePrice(String priceMode, int basePriceType, JSONObject skuMap, String aliPriceType, String source) {
// TODO
private JSONObject resetSkuSalePrice(int isFastMode, String priceMode, int basePriceType, JSONObject skuMap, String aliPriceType, String source, int hasImportPrice) {
if (isFastMode != 0 && hasImportPrice == 0 && skuMap != null) {
for (String propString : skuMap.keySet()) {
// TODO: 2023/9/12 FetchClientConst常量文件还没给 暂时注释
// JSONObject skuDetail = skuMap.getJSONObject(propString);
// if (source != FetchClientConst.collectTaskSource1688) {
// if (priceMode.equals("buyNow") && skuDetail.containsKey("sale_price") && skuDetail.getDouble("sale_price") > 0) {
// skuDetail.put("sale_price", skuDetail.getDouble("price"));
// } else if (basePriceType == MoveConst.basePriceTypeCostPrice && skuDetail.containsKey("wholesale_price") && skuDetail.getDouble("wholesale_price") > 0) {
// skuDetail.put("price", skuDetail.getDouble("wholesale_price"));
// }
// }
//
// if (source == FetchClientConst.collectTaskSource1688 && aliPriceType.equals(MoveConst.aliPriceTypeConsign)) {
// if (skuDetail.containsKey("consignPrice")) {
// skuDetail.put("price", skuDetail.getDoubleValue("consignPrice"));
// if (skuDetail.containsKey("sale_price")) {
// skuDetail.put("sale_price", skuDetail.getDoubleValue("consignPrice"));
// }
// }
// }
}
}
return skuMap;
}
@ -2004,7 +2127,6 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
}
private Ret searchBrandIdByBrandNameFromDd(String cid, String brandName, AccessToken accessToken, boolean isReturnNoBrand) {
// TODO 处理匹配品牌
// 此处算兼容api的bug品牌名"gefeila/歌菲拉"拿去接口查不到,但是gefeila 或者 /歌菲拉 或者 歌菲拉 都查的到
String queryName = brandName;
if (brandName.contains("/")) {
@ -2020,7 +2142,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
}
BrandListParam requestParams = new BrandListParam();
if (StrUtil.isNotBlank(brandName)) {
if (!Objects.isNull(brandName)) {
requestParams.setQuery(brandName);
}
if (StrUtil.isNotBlank(cid)) {
@ -2474,8 +2596,6 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
}
private Ret checkMoveDataCompletion(MoveProductPublishQueueBO taskDetail, JSONObject sourceProductData) {
// TODO 检查数据完整性 先都成功
if (ObjectUtil.isNull(taskDetail.getCondition())) {
return CommonTool.failResult("配置信息丢失,请联系客服");
}
@ -2493,23 +2613,25 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return CommonTool.failResult("商品描述必填~~");
}
if (sourceProductData.getBigDecimal("price") == null) {
return CommonTool.failResult("获取价格为空,请重试或联系客服~~");
}
if (sourceProductData.getJSONArray("image_paths") == null || sourceProductData.getJSONArray("image_paths").isEmpty()) {
return CommonTool.failResult("图片信息必填~~");
}
if (ObjectUtil.isNotNull(taskDetail.getIsFastMode()) && taskDetail.getIsFastMode() != 0) {
return CommonTool.successResult();
}
if (taskDetail.getPrice() == null) {
return CommonTool.failResult("搬家价格不完整,请联系客服");
}
// TODO 校验那边
if (taskDetail.getSkus().getJSONObject("skuMap").isEmpty() && !sourceProductData.getJSONObject("skuMap").isEmpty()) {
return CommonTool.failResult("搬家SKU不完整请复制来源链接重新复制商品");
}
// if (sourceProductData.getBigDecimal("price") == null) {
// return CommonTool.failResult("获取价格为空,请重试或联系客服~~");
// }
// if (sourceProductData.getJSONArray("image_paths") == null || sourceProductData.getJSONArray("image_paths").isEmpty()) {
// return CommonTool.failResult("图片信息必填~~");
// }
// if (ObjectUtil.isNotNull(taskDetail.getIsFastMode()) && taskDetail.getIsFastMode() != 0) {
// return CommonTool.successResult();
// }
//
// if (taskDetail.getPrice() == null) {
// return CommonTool.failResult("搬家价格不完整,请联系客服");
// }
//
// if (taskDetail.getSkus().getJSONObject("skuMap").isEmpty() && !sourceProductData.getJSONObject("skuMap").isEmpty()) {
// return CommonTool.failResult("搬家SKU不完整请复制来源链接重新复制商品");
// }
return CommonTool.successResult();
}
@ -2617,6 +2739,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
// 更新搬家detail数据
// updateMoveCollectTaskDetail(updateMoveCollectTaskDetailData, shopId, detailId);
} else {
E.throwMSException(processRet.getReason());
// TODO
// // 限流等情况的处理
// checkIsFrequencyLimitReason();

Loading…
Cancel
Save