订单 退款 问题
This commit is contained in:
@@ -1060,8 +1060,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
distributionUserService.costUpgradeLevelBefore(orderInfo.getUserId(), orderInfo.getShopId());
|
||||
// 分销奖励
|
||||
distributionUserService.distribute(orderInfo.getId(), orderInfo.getOrderNo(), payment.getAmount(), orderInfo.getUserId(), orderInfo.getShopId(), "order");
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.MEMBER_IN.equals(payment.getSourceType()) || PayTypeConstants.SourceType.FREE.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.MEMBER_IN.equals(payment.getSourceType()) || PayTypeConstants.SourceType.FREE.equals(payment.getSourceType())) {
|
||||
boolean isFree = PayTypeConstants.SourceType.FREE.equals(payment.getSourceType());
|
||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||
OrderInfo orderInfo = null;
|
||||
@@ -1162,8 +1161,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
// if (orderInfo != null) {
|
||||
// distributionUserService.distribute(payment.getId(), payment.getOrderNo(), payment.getAmount(), orderInfo.getUserId(), payment.getShopId(), "recharge");
|
||||
// }
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.MEMBER_PAY.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.MEMBER_PAY.equals(payment.getSourceType())) {
|
||||
//购买会员
|
||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||
memberConfigService.joinMember(payment.getShopId(), shopUser.getUserId(), payment.getRelatedId());
|
||||
@@ -1171,17 +1169,13 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
// memberConfigService.deliver(shopUser.getMainShopId(), shopUser.getUserId(), TableValueConstant.MemberExpFlow.Type.COST, payment.getAmount(), null, payment.getId());
|
||||
|
||||
// 分销员开通
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.DISTRIBUTION.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.DISTRIBUTION.equals(payment.getSourceType())) {
|
||||
distributionUserService.open(payment.getSourceId(), payment.getAmount(), payment.getShopId(), payment.getId());
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.POINT.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.POINT.equals(payment.getSourceType())) {
|
||||
goodPayService.payCallBack(payment.getSourceId(), payment.getId());
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.WARE.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.WARE.equals(payment.getSourceType())) {
|
||||
gbOrderService.payCallBack(payment.getSourceId(), payment.getId());
|
||||
}
|
||||
else if (PayTypeConstants.SourceType.PP.equals(payment.getSourceType())) {
|
||||
} else if (PayTypeConstants.SourceType.PP.equals(payment.getSourceType())) {
|
||||
ppPackageOrderService.paySuccess(payment.getSourceId(), payment.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.czg.market.dto.MemberOrderDTO;
|
||||
import com.czg.market.entity.MemberOrder;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.entity.MkShopRechargeDetail;
|
||||
import com.czg.market.enums.PointsConstant;
|
||||
import com.czg.market.service.*;
|
||||
import com.czg.market.vo.MkShopRechargeVO;
|
||||
import com.czg.order.dto.CheckOrderPay;
|
||||
@@ -51,12 +52,14 @@ import com.czg.service.order.service.PayService;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.CzgRandomUtils;
|
||||
import com.czg.utils.FunUtils;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -116,9 +119,13 @@ public class PayServiceImpl implements PayService {
|
||||
@Resource
|
||||
private MkShopRechargeDetailService shopRechargeDetailService;
|
||||
@Resource
|
||||
private TbMemberConfigService memberConfigService;
|
||||
@Resource
|
||||
private MkDistributionUserService distributionUserService;
|
||||
@Resource
|
||||
private MkShopConsumerCouponService consumerCouponService;
|
||||
@Resource
|
||||
private MkPointsUserService mkPointsUserService;
|
||||
@Resource
|
||||
private MkConsumeCashbackService consumeCashbackService;
|
||||
|
||||
private final BigDecimal MONEY_RATE = new BigDecimal("100");
|
||||
|
||||
@@ -152,7 +159,6 @@ public class PayServiceImpl implements PayService {
|
||||
throw new CzgException("该店铺未启用霸王餐");
|
||||
}
|
||||
CheckOrderPay checkOrderPay = payParam.getCheckOrderPay();
|
||||
// CheckOrderPay checkOrderPay = BeanUtil.copyProperties(payParam, CheckOrderPay.class);
|
||||
OrderInfo orderInfo = orderInfoCustomService.checkOrderPay(checkOrderPay.setFreeDine(true).setWithCoupon(freeConfig.getWithCoupon()).setWithPoints(freeConfig.getWithPoints()));
|
||||
payParam.setAmount(orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(freeConfig.getRechargeTimes())));
|
||||
return true;
|
||||
@@ -245,14 +251,9 @@ public class PayServiceImpl implements PayService {
|
||||
orderInfo.setRemark(payParam.getCheckOrderPay().getRemark());
|
||||
}
|
||||
|
||||
// log.info("发放经验值");
|
||||
// memberConfigService.deliver(shopUser, TableValueConstant.MemberExpFlow.Type.COST, orderInfo.getOrderAmount(), null, orderInfo.getId());
|
||||
|
||||
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), flowId, PayEnums.VIP_PAY);
|
||||
|
||||
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@@ -261,9 +262,6 @@ public class PayServiceImpl implements PayService {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
ShopInfo shopInfo = shopInfoService.getById(payParam.getShopId());
|
||||
AssertUtil.isNull(shopInfo, "店铺不存在");
|
||||
// if (!shopInfo.getIsAccountPay().equals(1)) {
|
||||
// return CzgResult.failure("支付失败,店铺暂未开启会员余额支付。");
|
||||
// }
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "请选择付款人后重试");
|
||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
AssertUtil.isNull(shopUser, "支付失败 该店铺用户不存在");
|
||||
@@ -812,16 +810,36 @@ public class PayServiceImpl implements PayService {
|
||||
}
|
||||
orderInfo.setRefundRemark(orderInfo.getRefundRemark() + param.getRefundReason());
|
||||
orderInfoService.updateById(orderInfo);
|
||||
//退款后续
|
||||
//退款返还库存
|
||||
if (!returnProMap.isEmpty()) {
|
||||
rabbitPublisher.sendOrderRefundMsg(JSONObject.toJSONString(Map.of("orderId", orderInfo.getId(), "returnProMap", returnProMap)));
|
||||
}
|
||||
|
||||
// 退款分销还原
|
||||
distributionUserService.refund(orderInfo.getId(), orderInfo.getOrderNo());
|
||||
refundOrderAfter(orderInfo.getId(), orderInfo.getShopId(), orderInfo.getUserId(), orderInfo.getOrderNo(), orderInfo.getPointsNum());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
//触发订单退款时 后续处理
|
||||
@Async
|
||||
public void refundOrderAfter(@NonNull Long orderId, @NonNull Long shopId, Long userId, String orderNo, Integer pointsNum) {
|
||||
// 退款分销还原
|
||||
FunUtils.safeRunVoid(() -> distributionUserService.refund(orderId, orderNo),
|
||||
"订单id:{} 退款,分销处理失败", orderId);
|
||||
if (userId != null) {
|
||||
FunUtils.safeRunVoid(() -> consumerCouponService.removeConsumerCoupon(shopId, userId, orderId),
|
||||
"订单id:{} 退款,消费赠券回撤处理失败", orderId);
|
||||
FunUtils.safeRunVoid(() -> consumeCashbackService.removeCashback(shopId, userId, orderId, orderNo),
|
||||
"订单id:{} 退款,消费返现处理失败", orderId);
|
||||
FunUtils.safeRunVoid(() -> {
|
||||
if (pointsNum != null && pointsNum > 0) {
|
||||
mkPointsUserService.alterPoints(userId, null, shopId, PointsConstant.ADD,
|
||||
pointsNum, orderId, StrUtil.format("订单退款返还{}积分", pointsNum));
|
||||
}
|
||||
},
|
||||
"订单id:{} 退款,积分返还处理失败", orderId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void refundOrder(@NonNull Long shopId, @NonNull Long orderId, @NonNull Long payOrderId, @NonNull String refPayOrderNo,
|
||||
|
||||
Reference in New Issue
Block a user