Merge remote-tracking branch 'origin/master'

# Conflicts:
#	cash-service/order-service/src/main/java/com/czg/service/order/service/impl/OrderInfoServiceImpl.java
This commit is contained in:
Tankaikai 2025-03-17 16:46:21 +08:00
commit 7a5882ed38
2 changed files with 30 additions and 4 deletions

View File

@ -715,8 +715,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
}
}
}
//下单赠送积分
pointsService.consumeAwardPoints(shopUser.getId(), orderInfo);
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())) {

View File

@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.exceptions.ValidateException;
import cn.hutool.core.util.IdUtil;
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.*;
@ -104,8 +105,31 @@ public class PayServiceImpl implements PayService {
private OrderInfo checkPay(CheckOrderPay checkOrderPay) {
OrderInfo orderInfo = orderInfoService.checkOrderPay(checkOrderPay);
if (orderInfo.getOrderAmount().compareTo(BigDecimal.ZERO) == 0) {
//积分使用
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());
}
}
}
}
orderDetailService.updateChain().set(OrderDetail::getStatus, OrderStatusEnums.DONE.getCode()).eq(OrderDetail::getOrderId, orderInfo.getId()).update();
//发送打票信息
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString(), true);
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
throw new PaySuccessException();
}
return orderInfo;
@ -166,8 +190,6 @@ public class PayServiceImpl implements PayService {
@Override
@Transactional(noRollbackFor = PaySuccessException.class)
public CzgResult<Object> vipPayOrder(OrderPayParamDTO payParam) {
AssertUtil.isNull(payParam.getCheckOrderPay().getUserId(), "会员支付,订单用户不能为空");
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
ShopUser shopUser = new ShopUser();
if ("scanCode".equals(payParam.getPayType())) {
AssertUtil.isBlank(payParam.getAuthCode(), "会员码不能为空");
@ -197,6 +219,8 @@ public class PayServiceImpl implements PayService {
if (shopUser == null || shopUser.getId() == null) {
AssertUtil.isNull(shopUser, "会员不存在");
}
payParam.getCheckOrderPay().setUserId(shopUser.getUserId());
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
if (!shopUser.getShopId().equals(orderInfo.getShopId())) {
return CzgResult.failure("违规操作,请确认店铺后重试");
}