【缺陷修复】商城: 订单支付后记录 log error 日志,保证订单最大化可推导。
This commit is contained in:
parent
01fca4e9c7
commit
6ffb4ed116
|
@ -2,10 +2,7 @@ package cn.iocoder.yudao.module.trade.service.brokerage;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.*;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||
|
@ -183,10 +180,7 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService {
|
|||
} else if (Objects.equals(sourceUserLevel, 2)) {
|
||||
fixedPrice = item.getSecondFixedPrice();
|
||||
} else {
|
||||
log.error("[addBrokerage][user({}) list({}) brokerageFrozenDays({}) brokeragePercent({}) " +
|
||||
"bizType({}) 用户等级sourceUserLevel({}) 不合法]", user, list, brokerageFrozenDays,
|
||||
brokeragePercent, bizType, sourceUserLevel);
|
||||
return;
|
||||
throw new IllegalArgumentException(StrUtil.format("用户等级({}) 不合法", sourceUserLevel));
|
||||
}
|
||||
int brokeragePrice = calculatePrice(item.getBasePrice(), brokeragePercent, fixedPrice);
|
||||
if (brokeragePrice <= 0) {
|
||||
|
|
|
@ -920,9 +920,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|||
// 1. 检验订单存在
|
||||
TradeOrderDO order = tradeOrderMapper.selectOrderByIdAndUserId(orderId, userId);
|
||||
if (order == null) {
|
||||
log.error("[updateOrderGiveCouponIds][userId({}) orderId({}) giveCouponIds({}) {}]", userId, orderId,
|
||||
giveCouponIds, ORDER_NOT_FOUND);
|
||||
return;
|
||||
throw exception(ORDER_NOT_FOUND);
|
||||
}
|
||||
|
||||
// 2. 更新订单赠送的优惠券编号列表
|
||||
|
|
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
|
|||
import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService;
|
||||
import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -19,6 +20,7 @@ import java.util.List;
|
|||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TradeCouponOrderHandler implements TradeOrderHandler {
|
||||
|
||||
@Resource
|
||||
|
@ -46,11 +48,15 @@ public class TradeCouponOrderHandler implements TradeOrderHandler {
|
|||
return;
|
||||
}
|
||||
// 赠送优惠券
|
||||
List<Long> couponIds = couponApi.takeCouponsByAdmin(order.getGiveCouponTemplateCounts(), order.getUserId());
|
||||
if (CollUtil.isEmpty(couponIds)) {
|
||||
return;
|
||||
try {
|
||||
List<Long> couponIds = couponApi.takeCouponsByAdmin(order.getGiveCouponTemplateCounts(), order.getUserId());
|
||||
if (CollUtil.isEmpty(couponIds)) {
|
||||
return;
|
||||
}
|
||||
orderUpdateService.updateOrderGiveCouponIds(order.getUserId(), order.getId(), couponIds);
|
||||
} catch (Exception e) {
|
||||
log.error("[afterPayOrder][order({}) 赠送优惠券({})失败,需要手工补偿]", order.getId(), order.getGiveCouponTemplateCounts(), e);
|
||||
}
|
||||
orderUpdateService.updateOrderGiveCouponIds(order.getUserId(), order.getId(), couponIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.EXPERIENCE_BIZ_NOT_SUPPORT;
|
||||
|
||||
/**
|
||||
|
@ -33,9 +34,7 @@ public class MemberLevelApiImpl implements MemberLevelApi {
|
|||
public void addExperience(Long userId, Integer experience, Integer bizType, String bizId) {
|
||||
MemberExperienceBizTypeEnum bizTypeEnum = MemberExperienceBizTypeEnum.getByType(bizType);
|
||||
if (bizTypeEnum == null) {
|
||||
log.error("[addExperience][userId({}) experience({}) bizType({}) bizId({}) {}]", userId, experience, bizType,
|
||||
bizId, EXPERIENCE_BIZ_NOT_SUPPORT);
|
||||
return;
|
||||
throw exception(EXPERIENCE_BIZ_NOT_SUPPORT);
|
||||
}
|
||||
memberLevelService.addExperience(userId, experience, bizTypeEnum, bizId);
|
||||
}
|
||||
|
|
|
@ -41,9 +41,7 @@ public class MemberPointApiImpl implements MemberPointApi {
|
|||
Assert.isTrue(point > 0);
|
||||
MemberPointBizTypeEnum bizTypeEnum = MemberPointBizTypeEnum.getByType(bizType);
|
||||
if (bizTypeEnum == null) {
|
||||
log.error("[addPoint][userId({}) point({}) bizType({}) bizId({}) {}]", userId, point, bizType, bizId,
|
||||
POINT_RECORD_BIZ_NOT_SUPPORT);
|
||||
return;
|
||||
throw exception(POINT_RECORD_BIZ_NOT_SUPPORT);
|
||||
}
|
||||
memberPointRecordService.createPointRecord(userId, -point, bizTypeEnum, bizId);
|
||||
}
|
||||
|
|
|
@ -82,9 +82,7 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService {
|
|||
// 2. 更新用户积分
|
||||
boolean success = memberUserService.updateUserPoint(userId, point);
|
||||
if (!success) {
|
||||
log.error("[createPointRecord][userId({}) point({}) bizType({}) bizId({}) {}]", userId, point, bizType, bizId,
|
||||
USER_POINT_NOT_ENOUGH);
|
||||
return;
|
||||
throw exception(USER_POINT_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
// 3. 增加积分记录
|
||||
|
|
Loading…
Reference in New Issue