0元付款 积分消耗 优惠券消耗

This commit is contained in:
2025-03-21 14:11:32 +08:00
parent 9d969c60f0
commit b617806c80

View File

@@ -863,6 +863,28 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
orderInfo.setStatus(OrderStatusEnums.DONE.getCode());
orderInfo.setPayType(PayEnums.CASH_PAY.getValue());
orderInfo.setPaidTime(LocalDateTime.now());
if (orderInfo.getUserId() != null) {
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
if (shopUser == null) {
if ((orderInfo.getPointsNum() != null && orderInfo.getPointsNum() > 0)
|| (StrUtil.isNotBlank(orderInfo.getCouponInfoList()) && !"null".equals(orderInfo.getCouponInfoList()))) {
log.error("订单积分使用或优惠券扣除失败订单id{}", orderInfo.getId());
}
} else {
//积分使用
if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() > 0) {
pointsService.deductPoints(shopUser.getId(), orderInfo.getPointsNum(), "积分抵扣账单", orderInfo);
}
//更新优惠券信息
if (StrUtil.isNotBlank(orderInfo.getCouponInfoList()) && !"null".equals(orderInfo.getCouponInfoList())) {
//券消耗
List<Long> coupons = JSON.parseArray(orderInfo.getCouponInfoList(), Long.class);
if (CollUtil.isNotEmpty(coupons)) {
couponService.use(coupons, shopUser.getId(), orderInfo.getId());
}
}
}
}
}
saveOrUpdate(orderInfo);
}