订单支付 userId问题

This commit is contained in:
wangw 2025-03-17 17:01:09 +08:00
parent 7a5882ed38
commit fb9745e70e
1 changed files with 21 additions and 21 deletions

View File

@ -694,7 +694,14 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
updateChain.set(OrderInfo::getPayType, payType.getValue());
}
updateChain.update();
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);
@ -704,22 +711,15 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
//券消耗
List<Long> coupons = JSON.parseArray(orderInfo.getCouponInfoList(), Long.class);
if (CollUtil.isNotEmpty(coupons)) {
if (orderInfo.getUserId() == null) {
log.info("订单:{}优惠券使用失败用户Id为空", orderInfo.getId());
} else {
if (shopUser == null) {
log.info("订单:{}优惠券使用失败,店铺用户不存在", orderInfo.getId());
} else {
couponService.use(coupons, shopUser.getId(), orderInfo.getId());
}
}
}
}
if (!payType.equals(PayEnums.VIP_PAY)) {
//下单赠送积分
pointsService.consumeAwardPoints(shopUser.getId(), orderInfo);
}
}
}
orderDetailService.updateChain().set(OrderDetail::getStatus, OrderStatusEnums.DONE.getCode()).eq(OrderDetail::getOrderId, orderInfo.getId()).update();
// if (!"after-pay".equals(orderInfo.getPayMode())) {
//发送打票信息