Merge branch 'master' of codeup.aliyun.com:64d9c5feeceb191898f636d7/honor-dd-light-ds-java

20230922-ljl-fixBug
cxxxxxxx详 1 year ago
commit 83c9cf0ef0

@ -1,39 +1,62 @@
package com.ms.api.biz;
import com.alibaba.fastjson.JSON;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.product_getCatePropertyV2.ProductGetCatePropertyV2Request;
import com.doudian.open.api.product_getCatePropertyV2.ProductGetCatePropertyV2Response;
import com.doudian.open.api.product_getCatePropertyV2.param.ProductGetCatePropertyV2Param;
import com.doudian.open.api.product_getProductUpdateRule.data.FulfillmentRule;
import com.doudian.open.api.product_getProductUpdateRule.data.NormalRule;
import com.doudian.open.api.product_getProductUpdateRule.data.ProductGetProductUpdateRuleData;
import com.doudian.open.api.product_getProductUpdateRule.param.ProductGetProductUpdateRuleParam;
import com.doudian.open.core.AccessToken;
import com.ms.api.bo.AttributeBO;
import com.ms.api.bo.CateAttributeResultBO;
import com.ms.api.bo.MoveProductPublishQueueBO;
import com.ms.api.bo.MoveShopSettingBO;
import com.ms.api.common.ApiResult;
import com.ms.api.common.MSException;
import com.ms.api.common.Ret;
import com.ms.api.common.StrObjMap;
import com.ms.api.consts.MoveConst;
import com.ms.api.consts.StatusConst;
import com.ms.api.service.MoveCollectTaskDetailService;
import com.ms.api.tool.CommonTool;
import com.ms.api.util.DdRequestUtil;
import com.ms.dal.bo.CollectTaskDetailBO;
import com.ms.dal.entity.MoveCollectTask;
import com.ms.dal.entity.MoveCollectTaskDetail;
import com.ms.dal.entity.MoveProductPublishBuffer;
import com.ms.dal.entity.MoveShopSetting;
import com.ms.dal.mapper.MoveCollectTaskDetailMapper;
import com.ms.dal.mapper.MoveCollectTaskMapper;
import com.ms.dal.mapper.MoveProductPublishBufferMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Component
public class MoveService {
@Autowired
private PlatformTransactionManager transactionManager;
@Autowired
private SaveBatchMoveTaskBizService saveBatchMoveTaskBizService;
@Autowired
private MoveCollectTaskDetailService moveCollectTaskDetailService;
@Autowired
private MoveCollectTaskDetailMapper moveCollectTaskDetailMapper;
@Autowired
private MoveProductPublishBufferMapper moveProductPublishBufferMapper;
@Autowired
private MoveCollectTaskMapper moveCollectTaskMapper;
/**
*
*
@ -303,14 +326,19 @@ public class MoveService {
}
if (sizeTemplateIdObj instanceof String) {
long cid = moveBaseData.getLong("cid");
long commonTemplateId = 0;
// TODO 这里可能不需要
// sizeTemplateId = $this->moveService->getShopSettingSizeTemplateIdByCid($shopId, $condition['moveShopSettingId'], $cid, $commonTemplateId);
sizeTemplateId = getShopSettingSizeTemplateIdByCid(shopId, condition.getMoveShopSettingId(), cid, commonTemplateId);
} else {
sizeTemplateId = (int) sizeTemplateIdObj;
}
return sizeTemplateId;
}
private int getShopSettingSizeTemplateIdByCid(long shopId, Integer moveShopSettingId, long cid, long commonTemplateId) {
return 0;
}
public List<String> getMovePublishAllImgs(JSONObject productDetailBase) {
List<String> imgUrls = new ArrayList<>();
imgUrls.addAll(Arrays.asList(((String) productDetailBase.getOrDefault("mainImgUrls", "")).split("\\|")));
@ -341,4 +369,177 @@ public class MoveService {
return uniqueUrls.stream().filter(url -> url != null && !url.isEmpty()).collect(Collectors.toList());
}
public Long moveAgainDetailsByDetailId(Long shopId, Long detailId) {
MoveCollectTaskDetail moveDetail = moveCollectTaskDetailService.getMoveCollectTaskDetail(shopId, detailId);
if (moveDetail == null) {
return null;
}
int needAddCnt = 1;
Ret checkAndGetConfigIdRet = saveBatchMoveTaskBizService.checkAvailableCopyAndGetMoveConfigId(shopId, needAddCnt);
if (CommonTool.isFailRet(checkAndGetConfigIdRet)) {
return null;
}
Integer moveShopConfigId = null;
if (checkAndGetConfigIdRet.getData().containsKey("moveShopConfigId")) {
moveShopConfigId = Integer.valueOf(checkAndGetConfigIdRet.getData().get("moveShopConfigId").toString());
}
// todo MoveAgainDetailsForDsApi相关判断逻辑 用不上,跳过
MoveCollectTaskDetail taskDetailData = new MoveCollectTaskDetail();
taskDetailData.setShopId(shopId);
taskDetailData.setMoveCollectTaskId(moveDetail.getMoveCollectTaskId());
taskDetailData.setIsFastMode(moveDetail.getIsFastMode());
taskDetailData.setMoveShopConfigId(moveShopConfigId);
taskDetailData.setSource(moveDetail.getSource());
taskDetailData.setSite(moveDetail.getSource());
taskDetailData.setSourceItemId(moveDetail.getSourceItemId());
taskDetailData.setSourceTitle(moveDetail.getSourceTitle());
taskDetailData.setSourceImgUrl(moveDetail.getSourceImgUrl());
taskDetailData.setSourceShopName(moveDetail.getSourceShopName());
taskDetailData.setCid(moveDetail.getCid());
taskDetailData.setStatus(StatusConst.processing);
taskDetailData.setGmtCreate(new Date());
taskDetailData.setGmtModified(new Date());
// todo: 构建 MoveCollectTaskDetailExt这个版本不用
Integer priority = saveBatchMoveTaskBizService.getTaskPriority(shopId, 1);
MoveProductPublishBuffer insertPublishBuffer = new MoveProductPublishBuffer();
insertPublishBuffer.setShopId(shopId);
insertPublishBuffer.setMoveCollectTaskId(moveDetail.getMoveCollectTaskId().intValue());
insertPublishBuffer.setTryTimes(0);
insertPublishBuffer.setPriority(priority);
insertPublishBuffer.setGmtCreate(new Date());
insertPublishBuffer.setGmtModified(new Date());
Long newDetailId = addMoveTaskDetail(shopId, taskDetailData, insertPublishBuffer, moveShopConfigId, detailId);
if (newDetailId == null) {
return null;
}
return newDetailId;
}
public Long addMoveTaskDetail(Long shopId, MoveCollectTaskDetail taskDetailData, MoveProductPublishBuffer insertPublishBuffer, Integer moveShopConfigId, Long detailId) {
CollectTaskDetailBO taskDetail = getCollectTaskDetail(detailId);
if (shopId == null || moveShopConfigId == null || ObjectUtil.isEmpty(taskDetailData) || ObjectUtil.isEmpty(insertPublishBuffer)) {
log.error("商品添加是,参数有误");
return null;
// return Ret.fail("商品添加是,参数有误");
}
if (StatusConst.wait.equals(taskDetail.getStatus()) || StatusConst.process.equals(taskDetail.getStatus()) || taskDetail.getShopId() != shopId) {
log.error("重试失败,任务状态错误");
return null;
// return Ret.fail("重试失败,任务状态错误");
}
int needAddCnt = 1;
Ret checkAndGetConfigIdRet = saveBatchMoveTaskBizService.checkAvailableCopyAndGetMoveConfigId(shopId, needAddCnt);
if (CommonTool.isFailRet(checkAndGetConfigIdRet)) {
return null;
}
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
TransactionStatus status = transactionManager.getTransaction(def);
try {
if (needAddCnt > 0) {
Ret deductRet = saveBatchMoveTaskBizService.deductMoveCopyCount(shopId, needAddCnt, moveShopConfigId);
if (CommonTool.isFailRet(deductRet)) {
throw new MSException("扣除额度失败");
}
}
taskDetailData.setMoveShopConfigId(moveShopConfigId);
moveCollectTaskDetailMapper.insertSelective(taskDetailData);
detailId = taskDetailData.getMoveCollectTaskDetailId();
insertPublishBuffer.setMoveCollectTaskDetailId(detailId);
moveProductPublishBufferMapper.insertSelective(insertPublishBuffer);
log.info(String.format("addMoveTaskDetail shopId[%s] detailId[%s] success", shopId, detailId));
if (taskDetail.getCondition().getSkipCopied() != 0) {
MoveShopSetting newCondition = getMoveCollectTaskCondition(Long.valueOf(taskDetail.getMoveCollectTaskId()));
String jsonStr = JSONObject.toJSONString(newCondition);
JSONObject jsonObject = JSONObject.parseObject(jsonStr);
jsonObject.remove("skipCopied");
MoveCollectTask updateData = new MoveCollectTask();
updateData.setMoveCollectTaskId(taskDetail.getMoveCollectTaskId().intValue());
updateData.setCondition(jsonObject.toJSONString());
updateData.setGmtModified(new Date());
moveCollectTaskMapper.updateByPrimaryKeySelective(updateData);
}
transactionManager.commit(status);
} catch (Exception e) {
log.error(String.format("addMoveTaskDetail, shopId[%s] ,detailId[%s] error", shopId, detailId), e);
transactionManager.rollback(status);
return null;
}
return detailId;
}
public MoveShopSetting getMoveCollectTaskCondition(Long moveCollectTaskId) {
MoveShopSetting condition = null;
try {
MoveCollectTask moveCollectTask = moveCollectTaskMapper.selectByPrimaryKey(moveCollectTaskId);
MoveShopSetting moveShopSetting = JSONObject.parseObject(moveCollectTask.getCondition(), MoveShopSetting.class);
// PHPSerializer p = new PHPSerializer();
// condition = (MoveShopSetting) p.unserialize(moveCollectTask.getCondition().getBytes(), MoveShopSetting.class);
} catch (Exception e) {
log.error("getMoveCollectTaskCondition unserialize failed", e);
}
return condition;
}
public CollectTaskDetailBO getCollectTaskDetail(Long collectTaskDetailId) {
CollectTaskDetailBO ret = moveCollectTaskDetailMapper.getCollectTaskDetail(collectTaskDetailId);
try {
MoveShopSetting moveShopSetting = JSONObject.parseObject(ret.getConditionStr(), MoveShopSetting.class);
// PHPSerializer p = new PHPSerializer();
// MoveShopSetting moveShopSetting = (MoveShopSetting) p.unserialize(ret.getConditionStr().getBytes(), MoveShopSetting.class);
ret.setCondition(moveShopSetting);
} catch (Exception e) {
log.error("getCollectTaskDetail condition unserialize failed", e);
}
return ret;
}
public Ret getCategoryAttrV2FromDd(String cid, AccessToken accessToken) {
if (StringUtils.isBlank(cid)) {
return CommonTool.failResult("参数错误");
}
// TODO存取添加缓存
// $accessTokenSecret = md5($accessToken);
// if ($useCache && ($cache = $this->getCategoryAttrV2FromCache($cid, $accessTokenSecret))) {
// return CommonTool::successResult($cache);
// }
ProductGetCatePropertyV2Request request = new ProductGetCatePropertyV2Request();
ProductGetCatePropertyV2Param param = request.getParam();
param.setCategoryLeafId(Long.valueOf(cid));
ProductGetCatePropertyV2Response response = request.execute(accessToken);
Ret checkRet = CommonTool.checkDdApiRetStatus(response);
if (CommonTool.isFailRet(checkRet)) {
return checkRet;
}
// $this->setCategoryAttrV2Cache($cid, $ret['data'], $accessTokenSecret);
return CommonTool.successResult("data", response.getData());
}
}

@ -105,4 +105,6 @@ public class MoveProductPublishQueueBO {
private StrObjMap skuPresellChildSkuDetail;
private Double hasImportPrice;
}

@ -172,4 +172,6 @@ public class MoveShopSettingBO {
private Integer resetSkuStockNum;
private Integer resetSkuZeroStockNum;
private Integer quantity;
private String skuCodeRule;
}

@ -102,7 +102,7 @@ public class MoveConst {
public static String aliPriceTypeConfig = "config";
public static String collectTaskSource1688 = "1688";
public static String proxyPlatformTypePicUrl = "picUrl";
public static String brandEmpty = "empty";
public static List<String> getSpecialBanWordList() {
List<String> result = new ArrayList<String>();
result.add("特价");

@ -7,6 +7,7 @@ import com.jinritemai.cloud.base.api.BaseRequest;
import com.jinritemai.cloud.base.api.BaseResponse;
import com.jinritemai.cloud.base.api.ExtensionService;
import com.jinritemai.cloud.base.api.ExtensionServiceHandler;
import com.ms.api.biz.MoveService;
import com.ms.api.biz.SaveBatchMoveTaskBizService;
import com.ms.api.common.R;
import com.ms.api.common.Ret;
@ -43,7 +44,8 @@ public class MoveAgainDetailService extends SPIBaseService implements ExtensionS
private MoveCollectTaskDetailService moveCollectTaskDetailService;
@Autowired
private ShopService shopService;
private MoveService moveService;
@Override
public BaseResponse<Ret> handle(BaseRequest<MoveAgainDetailRequestDTO> req) {
@ -56,7 +58,7 @@ public class MoveAgainDetailService extends SPIBaseService implements ExtensionS
int size = taskDetailIds.size();
if (size == 1) {
Long lastDetails = taskDetailIds.get(0);
Long newDetailId = this.moveAgainDetailsByDetailId(shopId, lastDetails, null);
Long newDetailId = moveService.moveAgainDetailsByDetailId(shopId, lastDetails);
if (newDetailId != null && newDetailId != 0) {
JSONObject retObj = new JSONObject();
retObj.put("processCount", 1);
@ -65,73 +67,10 @@ public class MoveAgainDetailService extends SPIBaseService implements ExtensionS
return R.ok(Ret.fail("当前商品数据已失效,暂不支持操作,如有疑问请联系客服"));
}
} else {
// todo:
// todo: 批量
}
// ----结果返回----
return R.fail("111");
return R.ok(Ret.success());
}
private Long moveAgainDetailsByDetailId(Long shopId, Long detailId, Long cnaliDetailId) {
MoveCollectTaskDetail moveDetail = moveCollectTaskDetailService.getMoveCollectTaskDetail(shopId, detailId);
if (moveDetail == null) {
return null;
}
int needAddCnt = 1;
if (cnaliDetailId != null) {
needAddCnt = 0;
}
Ret checkAndGetConfigIdRet = saveBatchMoveTaskBizService.checkAvailableCopyAndGetMoveConfigId(shopId, needAddCnt);
if (checkAndGetConfigIdRet.getResult().equals("fail")) {
return null;
}
Integer moveShopConfigId = Integer.valueOf(checkAndGetConfigIdRet.getData().get("moveShopConfigId").toString());
// todo MoveAgainDetailsForDsApi相关判断逻辑 用不上,跳过
MoveCollectTaskDetail taskDetailData = new MoveCollectTaskDetail();
taskDetailData.setShopId(shopId);
taskDetailData.setMoveCollectTaskId(moveDetail.getMoveCollectTaskId());
taskDetailData.setIsFastMode(moveDetail.getIsFastMode());
taskDetailData.setMoveShopConfigId(moveShopConfigId);
taskDetailData.setSource(moveDetail.getSource());
taskDetailData.setSite(moveDetail.getSource());
taskDetailData.setSourceItemId(moveDetail.getSourceItemId());
taskDetailData.setSourceTitle(moveDetail.getSourceTitle());
taskDetailData.setSourceImgUrl(moveDetail.getSourceImgUrl());
taskDetailData.setSourceShopName(moveDetail.getSourceShopName());
taskDetailData.setCid(moveDetail.getCid());
taskDetailData.setStatus(StatusConst.processing);
taskDetailData.setGmtCreate(new Date());
taskDetailData.setGmtModified(new Date());
// todo: 构建 MoveCollectTaskDetailExt这个版本不用
Integer priority = saveBatchMoveTaskBizService.getTaskPriority(shopId, 1);
MoveProductPublishBuffer insertPublishBuffer = new MoveProductPublishBuffer();
insertPublishBuffer.setShopId(shopId);
insertPublishBuffer.setMoveCollectTaskId(moveDetail.getMoveCollectTaskId().intValue());
insertPublishBuffer.setTryTimes(0);
insertPublishBuffer.setPriority(priority);
insertPublishBuffer.setGmtCreate(new Date());
insertPublishBuffer.setGmtModified(new Date());
boolean addRet = addMoveTaskDetail(shopId, taskDetailData, insertPublishBuffer, moveShopConfigId, detailId);
if (!addRet) {
return null;
}
return detailId;
}
private boolean addMoveTaskDetail(Long shopId, MoveCollectTaskDetail taskDetailData, MoveProductPublishBuffer insertPublishBuffer, Integer moveShopConfigId, Long detailId) {
// todo:
return true;
}
}

@ -1,6 +1,21 @@
package com.ms.api.task;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.product_addV2.ProductAddV2Request;
import com.doudian.open.api.product_addV2.ProductAddV2Response;
@ -11,20 +26,50 @@ import com.doudian.open.api.product_addV2.param.RecruitInfo;
import com.doudian.open.api.product_detail.ProductDetailRequest;
import com.doudian.open.api.product_detail.ProductDetailResponse;
import com.doudian.open.api.product_detail.param.ProductDetailParam;
import com.doudian.open.api.product_getCatePropertyV2.data.DataItem;
import com.doudian.open.api.product_getCatePropertyV2.data.ProductGetCatePropertyV2Data;
import com.doudian.open.core.AccessToken;
import com.ms.api.biz.MoveService;
import com.ms.api.bo.MoveProductPublishToPicQueueBO;
import com.ms.api.bo.MoveShopSettingBO;
import com.ms.api.common.*;
import com.ms.api.consts.*;
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.AppConst;
import com.ms.api.consts.CommonConst;
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.service.DsRelateProductAnalysisOpOrderQueueService;
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.MoveProductLogService;
import com.ms.api.service.MoveProductPublishQueueService;
import com.ms.api.service.MoveProductPublishToPicQueueService;
import com.ms.api.service.ProductToDsItemService;
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.SecurityTool;
import com.ms.api.util.MoveUtil;
import com.ms.dal.entity.*;
import com.ms.dal.entity.DsRelateProductAnalysisOpOrderQueue;
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.MoveProductLog;
import com.ms.dal.entity.MoveProductPublishToPicQueue;
import com.ms.dal.entity.ProductToDsItem;
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.springframework.beans.factory.annotation.Autowired;
@ -33,15 +78,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
@ -254,7 +290,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
JSONObject productDetailBase = data.getJSONObject("productDetailBase");
JSONObject sourceProductData = data.getJSONObject("sourceProductData");
JSONObject moveBaseData = data.getJSONObject("moveBaseData");
JSONObject brandList = data.getJSONObject("brandList");
JSONArray brandList = data.getJSONArray("brandList");
AccessToken accessToken = getShopAccessToken(shopId);
// 检查详情图片数量和长度
productDetailBase.put("noteImgUrls", filterNoteImgUrls((String) productDetailBase.get("noteImgUrls")));
@ -298,7 +334,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
return mAccessToken;
}
private Ret createProduct(JSONObject productDetailBase, JSONObject sourceProductData, MoveShopSettingBO condition, MoveProductPublishToPicQueueBO queueMsg, JSONObject moveBaseData, JSONObject brandList, AccessToken accessToken) {
private Ret createProduct(JSONObject productDetailBase, JSONObject sourceProductData, MoveShopSettingBO condition, MoveProductPublishToPicQueueBO queueMsg, JSONObject moveBaseData, JSONArray brandList, AccessToken accessToken) {
long shopId = queueMsg.getShopId();
Ret addRet = postDataToDdV2(productDetailBase, condition, queueMsg, moveBaseData, accessToken);
// TODO 几个方法的实现
@ -338,47 +374,80 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
}
// TODO
private Ret rebuildAddRetReason(Ret addRet, JSONObject brandList, MoveShopSettingBO condition, String cid, AccessToken accessToken) {
// if (strpos($addRet['reason'], '请重新选择品牌') !== false || strpos($addRet['reason'], '该类目下无品牌') !== false || strpos($addRet['reason'], '品牌不属于该类目') !== false) {
// if (is_numeric($condition['brandId'])) {
// $brandMap = array_column($brandList, null, 'id');
// $brandId = $condition['brandId'];
// $brandName = $brandMap[$brandId]['brand_chinese_name'] ? $brandMap[$brandId]['brand_chinese_name'] : $brandMap[$brandId]['brand_english_name'];
// $addRet['reason'] = "当前类目无 $brandName 品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>";
// return $addRet;
// } else if ($condition['brandId'] == MoveConst::brandEmpty) {
// $addRet['reason'] = '当前类目品牌必填,请前往店铺后台申请品牌,<a href="https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2" target="_blank">立即申请</a><br>您在搬家配置设置“品牌留空”。若您已经申请品牌,请修改搬家配置,若没有申请品牌,请前往店铺后台申请品牌';
// return $addRet;
// } else if (empty($brandList)) {
// $addRet['reason'] = '当前类目品牌必填,请前往店铺后台申请品牌,<a href="https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2" target="_blank">立即申请</a>';
// return $addRet;
// } else if (count($brandList)) {
// $brandNames = [];
// foreach ($brandList as $brand) {
// $brandNames[] = $brand['brand_chinese_name'] ? $brand['brand_chinese_name'] : $brand['brand_english_name'];
// }
// $addRet['reason'] = '当前类目无"'. implode(',', $brandNames) .'"品牌权限,请前往店铺后台申请品牌,<a href="https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2" target="_blank">立即申请</a>';
// return $addRet;
// }
// }
//
// if (strpos($addRet['reason'], '没有品牌资质,非普通店商品请使用有资质的品牌') !== false) {
// return $this->rebuildAddRetBrandQualificationReason($addRet, $brandList, $cid, $accessToken);
// }
//
// if (strpos($addRet['reason'], '颜色对应的规格值不能重复,请核对') !== false) {
// $addRet['reason'] = $addRet['reason'] . ',请检查是否包含特殊符号或违禁词(' . implode('', MoveConst::getSpecialBanWordList()) . '';
// }
//
// if (preg_match('/规格值含有敏感词(?::|)\[([^\]]+)\]/', $addRet['reason'], $matchBanWord) || preg_match('/商品规格值描述“(.*)”不符合平台要求/', $addRet['reason'], $matchBanWord)) {
// $addRet['reason'] = $addRet['reason'] . ',并且过滤后会导致sku规格值重复请检查并手动修改';
// }
//
// return $addRet;
private Ret rebuildAddRetReason(Ret addRet, JSONArray brandList, MoveShopSettingBO condition, String cid, AccessToken accessToken) {
if (addRet.getReason().contains("请重新选择品牌") || addRet.getReason().contains("该类目下无品牌") || addRet.getReason().contains("品牌不属于该类目")) {
if (StringUtils.isNumeric(condition.getBrandId())) {
Map<String, JSONObject> brandMap = brandList.stream().filter(x -> ((JSONObject) x).containsKey("id")).collect(Collectors.toMap(x -> ((JSONObject) x).getString("id"), x -> (JSONObject) x, (v1, v2) -> v1));
JSONObject brand = brandMap.get(condition.getBrandId());
String brandName = brand.getString("brand_chinese_name") != null ? brand.getString("brand_chinese_name") : brand.getString("brand_english_name");
addRet.setReason("当前类目无 " + brandName + " 品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
return addRet;
} else if (Objects.equals(condition.getBrandId(), MoveConst.brandEmpty)) {
addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a><br>您在搬家配置设置“品牌留空”。若您已经申请品牌,请修改搬家配置,若没有申请品牌,请前往店铺后台申请品牌");
return addRet;
} else if (brandList.isEmpty()) {
addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
return addRet;
} else if (brandList.size() != 0) {
List<String> brandNames = brandList.stream().map(x -> {
JSONObject temp = (JSONObject) x;
return temp.containsKey("brand_chinese_name") ? temp.getString("brand_chinese_name") : temp.getString("brand_english_name");
}).collect(Collectors.toList());
addRet.setReason("当前类目无\"" + String.join(",", brandNames) + "\"品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
return addRet;
}
}
if (addRet.getReason().contains("没有品牌资质,非普通店商品请使用有资质的品牌")) {
return rebuildAddRetBrandQualificationReason(addRet, brandList, cid, accessToken);
}
if (addRet.getReason().contains("颜色对应的规格值不能重复,请核对")) {
addRet.setReason(addRet.getReason() + ",请检查是否包含特殊符号或违禁词(" + String.join("", MoveConst.getSpecialBanWordList()) + "");
}
Matcher matcherBanWord = Pattern.compile("规格值含有敏感词(?::|)\\[([^\\]]+)\\]").matcher(addRet.getReason());
Matcher matcherBanWordDescription = Pattern.compile("商品规格值描述“(.*)”不符合平台要求").matcher(addRet.getReason());
if (matcherBanWord.matches() || matcherBanWordDescription.matches()) {
addRet.setReason(addRet.getReason() + ",并且过滤后会导致sku规格值重复请检查并手动修改");
}
return addRet;
}
private Ret rebuildAddRetBrandQualificationReason(Ret addRet, JSONArray brandList, String cid, AccessToken accessToken) {
Ret categoryAttrRet = moveService.getCategoryAttrV2FromDd(cid, accessToken);
if (CommonTool.isFailRet(categoryAttrRet)) {
return addRet;
}
boolean isNeedCheckShopBrand = checkIsNeedShopBrand((ProductGetCatePropertyV2Data) categoryAttrRet.getData().get("data"));
if (!isNeedCheckShopBrand) {
return addRet;
}
if (!brandList.isEmpty()) {
addRet.setReason("当前商品发布的类目未申请品牌资质,请到店铺后台申请品牌资质,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/brand-edit\" target=\"_blank\">前往申请</a>");
}
return addRet;
}
private boolean checkIsNeedShopBrand(ProductGetCatePropertyV2Data data) {
List<DataItem> attrs = data.getData();
boolean isNeed = false;
for (DataItem attr : attrs) {
if (!"品牌".equals(attr.getPropertyName())) {
continue;
}
if (ObjectUtil.isNotEmpty(attr.getRequired()) && attr.getRequired() != 0) {
break;
}
if (ObjectUtil.isEmpty(attr.getOptions())) {
isNeed = true;
}
}
return isNeed;
}
private void deleteShopCategoryBrand(long shopId, JSONObject productDetailBase, Ret addRet) {
// if(CommonTool::isSuccessRet($addProductRet)) {
// return ;
@ -457,7 +526,6 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
return addRet;
}
private StrObjMap processAddProductError(long shopId, JSONObject productDetailBase, MoveShopSettingBO condition, MoveProductPublishToPicQueueBO queueMsg, JSONObject moveBaseData, String reason, int i, AccessToken accessToken) {
boolean dataIsChange = false;
//
@ -521,7 +589,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
String title = productData.getString("title");
if (!Objects.isNull(title)) {
param.setName(title.substring(0, Math.min(title.length(), 10)));
param.setName(title.substring(0, Math.min(title.length(), 10)));
}
String mainImgUrls = productData.getString("mainImgUrls");
@ -590,7 +658,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
// Object productFormatNew = productData.get("productFormatNew");
// if (!Objects.isNull(productFormatNew)) {
// param.setProductFormatNew(JSON.toJSONString(productFormatNew));
param.setProductFormatNew("{\"631\":[{\"diy_type\":1,\"name\":\"嘻哈风\",\"value\":196227}],\"1467\":[{\"diy_type\":0,\"name\":\"59%-69%(含)\",\"value\":168368}],\"1551\":[{\"diy_type\":1,\"name\":\"超短裙\",\"value\":22064}],\"1687\":[{\"diy_type\":0,\"name\":\"改为具体的品牌,没有可以为空\",\"value\":0}],\"1878\":[{\"diy_type\":1,\"name\":\"高腰\",\"value\":16521}],\"2592\":[{\"diy_type\":1,\"name\":\"甜美\",\"value\":23925}],\"785\":[{\"diy_type\":0,\"name\":\"涤纶\",\"value\":25708}],\"813\":[{\"diy_type\":1,\"name\":\"X型\",\"value\":8017}],\"981\":[{\"diy_type\":1,\"name\":\"蛋糕裙\",\"value\":22253}]}");
param.setProductFormatNew("{\"631\":[{\"diy_type\":1,\"name\":\"嘻哈风\",\"value\":196227}],\"1467\":[{\"diy_type\":0,\"name\":\"59%-69%(含)\",\"value\":168368}],\"1551\":[{\"diy_type\":1,\"name\":\"超短裙\",\"value\":22064}],\"1687\":[{\"diy_type\":0,\"name\":\"改为具体的品牌,没有可以为空\",\"value\":0}],\"1878\":[{\"diy_type\":1,\"name\":\"高腰\",\"value\":16521}],\"2592\":[{\"diy_type\":1,\"name\":\"甜美\",\"value\":23925}],\"785\":[{\"diy_type\":0,\"name\":\"涤纶\",\"value\":25708}],\"813\":[{\"diy_type\":1,\"name\":\"X型\",\"value\":8017}],\"981\":[{\"diy_type\":1,\"name\":\"蛋糕裙\",\"value\":22253}]}");
// }
// Long deliveryDelayDay = productData.getLong("deliveryDelayDay");

@ -1327,7 +1327,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
moveBaseData.put("brandName", brandName);
// 从抖店获取的类目属性
Ret categoryAttrRet = getCategoryAttrV2FromDd(cid, accessToken);
Ret categoryAttrRet = moveService.getCategoryAttrV2FromDd(cid, accessToken);
if (CommonTool.isFailRet(categoryAttrRet)) {
return categoryAttrRet;
}
@ -1457,31 +1457,6 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return matchAttrs;
}
private Ret getCategoryAttrV2FromDd(String cid, AccessToken accessToken) {
if (StringUtils.isBlank(cid)) {
return CommonTool.failResult("参数错误");
}
// TODO存取添加缓存
// $accessTokenSecret = md5($accessToken);
// if ($useCache && ($cache = $this->getCategoryAttrV2FromCache($cid, $accessTokenSecret))) {
// return CommonTool::successResult($cache);
// }
ProductGetCatePropertyV2Request request = new ProductGetCatePropertyV2Request();
ProductGetCatePropertyV2Param param = request.getParam();
param.setCategoryLeafId(Long.valueOf(cid));
ProductGetCatePropertyV2Response response = request.execute(accessToken);
Ret checkRet = CommonTool.checkDdApiRetStatus(response);
if (CommonTool.isFailRet(checkRet)) {
return checkRet;
}
// $this->setCategoryAttrV2Cache($cid, $ret['data'], $accessTokenSecret);
return CommonTool.successResult("data", response.getData());
}
private List<StrObjMap> matchSourceAttr(DataItem attribute, JSONObject sourceAttrs, String title) {
List<StrObjMap> matchAttr;
if (attribute.getType().equals(MoveConst.attrInputTypeText)) {
@ -2020,7 +1995,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
price = 0;
}
// TODO
// skuMap = appendSkuCode(moveBaseData, queueMsg, skuMap, itemNum);
skuMap = appendSkuCode(moveBaseData, queueMsg, skuMap, itemNum);
// skuList = buildSkuListAndSkuImages(mSkus.getJSONObject() ['skuMap'], mSkus['colorMap'], mSkus['sizeMap'], condition, (price > 0 ? price : queueMsg.getPrice()), queueMsg.getShopId());
// skuList = calSkuPriceByCondition($isFastMode, $skuList, $condition['price'], $moveBaseData, $cnaliDsDetailId, $hasImportPrice);
// updateSkuMinPriceInfo = getUpdateSkuMinPriceInfo($condition['price'], $skuList);
@ -2034,6 +2009,12 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return result;
}
private JSONObject appendSkuCode(JSONObject moveBaseData, MoveProductPublishQueueBO queueMsg, JSONObject skuList, String itemNum) {
MoveShopSettingBO condition = queueMsg.getCondition();
return null;
}
private JSONObject resetSkuStock(MoveShopSettingBO condition, JSONObject skuMap, int isFastMode) {
if (isFastMode == 0) {
return skuMap;

@ -0,0 +1,30 @@
package com.ms.dal.bo;
import com.ms.dal.entity.MoveCollectTaskDetail;
import com.ms.dal.entity.MoveShopSetting;
import lombok.Data;
@Data
public class CollectTaskDetailBO extends MoveCollectTaskDetail {
// /**
// * move_collect_task_id
// */
// private Integer moveCollectTaskId;
/**
* name
*/
private String name;
/**
* copy_type
*/
private String copyType;
/**
* condition
*/
private String conditionStr;
private MoveShopSetting condition;
}

