|
@@ -446,7 +446,7 @@ public class OrderTaskServiceImpl implements OrderTaskService {
|
|
|
}
|
|
|
try {
|
|
|
Boolean result = payService.payAfterProcessingTemp(String.valueOf(data));
|
|
|
-// Boolean result = payService.payAfterProcessing(String.valueOf(data));
|
|
|
+ //Boolean result = payService.payAfterProcessing(String.valueOf(data));
|
|
|
if (!result) {
|
|
|
redisUtil.lPush(redisKey, data);
|
|
|
}
|
|
@@ -623,24 +623,31 @@ public class OrderTaskServiceImpl implements OrderTaskService {
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
User user = userService.getById(order.getUid());
|
|
|
- // 获取佣金记录
|
|
|
- List<UserBrokerageRecord> recordList = userBrokerageRecordService.findListByLinkNoAndLinkType(orderNo, BrokerageRecordConstants.BROKERAGE_RECORD_LINK_TYPE_ORDER);
|
|
|
- logger.info("收货处理佣金条数:" + recordList.size());
|
|
|
- for (UserBrokerageRecord record : recordList) {
|
|
|
- if (!record.getStatus().equals(BrokerageRecordConstants.BROKERAGE_RECORD_STATUS_CREATE)) {
|
|
|
- throw new CrmebException(StrUtil.format("订单收货task处理,订单佣金记录不是创建状态,orderNo={}", orderNo));
|
|
|
- }
|
|
|
- // 佣金进入冻结期
|
|
|
- record.setStatus(BrokerageRecordConstants.BROKERAGE_RECORD_STATUS_FROZEN);
|
|
|
- // 计算解冻时间
|
|
|
- long thawTime = DateUtil.current(false);
|
|
|
- if (record.getFrozenTime() > 0) {
|
|
|
- DateTime dateTime = DateUtil.offsetDay(new Date(), record.getFrozenTime());
|
|
|
- thawTime = dateTime.getTime();
|
|
|
+ // 分销
|
|
|
+ List<UserBrokerageRecord> recordList = null;
|
|
|
+ String isOpen = systemConfigService.getValueByKey(SysConfigConstants.RETAIL_STORE_SWITCH);
|
|
|
+ if (StrUtil.isNotBlank(isOpen) && Constants.COMMON_SWITCH_OPEN.equals(isOpen)) {
|
|
|
+ // 开启分销功能
|
|
|
+ // 获取佣金记录
|
|
|
+ recordList = userBrokerageRecordService.findListByLinkNoAndLinkType(orderNo, BrokerageRecordConstants.BROKERAGE_RECORD_LINK_TYPE_ORDER);
|
|
|
+ logger.info("收货处理佣金条数:" + recordList.size());
|
|
|
+ for (UserBrokerageRecord record : recordList) {
|
|
|
+ if (!record.getStatus().equals(BrokerageRecordConstants.BROKERAGE_RECORD_STATUS_CREATE)) {
|
|
|
+ throw new CrmebException(StrUtil.format("订单收货task处理,订单佣金记录不是创建状态,orderNo={}", orderNo));
|
|
|
+ }
|
|
|
+ // 佣金进入冻结期
|
|
|
+ record.setStatus(BrokerageRecordConstants.BROKERAGE_RECORD_STATUS_FROZEN);
|
|
|
+ // 计算解冻时间
|
|
|
+ long thawTime = DateUtil.current(false);
|
|
|
+ if (record.getFrozenTime() > 0) {
|
|
|
+ DateTime dateTime = DateUtil.offsetDay(new Date(), record.getFrozenTime());
|
|
|
+ thawTime = dateTime.getTime();
|
|
|
+ }
|
|
|
+ record.setThawTime(thawTime);
|
|
|
}
|
|
|
- record.setThawTime(thawTime);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 获取积分记录
|
|
|
List<UserIntegralRecord> integralRecordList = userIntegralRecordService.findListByOrderNoAndUid(orderNo, order.getUid());
|
|
|
logger.info("收货处理积分条数:" + integralRecordList.size());
|
|
@@ -660,12 +667,13 @@ public class OrderTaskServiceImpl implements OrderTaskService {
|
|
|
record.setThawTime(thawTime);
|
|
|
}
|
|
|
|
|
|
+ List<UserBrokerageRecord> finalRecordList = recordList;
|
|
|
Boolean execute = transactionTemplate.execute(e -> {
|
|
|
// 日志
|
|
|
orderStatusService.createLog(order.getOrderNo(), OrderStatusConstants.ORDER_STATUS_USER_TAKE_DELIVERY, OrderStatusConstants.ORDER_LOG_MESSAGE_TAKE);
|
|
|
// 分佣-佣金进入冻结期
|
|
|
- if (CollUtil.isNotEmpty(recordList)) {
|
|
|
- userBrokerageRecordService.updateBatchById(recordList);
|
|
|
+ if (CollUtil.isNotEmpty(finalRecordList)) {
|
|
|
+ userBrokerageRecordService.updateBatchById(finalRecordList);
|
|
|
}
|
|
|
// 积分进入冻结期
|
|
|
if (CollUtil.isNotEmpty(userIntegralRecordList)) {
|
|
@@ -675,7 +683,13 @@ public class OrderTaskServiceImpl implements OrderTaskService {
|
|
|
});
|
|
|
if (execute) {
|
|
|
// 发送消息 确认收获通知
|
|
|
- pushMessageOrder(order, user);
|
|
|
+ try {
|
|
|
+ pushMessageOrder(order, user);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 防止将订单号再次放入redis定时器重复计算佣金积分,这里捕捉异常并不抛出
|
|
|
+ logger.error("收获后续处理发送模板消息失败,{}", e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
return execute;
|
|
|
}
|