fix: 霸王餐返还订单券

This commit is contained in:
张松
2024-11-23 11:28:25 +08:00
parent 165e1fde14
commit e1b4e2500a

View File

@@ -192,6 +192,7 @@ public class PayService {
private final TbShopCouponService shopCouponService;
private final MpMemberInMapper mpMemberInMapper;
private final TbMemberPointsServiceImpl memberPointsService;
private final CartService cartService;
@Qualifier("tbShopCouponService")
@Autowired
@@ -204,13 +205,14 @@ public class PayService {
private TbFreeDineRecordMapper tbFreeDineRecordMapper;
private final TbFreeDineRecordService freeDineRecordService;
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, MpShopTableService mpShopTableService, TbFreeDineConfigService freeDineConfigService, TbShopCouponService shopCouponService, MpMemberInMapper mpMemberInMapper, TbMemberPointsServiceImpl memberPointsService, TbFreeDineRecordService freeDineRecordService) {
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, MpShopTableService mpShopTableService, TbFreeDineConfigService freeDineConfigService, TbShopCouponService shopCouponService, MpMemberInMapper mpMemberInMapper, TbMemberPointsServiceImpl memberPointsService, CartService cartService, TbFreeDineRecordService freeDineRecordService) {
this.shopSongOrderService = shopSongOrderService;
this.mpShopTableService = mpShopTableService;
this.freeDineConfigService = freeDineConfigService;
this.shopCouponService = shopCouponService;
this.mpMemberInMapper = mpMemberInMapper;
this.memberPointsService = memberPointsService;
this.cartService = cartService;
this.freeDineRecordService = freeDineRecordService;
}
@@ -386,6 +388,15 @@ public class PayService {
}
private BigDecimal getFreeDineOrderInfo(MemberInDTO payDTO, TbUserInfo userInfo) {
// 取消券
UseCouponDTO useCouponDTO = new UseCouponDTO();
useCouponDTO.setOrderId(payDTO.getOrderId());
useCouponDTO.setUserCouponInfos(new ArrayList<>());
useCouponDTO.setPointsNum(null);
useCouponDTO.setShopId(payDTO.getShopId());
cartService.useCoupon(useCouponDTO);
TbOrderInfo orderInfo = mpOrderInfoMapper.selectOne(new LambdaQueryWrapper<TbOrderInfo>()
.eq(TbOrderInfo::getId, payDTO.getOrderId())
.in(TbOrderInfo::getStatus, TableConstant.OrderInfo.Status.UNPAID.getValue(), TableConstant.OrderInfo.Status.PAYING.getValue()));
@@ -419,13 +430,13 @@ public class PayService {
}
// 返还优惠券
returnCoupon(orderInfo, shopCouponService, mpCashierCartMapper);
// returnCoupon(orderInfo, shopCouponService, mpCashierCartMapper);
BigDecimal shouldPayAmount = orderInfo.getOriginAmount().multiply(BigDecimal.valueOf(freeDineConfig.getRechargeTimes()));
// 霸王餐积分抵扣
if (payDTO.getPointsNum() != null) {
// 霸王餐积分抵扣 预留
if (false && payDTO.getPointsNum() != null) {
OrderDeductionPointsDTO memberUsablePoints = memberPointsService.getMemberUsablePoints(Long.valueOf(userInfo.getId()), shouldPayAmount);
if (!memberUsablePoints.getUsable()) {
throw new MsgException(memberUsablePoints.getUnusableReason());