@ -1,5 +1,6 @@
package com.ms.dal.mapper;
import com.ms.dal.bo.CollectTaskDetailBO;
import com.ms.dal.entity.MoveCollectTaskDetail;
import org.apache.ibatis.annotations.Mapper;
@ -32,4 +33,6 @@ public interface MoveCollectTaskDetailMapper {
List<Long> getMoveDetailIdsByStatus(Long shopId, String status);
MoveCollectTaskDetail getMoveCollectTaskDetail(Long shopId,Long moveCollectTaskDetailId);
CollectTaskDetailBO getCollectTaskDetail(Long collectTaskDetailId);
}

@ -31,6 +31,13 @@
<result property="productId" column="product_id" jdbcType="BIGINT"/>
</resultMap>
<resultMap id="QOResultMap" type="com.ms.dal.bo.CollectTaskDetailBO" extends="BaseResultMap">
<result property="moveCollectTaskId" column="move_collect_task_id"/>
<result property="name" column="name"/>
<result property="conditionStr" column="condition_str"/>
<result property="copyType" column="copy_type"/>
</resultMap>
<sql id="Base_Column_List">
move_collect_task_detail_id,shop_id,move_collect_task_id,
is_fast_mode,move_shop_config_id,source,
@ -46,12 +53,12 @@
select
<include refid="Base_Column_List" />
from move_collect_task_detail
where move_collect_task_detail_id = #{moveCollectTaskDetailId,jdbcType=BIGINT}
where move_collect_task_detail_id = #{moveCollectTaskDetailId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from move_collect_task_detail
where move_collect_task_detail_id = #{moveCollectTaskDetailId,jdbcType=BIGINT}
where move_collect_task_detail_id = #{moveCollectTaskDetailId,jdbcType=BIGINT}
</delete>
<insert id="insert" keyColumn="move_collect_task_detail_id" keyProperty="moveCollectTaskDetailId" parameterType="com.ms.dal.entity.MoveCollectTaskDetail" useGeneratedKeys="true">
insert into move_collect_task_detail
@ -195,11 +202,11 @@
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},
</if>
</set>
where move_collect_task_detail_id = #{moveCollectTaskDetailId,jdbcType=BIGINT}
where move_collect_task_detail_id = #{moveCollectTaskDetailId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ms.dal.entity.MoveCollectTaskDetail">
update move_collect_task_detail
set
set
shop_id = #{shopId,jdbcType=BIGINT},
move_collect_task_id = #{moveCollectTaskId,jdbcType=BIGINT},
is_fast_mode = #{isFastMode,jdbcType=TINYINT},
@ -222,7 +229,7 @@
publish_wait_seconds = #{publishWaitSeconds,jdbcType=INTEGER},
gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where move_collect_task_detail_id = #{moveCollectTaskDetailId,jdbcType=BIGINT}
where move_collect_task_detail_id = #{moveCollectTaskDetailId,jdbcType=BIGINT}
</update>
<select id="getMoveCollectTaskList" resultMap="BaseResultMap">
select a.*,b.product_id
@ -266,4 +273,9 @@
from move_collect_task_detail
where move_collect_task_detail_id = #{moveCollectTaskDetailId,jdbcType=BIGINT} and shop_id = #{shopId,jdbcType=BIGINT}
</select>
<select id="getCollectTaskDetail" resultMap="QOResultMap">
SELECT ct.move_collect_task_id, ct.name, ct.condition as condition_str , ct.copy_type, ctd.*
FROM move_collect_task_detail ctd LEFT JOIN move_collect_task ct ON ct.move_collect_task_id = ctd.move_collect_task_id
WHERE ctd.move_collect_task_detail_id = #{collectTaskDetailId,jdbcType=BIGINT}
</select>
</mapper>

Loading…
Cancel
Save