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

20230922-ljl-fixBug
cxxxxxxx详 1 year ago
commit 316b95d580

@ -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'),

@ -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;
@ -32,6 +21,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,8 +31,10 @@ 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.entity.*;
import com.ms.dal.mapper.MoveCollectTaskDetailMapper;
import com.ms.dal.mapper.MoveCollectTaskMapper;
import com.ms.dal.mapper.MoveProductPublishBufferMapper;
@ -54,6 +46,9 @@ 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 {
@ -75,6 +70,10 @@ public class MoveService {
@Autowired
private CategorySizeTemplateSubTypeService categorySizeTemplateSubTypeService;
@Autowired
private MoveShopConfigService moveShopConfigService;
/**
*
*
@ -100,11 +99,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) {
@ -171,8 +172,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;
@ -181,61 +181,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);
}
@ -624,4 +572,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;
}
}

@ -47,6 +47,9 @@ public class SaveBatchMoveTaskBizService extends BizBaseService {
@Autowired
private MoveShopConfigService moveShopConfigService;
@Autowired
private MoveService moveService;
public Ret checkAndFormatData(Long shopId, List<MoveProductDTO> 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;
}

@ -108,4 +108,5 @@ public class MoveProductPublishQueueBO {
private Double hasImportPrice;
private Integer supply7dayReturn;
private Integer limitSource;
}

@ -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();
// 为了避免线程池满了,导致定时任务无法执行,这里多加一个线程
@ -52,8 +40,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 +53,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);
}
}

@ -20,10 +20,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;
/**
*
@ -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,18 @@ 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 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<String> getSpecialBanWordList() {
List<String> result = new ArrayList<String>();
@ -134,7 +145,6 @@ public class MoveConst {
return result;
}
public static Map<String, String> getSupply7dayReturnOption() {
Map<String, String> options = new HashMap<>();
options.put(String.valueOf(MoveConst.supply7dayReturnNo), "不支持");

@ -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);

@ -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<String, Object> 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<String> 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<String> orderIds) {
List<OpOrderChild> children = opOrderChildService.getListByOrderIds(orderIds);
log.info("updateOrderStatusAfterPackageSendChildren: " + children);
Map<String, Map<String, Integer>> orderIdAndChildOrderIdAndComboNumMap = buildOrderIdAndChildOrderIdAndComboNumMap(children);
log.info("orderIdAndChildOrderIdAndComboNumMap: " + orderIdAndChildOrderIdAndComboNumMap);
List<OpOrderChildLogistics> childLogisticsRows = opOrderChildLogisticsService.getListByOrderIds(orderIds);
Map<String, Map<String, Integer>> 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<Integer> 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());

@ -26,7 +26,7 @@ public class OpenMsgConsumerService extends SPIBaseService implements ExtensionS
@Override
public BaseResponse<Void> handle(BaseRequest<List<String>> req) {
initHandle(req);
// initHandle(req);
// ----参数校验----
List<String> msgList = req.getData();

@ -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();

@ -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.*;
@ -61,7 +58,7 @@ public class MoveMaterialAuditProcessTaskService extends TaskBaseService {
*
*/
public int getCorePoolSiz() {
return 3;
return 10;
}
/**
@ -86,7 +83,7 @@ public class MoveMaterialAuditProcessTaskService extends TaskBaseService {
}
@Async("moveMaterialAuditProcessPool")
@Scheduled(fixedRate = 10000)
@Scheduled(fixedRate = 2000)
@Override
public void runTask() {
super.runTaskWithTransaction();

@ -81,7 +81,7 @@ public class MoveMaterialBizProcessTaskService extends TaskBaseService {
}
@Async("moveMaterialBizProcessTaskPool")
@Scheduled(fixedRate = 10000)
@Scheduled(fixedRate = 5000)
@Override
public void runTask() {
super.runTaskWithTransaction();

@ -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();
@ -603,7 +681,6 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
}
String mobile = productData.getString("mobile");
param.setMobile("400123456");
if (!Objects.isNull(mobile)) {
param.setMobile(mobile);
}
@ -661,17 +738,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)) {
@ -688,11 +759,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)) {
@ -734,16 +804,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)) {
@ -759,7 +824,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
// if (!Objects.isNull(afterSaleService)) {
// param.setAfterSaleService(afterSaleService);
// }
// TODO
Map<String, String> ss = new HashMap<>();
ss.put("supply_day_return_selector", "7-1");
param.setAfterSaleService(ss);

@ -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<String, String> redisTemplate;
@ -416,7 +429,7 @@ public class ProcessProductPublishTaskService extends TaskBaseService {
return CommonTool.successResult();
}
private List<String> getUploadImgSuccessMapAndFailUrls(Map<String,Object> data, List<String> uploadImgs) {
private List<String> getUploadImgSuccessMapAndFailUrls(Map<String, Object> data, List<String> uploadImgs) {
Map<String, String> sourceImgUrlToDdImgUrl = new HashMap<>();
for (Map.Entry<String, Object> 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);
}
@ -566,7 +579,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);
@ -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<String> 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
}

@ -12,6 +12,7 @@ public class CollectTaskDetailBO extends MoveCollectTaskDetail {
// */
// private Integer moveCollectTaskId;
private Long cnaliDsDetailId;
/**
* name
*/

@ -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 {
/**

@ -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<Void> cloudOpenMsgConsumer(@RequestBody List<String> request) {
log.info("receive doudian callback: " + JSON.toJSONString(request));
BaseRequest<List<String>> req = new BaseRequest<>();
req.setData(request);
return openMsgConsumerService.handle(req);
}
}

Loading…
Cancel
Save