From 89bfffd8c860659c0b8869f73fab4bae6bf97744 Mon Sep 17 00:00:00 2001 From: qiushengjie Date: Wed, 13 Sep 2023 17:54:25 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ms/api/biz/MoveService.java | 83 +++---------------- .../com/ms/api/common/TaskBaseService.java | 8 +- .../java/com/ms/api/consts/MoveConst.java | 8 +- .../CheckAuditStatusTimeoutTaskService.java | 5 +- .../MoveMaterialAuditProcessTaskService.java | 4 +- .../MoveMaterialBizProcessTaskService.java | 2 +- .../ProcessMovePublishToPicTaskService.java | 37 +++------ .../ProcessProductPublishTaskService.java | 2 +- .../java/com/ms/deploy/MsApplication.java | 2 +- 9 files changed, 39 insertions(+), 112 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/biz/MoveService.java b/ms-biz/src/main/java/com/ms/api/biz/MoveService.java index 2703e1ba..c7eb5061 100644 --- a/ms-biz/src/main/java/com/ms/api/biz/MoveService.java +++ b/ms-biz/src/main/java/com/ms/api/biz/MoveService.java @@ -1,15 +1,5 @@ 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_getProductUpdateRule.data.FulfillmentRule; @@ -17,19 +7,19 @@ 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.Ret; -import com.ms.api.common.StrObjMap; import com.ms.api.consts.MoveConst; import com.ms.api.tool.CommonTool; import com.ms.api.util.DdRequestUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import java.util.*; +import java.util.stream.Collectors; + @Slf4j @Component public class MoveService { @@ -59,11 +49,13 @@ public class MoveService { productDetailBase.put("outProductId", moveBaseData.get("source_item_id")); // 客服电话 -// productDetailBase.put("mobile",condition.getMobile()); - productDetailBase.put("mobile","18584852136"); + productDetailBase.put("mobile","0"); + + // 产品类型 + productDetailBase.put("productType", MoveConst.PRODUCT_TYPE_NORMAL); // 预售模式,0为现货 - productDetailBase.put("presellType", 0); + productDetailBase.put("presellType", 0L); // 1 减库存类型:1-拍下减库存 2-付款减库存 if (condition.getReduceType() > 0) { @@ -130,8 +122,7 @@ public class MoveService { } productDetailBase.put("deliveryDelayDay", deliveryDelayDay); - productDetailBase.put("productType", MoveConst.PRODUCT_TYPE_NORMAL); - int freightTemplateId = condition.getFreightTemplateId() > 0 ? condition.getFreightTemplateId() : MoveConst.DEFAULT_FREIGHT_TEMPLATE_ID; + long freightTemplateId = condition.getFreightTemplateId() > 0 ? condition.getFreightTemplateId() : MoveConst.DEFAULT_FREIGHT_TEMPLATE_ID; productDetailBase.put("freightTemplateId", freightTemplateId); productDetailBase.put("supply7dayReturn", buildSupply7dayReturn(queueMsg, condition, accessToken)); boolean commit = condition.getMoveOnsaleType() != MoveConst.MOVE_ON_SALE_TYPE_DRAFT; @@ -140,59 +131,6 @@ public class MoveService { productDetailBase.put("status", MoveConst.MOVE_ON_SALE_TYPE_FOR_SALE); } -// $productDetailBase['productFormatNew'] = $this->buildProductFormat($moveBaseData, $previewAttrData, $condition, $cid, $attributes, $sourceAttrs, $productDetailBase, $presetAttrs, $shopId); -// $productDetailBase['productFormatNew'] = $this->attachBrand2ProductFormatNew($productDetailBase['standardBrandId'], $brandName, $productDetailBase['productFormatNew']); - - // 一下这些暂时不需要 -// $productDetailBase['weight'] = $packageInfo['weight'] ? $packageInfo['weight'] : MoveConst::defaultWeight; -// $productDetailBase['weight'] = ($productDetailBase['weight'] > 10000) ? 9999 : $productDetailBase['weight']; -// $productDetailBase['recommendRemark'] = $this->getRecommendRemark($isFastMode, $condition, $moveBaseData); -// $productDetailBase['qualityList'] = $this->buildQualityList($queueMsg, $accessToken); -// $productDetailBase['limitPerBuyer'] = $queueMsg['limit_per_buyer'] ? $queueMsg['limit_per_buyer'] : $condition['limitPerBuyer']; -// $productDetailBase['minimumPerOrder'] = $queueMsg['minimum_per_order'] ? $queueMsg['minimum_per_order'] : $condition['minimumPerOrder']; -// $productDetailBase['maximumPerOrder'] = $queueMsg['maximum_per_order'] ? $queueMsg['maximum_per_order'] : $condition['maximumPerOrder']; -// if ($productDetailBase['maximumPerOrder'] > MoveConst::maxMaximumPerOrder) { -// $productDetailBase['maximumPerOrder'] = MoveConst::maxMaximumPerOrder; -// } -// -// if($productDetailBase['limitPerBuyer'] > MoveConst::maxMaximumPerOrder) { -// $productDetailBase['limitPerBuyer'] = MoveConst::maxMaximumPerOrder; -// } -// -// if($productDetailBase['minimumPerOrder'] > MoveConst::maxMaximumPerOrder) { -// $productDetailBase['minimumPerOrder'] = MoveConst::maxMaximumPerOrder; -// } -// list($productDetailBase['supply7dayReturn'], $productDetailBase['afterSaleService']) = $this->buildSupply7dayReturn($queueMsg, $condition, $accessToken); - -// $assocIds = CommonTool::pregSplitAndFilterStr($condition['assocIds']); -// if (count($assocIds) >= 5 && count($assocIds) <= 10) { -// $productDetailBase['assocIds'] = implode('|', $assocIds); -// } -// -// if (isset($condition['moveOnsaleType']) && $condition['moveOnsaleType'] == MoveConst::moveOnsaleTypeForSale) { -// $productDetailBase['status'] = MoveConst::moveOnsaleTypeForSale; -// } -// -// $productDetailBase['substituteGoodsUrl'] = FetchClientTool::buildMoveSourceUrl($queueMsg['source_item_id'], $queueMsg['source'], $queueMsg['site']); -// -// if (!empty($queueMsg['white_bg_img_url'])) { -// $productDetailBase['whiteBgImgUrl'] = $queueMsg['white_bg_img_url']; -// } -// -// if (!empty($queueMsg['long_pic_url'])) { -// $productDetailBase['longPicUrl'] = $queueMsg['long_pic_url']; -// } -// if ($isFastMode && $condition['isUseSourceLongPic']) { -// $productDetailBase['longPicUrl'] = $moveBaseData['longPicUrl']; -// } -// -// if (!empty($queueMsg['clue_id'])) { -// $productDetailBase['recruitInfo'] = [ -// 'recruit_follow_id' => $queueMsg['clue_id'], -// 'recruit_type' => '99', -// ]; -// } -// return CommonTool.successResult("productDetailBase", productDetailBase); } @@ -303,8 +241,7 @@ public class MoveService { } if (sizeTemplateIdObj instanceof String) { long cid = moveBaseData.getLong("cid"); - // TODO 这里可能不需要 -// sizeTemplateId = $this->moveService->getShopSettingSizeTemplateIdByCid($shopId, $condition['moveShopSettingId'], $cid, $commonTemplateId); + //sizeTemplateId = getShopSettingSizeTemplateIdByCid(shopId, condition['moveShopSettingId'], cid, commonTemplateId); } else { sizeTemplateId = (int) sizeTemplateIdObj; } diff --git a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java index a2fd9a72..f3835919 100644 --- a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java +++ b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java @@ -52,8 +52,8 @@ public abstract class TaskBaseService implements TaskHandler { if(isPoolFull()){ return;} execute(); }catch (Throwable e){ - e.printStackTrace(); - log.info("任务执行失败",e); + //e.printStackTrace(); + log.info("任务执行失败 : ",e.getMessage()); } } @@ -65,8 +65,8 @@ public abstract class TaskBaseService implements TaskHandler { execute(); transactionManager.commit(status); }catch (Throwable e){ - e.printStackTrace(); - log.info("任务执行失败",e); + //e.printStackTrace(); + log.info("任务执行失败 : ",e.getMessage()); transactionManager.rollback(status); } } 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 234b7202..08b09fc5 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 @@ -18,10 +18,10 @@ public class MoveConst { public static final int MOVE_TITLE_LEN = 58; //标题最多60个字符(汉字算2,英文数字算1) //0-普通,3-虚拟,6玉石闪购,7云闪购 - public static final int PRODUCT_TYPE_NORMAL = 0; - public static final int PRODUCT_TYPE_VIRTUAL = 3; - public static final int PRODUCT_TYPE_YSSG = 6; - public static final int DEFAULT_FREIGHT_TEMPLATE_ID = 7; + public static final long PRODUCT_TYPE_NORMAL = 0L; + public static final long PRODUCT_TYPE_VIRTUAL = 3L; + public static final long PRODUCT_TYPE_YSSG = 6L; + public static final long DEFAULT_FREIGHT_TEMPLATE_ID = 7L; /** * 立即上架 diff --git a/ms-biz/src/main/java/com/ms/api/task/CheckAuditStatusTimeoutTaskService.java b/ms-biz/src/main/java/com/ms/api/task/CheckAuditStatusTimeoutTaskService.java index 828d2835..dee33e23 100644 --- a/ms-biz/src/main/java/com/ms/api/task/CheckAuditStatusTimeoutTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/CheckAuditStatusTimeoutTaskService.java @@ -10,6 +10,8 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Async; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -61,7 +63,8 @@ public class CheckAuditStatusTimeoutTaskService extends TaskBaseService { return taskPool; } - //@Async("checkAuditStatusTimeoutTaskPool") + @Async("checkAuditStatusTimeoutTaskPool") + @Scheduled(fixedRate = 10000) @Override public void runTask() { super.runTaskWithTransaction(); diff --git a/ms-biz/src/main/java/com/ms/api/task/MoveMaterialAuditProcessTaskService.java b/ms-biz/src/main/java/com/ms/api/task/MoveMaterialAuditProcessTaskService.java index 6da5661d..8f82fcfa 100644 --- a/ms-biz/src/main/java/com/ms/api/task/MoveMaterialAuditProcessTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/MoveMaterialAuditProcessTaskService.java @@ -61,7 +61,7 @@ public class MoveMaterialAuditProcessTaskService extends TaskBaseService { * 同时开启任务处理数量 */ public int getCorePoolSiz() { - return 3; + return 10; } /** @@ -86,7 +86,7 @@ public class MoveMaterialAuditProcessTaskService extends TaskBaseService { } @Async("moveMaterialAuditProcessPool") - @Scheduled(fixedRate = 10000) + @Scheduled(fixedRate = 2000) @Override public void runTask() { super.runTaskWithTransaction(); diff --git a/ms-biz/src/main/java/com/ms/api/task/MoveMaterialBizProcessTaskService.java b/ms-biz/src/main/java/com/ms/api/task/MoveMaterialBizProcessTaskService.java index 17882f62..99ec94f7 100644 --- a/ms-biz/src/main/java/com/ms/api/task/MoveMaterialBizProcessTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/MoveMaterialBizProcessTaskService.java @@ -81,7 +81,7 @@ public class MoveMaterialBizProcessTaskService extends TaskBaseService { } @Async("moveMaterialBizProcessTaskPool") - @Scheduled(fixedRate = 10000) + @Scheduled(fixedRate = 5000) @Override public void runTask() { super.runTaskWithTransaction(); diff --git a/ms-biz/src/main/java/com/ms/api/task/ProcessMovePublishToPicTaskService.java b/ms-biz/src/main/java/com/ms/api/task/ProcessMovePublishToPicTaskService.java index 290af812..05892ab9 100644 --- a/ms-biz/src/main/java/com/ms/api/task/ProcessMovePublishToPicTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/ProcessMovePublishToPicTaskService.java @@ -521,7 +521,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"); @@ -535,7 +535,6 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService { } String mobile = productData.getString("mobile"); - param.setMobile("400123456"); if (!Objects.isNull(mobile)) { param.setMobile(mobile); } @@ -593,17 +592,11 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService { 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"); -// if (!Objects.isNull(deliveryDelayDay)) { -// param.setDeliveryDelayDay(deliveryDelayDay); -// } - - param.setDeliveryDelayDay(2L); - - Long brandId = productData.getLong("brandId"); - if (!Objects.isNull(brandId)) { - param.setBrandId(brandId); + Long deliveryDelayDay = productData.getLong("deliveryDelayDay"); + if (!Objects.isNull(deliveryDelayDay)) { + param.setDeliveryDelayDay(deliveryDelayDay); } + param.setDeliveryDelayDay(2L);// TODO Long standardBrandId = productData.getLong("standardBrandId"); if (!Objects.isNull(standardBrandId)) { @@ -620,11 +613,10 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService { param.setRemark(remark); } -// Long presellType = productData.getLong("presellType"); -// if (!Objects.isNull(presellType)) { -// param.setPresellType(presellType); -// } - param.setPresellType(0L); + Long presellType = productData.getLong("presellType"); + if (!Objects.isNull(presellType)) { + param.setPresellType(presellType); + } Long presellConfigLevel = productData.getLong("presellConfigLevel"); if (!Objects.isNull(presellConfigLevel)) { @@ -666,16 +658,11 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService { param.setMaterialVideoId(materialVideoId); } - Long sizeInfoTemplateId = productData.getLong("sizeInfoTemplateId"); + Long sizeInfoTemplateId = productData.getLong("sizeTemplateId"); if (!Objects.isNull(sizeInfoTemplateId)) { param.setSizeInfoTemplateId(sizeInfoTemplateId); } - -// Long sizeTemplateId = productData.getLong("sizeTemplateId"); -// if (!Objects.isNull(sizeTemplateId)) { -// param.setSizeInfoTemplateId(sizeTemplateId); -// } - param.setSizeInfoTemplateId(7119681499770667267L); + param.setSizeInfoTemplateId(7119681499770667267L); // TODO Long spuId = productData.getLong("spuId"); if (!Objects.isNull(spuId)) { @@ -691,7 +678,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService { // if (!Objects.isNull(afterSaleService)) { // param.setAfterSaleService(afterSaleService); // } - + // TODO Map ss = new HashMap<>(); ss.put("supply_day_return_selector", "7-1"); param.setAfterSaleService(ss); 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 956ec74d..e0047972 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 @@ -566,7 +566,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { } param.setFolderId(filter.getOrDefault("folderId", "0")); if (filter.containsKey("materialName")) { - param.setFolderId(filter.get("materialName")); + param.setMaterialName(filter.get("materialName")); } MaterialUploadImageSyncResponse response = request.execute(accessToken); Ret checkRet = CommonTool.checkDdApiRetStatus(response); 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 d68de36e..2de64b72 100644 --- a/ms-deploy/src/main/java/com/ms/deploy/MsApplication.java +++ b/ms-deploy/src/main/java/com/ms/deploy/MsApplication.java @@ -9,7 +9,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) { From 0f43cdcd53696c95272d03fc4f44a55813a11806 Mon Sep 17 00:00:00 2001 From: qiushengjie Date: Wed, 13 Sep 2023 17:59:44 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ms/api/biz/MoveService.java | 70 +------------------ 1 file changed, 1 insertion(+), 69 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/biz/MoveService.java b/ms-biz/src/main/java/com/ms/api/biz/MoveService.java index 058d5f22..26209834 100644 --- a/ms-biz/src/main/java/com/ms/api/biz/MoveService.java +++ b/ms-biz/src/main/java/com/ms/api/biz/MoveService.java @@ -1,16 +1,5 @@ package com.ms.api.biz; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.HashMap; -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; @@ -37,12 +26,7 @@ import com.ms.api.tool.CommonTool; import com.ms.api.util.DdRequestUtil; import com.ms.api.util.MoveUtil; import com.ms.dal.bo.CollectTaskDetailBO; -import com.ms.dal.entity.CategorySizeTemplateSubType; -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.entity.Shop; +import com.ms.dal.entity.*; import com.ms.dal.mapper.MoveCollectTaskDetailMapper; import com.ms.dal.mapper.MoveCollectTaskMapper; import com.ms.dal.mapper.MoveProductPublishBufferMapper; @@ -185,61 +169,9 @@ public class MoveService { productDetailBase.put("status", MoveConst.MOVE_ON_SALE_TYPE_FOR_SALE); } -// $productDetailBase['productFormatNew'] = $this->buildProductFormat($moveBaseData, $previewAttrData, $condition, $cid, $attributes, $sourceAttrs, $productDetailBase, $presetAttrs, $shopId); -// $productDetailBase['productFormatNew'] = $this->attachBrand2ProductFormatNew($productDetailBase['standardBrandId'], $brandName, $productDetailBase['productFormatNew']); - - // 一下这些暂时不需要 -// $productDetailBase['weight'] = $packageInfo['weight'] ? $packageInfo['weight'] : MoveConst::defaultWeight; -// $productDetailBase['weight'] = ($productDetailBase['weight'] > 10000) ? 9999 : $productDetailBase['weight']; -// $productDetailBase['recommendRemark'] = $this->getRecommendRemark($isFastMode, $condition, $moveBaseData); -// $productDetailBase['qualityList'] = $this->buildQualityList($queueMsg, $accessToken); -// $productDetailBase['limitPerBuyer'] = $queueMsg['limit_per_buyer'] ? $queueMsg['limit_per_buyer'] : $condition['limitPerBuyer']; -// $productDetailBase['minimumPerOrder'] = $queueMsg['minimum_per_order'] ? $queueMsg['minimum_per_order'] : $condition['minimumPerOrder']; -// $productDetailBase['maximumPerOrder'] = $queueMsg['maximum_per_order'] ? $queueMsg['maximum_per_order'] : $condition['maximumPerOrder']; -// if ($productDetailBase['maximumPerOrder'] > MoveConst::maxMaximumPerOrder) { -// $productDetailBase['maximumPerOrder'] = MoveConst::maxMaximumPerOrder; -// } -// -// if($productDetailBase['limitPerBuyer'] > MoveConst::maxMaximumPerOrder) { -// $productDetailBase['limitPerBuyer'] = MoveConst::maxMaximumPerOrder; -// } -// -// if($productDetailBase['minimumPerOrder'] > MoveConst::maxMaximumPerOrder) { -// $productDetailBase['minimumPerOrder'] = MoveConst::maxMaximumPerOrder; -// } Object[] supply7dayReturn = buildSupply7dayReturn(queueMsg, condition, accessToken); productDetailBase.put("supply7dayReturn", supply7dayReturn[0]); productDetailBase.put("afterSaleService", supply7dayReturn[1]); - -// $assocIds = CommonTool::pregSplitAndFilterStr($condition['assocIds']); -// if (count($assocIds) >= 5 && count($assocIds) <= 10) { -// $productDetailBase['assocIds'] = implode('|', $assocIds); -// } -// -// if (isset($condition['moveOnsaleType']) && $condition['moveOnsaleType'] == MoveConst::moveOnsaleTypeForSale) { -// $productDetailBase['status'] = MoveConst::moveOnsaleTypeForSale; -// } -// -// $productDetailBase['substituteGoodsUrl'] = FetchClientTool::buildMoveSourceUrl($queueMsg['source_item_id'], $queueMsg['source'], $queueMsg['site']); -// -// if (!empty($queueMsg['white_bg_img_url'])) { -// $productDetailBase['whiteBgImgUrl'] = $queueMsg['white_bg_img_url']; -// } -// -// if (!empty($queueMsg['long_pic_url'])) { -// $productDetailBase['longPicUrl'] = $queueMsg['long_pic_url']; -// } -// if ($isFastMode && $condition['isUseSourceLongPic']) { -// $productDetailBase['longPicUrl'] = $moveBaseData['longPicUrl']; -// } -// -// if (!empty($queueMsg['clue_id'])) { -// $productDetailBase['recruitInfo'] = [ -// 'recruit_follow_id' => $queueMsg['clue_id'], -// 'recruit_type' => '99', -// ]; -// } -// return CommonTool.successResult("productDetailBase", productDetailBase); } From fe0928afa226ba1c186b8fc1acd3571111f37f69 Mon Sep 17 00:00:00 2001 From: wangchaoxu Date: Wed, 13 Sep 2023 18:38:48 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ms/api/consts/MoveConst.java | 11 +++ .../ProcessMovePublishToPicTaskService.java | 94 +++++++++++++++++-- 2 files changed, 97 insertions(+), 8 deletions(-) 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 cd814eb3..01c2d902 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 @@ -116,6 +116,17 @@ public class MoveConst { public static Integer supply7dayReturnIfCustomNo = 6; public static Integer supply7dayReturnIfContractNo = 8; + public static Integer deliveryDelayToday = 9999; + public static Integer deliveryDelayOneDay = 1; + public static Integer deliveryDelayTwoDay = 2; + public static Integer deliveryDelayThreeDay = 3; + public static Integer deliveryDelayFiveDay = 5; + public static Integer deliveryDelaySevenDay = 7; + public static Integer deliveryDelayTenDay = 10; + public static Integer deliveryDelayFifteenDay = 15; + public static Integer deliveryDelayThirtyDay = 30; + public static Integer deliveryDelayFortyFiveDay = 45; + public static List getSpecialBanWordList() { List result = new ArrayList(); result.add("特价"); diff --git a/ms-biz/src/main/java/com/ms/api/task/ProcessMovePublishToPicTaskService.java b/ms-biz/src/main/java/com/ms/api/task/ProcessMovePublishToPicTaskService.java index 983eb33a..275fae2f 100644 --- a/ms-biz/src/main/java/com/ms/api/task/ProcessMovePublishToPicTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/ProcessMovePublishToPicTaskService.java @@ -1,12 +1,6 @@ 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.*; import java.util.concurrent.Executor; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -527,7 +521,42 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService { } private StrObjMap processAddProductError(long shopId, JSONObject productDetailBase, MoveShopSettingBO condition, MoveProductPublishToPicQueueBO queueMsg, JSONObject moveBaseData, String reason, int i, AccessToken accessToken) { - boolean dataIsChange = false; + Boolean dataIsChange = false; + + StrObjMap processRes; + +// processRes = processTestShopError(productDetailBase, dataIsChange, reason); +// productDetailBase = (JSONObject) processRes.get("productDetailBase"); +// dataIsChange = (Boolean) processRes.get("dataIsChange"); + + processRes = processOuterProductIdError(productDetailBase, dataIsChange, reason); + productDetailBase = (JSONObject) processRes.get("productDetailBase"); + dataIsChange = (Boolean) processRes.get("dataIsChange"); + + processRes = processProductFormatMustExistError(productDetailBase, dataIsChange, reason); + productDetailBase = (JSONObject) processRes.get("productDetailBase"); + dataIsChange = (Boolean) processRes.get("dataIsChange"); + + processRes = processProductDeliveryDelayDayError(productDetailBase, dataIsChange, reason); + productDetailBase = (JSONObject) processRes.get("productDetailBase"); + dataIsChange = (Boolean) processRes.get("dataIsChange"); + +// processRes = processProductImgRequiredError(shopId, productDetailBase, dataIsChange, reason); +// productDetailBase = (JSONObject) processRes.get("productDetailBase"); +// dataIsChange = (Boolean) processRes.get("dataIsChange"); + +// processRes = processProductSpecImgError(shopId, productDetailBase, dataIsChange, reason); +// productDetailBase = (JSONObject) processRes.get("productDetailBase"); +// dataIsChange = (Boolean) processRes.get("dataIsChange"); + + +// processRes = processProductSpecImgError(productDetailBase, dataIsChange, reason); +// processRes = processProductImgSaveError(productDetailBase, dataIsChange, reason); +// processRes = processProductPresellError(productDetailBase, dataIsChange, reason); +// processRes = processProductStockNeedMoreThanStepStockError(productDetailBase, dataIsChange, reason); +// processRes = processPresellTypeByStairError(productDetailBase, dataIsChange, reason); +// processRes = processProductStockNumError(productDetailBase, dataIsChange, reason); + // // list($productDetailBase, $dataIsChange) = $this->processTestShopError($productDetailBase, $dataIsChange, $reason); // list($productDetailBase, $dataIsChange) = $this->processOuterProductIdError($productDetailBase, $dataIsChange, $reason); @@ -572,6 +601,55 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService { return data; } +// private StrObjMap processProductSpecImgError(long shopId, JSONObject productDetailBase, Boolean dataIsChange, String reason) { +// +// } + +// private StrObjMap processProductImgRequiredError(long shopId, JSONObject productDetailBase, Boolean dataIsChange, String reason) { +// +// } + + private StrObjMap processProductDeliveryDelayDayError(JSONObject productDetailBase, Boolean dataIsChange, String reason) { + if (reason.indexOf("承诺发货时间不在合理范围内") != -1 + || reason.indexOf("校验预售发货信息失败发货时间配置不满足要求") != -1) { + productDetailBase.put("deliveryDelayDay", MoveConst.deliveryDelayOneDay); + dataIsChange = true; + log.info("processProductDeliveryDelayDayError : " + productDetailBase.getString("deliveryDelayDay")); + } + StrObjMap ret = new StrObjMap(); + ret.put("productDetailBase", productDetailBase); + ret.put("dataIsChange", dataIsChange); + return ret; + } + + private StrObjMap processOuterProductIdError(JSONObject productDetailBase, Boolean dataIsChange, String reason) { + if (reason.indexOf("out_product_id需为数字字符串") != -1 + || reason.indexOf("该out_product_id无法被添加, 已存在") != -1 + || reason.indexOf("OutProductId已存在,请检查") != -1 + || reason.indexOf("outerProductId已经存在") != -1) { + Integer randNum = new Random().nextInt(100000000 - 1000000) + 1000000; + productDetailBase.put("outProductId", randNum); + dataIsChange = true; + log.info("processOuterProductIdError : " + productDetailBase.getString("outProductId")); + } + StrObjMap ret = new StrObjMap(); + ret.put("productDetailBase", productDetailBase); + ret.put("dataIsChange", dataIsChange); + return ret; + } + + private StrObjMap processProductFormatMustExistError(JSONObject productDetailBase, Boolean dataIsChange, String reason) { + if (reason.indexOf("product_format现为必填字段") != -1) { + productDetailBase.put("productFormat", "品牌"); + dataIsChange = true; + log.info("processProductFormatMustExistError : " + productDetailBase.getString("productFormat")); + } + StrObjMap ret = new StrObjMap(); + ret.put("productDetailBase", productDetailBase); + ret.put("dataIsChange", dataIsChange); + return ret; + } + private Ret addProductToDdV2(JSONObject productData, AccessToken accessToken) { ProductAddV2Request request = new ProductAddV2Request(); ProductAddV2Param param = request.getParam(); From 0d0785df1f7b2c4e8b1ecfb122e58c27445416ea Mon Sep 17 00:00:00 2001 From: daixiaogang <2510234660@qq.com> Date: Wed, 13 Sep 2023 18:42:20 +0800 Subject: [PATCH 04/11] =?UTF-8?q?processMovePublishQueueRet=20=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/move/service/class.MoveService.php | 11 -- .../main/java/com/ms/api/biz/MoveService.java | 43 +++++ .../api/biz/SaveBatchMoveTaskBizService.java | 19 +- .../ms/api/bo/MoveProductPublishQueueBO.java | 1 + .../java/com/ms/api/consts/MoveConst.java | 5 +- .../ProcessProductPublishTaskService.java | 176 ++++++++++++++---- .../com/ms/dal/bo/CollectTaskDetailBO.java | 1 + .../com/ms/dal/entity/MoveShopConfig.java | 6 + 8 files changed, 197 insertions(+), 65 deletions(-) diff --git a/doc/move/service/class.MoveService.php b/doc/move/service/class.MoveService.php index ecf28803..a8f97170 100644 --- a/doc/move/service/class.MoveService.php +++ b/doc/move/service/class.MoveService.php @@ -4899,17 +4899,6 @@ class MoveService { } } -// if (empty($currentMoveShopConfigId)) { -// -// return false; -// } - -// if ($this->deductIsCurrentMonthNum($deductMoveShopConfigId, $currentMoveShopConfigId)) { -// return $this->updateMoveShopConfig($shopId, $currentMoveShopConfigId, array( -// 'fail_total' => new ZcDbEval('fail_total + 1'), -// )); -// } - if ($this->isUseRechargeNum($shopId, $deductMoveShopConfigId)) { return $this->updateMoveShopConfig($shopId, $currentMoveShopConfigId, array( 'pre_paid_fail_total' => new ZcDbEval('pre_paid_fail_total + 1'), diff --git a/ms-biz/src/main/java/com/ms/api/biz/MoveService.java b/ms-biz/src/main/java/com/ms/api/biz/MoveService.java index 06823053..fe6d9c52 100644 --- a/ms-biz/src/main/java/com/ms/api/biz/MoveService.java +++ b/ms-biz/src/main/java/com/ms/api/biz/MoveService.java @@ -32,6 +32,7 @@ import com.ms.api.consts.MoveConst; import com.ms.api.consts.StatusConst; import com.ms.api.service.CategorySizeTemplateSubTypeService; import com.ms.api.service.MoveCollectTaskDetailService; +import com.ms.api.service.MoveShopConfigService; import com.ms.api.service.ShopService; import com.ms.api.tool.CommonTool; import com.ms.api.util.DdRequestUtil; @@ -41,6 +42,7 @@ import com.ms.dal.entity.CategorySizeTemplateSubType; import com.ms.dal.entity.MoveCollectTask; import com.ms.dal.entity.MoveCollectTaskDetail; import com.ms.dal.entity.MoveProductPublishBuffer; +import com.ms.dal.entity.MoveShopConfig; import com.ms.dal.entity.MoveShopSetting; import com.ms.dal.entity.Shop; import com.ms.dal.mapper.MoveCollectTaskDetailMapper; @@ -75,6 +77,10 @@ public class MoveService { @Autowired private CategorySizeTemplateSubTypeService categorySizeTemplateSubTypeService; + @Autowired + private MoveShopConfigService moveShopConfigService; + + /** * 根据搬家配置,修改数据 * @@ -624,4 +630,41 @@ public class MoveService { return processCount; } + public void updateMoveCollectTaskDetail(MoveCollectTaskDetail updateMoveCollectTaskDetailData, long shopId, Long detailId) { + if (ObjectUtil.isNull(detailId)){ + return; + } + updateMoveCollectTaskDetailData.setMoveCollectTaskDetailId(detailId); + moveCollectTaskDetailMapper.updateByPrimaryKeySelective(updateMoveCollectTaskDetailData); + } + + + public MoveShopConfigBO getAvailableCopyCount(long shopId) { + Shop shop = shopService.getDetailById(shopId); + if (shop.getGmtExpire().before(new Date())) { + return null; + } + // TODO this.accountBalancedLastMonth(); + MoveShopConfigBO currentMonthMoveConfig = this.getCurrentMonthMoveConfig(shopId); + if (Objects.isNull(currentMonthMoveConfig)) { + return null; + } + return currentMonthMoveConfig; + } + + public MoveShopConfigBO getCurrentMonthMoveConfig(long shopId) { + String curMonth = CommonTool.getCurMonthLastTime(); + MoveShopConfig moveConfig = moveShopConfigService.getByShopIdAndGmtExpire(shopId, curMonth); + if (Objects.isNull(moveConfig)) { + return null; + } + MoveShopConfigBO moveShopConfigBO = CommonTool.modelMapper(moveConfig, MoveShopConfigBO.class); + + moveShopConfigBO.setOriginalTotal(moveConfig.getTotal()); + moveShopConfigBO.setTotal(moveConfig.getTotal() + moveConfig.getAttachTotal()); + moveShopConfigBO.setUsedTotal(moveConfig.getUsedTotal() - moveConfig.getFailTotal());// TODO - moveConfig.getPrePaidFailTotal() + moveShopConfigBO.setAvailableTotal(moveConfig.getTotal());// TODO 临时测试 + + return moveShopConfigBO; + } } diff --git a/ms-biz/src/main/java/com/ms/api/biz/SaveBatchMoveTaskBizService.java b/ms-biz/src/main/java/com/ms/api/biz/SaveBatchMoveTaskBizService.java index 6d82a6c4..30690d96 100644 --- a/ms-biz/src/main/java/com/ms/api/biz/SaveBatchMoveTaskBizService.java +++ b/ms-biz/src/main/java/com/ms/api/biz/SaveBatchMoveTaskBizService.java @@ -47,6 +47,9 @@ public class SaveBatchMoveTaskBizService extends BizBaseService { @Autowired private MoveShopConfigService moveShopConfigService; + @Autowired + private MoveService moveService; + public Ret checkAndFormatData(Long shopId, List curProductDetails) { // 校验商品数量 if (curProductDetails.isEmpty()) { @@ -366,21 +369,7 @@ public class SaveBatchMoveTaskBizService extends BizBaseService { // } } - public MoveShopConfigBO getCurrentMonthMoveConfig(long shopId) { - String curMonth = CommonTool.getCurMonthLastTime(); - MoveShopConfig moveConfig = moveShopConfigService.getByShopIdAndGmtExpire(shopId, curMonth); - if (Objects.isNull(moveConfig)) { - return null; - } - MoveShopConfigBO moveShopConfigBO = CommonTool.modelMapper(moveConfig, MoveShopConfigBO.class); - - moveShopConfigBO.setOriginalTotal(moveConfig.getTotal()); - moveShopConfigBO.setTotal(moveConfig.getTotal() + moveConfig.getAttachTotal()); - moveShopConfigBO.setUsedTotal(moveConfig.getUsedTotal() - moveConfig.getFailTotal());// TODO - moveConfig.getPrePaidFailTotal() - moveShopConfigBO.setAvailableTotal(moveConfig.getTotal());// TODO 临时测试 - return moveShopConfigBO; - } public MoveShopConfigBO getAvailableCopyCount(long shopId) { Shop shop = shopService.getDetailById(shopId); @@ -388,7 +377,7 @@ public class SaveBatchMoveTaskBizService extends BizBaseService { return null; } // TODO this.accountBalancedLastMonth(); - MoveShopConfigBO currentMonthMoveConfig = this.getCurrentMonthMoveConfig(shopId); + MoveShopConfigBO currentMonthMoveConfig = moveService.getCurrentMonthMoveConfig(shopId); if (Objects.isNull(currentMonthMoveConfig)) { return null; } 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 6e3acd09..44feb3a1 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 @@ -108,4 +108,5 @@ public class MoveProductPublishQueueBO { private Double hasImportPrice; private Integer supply7dayReturn; + private Integer limitSource; } 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 cd814eb3..653a6382 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 @@ -103,10 +103,9 @@ public class MoveConst { public static String aliPriceTypeConsign = "consign"; public static String aliPriceTypeConfig = "config"; public static String collectTaskSource1688 = "1688"; - public static String proxyPlatformTypePicUrl = "picUrl"; + public static String proxyPlatformTypePicUrl = "picUrl"; public static String brandEmpty = "empty"; - public static Integer supply7dayReturnNo = 0; public static Integer supply7dayReturnYes = 1; public static Integer supply7dayReturnIfOpenNo = 2; @@ -115,6 +114,7 @@ public class MoveConst { public static Integer supply7dayReturnIfUseNo = 5; public static Integer supply7dayReturnIfCustomNo = 6; public static Integer supply7dayReturnIfContractNo = 8; + public static String collectDsCopy = "dsCopy"; public static List getSpecialBanWordList() { List result = new ArrayList(); @@ -134,7 +134,6 @@ public class MoveConst { return result; } - public static Map getSupply7dayReturnOption() { Map options = new HashMap<>(); options.put(String.valueOf(MoveConst.supply7dayReturnNo), "不支持"); 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 32efd819..76197bc5 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 @@ -28,6 +28,7 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import javax.annotation.Resource; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -51,18 +52,17 @@ import com.doudian.open.api.material_getFolderInfo.param.MaterialGetFolderInfoPa import com.doudian.open.api.material_uploadImageSync.MaterialUploadImageSyncRequest; import com.doudian.open.api.material_uploadImageSync.MaterialUploadImageSyncResponse; import com.doudian.open.api.material_uploadImageSync.param.MaterialUploadImageSyncParam; -import com.doudian.open.api.product_getCatePropertyV2.ProductGetCatePropertyV2Request; -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.biz.SaveBatchMoveTaskBizService; 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.MoveShopConfigBO; import com.ms.api.bo.MoveShopSettingBO; import com.ms.api.common.ApiResult; import com.ms.api.common.E; @@ -84,8 +84,10 @@ 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.MoveProductPublishBufferService; import com.ms.api.service.MoveProductPublishQueueService; import com.ms.api.service.MoveProductPublishToPicQueueService; +import com.ms.api.service.MoveShopConfigService; import com.ms.api.service.MoveShopSettingService; import com.ms.api.service.RsyncCategoryQueueService; import com.ms.api.service.Shop1688DsAuthService; @@ -97,6 +99,7 @@ import com.ms.api.tool.MoveTool; import com.ms.api.tool.SecurityTool; import com.ms.api.util.DdRequestUtil; import com.ms.api.util.MoveUtil; +import com.ms.dal.bo.CollectTaskDetailBO; import com.ms.dal.entity.Category; import com.ms.dal.entity.CategoryShop; import com.ms.dal.entity.MaterialAuditStatusBuffer; @@ -104,8 +107,10 @@ 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.MoveProductPublishBuffer; import com.ms.dal.entity.MoveProductPublishQueue; import com.ms.dal.entity.MoveProductPublishToPicQueue; +import com.ms.dal.entity.MoveShopConfig; import com.ms.dal.entity.RsyncCategoryQueue; import com.ms.dal.entity.Shop; import com.ms.dal.entity.Shop1688DsAuth; @@ -118,7 +123,6 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import sun.net.www.http.HttpClient; /** * 处理move_product_publish_queue中的数据 @@ -179,6 +183,15 @@ public class ProcessProductPublishTaskService extends TaskBaseService { @Autowired private MoveService moveService; + @Autowired + private MoveShopConfigService moveShopConfigService; + + @Autowired + private MoveProductPublishBufferService moveProductPublishBufferService; + + @Autowired + private SaveBatchMoveTaskBizService saveBatchMoveTaskBizService; + @Autowired private RedisTemplate redisTemplate; @@ -416,7 +429,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { return CommonTool.successResult(); } - private List getUploadImgSuccessMapAndFailUrls(Map data, List uploadImgs) { + private List getUploadImgSuccessMapAndFailUrls(Map data, List uploadImgs) { Map sourceImgUrlToDdImgUrl = new HashMap<>(); for (Map.Entry temp : data.entrySet()) { @@ -510,7 +523,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { byte[] imageData = convertToByteArray(imgUrl); if (CommonTool.isAnimatedGif(imageData)) { - return CommonTool.failResult( "gif动图,不处理"); + return CommonTool.failResult("gif动图,不处理"); } // TODO: 2023/9/13 涉及到oss 暂时不处理 @@ -524,7 +537,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService { // // return CommonTool.successResult("ossUrl", OssTool.getPubOssUrlByOssPath(ossPath)); StrStrMap strMap = new StrStrMap(); - strMap.put("ossUrl",""); + strMap.put("ossUrl", ""); return Ret.success(strMap); } @@ -2859,16 +2872,24 @@ public class ProcessProductPublishTaskService extends TaskBaseService { } Ret processRet = (Ret) params; MoveProductPublishQueueBO queueMsg = (MoveProductPublishQueueBO) processRet.getQueueMsg(); - Ret ret = processMovePublishQueueRet(processRet); + + // TODO: 2023/9/13 这个不知道怎么翻译 +// $publishCostSeconds = time() - $this->startTime; + + Ret ret = processMovePublishQueueRet(processRet, 0); log.info("processMovePublishQueueRet ret:{}", ret); // 前面已经挂起,这边删除que deleteQueueMsg(queueMsg); } - private Ret processMovePublishQueueRet(Ret processRet) { + private Ret processMovePublishQueueRet(Ret processRet, Integer publishCostSeconds) { MoveProductPublishQueueBO queueMsg = (MoveProductPublishQueueBO) processRet.getQueueMsg(); + Long detailId = queueMsg.getMoveCollectTaskDetailId(); StrObjMap nextData = (StrObjMap) processRet.getData(); long shopId = queueMsg.getShopId(); + String cnaliDsDetailId = queueMsg.getCnaliDsDetailId(); + Integer taskId = queueMsg.getMoveCollectTaskId(); + int tryTimes = queueMsg.getTryTimes() == 0 ? queueMsg.getTryTimes() : 0; if (CommonTool.isSuccessRet(processRet)) { JSONObject productDetailBase = (JSONObject) processRet.getData().get("productDetailBase"); // 要搬家的所有图片 @@ -2876,60 +2897,143 @@ public class ProcessProductPublishTaskService extends TaskBaseService { // 图片素材相关 StrStrMap urlAndMaterialIdMap = getUrlAndMaterialIdMapBySourceUrl(shopId, imgUrls); - + MoveCollectTaskDetail updateMoveCollectTaskDetailData = new MoveCollectTaskDetail(); // TODO -// $updateMoveCollectTaskDetailData = [ -// 'reason' => '铺货数据组装完毕,等待抖店审核图片通过', -// 'publish_cost_seconds' => $publishCostSeconds -// ]; + updateMoveCollectTaskDetailData.setReason("铺货数据组装完毕,等待抖店审核图片通过"); + updateMoveCollectTaskDetailData.setPublishCostSeconds(publishCostSeconds); // 移动到pic_queue 挂起 int queueId = createMoveProductPublishToPicQueue(queueMsg); if (queueId > 0) { -// $updateMoveCollectTaskDetailData = [ -// 'reason' => '写入图片处理队列失败,请重试任务', -// 'status' => StatusConst::fail -// ]; + updateMoveCollectTaskDetailData = new MoveCollectTaskDetail(); + updateMoveCollectTaskDetailData.setReason("写入图片处理队列失败,请重试任务"); + updateMoveCollectTaskDetailData.setStatus(StatusConst.fail); } List materialIds = Arrays.asList(urlAndMaterialIdMap.values().toArray(new String[0])); // 保存素材业务信息 // 素材的task和detail就加入了 Ret saveMaterialBizRet = saveMaterialBiz(shopId, CommonConst.BIZ_MOVE, queueId, materialIds, new HashMap()); if (CommonTool.isFailRet(saveMaterialBizRet)) { -// $updateMoveCollectTaskDetailData = [ -// 'reason' => '图片业务处理失败,请重试任务', -// 'status' => StatusConst::fail -// ]; + updateMoveCollectTaskDetailData = new MoveCollectTaskDetail(); + updateMoveCollectTaskDetailData.setReason("图片业务处理失败,请重试任务"); + updateMoveCollectTaskDetailData.setStatus(StatusConst.fail); } // 更新搬家detail数据 -// updateMoveCollectTaskDetail(updateMoveCollectTaskDetailData, shopId, detailId); + moveService.updateMoveCollectTaskDetail(updateMoveCollectTaskDetailData, shopId, detailId); } else { - E.throwMSException(processRet.getReason()); - // TODO -// // 限流等情况的处理 -// checkIsFrequencyLimitReason(); -// -// // 回滚次数 -// revertMoveCopyCount(); + if (CommonTool.checkIsFrequencyLimitReason(processRet.getReason()) && queueMsg.getTryTimes() < 3) { + addTaskBuffer(shopId, taskId, detailId, 1, queueMsg.getLimitSource(), tryTimes + 1, DateUtil.formatDateTime(DateUtil.offsetSecond(new Date(), new Random().nextInt(541) + 60))); + return Ret.success(); + } + String publishStat = processRet.getCode(); + + if (StrUtil.isNotBlank(cnaliDsDetailId)) { + revertMoveCopyCount(shopId, detailId, "processMovePublishQueueRet"); + } + + MoveCollectTaskDetail updateMoveCollectTaskDetailDto = new MoveCollectTaskDetail(); + updateMoveCollectTaskDetailDto.setStatus(processRet.getCode()); + updateMoveCollectTaskDetailDto.setReason(processRet.getReason()); + updateMoveCollectTaskDetailDto.setPublishCostSeconds(publishCostSeconds); // // // 更新搬家detail数据 -// updateMoveCollectTaskDetail(new StrObjMap(), shopId, queueMsg.getMoveCollectTaskDetailId()); + updateMoveCollectTaskDetail(updateMoveCollectTaskDetailDto, shopId, detailId); // -// processCreateProductRetCommonPart(); + processCreateProductRetCommonPart(queueMsg, StatusConst.fail, processRet, publishCostSeconds, publishStat); } return processRet; } - private void revertMoveCopyCount() { - //TODO + private void processCreateProductRetCommonPart(MoveProductPublishQueueBO queueMsg, String fail, Ret processRet, Integer publishCostSeconds, String publishStat) { + // TODO: 2023/9/13 进度 + } - private void processCreateProductRetCommonPart() { - //TODO + private void addTaskBuffer(long shopId, Integer moveCollectTaskId, Long moveCollectTaskDetailId, int productTotal, Integer limitSource, int tryTimes, String gmtExec) { + int priority = saveBatchMoveTaskBizService.getTaskPriority(shopId, productTotal); + + MoveProductPublishBuffer dto = new MoveProductPublishBuffer(); + dto.setMoveCollectTaskId(moveCollectTaskId); + dto.setMoveCollectTaskDetailId(moveCollectTaskDetailId); + dto.setShopId(shopId); + dto.setPriority(priority); + dto.setTryTimes(tryTimes); + dto.setGmtExec(DateUtil.parse(gmtExec)); + dto.setGmtCreate(new Date()); + dto.setGmtModified(new Date()); + moveProductPublishBufferService.insert(dto); + } + + private void updateMoveCollectTaskDetail(MoveCollectTaskDetail updateMoveCollectTaskDetailDto, long shopId, Long detailId) { + MoveCollectTaskDetail moveCollectTaskDetail = moveCollectTaskDetailService.selectByPrimaryKey(detailId); + if (ObjectUtil.isNull(moveCollectTaskDetail) || !moveCollectTaskDetail.getShopId().equals(shopId)) { + return; + } + updateMoveCollectTaskDetailDto.setMoveCollectTaskDetailId(detailId); + moveCollectTaskDetailService.updateByPrimaryKeySelective(updateMoveCollectTaskDetailDto); + + } + + private void revertMoveCopyCount(Long shopId, Long detailId, String funcName) { + if (shopId <= 0 || ObjectUtil.isNull(detailId)) { + return; + } + + MoveCollectTaskDetail moveCollectTaskDetail = moveCollectTaskDetailService.selectByPrimaryKey(detailId); + if (ObjectUtil.isNull(moveCollectTaskDetail)) { + return; + } + Integer deductMoveShopConfigId = moveCollectTaskDetail.getMoveShopConfigId(); + MoveShopConfigBO currentMonthMoveConfig = moveService.getAvailableCopyCount(shopId); + Integer currentMoveShopConfigId = currentMonthMoveConfig.getMoveShopConfigId(); + CollectTaskDetailBO detail = moveService.getCollectTaskDetail(detailId); + if (detail.getCopyType().equals(MoveConst.collectDsCopy)) { + // TODO: 2023/9/13 没 ds_revert_log表 +// logRevertDsCopyMoveCnt(shopId, detailId, funcName); + if (ObjectUtil.isNotNull(detail.getCnaliDsDetailId())) { + return; + } + } + + if (isUseRechargeNum(shopId, Long.valueOf(deductMoveShopConfigId))) { + MoveShopConfig moveShopConfig = moveShopConfigService.selectByPrimaryKey(Long.valueOf(deductMoveShopConfigId)); + // TODO: 2023/9/13 没有这个 pre_paid_fail_total +// updateMoveShopConfig(shopId, currentMoveShopConfigId, Map.of("pre_paid_fail_total", new ZcDbEval("pre_paid_fail_total + 1"))); + } else { + MoveShopConfig moveShopConfig = moveShopConfigService.selectByPrimaryKey(Long.valueOf(deductMoveShopConfigId)); + updateMoveShopConfig(shopId, deductMoveShopConfigId, MoveShopConfig.builder().failTotal(moveShopConfig.getFailTotal() + 1).build()); + } + + } + + public Boolean updateMoveShopConfig(long shopId, Integer moveShopConfigId, MoveShopConfig updateData) { + if (ObjectUtil.isNull(moveShopConfigId)) { + return false; + } + updateData.setMoveShopConfigId(moveShopConfigId); + moveShopConfigService.updateByPrimaryKeySelective(updateData); + return true; } + private boolean isUseRechargeNum(Long shopId, Long moveShopConfigId) { + MoveShopConfig moveShopConfig = moveShopConfigService.selectByPrimaryKey(moveShopConfigId); + if (ObjectUtil.isNull(moveShopConfig)) { + return true; + } + int presentNumSurplus = getPresentNumSurplus(moveShopConfig); + return presentNumSurplus <= 0; + } + + public int getPresentNumSurplus(MoveShopConfig moveConfig) { + int monthTotal = moveConfig.getTotal() + moveConfig.getAttachTotal(); + // TODO: 2023/9/13 没有这个 pre_paid_fail_total 取0 + int moveSuccessTotal = moveConfig.getUsedTotal() - (moveConfig.getFailTotal() + 0); + return monthTotal - moveSuccessTotal; + } + + private void checkIsFrequencyLimitReason() { //TODO } diff --git a/ms-dal/src/main/java/com/ms/dal/bo/CollectTaskDetailBO.java b/ms-dal/src/main/java/com/ms/dal/bo/CollectTaskDetailBO.java index ee7f2e32..a5fbe0a7 100644 --- a/ms-dal/src/main/java/com/ms/dal/bo/CollectTaskDetailBO.java +++ b/ms-dal/src/main/java/com/ms/dal/bo/CollectTaskDetailBO.java @@ -12,6 +12,7 @@ public class CollectTaskDetailBO extends MoveCollectTaskDetail { // */ // private Integer moveCollectTaskId; + private Long cnaliDsDetailId; /** * name */ diff --git a/ms-dal/src/main/java/com/ms/dal/entity/MoveShopConfig.java b/ms-dal/src/main/java/com/ms/dal/entity/MoveShopConfig.java index 2ba051c7..36a52c22 100644 --- a/ms-dal/src/main/java/com/ms/dal/entity/MoveShopConfig.java +++ b/ms-dal/src/main/java/com/ms/dal/entity/MoveShopConfig.java @@ -1,6 +1,9 @@ package com.ms.dal.entity; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.io.Serializable; import java.util.Date; @@ -10,6 +13,9 @@ import java.util.Date; * @Date: 2023/8/24 */ @Data +@Builder +@NoArgsConstructor +@AllArgsConstructor public class MoveShopConfig implements Serializable { /** From 98ffabfaa0d3bb05014f3e2edc2a3636e6a17652 Mon Sep 17 00:00:00 2001 From: wangchaoxu Date: Wed, 13 Sep 2023 18:50:19 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8A=96=E5=BA=97?= =?UTF-8?q?=E5=9B=9E=E8=B0=83controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ms/api/spi/callback/OpenMsgConsumerService.java | 2 +- ms-web/src/main/java/com/ms/web/Test.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ms-biz/src/main/java/com/ms/api/spi/callback/OpenMsgConsumerService.java b/ms-biz/src/main/java/com/ms/api/spi/callback/OpenMsgConsumerService.java index 45431743..2a2087bf 100644 --- a/ms-biz/src/main/java/com/ms/api/spi/callback/OpenMsgConsumerService.java +++ b/ms-biz/src/main/java/com/ms/api/spi/callback/OpenMsgConsumerService.java @@ -26,7 +26,7 @@ public class OpenMsgConsumerService extends SPIBaseService implements ExtensionS @Override public BaseResponse handle(BaseRequest> req) { - initHandle(req); +// initHandle(req); // ----参数校验---- List msgList = req.getData(); diff --git a/ms-web/src/main/java/com/ms/web/Test.java b/ms-web/src/main/java/com/ms/web/Test.java index 594e2c04..60b66281 100644 --- a/ms-web/src/main/java/com/ms/web/Test.java +++ b/ms-web/src/main/java/com/ms/web/Test.java @@ -2,6 +2,7 @@ package com.ms.web; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.jinritemai.cloud.base.api.BaseRequest; import com.jinritemai.cloud.base.api.BaseResponse; import com.ms.api.common.Pager; import com.ms.api.common.R; @@ -13,6 +14,7 @@ import com.ms.api.dto.dsorder.RemarkTplTagDTO; import com.ms.api.dto.order.SearchDsOrderFilterDTO; import com.ms.api.dto.order.SearchDsOrderListRequestDTO; import com.ms.api.service.*; +import com.ms.api.spi.callback.OpenMsgConsumerService; import com.ms.api.tool.CommonTool; import com.ms.api.tool.PurchaseTool; import com.ms.common.util.DsClient; @@ -58,6 +60,9 @@ public class Test { @Autowired private DsApiService dsApiService; + @Autowired + private OpenMsgConsumerService openMsgConsumerService; + @GetMapping("/hello") public String hello(@RequestParam(value = "name", defaultValue = "World") String name) { return String.format("Hello %s!", name); @@ -190,4 +195,12 @@ public class Test { return R.ok(Ret.fail(e.getMessage())); } } + + @PostMapping("/cloudOpenMsgConsumer") + public BaseResponse cloudOpenMsgConsumer(@RequestBody List request) { + log.info("receive callback: " + JSON.toJSONString(request)); + BaseRequest> req = new BaseRequest<>(); + req.setData(request); + return openMsgConsumerService.handle(req); + } } From 556d4f60667812f5c61841812deae52b78a7bbda Mon Sep 17 00:00:00 2001 From: daixiaogang <2510234660@qq.com> Date: Wed, 13 Sep 2023 18:50:54 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20corePoolSiz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java index f3835919..5022fa3d 100644 --- a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java +++ b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java @@ -15,7 +15,7 @@ public abstract class TaskBaseService implements TaskHandler { @Autowired private PlatformTransactionManager transactionManager; - protected int corePoolSiz = 4; + protected int corePoolSiz = 40; protected int maxPoolSize = 10; protected int queueCapacity = 500; protected String taskExecutorName = "TaskPool"; From 83d254560f016b4650fe0cb2386d58ed4ae7756d Mon Sep 17 00:00:00 2001 From: qiushengjie Date: Wed, 13 Sep 2023 18:55:10 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ms/api/common/TaskBaseService.java | 26 +++++-------------- .../MoveMaterialAuditProcessTaskService.java | 3 --- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java index f3835919..a995e3b3 100644 --- a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java +++ b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java @@ -1,5 +1,6 @@ package com.ms.api.common; +import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -14,28 +15,15 @@ public abstract class TaskBaseService implements TaskHandler { @Autowired private PlatformTransactionManager transactionManager; - + @Getter protected int corePoolSiz = 4; - protected int maxPoolSize = 10; - protected int queueCapacity = 500; + @Getter + protected int maxPoolSize = 10000; + @Getter + protected int queueCapacity = 50000; + @Getter protected String taskExecutorName = "TaskPool"; - public int getCorePoolSiz() { - return corePoolSiz; - } - - public int getMaxPoolSize() { - return maxPoolSize; - } - - public int getQueueCapacity() { - return queueCapacity; - } - - public String getTaskExecutorName() { - return taskExecutorName; - } - public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); // 为了避免线程池满了,导致定时任务无法执行,这里多加一个线程 diff --git a/ms-biz/src/main/java/com/ms/api/task/MoveMaterialAuditProcessTaskService.java b/ms-biz/src/main/java/com/ms/api/task/MoveMaterialAuditProcessTaskService.java index 8f82fcfa..e34b0b5f 100644 --- a/ms-biz/src/main/java/com/ms/api/task/MoveMaterialAuditProcessTaskService.java +++ b/ms-biz/src/main/java/com/ms/api/task/MoveMaterialAuditProcessTaskService.java @@ -29,9 +29,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.*; From 9e0ee9407fdcae590c14e22cf8720cee28a6c980 Mon Sep 17 00:00:00 2001 From: daixiaogang <2510234660@qq.com> Date: Wed, 13 Sep 2023 18:56:19 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20corePoolSiz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java index 5022fa3d..e1e3fba6 100644 --- a/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java +++ b/ms-biz/src/main/java/com/ms/api/common/TaskBaseService.java @@ -15,8 +15,8 @@ public abstract class TaskBaseService implements TaskHandler { @Autowired private PlatformTransactionManager transactionManager; - protected int corePoolSiz = 40; - protected int maxPoolSize = 10; + protected int corePoolSiz = 4; + protected int maxPoolSize = 40; protected int queueCapacity = 500; protected String taskExecutorName = "TaskPool"; From 02763901c776b3f1588d8b3d1f8096f76f8f1f4e Mon Sep 17 00:00:00 2001 From: wangchaoxu Date: Wed, 13 Sep 2023 19:18:45 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8A=96=E5=BA=97?= =?UTF-8?q?=E5=9B=9E=E8=B0=83controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ms-web/src/main/java/com/ms/web/Test.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ms-web/src/main/java/com/ms/web/Test.java b/ms-web/src/main/java/com/ms/web/Test.java index 60b66281..400c4187 100644 --- a/ms-web/src/main/java/com/ms/web/Test.java +++ b/ms-web/src/main/java/com/ms/web/Test.java @@ -198,7 +198,7 @@ public class Test { @PostMapping("/cloudOpenMsgConsumer") public BaseResponse cloudOpenMsgConsumer(@RequestBody List request) { - log.info("receive callback: " + JSON.toJSONString(request)); + log.info("receive doudian callback: " + JSON.toJSONString(request)); BaseRequest> req = new BaseRequest<>(); req.setData(request); return openMsgConsumerService.handle(req); From 74e5abcc1a268d1eb94d9714b8aee9ee6b70725d Mon Sep 17 00:00:00 2001 From: ljl Date: Wed, 13 Sep 2023 19:34:23 +0800 Subject: [PATCH 10/11] yh --- .../OpOrderChildLogisticsServiceImpl.java | 2 +- .../service/impl/OutstorageServiceImpl.java | 45 ++++++++++++++----- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderChildLogisticsServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderChildLogisticsServiceImpl.java index 8aa34d88..b7bf1760 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderChildLogisticsServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderChildLogisticsServiceImpl.java @@ -117,7 +117,7 @@ public class OpOrderChildLogisticsServiceImpl implements OpOrderChildLogisticsSe childLogistics.setCompanyCode(companyCode); childLogistics.setGmtModified(new Date()); - if (childLogistics.getOpOrderChildLogisticsId() > 0) { + if (childLogistics.getOpOrderChildLogisticsId() != null && childLogistics.getOpOrderChildLogisticsId() > 0) { updateByPrimaryKeySelective(childLogistics); } else { insertSelective(childLogistics); diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OutstorageServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OutstorageServiceImpl.java index ace427f0..7f23a23f 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OutstorageServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OutstorageServiceImpl.java @@ -31,7 +31,10 @@ import com.ms.dal.mapper.OpOrderMapper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Service; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; import java.util.*; import java.util.stream.Collectors; @@ -44,6 +47,9 @@ import java.util.stream.Stream; @Slf4j @AllArgsConstructor public class OutstorageServiceImpl implements OutstorageService { + private final DataSourceTransactionManager dataSourceTransactionManager; + private final TransactionDefinition transactionDefinition; + private OpOrderMapper opOrderMapper; private OpOrderChildAfterSaleMapper opOrderChildAfterSaleMapper; @@ -90,8 +96,15 @@ public class OutstorageServiceImpl implements OutstorageService { } ResultDTO result = orderLogisticsAddMultiPackToDd(shopBO, opOrder.getOrderId(), packageList); - saveOrderMultiPackageOutstorageResult(opOrder, packageList, result, outStorageSource); - + TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); + try { + saveOrderMultiPackageOutstorageResult(opOrder, packageList, result, outStorageSource); + dataSourceTransactionManager.commit(transactionStatus); + } catch (Throwable e) { + dataSourceTransactionManager.rollback(transactionStatus); + log.error("saveOrderMultiPackageOutstorageResult transaction error: " + e.getMessage()); + throw new RuntimeException("处理异常"); + } return result; } @@ -131,10 +144,17 @@ public class OutstorageServiceImpl implements OutstorageService { param.setPackList(itemList); request.setParam(param); - OrderLogisticsAddMultiPackResponse response = request.execute(); + log.error("shopBO: " + shopBO); + log.error("OrderLogisticsAddMultiPackRequest: " + request); + OrderLogisticsAddMultiPackResponse response = request.execute(shopBO.getShopAccessToken()); log.error("OrderLogisticsAddMultiPackResponse: " + response); if (!response.isSuccess()) { - throw new RuntimeException(response.getSubMsg()); + // 模拟成功 + if (Objects.equals(response.getCode(), "30002") && Objects.equals(response.getSubCode(), "isv.test-order-permissions-insufficient")) { + return ResultDTO.success(); + } else { + throw new RuntimeException(response.getSubMsg()); + } } Map data = new HashMap<>(); data.put("packList", response.getData().getPackList()); @@ -211,7 +231,7 @@ public class OutstorageServiceImpl implements OutstorageService { for (OrderMultiPackageOutstorageDTO.PackageInfoDTO packageInfo: packageList) { String ddPackId = OrderTool.buildDdPackId(packageInfo.getCompanyCode(), packageInfo.getWaybillCode()); OpPackage newPackage = opPackageService.save(opOrder.getShopId(), ddPackId, packageInfo.getCompanyCode(), packageInfo.getWaybillCode()); - OpPackageOrder newPackageOrder = opPackageOrderService.saveByOpPackage(newPackage, opOrder.getOrderId()); + opPackageOrderService.saveByOpPackage(newPackage, opOrder.getOrderId()); for (OrderMultiPackageOutstorageDTO.ShippedOrderInfo shippedOrderInfo: packageInfo.getShippedOrderInfo()) { opOrderChildLogisticsService.saveByOpPackageOrderChild(opOrder.getOrderId(), shippedOrderInfo.getShippedOrderId(), opOrder.getShopId(), shippedOrderInfo.getShippedNum(), packageInfo.getCompanyCode(), packageInfo.getWaybillCode(), packageInfo.getLogisticsName()); opPackageOrderChildService.save(newPackage.getOpPackageId(), shippedOrderInfo.getShippedOrderId(), opOrder.getOrderId(), shippedOrderInfo.getShippedNum()); @@ -431,7 +451,7 @@ public class OutstorageServiceImpl implements OutstorageService { } OpPackage newPackage = opPackageService.save(opOrder.getShopId(), newDdPackId, companyCode, waybillCode); - OpPackageOrder newPackageOrder = opPackageOrderService.saveByOpPackage(newPackage, opOrder.getOrderId()); + opPackageOrderService.saveByOpPackage(newPackage, opOrder.getOrderId()); List childOrderIds = new ArrayList<>(); for (OpPackageOrderChild packageOrderChild: oldPackageOrderChildren) { @@ -455,7 +475,7 @@ public class OutstorageServiceImpl implements OutstorageService { param.setLogisticsCode(logisticsCode); request.setParam(param); request.execute(); - OrderLogisticsEditByPackResponse response = request.execute(); + OrderLogisticsEditByPackResponse response = request.execute(shopBO.getShopAccessToken()); if (!response.isSuccess()) { return ResultDTO.fail(response.getMsg()); } @@ -464,8 +484,9 @@ public class OutstorageServiceImpl implements OutstorageService { private void updateOrderStatusAfterPackageSend(List orderIds) { List children = opOrderChildService.getListByOrderIds(orderIds); + log.info("updateOrderStatusAfterPackageSendChildren: " + children); Map> orderIdAndChildOrderIdAndComboNumMap = buildOrderIdAndChildOrderIdAndComboNumMap(children); - + log.info("orderIdAndChildOrderIdAndComboNumMap: " + orderIdAndChildOrderIdAndComboNumMap); List childLogisticsRows = opOrderChildLogisticsService.getListByOrderIds(orderIds); Map> orderIdAndChildOrderIdAndShippedNumMap = new HashMap<>(); for (OpOrderChildLogistics childLogistics: childLogisticsRows) { @@ -480,7 +501,7 @@ public class OutstorageServiceImpl implements OutstorageService { } orderIdAndChildOrderIdAndShippedNumMap.put(childLogistics.getOrderId(), childOrderIdAndShippedNumMap); } - + log.info("orderIdAndChildOrderIdAndComboNumMap: " + orderIdAndChildOrderIdAndComboNumMap); List beforeStatusList = new ArrayList<>(); beforeStatusList.add(OrderConst.ORDER_STATUS_WAIT_SELLER_SEND_GOODS); beforeStatusList.add(OrderConst.ORDER_STATUS_PART_DELIVERY); @@ -493,7 +514,7 @@ public class OutstorageServiceImpl implements OutstorageService { String childOrderId = subEntry.getKey(); Integer comboNum = subEntry.getValue(); Integer shippedNum = comboIdAndShippedNumMap.get(childOrderId); - if (shippedNum > 0) { + if (shippedNum == 0) { allShipped = false; continue; } @@ -641,6 +662,10 @@ public class OutstorageServiceImpl implements OutstorageService { packageInfo = new OrderMultiPackageOutstorageDTO.PackageInfoDTO(); packageInfo.setLogisticsId(String.valueOf(deliverInfoDTO.getLogisticsId())); packageInfo.setLogisticsCode(deliverInfoDTO.getWaybillCode()); + packageInfo.setWaybillCode(deliverInfoDTO.getWaybillCode()); + packageInfo.setLogisticsName(deliverInfoDTO.getLogisticsName()); + packageInfo.setCompany(deliverInfoDTO.getLogisticsName()); + packageInfo.setCompanyCode(deliverInfoDTO.getCompanyCode()); packageInfo.setShippedOrderInfo(new ArrayList<>()); } else { packageInfo = skuIdAndPackageInfoMap.get(orderChild.getSkuId()); From c6f58f42e743250fe72513a08d169eeff9f517e4 Mon Sep 17 00:00:00 2001 From: ljl Date: Wed, 13 Sep 2023 19:35:16 +0800 Subject: [PATCH 11/11] yh --- 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 2de64b72..d68de36e 100644 --- a/ms-deploy/src/main/java/com/ms/deploy/MsApplication.java +++ b/ms-deploy/src/main/java/com/ms/deploy/MsApplication.java @@ -9,7 +9,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) {