优惠券使用 位置
This commit is contained in:
parent
4aa5574c6e
commit
8ac6688142
|
|
@ -8,6 +8,7 @@ import cn.hutool.core.thread.ThreadUtil;
|
|||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
import com.czg.account.entity.*;
|
||||
|
|
@ -367,11 +368,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
//生成订单 //discount_info 所有折扣 几折 折扣金额 满减金额 优惠券金额 积分抵扣金额 抹零
|
||||
upOrderPayInfo(orderInfo, param);
|
||||
orderDetailService.updateBatch(orderDetails);
|
||||
//更新优惠券信息
|
||||
if (CollUtil.isNotEmpty(param.getCouponList()) && shopUser != null) {
|
||||
//券消耗
|
||||
couponService.use(param.getCouponList(), shopUser.getId(), orderInfo.getId());
|
||||
}
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
|
|
@ -571,6 +567,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
OrderPayment payment = paymentService.queryChain().eq(OrderPayment::getOrderNo, orderNo).one();
|
||||
if (payment == null) {
|
||||
log.error("订单支付回调失败,支付记录不存在,payment:{}", payment);
|
||||
return;
|
||||
}
|
||||
if (StrUtil.isNotBlank(payment.getTradeNumber())) {
|
||||
log.info("订单处理过,payment id:{}", payment.getId());
|
||||
|
|
@ -591,11 +588,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
}
|
||||
upOrderInfo(orderInfo, new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN),
|
||||
DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()), payment.getId(), null);
|
||||
if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() > 0) {
|
||||
pointsService.deductPoints(orderInfo.getUserId(), orderInfo.getPointsNum(), "积分抵扣账单", orderInfo);
|
||||
}
|
||||
pointsService.consumeAwardPoints(orderInfo.getUserId(), orderInfo);
|
||||
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
|
||||
} else if ("memberIn".equals(payment.getPayType()) || "free".equals(payment.getPayType())) {
|
||||
boolean isFree = "free".equals(payment.getPayType());
|
||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||
|
|
@ -703,11 +695,36 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
updateChain.set(OrderInfo::getPayType, payType.getValue());
|
||||
}
|
||||
updateChain.update();
|
||||
//积分使用
|
||||
if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() > 0) {
|
||||
pointsService.deductPoints(orderInfo.getUserId(), 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)) {
|
||||
if (orderInfo.getUserId() == null) {
|
||||
log.info("订单:{}优惠券使用失败,用户Id为空", orderInfo.getId());
|
||||
} else {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
|
||||
if (shopUser == null) {
|
||||
log.info("订单:{}优惠券使用失败,店铺用户不存在", orderInfo.getId());
|
||||
} else {
|
||||
couponService.use(coupons, shopUser.getId(), orderInfo.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//下单赠送积分
|
||||
pointsService.consumeAwardPoints(orderInfo.getUserId(), orderInfo);
|
||||
|
||||
orderDetailService.updateChain().set(OrderDetail::getStatus, OrderStatusEnums.DONE.getCode()).eq(OrderDetail::getOrderId, orderInfo.getId()).update();
|
||||
// if (!"after-pay".equals(orderInfo.getPayMode())) {
|
||||
//发送打票信息
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString(), true);
|
||||
// }
|
||||
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -151,7 +151,6 @@ public class PayServiceImpl implements PayService {
|
|||
LocalDateTime.now(), null, PayEnums.CREDIT_PAY);
|
||||
//挂账后续逻辑
|
||||
buyerOrderService.save(payParam.getCreditBuyerId().toString(), orderInfo.getId());
|
||||
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -161,11 +160,6 @@ public class PayServiceImpl implements PayService {
|
|||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), null, PayEnums.CASH_PAY);
|
||||
if (orderInfo.getPointsNum() != null && orderInfo.getPointsNum() > 0) {
|
||||
pointsService.deductPoints(orderInfo.getUserId(), orderInfo.getPointsNum(), "积分抵扣账单", orderInfo);
|
||||
}
|
||||
pointsService.consumeAwardPoints(orderInfo.getUserId(), orderInfo);
|
||||
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +213,6 @@ public class PayServiceImpl implements PayService {
|
|||
Long flowId = shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
|
||||
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), flowId, PayEnums.VIP_PAY);
|
||||
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
|
@ -635,7 +628,9 @@ public class PayServiceImpl implements PayService {
|
|||
orderInfo.setRefundRemark(orderInfo.getRefundRemark() + param.getRefundReason());
|
||||
orderInfoService.updateById(orderInfo);
|
||||
//退款返还库存
|
||||
rabbitPublisher.sendOrderRefundMsg(JSONObject.toJSONString(Map.of("orderId", orderInfo.getId(), "returnProMap", returnProMap)));
|
||||
if (!returnProMap.isEmpty()) {
|
||||
rabbitPublisher.sendOrderRefundMsg(JSONObject.toJSONString(Map.of("orderId", orderInfo.getId(), "returnProMap", returnProMap)));
|
||||
}
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue