积分 赠送与扣除

This commit is contained in:
wangw 2025-03-05 17:01:03 +08:00
parent bdecc4542e
commit e7163f5476
2 changed files with 15 additions and 3 deletions

View File

@ -15,6 +15,7 @@ import com.czg.config.RedisCst;
import com.czg.entity.notify.CzgPayNotifyDTO; import com.czg.entity.notify.CzgPayNotifyDTO;
import com.czg.entity.notify.CzgRefundNotifyDTO; import com.czg.entity.notify.CzgRefundNotifyDTO;
import com.czg.enums.ShopUserFlowBizEnum; import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.order.dto.BigDecimalDTO;
import com.czg.order.dto.CheckOrderPay; import com.czg.order.dto.CheckOrderPay;
import com.czg.order.dto.OrderInfoAddDTO; import com.czg.order.dto.OrderInfoAddDTO;
import com.czg.order.dto.OrderInfoQueryDTO; import com.czg.order.dto.OrderInfoQueryDTO;
@ -31,9 +32,7 @@ import com.czg.order.vo.HistoryOrderVo;
import com.czg.order.vo.OrderDetailSmallVO; import com.czg.order.vo.OrderDetailSmallVO;
import com.czg.order.vo.OrderInfoVo; import com.czg.order.vo.OrderInfoVo;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.czg.order.dto.BigDecimalDTO;
import com.czg.service.order.enums.OrderStatusEnums; import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.service.order.mapper.OrderInfoMapper; import com.czg.service.order.mapper.OrderInfoMapper;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
@ -76,6 +75,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
private RedisService redisService; private RedisService redisService;
@Resource @Resource
private RabbitPublisher rabbitPublisher; private RabbitPublisher rabbitPublisher;
@Resource
private MemberPointsService pointsService;
@DubboReference @DubboReference
private ShopInfoService shopInfoService; private ShopInfoService shopInfoService;
@DubboReference @DubboReference
@ -235,7 +236,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
if (!orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) { if (!orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
throw new ValidateException("生成支付订单失败,订单不可支付"); throw new ValidateException("生成支付订单失败,订单不可支付");
} }
Long shopId = StpKit.USER.getShopId(); Long shopId = orderInfo.getShopId();
AssertUtil.isNull(shopId, "生成支付订单失败,订单信息异常");
PointsBasicSetting pointSetting = pointsBasicService.getById(shopId); PointsBasicSetting pointSetting = pointsBasicService.getById(shopId);
if (param.getPointsNum() > 0 && !pointSetting.getEnableDeduction().equals(1)) { if (param.getPointsNum() > 0 && !pointSetting.getEnableDeduction().equals(1)) {
throw new ValidateException("生成支付订单失败,该店铺未开启积分抵扣"); throw new ValidateException("生成支付订单失败,该店铺未开启积分抵扣");
@ -477,6 +479,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
} }
upOrderInfo(orderInfo, new BigDecimal(czgCallBackDto.getAmount() / 100L), upOrderInfo(orderInfo, new BigDecimal(czgCallBackDto.getAmount() / 100L),
DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()), payment.getId(), null); DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()), payment.getId(), null);
if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() > 0) {
pointsService.deductPoints(orderInfo.getUserId(), orderInfo.getPointsNum(), "积分抵扣账单", orderInfo.getId());
}
pointsService.consumeAwardPoints(orderInfo.getUserId(), orderInfo.getId());
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId()); redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
} else if ("memberIn".equals(payment.getPayType()) || "free".equals(payment.getPayType())) { } else if ("memberIn".equals(payment.getPayType()) || "free".equals(payment.getPayType())) {
boolean isFree = "free".equals(payment.getPayType()); boolean isFree = "free".equals(payment.getPayType());

View File

@ -79,6 +79,8 @@ public class PayServiceImpl implements PayService {
@Resource @Resource
private CzgPayService czgPayService; private CzgPayService czgPayService;
@Resource @Resource
private MemberPointsService pointsService;
@Resource
private OrderInfoService orderInfoService; private OrderInfoService orderInfoService;
@Resource @Resource
private OrderDetailService orderDetailService; private OrderDetailService orderDetailService;
@ -151,6 +153,10 @@ public class PayServiceImpl implements PayService {
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay()); OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(), orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
LocalDateTime.now(), null, PayEnums.CASH_PAY); LocalDateTime.now(), null, PayEnums.CASH_PAY);
if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() > 0) {
pointsService.deductPoints(orderInfo.getUserId(), orderInfo.getPointsNum(), "积分抵扣账单", orderInfo.getId());
}
pointsService.consumeAwardPoints(orderInfo.getUserId(), orderInfo.getId());
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId()); redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
return CzgResult.success(); return CzgResult.success();
} }