|
@@ -54,8 +54,6 @@ import com.google.common.collect.Maps;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.transaction.support.TransactionSynchronization;
|
|
|
-import org.springframework.transaction.support.TransactionSynchronizationManager;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -244,8 +242,8 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus);
|
|
|
|
|
|
// TODO 发送售后消息
|
|
|
- if(afterSale.getWay().equals(AfterSaleWayEnum.RETURN_AND_REFUND.getWay())){
|
|
|
- sentWcChatMessage(afterSale,AfterSaleStatusEnum.SELLER_AGREE.getContent());
|
|
|
+ if (afterSale.getWay().equals(AfterSaleWayEnum.RETURN_AND_REFUND.getWay())) {
|
|
|
+ sentWcChatMessage(afterSale, AfterSaleStatusEnum.SELLER_AGREE.getContent());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -266,7 +264,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus);
|
|
|
|
|
|
// 发送给微信用户售后消息
|
|
|
- sentWcChatMessage(afterSale,AfterSaleStatusEnum.SELLER_DISAGREE.getContent());
|
|
|
+ sentWcChatMessage(afterSale, AfterSaleStatusEnum.SELLER_DISAGREE.getContent());
|
|
|
|
|
|
// 更新交易订单项的售后状态为【未申请】
|
|
|
tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId());
|
|
@@ -367,7 +365,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
MapUtil.of("reason", refuseReqVO.getRefuseMemo()));
|
|
|
|
|
|
// TODO 发送售后消息
|
|
|
- sentWcChatMessage(afterSale,AfterSaleStatusEnum.SELLER_REFUSE.getContent());
|
|
|
+ sentWcChatMessage(afterSale, AfterSaleStatusEnum.SELLER_REFUSE.getContent());
|
|
|
|
|
|
// 更新交易订单项的售后状态为【未申请】
|
|
|
tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId());
|
|
@@ -421,67 +419,67 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
PtDailyBillDO ptDailyBill = ptDailyBillService.getPtDailyBill(tradeOrderDO.getCreateTime().toLocalDate());
|
|
|
|
|
|
//记录退还积分
|
|
|
- if(payIntegral>0) {
|
|
|
+ if (payIntegral > 0) {
|
|
|
TradeOrderItemDO toid = new TradeOrderItemDO();
|
|
|
toid.setId(tradeOrderItemDO.getId());
|
|
|
toid.setRefundIntegral(payIntegral);
|
|
|
tradeOrderItemMapper.updateById(toid);
|
|
|
|
|
|
- if(tradeOrderDO.getRefundIntegral() != null){
|
|
|
- tradeOrderDO.setRefundIntegral(tradeOrderDO.getRefundIntegral()+payIntegral);
|
|
|
- }else{
|
|
|
+ if (tradeOrderDO.getRefundIntegral() != null) {
|
|
|
+ tradeOrderDO.setRefundIntegral(tradeOrderDO.getRefundIntegral() + payIntegral);
|
|
|
+ } else {
|
|
|
tradeOrderDO.setRefundIntegral(payIntegral);
|
|
|
}
|
|
|
tradeOrderMapper.updateById(tradeOrderDO);
|
|
|
|
|
|
//退回退款订单项,购物者支付的积分
|
|
|
- integralService.updateUserIntegral(orderUserId,orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL, payIntegral, 0L, tradeOrderId, tradeOrderNum);
|
|
|
+ integralService.updateUserIntegral(orderUserId, orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL, payIntegral, 0L, tradeOrderId, tradeOrderNum);
|
|
|
|
|
|
- if(dailyBill != null){
|
|
|
+ if (dailyBill != null) {
|
|
|
//有就追加退回积分
|
|
|
- dailyBill.setRefundIntegral(dailyBill.getRefundIntegral()+payIntegral);
|
|
|
- dailyBill.setReceivedIntegral(dailyBill.getReceivedIntegral()-payIntegral);
|
|
|
+ dailyBill.setRefundIntegral(dailyBill.getRefundIntegral() + payIntegral);
|
|
|
+ dailyBill.setReceivedIntegral(dailyBill.getReceivedIntegral() - payIntegral);
|
|
|
|
|
|
- ptDailyBill.setRefundIntegral(ptDailyBill.getRefundIntegral()+payIntegral);
|
|
|
- ptDailyBill.setReceivedIntegral(ptDailyBill.getReceivedIntegral()-payIntegral);
|
|
|
+ ptDailyBill.setRefundIntegral(ptDailyBill.getRefundIntegral() + payIntegral);
|
|
|
+ ptDailyBill.setReceivedIntegral(ptDailyBill.getReceivedIntegral() - payIntegral);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//记录退还消费分
|
|
|
- if(payConsumptionPoints>0) {
|
|
|
+ if (payConsumptionPoints > 0) {
|
|
|
TradeOrderItemDO toid = new TradeOrderItemDO();
|
|
|
toid.setId(tradeOrderItemDO.getId());
|
|
|
toid.setRefundConsumption(payConsumptionPoints);
|
|
|
tradeOrderItemMapper.updateById(toid);
|
|
|
|
|
|
- if(tradeOrderDO.getRefundConsumption() != null){
|
|
|
- tradeOrderDO.setRefundConsumption(tradeOrderDO.getRefundConsumption()+payConsumptionPoints);
|
|
|
- }else{
|
|
|
+ if (tradeOrderDO.getRefundConsumption() != null) {
|
|
|
+ tradeOrderDO.setRefundConsumption(tradeOrderDO.getRefundConsumption() + payConsumptionPoints);
|
|
|
+ } else {
|
|
|
tradeOrderDO.setRefundConsumption(payConsumptionPoints);
|
|
|
}
|
|
|
tradeOrderMapper.updateById(tradeOrderDO);
|
|
|
|
|
|
//退回退款订单项,购物者支付的消费分
|
|
|
- integralService.updateUserConsumptionPoints(orderUserId,orderUserId, payConsumptionPoints, tradeOrderId, tradeOrderNum);
|
|
|
+ integralService.updateUserConsumptionPoints(orderUserId, orderUserId, payConsumptionPoints, tradeOrderId, tradeOrderNum);
|
|
|
|
|
|
- if(dailyBill != null){
|
|
|
+ if (dailyBill != null) {
|
|
|
//有就追加退回消费分
|
|
|
- dailyBill.setRefundConsumptionPoints(dailyBill.getRefundConsumptionPoints()+payConsumptionPoints);
|
|
|
- dailyBill.setReceivedConsumptionPoints(dailyBill.getReceivedConsumptionPoints()-payConsumptionPoints);
|
|
|
+ dailyBill.setRefundConsumptionPoints(dailyBill.getRefundConsumptionPoints() + payConsumptionPoints);
|
|
|
+ dailyBill.setReceivedConsumptionPoints(dailyBill.getReceivedConsumptionPoints() - payConsumptionPoints);
|
|
|
|
|
|
- ptDailyBill.setRefundConsumptionPoints(ptDailyBill.getRefundConsumptionPoints()+payConsumptionPoints);
|
|
|
- ptDailyBill.setReceivedConsumptionPoints(ptDailyBill.getReceivedConsumptionPoints()-payConsumptionPoints);
|
|
|
+ ptDailyBill.setRefundConsumptionPoints(ptDailyBill.getRefundConsumptionPoints() + payConsumptionPoints);
|
|
|
+ ptDailyBill.setReceivedConsumptionPoints(ptDailyBill.getReceivedConsumptionPoints() - payConsumptionPoints);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(dailyBill != null){
|
|
|
+ if (dailyBill != null) {
|
|
|
//有就追加退款金额
|
|
|
- dailyBill.setRefundPrice(dailyBill.getRefundPrice()+afterSale.getRefundPrice());
|
|
|
- dailyBill.setReceivedPrice(dailyBill.getReceivedPrice()-afterSale.getRefundPrice());
|
|
|
- dailyBillService.updateDailyBill(BeanUtils.toBean(dailyBill,DailyBillSaveReqVO.class));
|
|
|
+ dailyBill.setRefundPrice(dailyBill.getRefundPrice() + afterSale.getRefundPrice());
|
|
|
+ dailyBill.setReceivedPrice(dailyBill.getReceivedPrice() - afterSale.getRefundPrice());
|
|
|
+ dailyBillService.updateDailyBill(BeanUtils.toBean(dailyBill, DailyBillSaveReqVO.class));
|
|
|
|
|
|
- ptDailyBill.setRefundPrice(ptDailyBill.getRefundPrice()+afterSale.getRefundPrice());
|
|
|
- ptDailyBill.setReceivedPrice(ptDailyBill.getReceivedPrice()-afterSale.getRefundPrice());
|
|
|
+ ptDailyBill.setRefundPrice(ptDailyBill.getRefundPrice() + afterSale.getRefundPrice());
|
|
|
+ ptDailyBill.setReceivedPrice(ptDailyBill.getReceivedPrice() - afterSale.getRefundPrice());
|
|
|
ptDailyBillService.updatePtDailyBill(BeanUtils.toBean(ptDailyBill, PtDailyBillSaveReqVO.class));
|
|
|
}
|
|
|
|
|
@@ -492,15 +490,15 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
|
|
|
|
|
|
//订单退款,收回消费者获得的冻结积分
|
|
|
- integralService.updateUserIntegral(orderUserId,orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL_CONSUMER, increaseIntegral*(-1),0L,tradeOrderId,tradeOrderNum);
|
|
|
+ integralService.updateUserIntegral(orderUserId, orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL_CONSUMER, increaseIntegral * (-1), 0L, tradeOrderId, tradeOrderNum);
|
|
|
|
|
|
//20240604 推荐人(上级用户ID)
|
|
|
Long ancesterUserId = tradeOrderMapper.selectAncesterByMemberUserId(orderUserId);
|
|
|
//订单退款,收回消费者推荐人获得的冻结积分
|
|
|
- integralService.updateUserIntegral(orderUserId,ancesterUserId, CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER, ancestorIncreaseIntegral*(-1),0L,tradeOrderId,tradeOrderNum);
|
|
|
+ integralService.updateUserIntegral(orderUserId, ancesterUserId, CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER, ancestorIncreaseIntegral * (-1), 0L, tradeOrderId, tradeOrderNum);
|
|
|
|
|
|
//订单退款,收回消费者获得的冻结峰值
|
|
|
- integralService.updateIntegralFreezeHighQuota(orderUserId,orderUserId, CaclEnum.ORDER_REFUND_ORDER_PAY_FREEZE_HIGH_QUOTA, freezeHighQuota,tradeOrderId,tradeOrderNum);
|
|
|
+ integralService.updateIntegralFreezeHighQuota(orderUserId, orderUserId, CaclEnum.ORDER_REFUND_ORDER_PAY_FREEZE_HIGH_QUOTA, freezeHighQuota, tradeOrderId, tradeOrderNum);
|
|
|
|
|
|
// 发起退款单。注意,需要在事务提交后,再进行发起,避免重复发起
|
|
|
createPayRefund(userIp, afterSale);
|
|
@@ -514,7 +512,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
AfterSaleStatusEnum.COMPLETE.getStatus());
|
|
|
|
|
|
// 发送给微信用户售后消息
|
|
|
- sentWcChatMessage(afterSale , AfterSaleStatusEnum.COMPLETE.getContent());
|
|
|
+ sentWcChatMessage(afterSale, AfterSaleStatusEnum.COMPLETE.getContent());
|
|
|
|
|
|
// 更新交易订单项的售后状态为【已完成】
|
|
|
tradeOrderUpdateService.updateOrderItemWhenAfterSaleSuccess(afterSale.getOrderItemId(), afterSale.getRefundPrice());
|
|
@@ -522,10 +520,11 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
|
|
|
/**
|
|
|
* 发送微信消息
|
|
|
- * @param afterSale 售后订单
|
|
|
+ *
|
|
|
+ * @param afterSale 售后订单
|
|
|
* @param afterStatus 是否同意退款
|
|
|
*/
|
|
|
- private void sentWcChatMessage(AfterSaleDO afterSale,String afterStatus) {
|
|
|
+ private void sentWcChatMessage(AfterSaleDO afterSale, String afterStatus) {
|
|
|
List<String> params = new ArrayList<>();
|
|
|
params.add(afterSale.getNo());
|
|
|
params.add(afterSale.getSpuName());
|
|
@@ -542,18 +541,18 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
}
|
|
|
|
|
|
private void createPayRefund(String userIp, AfterSaleDO afterSale) {
|
|
|
- TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void afterCommit() {
|
|
|
- // 创建退款单
|
|
|
- PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties)
|
|
|
- .setReason(StrUtil.format("退款【{}】", afterSale.getSpuName()));
|
|
|
- Long payRefundId = payRefundApi.createRefund(createReqDTO);
|
|
|
- // 更新售后单的退款单号
|
|
|
- tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId));
|
|
|
- }
|
|
|
- });
|
|
|
+// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public void afterCommit() {
|
|
|
+ // 创建退款单
|
|
|
+ PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties)
|
|
|
+ .setReason(StrUtil.format("退款【{}】", afterSale.getSpuName()));
|
|
|
+ Long payRefundId = payRefundApi.createRefund(createReqDTO);
|
|
|
+ // 更新售后单的退款单号
|
|
|
+ tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId));
|
|
|
+// }
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -590,7 +589,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
UserShopDetailsVO userShopDetails = userService.getUserShopDetails();
|
|
|
reqVO.setShopId(userShopDetails.getShopId());
|
|
|
reqVO.setMerchantId(userShopDetails.getMerId());
|
|
|
- return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES,reqVO);
|
|
|
+ return tradeAfterSaleMapper.selectCountByUserIdAndStatus(userId, AfterSaleStatusEnum.APPLYING_STATUSES, reqVO);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -605,7 +604,7 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
return tradeAfterSaleMapper.selectList(new LambdaQueryWrapperX<AfterSaleDO>()
|
|
|
.eq(AfterSaleDO::getSpuId, spuId)
|
|
|
.eqIfPresent(AfterSaleDO::getShopId, userShopDetails.getShopId())
|
|
|
- .eqIfPresent(AfterSaleDO::getMerchantId,userShopDetails.getMerId())
|
|
|
+ .eqIfPresent(AfterSaleDO::getMerchantId, userShopDetails.getMerId())
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -626,27 +625,27 @@ public class AfterSaleServiceImpl implements AfterSaleService {
|
|
|
|
|
|
Map<Integer, Long> counts = Maps.newLinkedHashMapWithExpectedSize(8);
|
|
|
// 查询申请售后的售后订单
|
|
|
- counts.put(AfterSaleStatusEnum.APPLY.getStatus(),tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.APPLY.getStatus(),pageVO));
|
|
|
+ counts.put(AfterSaleStatusEnum.APPLY.getStatus(), tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.APPLY.getStatus(), pageVO));
|
|
|
// 查询商品待退货的售后订单
|
|
|
- counts.put(AfterSaleStatusEnum.SELLER_AGREE.getStatus(),tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.SELLER_AGREE.getStatus(),pageVO));
|
|
|
+ counts.put(AfterSaleStatusEnum.SELLER_AGREE.getStatus(), tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.SELLER_AGREE.getStatus(), pageVO));
|
|
|
// 查询商家待收货的售后订单
|
|
|
- counts.put(AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(),tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(),pageVO));
|
|
|
+ counts.put(AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(), pageVO));
|
|
|
// 查询等待退款的售后订单
|
|
|
- counts.put(AfterSaleStatusEnum.WAIT_REFUND.getStatus(),tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.WAIT_REFUND.getStatus(),pageVO));
|
|
|
+ counts.put(AfterSaleStatusEnum.WAIT_REFUND.getStatus(), tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.WAIT_REFUND.getStatus(), pageVO));
|
|
|
// 查询退款成功的售后订单
|
|
|
- counts.put(AfterSaleStatusEnum.COMPLETE.getStatus(),tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.COMPLETE.getStatus(),pageVO));
|
|
|
+ counts.put(AfterSaleStatusEnum.COMPLETE.getStatus(), tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.COMPLETE.getStatus(), pageVO));
|
|
|
// 查询买家取消的售后订单
|
|
|
- counts.put(AfterSaleStatusEnum.BUYER_CANCEL.getStatus(),tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.BUYER_CANCEL.getStatus(),pageVO));
|
|
|
+ counts.put(AfterSaleStatusEnum.BUYER_CANCEL.getStatus(), tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.BUYER_CANCEL.getStatus(), pageVO));
|
|
|
// 查询商家拒绝的售后订单
|
|
|
- counts.put(AfterSaleStatusEnum.SELLER_DISAGREE.getStatus(),tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.SELLER_DISAGREE.getStatus(),pageVO));
|
|
|
+ counts.put(AfterSaleStatusEnum.SELLER_DISAGREE.getStatus(), tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.SELLER_DISAGREE.getStatus(), pageVO));
|
|
|
// 查询商家拒收货的售后订单
|
|
|
- counts.put(AfterSaleStatusEnum.SELLER_REFUSE.getStatus(),tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.SELLER_REFUSE.getStatus(),pageVO));
|
|
|
+ counts.put(AfterSaleStatusEnum.SELLER_REFUSE.getStatus(), tradeAfterSaleMapper.selectCount(AfterSaleStatusEnum.SELLER_REFUSE.getStatus(), pageVO));
|
|
|
return counts;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Long selectCountByStatus(Long shopId, Long merId) {
|
|
|
- return tradeAfterSaleMapper.selectCount(shopId,merId,AfterSaleStatusEnum.APPLY.getStatus(),
|
|
|
+ return tradeAfterSaleMapper.selectCount(shopId, merId, AfterSaleStatusEnum.APPLY.getStatus(),
|
|
|
AfterSaleStatusEnum.BUYER_DELIVERY.getStatus(),
|
|
|
AfterSaleStatusEnum.WAIT_REFUND.getStatus());
|
|
|
}
|