From be88561d749031f6da0676cddb9de4a19f271304 Mon Sep 17 00:00:00 2001 From: daixiaogang <2510234660@qq.com> Date: Tue, 12 Sep 2023 17:09:12 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=BA=97=E9=93=BAcid=20c?= =?UTF-8?q?heckTaskDetailCidIsValid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProcessProductPublishTaskService.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java b/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java index dac6106a..117e12ab 100644 --- a/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java @@ -74,6 +74,7 @@ import com.ms.api.tool.MoveTool; import com.ms.api.tool.SecurityTool; import com.ms.api.util.DdRequestUtil; 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; @@ -918,7 +919,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { productDetailBase.put("updateSkuMinPriceInfo", updateSkuMinPriceInfo); // 品牌 - Ret matchBrandRet = searchBrandIdByBrandNameFromDd(cid, brandName, accessToken,true); + Ret matchBrandRet = searchBrandIdByBrandNameFromDd(cid, brandName, accessToken, true); if (CommonTool.isFailRet(matchBrandRet)) { return matchBrandRet; } @@ -1321,6 +1322,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { private String getBrandNameFromDdBrand(AuthBrandListItem brand) { return StrUtil.isBlank(brand.getNameCn()) ? brand.getNameEn() : (StrUtil.isBlank(brand.getNameEn()) ? brand.getNameCn() : brand.getNameEn().concat(".").concat(brand.getNameCn())); } + private String getBrandNameFromDdBrand(BrandListItem brand) { return StrUtil.isBlank(brand.getNameCn()) ? brand.getNameEn() : (StrUtil.isBlank(brand.getNameEn()) ? brand.getNameCn() : brand.getNameEn().concat(".").concat(brand.getNameCn())); } @@ -1544,23 +1546,21 @@ public class ProcessProductPublishTaskService extends TaskBaseService { private Ret checkTaskDetailCidIsValid(MoveProductPublishQueueBO queueMsg, long shopId) { // TODO 检查店铺的Cid,假设是成功了 -// if ($queueMsg['cnali_ds_detail_id']) { -// return CommonTool::successResult(); -// } -// -// $cid = $queueMsg['cid']; -// $ret = $this->shopService->checkTaskDetailCidIsValidByCategoryShop($cid, $shopId); -// if (CommonTool::isSuccessRet($ret)) { -// return CommonTool::successResult(); -// } -// -// $cateListAll = $this->rsyncProductService->getAllShopCategorys($shopId); -// $categoryIds = ZcArrayHelper::getSub($cateListAll, 'category_id'); -// if(!in_array($cid, $categoryIds)) { -// $this->productPublishLog->info("checkTaskDetailCidIsValid fail cid:" . $cid . ",categoryIds:" . var_export($categoryIds, 1)); -// return CommonTool::failResult('店铺分类不存在'); -// } -// return CommonTool::successResult(); + if (ObjectUtil.isNotNull(queueMsg.getCnaliDsDetailId())) { + return Ret.success(); + } + + String cid = queueMsg.getCid(); + CategoryShop ret = categoryShopService.selectByPrimaryKey(shopId, Long.valueOf(cid)); + if (ObjectUtil.isNotNull(ret)) { + return Ret.success(); + } + Map allShopCategorys = getAllLeafProductCatListFromDb(shopId); + Set categoryIds = allShopCategorys.keySet(); + if (!categoryIds.contains(cid)) { + log.info("checkTaskDetailCidIsValid fail cid:" + cid + ",categoryIds:{}", JSON.toJSONString(categoryIds)); + return Ret.fail("店铺分类不存在"); + } return Ret.success(); } From 3420433b2f7349966ff06cc0a171bc04b2bdb2b5 Mon Sep 17 00:00:00 2001 From: daixiaogang <2510234660@qq.com> Date: Tue, 12 Sep 2023 17:24:26 +0800 Subject: [PATCH 2/5] =?UTF-8?q?checkMoveDataCompletion=20=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=95=B0=E6=8D=AE=E5=AE=8C=E6=95=B4=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms/api/bo/MoveProductPublishQueueBO.java | 10 ++- .../java/com/ms/api/bo/MoveShopSettingBO.java | 1 + .../java/com/ms/api/consts/MoveConst.java | 4 ++ .../ProcessProductPublishTaskService.java | 69 ++++++++++--------- 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/bo/MoveProductPublishQueueBO.java b/ms-biz/src/main/java/com/ms/api/bo/MoveProductPublishQueueBO.java index 161769e5..74428e7b 100644 --- a/ms-biz/src/main/java/com/ms/api/bo/MoveProductPublishQueueBO.java +++ b/ms-biz/src/main/java/com/ms/api/bo/MoveProductPublishQueueBO.java @@ -1,5 +1,6 @@ package com.ms.api.bo; +import com.alibaba.fastjson.JSONObject; import lombok.Data; import java.util.Date; @@ -86,5 +87,12 @@ public class MoveProductPublishQueueBO { private String itemNum; - private int price; + private Integer price; + + private Boolean hasSaveNotes; + + private String notes; + + private JSONObject skus; + } diff --git a/ms-biz/src/main/java/com/ms/api/bo/MoveShopSettingBO.java b/ms-biz/src/main/java/com/ms/api/bo/MoveShopSettingBO.java index 56a9f653..06fc4d56 100644 --- a/ms-biz/src/main/java/com/ms/api/bo/MoveShopSettingBO.java +++ b/ms-biz/src/main/java/com/ms/api/bo/MoveShopSettingBO.java @@ -162,4 +162,5 @@ public class MoveShopSettingBO { private JSONObject price; + private JSONObject desc; } diff --git a/ms-biz/src/main/java/com/ms/api/consts/MoveConst.java b/ms-biz/src/main/java/com/ms/api/consts/MoveConst.java index a68ecb00..8806a0e4 100644 --- a/ms-biz/src/main/java/com/ms/api/consts/MoveConst.java +++ b/ms-biz/src/main/java/com/ms/api/consts/MoveConst.java @@ -58,4 +58,8 @@ public class MoveConst { public static Integer noBrandId = 596120136; // 无品牌ID public static String noBrandChinaName = "无品牌"; public static Integer brandAuditStatusSuccess = 2; // 品牌审核通过 + + public static final String descCopyTypeCopy = "copy"; + public static final String descCopyTypeNoCopy = "noCopy"; + public static final String descCopyTypeUseMainImage = "useMainImage"; } diff --git a/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java b/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java index 117e12ab..01a2b779 100644 --- a/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/ProcessProductPublishTaskService.java @@ -1863,40 +1863,41 @@ public class ProcessProductPublishTaskService extends TaskBaseService { private Ret checkMoveDataCompletion(MoveProductPublishQueueBO taskDetail, JSONObject sourceProductData) { // TODO 检查数据完整性 先都成功 - // if (empty($taskDetail['condition'])) { -// return CommonTool::failResult("配置信息丢失,请联系客服"); -// } -// if(empty($sourceProductData['title'])){ -// return CommonTool::failResult("商品标题必填,检查源商品是否下架"); -// } -// if(empty($taskDetail['cid'])){ -// return CommonTool::failResult("类目ID必填~~"); -// } -// if($taskDetail['has_save_notes']) { -// if(empty($taskDetail['notes'])) { -// return CommonTool::failResult("商品描述必填~~"); -// } -// } elseif(empty($sourceProductData['notes']) && $taskDetail['condition']['desc']['descCopyType'] == MoveConst::descCopyTypeCopy){ -// return CommonTool::failResult("商品描述必填~~"); -// } -// -// if(empty($sourceProductData['price'])){ -// return CommonTool::failResult("获取价格为空,请重试或联系客服~~"); -// } -// if(empty($sourceProductData['image_paths'])){ -// return CommonTool::failResult("图片信息必填~~"); -// } -// if ($taskDetail['is_fast_mode']) { -// return CommonTool::successResult(); -// } -// -// if (empty($taskDetail['price'])) { -// return CommonTool::failResult("搬家价格不完整,请联系客服"); -// } -// -// if (empty($taskDetail['skus']['skuMap']) && !empty($sourceProductData['skuMap'])) { -// return CommonTool::failResult("搬家SKU不完整,请复制来源链接重新复制商品"); -// } + if (ObjectUtil.isNull(taskDetail.getCondition())) { + return CommonTool.failResult("配置信息丢失,请联系客服"); + } + if (sourceProductData.getString("title") == null || sourceProductData.getString("title").isEmpty()) { + return CommonTool.failResult("商品标题必填,检查源商品是否下架"); + } + if (StrUtil.isBlank(taskDetail.getCid())) { + return CommonTool.failResult("类目ID必填~~"); + } + if (ObjectUtil.isNotNull(taskDetail.getHasSaveNotes()) && taskDetail.getHasSaveNotes()) { + if (StrUtil.isBlank(taskDetail.getNotes())) { + return CommonTool.failResult("商品描述必填~~"); + } + } else if (sourceProductData.getString("notes") == null || sourceProductData.getString("notes").isEmpty() && + taskDetail.getCondition().getDesc().getString("descCopyType").equals(MoveConst.descCopyTypeCopy)) { + 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("搬家价格不完整,请联系客服"); + } + + if (taskDetail.getSkus().getJSONObject("skuMap").isEmpty() && !sourceProductData.getJSONObject("skuMap").isEmpty()) { + return CommonTool.failResult("搬家SKU不完整,请复制来源链接重新复制商品"); + } return CommonTool.successResult(); } From 0a6fc19412c030f92e472975f151dfbef48b82f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?cxxxxxxx=E8=AF=A6?= <286460656@qq.com> Date: Tue, 12 Sep 2023 17:26:37 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=8E=88=E6=9D=83=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../java/com/ms/api/consts/CommonConst.java | 2 +- ...ack.java => MemberAuthCallbackService.java} | 2 +- .../main/java/com/ms/web/MoveController.java | 18 +++++++++++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) rename ms-biz/src/main/java/com/ms/api/spi/callback/{MemberAuthCallback.java => MemberAuthCallbackService.java} (96%) diff --git a/README.md b/README.md index f9261058..c2345951 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ curl --location --request POST 'localhost:8080/base/cloud/spi' \ --data-raw '{ "appId":"7264840234423027259", "authId":"4463798", -"method":"batchDeleteTaskDetail", +"method":"searchDSProductCatTree", "data":"{\"moveCollectTaskDetailIds\":[26],\"deleteOnSaleProduct\":0,\"deleteProduct\":0}" }' diff --git a/ms-biz/src/main/java/com/ms/api/consts/CommonConst.java b/ms-biz/src/main/java/com/ms/api/consts/CommonConst.java index 581d42bc..0656f57f 100644 --- a/ms-biz/src/main/java/com/ms/api/consts/CommonConst.java +++ b/ms-biz/src/main/java/com/ms/api/consts/CommonConst.java @@ -6,7 +6,7 @@ import java.util.List; public class CommonConst { public static final String SUCCESS = "success"; public static final String FAIL = "fail"; - public static final String PLATFORM = "dd"; + public static final String PLATFORM = "ddmicroapp"; public static final String BIZ_MOVE = "move"; public static final int MATERIAL_AUDIT_STATUS_QUEUE_MAX_CNT = 5000; public static final String COLLECT_TASK_SOURCE_1688 = "1688"; diff --git a/ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallback.java b/ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallbackService.java similarity index 96% rename from ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallback.java rename to ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallbackService.java index b59c4361..7a318e8a 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallback.java +++ b/ms-biz/src/main/java/com/ms/api/spi/callback/MemberAuthCallbackService.java @@ -34,7 +34,7 @@ import java.util.Objects; */ @ExtensionService("memberAuthCallBack") @Slf4j -public class MemberAuthCallback extends SPIBaseService implements ExtensionServiceHandler { +public class MemberAuthCallbackService extends SPIBaseService implements ExtensionServiceHandler { @Autowired private Shop1688DsAuthService shop1688DsAuthService; @Autowired diff --git a/ms-web/src/main/java/com/ms/web/MoveController.java b/ms-web/src/main/java/com/ms/web/MoveController.java index 8f69809e..f748b7f2 100644 --- a/ms-web/src/main/java/com/ms/web/MoveController.java +++ b/ms-web/src/main/java/com/ms/web/MoveController.java @@ -1,11 +1,14 @@ package com.ms.web; import com.alibaba.fastjson.JSON; +import com.jinritemai.cloud.base.api.BaseRequest; import com.jinritemai.cloud.base.api.BaseResponse; import com.ms.api.common.R; import com.ms.api.common.Ret; +import com.ms.api.dto.auth.MemberAuthCallBackRequestDTO; import com.ms.api.dto.move.DsRelationRequestDTO; import com.ms.api.service.ProductToDsItemService; +import com.ms.api.spi.callback.MemberAuthCallbackService; import com.ms.api.tool.CommonTool; import com.ms.dal.entity.ProductToDsItem; import lombok.extern.slf4j.Slf4j; @@ -23,6 +26,9 @@ public class MoveController { @Autowired ProductToDsItemService productToDsItemService; + @Autowired + private MemberAuthCallbackService memberAuthCallbackService; + @GetMapping("/testDsRelation") public BaseResponse testDsRelation(@ModelAttribute DsRelationRequestDTO dto) { if(StringUtils.isBlank(dto.getPlatformItemId())){ @@ -46,5 +52,15 @@ public class MoveController { } return R.ok(CommonTool.successResult("data", JSON.toJSONString(productToDsItem))); } - + @PostMapping("/memberAuthCallBack") + public BaseResponse memberAuthCallBack(@RequestBody MemberAuthCallBackRequestDTO request) { + try { + BaseRequest baseRequest =new BaseRequest<>(); + baseRequest.setData(request); + memberAuthCallbackService.handle(baseRequest); + return R.ok(CommonTool.successResult()); + } catch (RuntimeException e) { + return R.ok(Ret.fail(e.getMessage())); + } + } } From d3372f1df38210ed8cbaf46fd420bfda126de0a8 Mon Sep 17 00:00:00 2001 From: wangchaoxu Date: Tue, 12 Sep 2023 17:39:19 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E6=90=AC=E5=AE=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/spi/move/MoveAgainDetailService.java | 65 +++++-------------- 1 file changed, 16 insertions(+), 49 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/spi/move/MoveAgainDetailService.java b/ms-biz/src/main/java/com/ms/api/spi/move/MoveAgainDetailService.java index 96ac1766..c92cf743 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/move/MoveAgainDetailService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/move/MoveAgainDetailService.java @@ -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.SaveBatchMoveTaskBizService; import com.ms.api.common.R; import com.ms.api.common.Ret; import com.ms.api.common.SPIBaseService; @@ -34,10 +35,11 @@ import java.util.Objects; public class MoveAgainDetailService extends SPIBaseService implements ExtensionServiceHandler { @Autowired - private DsJsonRequestTemplate dsJsonRequestTemplate; + private SaveBatchMoveTaskBizService saveBatchMoveTaskBizService; @Autowired private MoveCollectTaskDetailService moveCollectTaskDetailService; + @Autowired private ShopService shopService; @@ -52,13 +54,13 @@ public class MoveAgainDetailService extends SPIBaseService implements ExtensionS int size = taskDetailIds.size(); if (size == 1) { Long lastDetails = taskDetailIds.get(0); - int newDetailId = this.moveAgainDetailsByDetailId(shopId, lastDetails, false); - if (newDetailId == 1) { + Integer newDetailId = this.moveAgainDetailsByDetailId(shopId, lastDetails, null); + if (newDetailId != null && newDetailId != 0) { JSONObject retObj = new JSONObject(); retObj.put("processCount", 1); return R.ok(Ret.success(retObj)); } else { - return R.fail("当前商品数据已失效,暂不支持操作,如有疑问请联系客服"); + return R.ok(Ret.fail("当前商品数据已失效,暂不支持操作,如有疑问请联系客服")); } } else { for (int i = 0; i < size; i++) { @@ -69,64 +71,29 @@ public class MoveAgainDetailService extends SPIBaseService implements ExtensionS return R.fail("111"); } - private int moveAgainDetailsByDetailId(Long shopId, Long lastDetails, Boolean cnaliDetailId) { - MoveCollectTaskDetail moveCollectTaskDetail = moveCollectTaskDetailService.getMoveCollectTaskDetail(shopId, lastDetails); + private Integer moveAgainDetailsByDetailId(Long shopId, Long detailId, Long cnaliDetailId) { + MoveCollectTaskDetail moveCollectTaskDetail = moveCollectTaskDetailService.getMoveCollectTaskDetail(shopId, detailId); if (moveCollectTaskDetail == null) { -// return 0; + return null; } int needAddCnt = 1; - if (!BeanUtil.isEmpty(cnaliDetailId)) { + if (cnaliDetailId != null) { needAddCnt = 0; } - BaseResponse checkAndGetConfigIdRet = this.checkAvailableCopyAndGetMoveConfigId(shopId, needAddCnt); - //检验失败 返回0 - if (!Objects.equals(checkAndGetConfigIdRet.getCode(), "10000")) { - return 0; + Ret checkAndGetConfigIdRet = saveBatchMoveTaskBizService.checkAvailableCopyAndGetMoveConfigId(shopId, needAddCnt); + if (checkAndGetConfigIdRet.getResult().equals("fail")) { + return null; } + Integer moveShopConfigId = Integer.valueOf(checkAndGetConfigIdRet.getData().get("moveShopConfigId").toString()); - return 0; - } + // todo: checkIsNeedMoveAgainForDsApi相关判断逻辑 用不上,跳过 - private Boolean checkShopIsExpire(Long shopId) { - try { - Shop shop = shopService.getDetailById(shopId); - long nowTime = System.currentTimeMillis()/1000; - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String dateString = sdf.format(shop.getGmtExpire()); - long targetTimeOri=CommonTool.getTimeStampByDateStr(dateString); - long targetTime = targetTimeOri / 1000; - if (nowTime >= targetTime) { - return true; - } - } catch (Exception e) { - return true; - } - return false; - - } - private BaseResponse checkAvailableCopyAndGetMoveConfigId(Long shopId,Integer needAddCnt){ - Boolean shopIsExpire=this.checkShopIsExpire(shopId); - if(shopIsExpire){ - return R.fail("shopId "+shopId+" 店铺已过期,请先续费"); - } -// $moveConfig = $this->getAvailableCopyCount($shopId); -// $moveShopConfigId = $moveConfig['move_shop_config_id']; -// $availableCopy = $moveConfig['available_total']; -// if ($needAddCnt > 0 && $needAddCnt > $availableCopy) { -// return CommonTool::failResult("搬家额度不足,请先充值"); -// } -// -// return CommonTool::successResult('moveShopConfigId', $moveShopConfigId); - return R.ok(); + return null; } -// private JSON getAvailableCopyCount(Long shopId){ -// -// } } From f1dc45e177b3007b4f42aa54a245ff89ddeeaaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?cxxxxxxx=E8=AF=A6?= <286460656@qq.com> Date: Tue, 12 Sep 2023 17:43:53 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=85=B3=E9=97=AD=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ms-deploy/src/main/java/com/ms/deploy/MsApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ms-deploy/src/main/java/com/ms/deploy/MsApplication.java b/ms-deploy/src/main/java/com/ms/deploy/MsApplication.java index 7fe814f9..7bc68214 100644 --- a/ms-deploy/src/main/java/com/ms/deploy/MsApplication.java +++ b/ms-deploy/src/main/java/com/ms/deploy/MsApplication.java @@ -13,7 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication(scanBasePackages = {"com.ms","com.jinritemai"}) @MapperScan("com.ms.dal.mapper") @EnableAsync -@EnableScheduling +// @EnableScheduling public class MsApplication { public static void main(String[] args) {