|  | @@ -34,12 +34,14 @@ import cn.newfeifan.mall.module.trade.enums.aftersale.AfterSaleTypeEnum;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.trade.enums.aftersale.AfterSaleWayEnum;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.trade.enums.order.TradeOrderStatusEnum;
 | 
	
		
			
				|  |  | +import cn.newfeifan.mall.module.trade.enums.wxmessage.WcChatMessageTemplateIdEnum;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.trade.framework.aftersale.core.annotations.AfterSaleLog;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.trade.framework.aftersale.core.utils.AfterSaleLogUtils;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.trade.framework.order.config.TradeOrderProperties;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.trade.service.delivery.DeliveryExpressService;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.trade.service.order.TradeOrderQueryService;
 | 
	
		
			
				|  |  |  import cn.newfeifan.mall.module.trade.service.order.TradeOrderUpdateService;
 | 
	
		
			
				|  |  | +import cn.newfeifan.mall.module.trade.utils.wechat.WcChatMessageUtils;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
	
		
			
				|  |  |  import com.google.common.collect.Maps;
 | 
	
		
			
				|  |  |  import lombok.extern.slf4j.Slf4j;
 | 
	
	
		
			
				|  | @@ -50,7 +52,10 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
 | 
	
		
			
				|  |  |  import org.springframework.validation.annotation.Validated;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.annotation.Resource;
 | 
	
		
			
				|  |  | +import java.text.DecimalFormat;
 | 
	
		
			
				|  |  |  import java.time.LocalDateTime;
 | 
	
		
			
				|  |  | +import java.time.format.DateTimeFormatter;
 | 
	
		
			
				|  |  | +import java.util.ArrayList;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -95,6 +100,9 @@ public class AfterSaleServiceImpl implements AfterSaleService {
 | 
	
		
			
				|  |  |      @Resource
 | 
	
		
			
				|  |  |      private IntegralService integralService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Resource
 | 
	
		
			
				|  |  | +    private WcChatMessageUtils wcChatMessageUtils;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public PageResult<AfterSaleDO> getAfterSalePage(AfterSalePageReqVO pageReqVO) {
 | 
	
	
		
			
				|  | @@ -241,7 +249,8 @@ public class AfterSaleServiceImpl implements AfterSaleService {
 | 
	
		
			
				|  |  |          // 记录售后日志
 | 
	
		
			
				|  |  |          AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(), newStatus);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        // TODO 发送售后消息
 | 
	
		
			
				|  |  | +        // 发送给微信用户售后消息
 | 
	
		
			
				|  |  | +        sentWcChatMessage(afterSale,false);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 更新交易订单项的售后状态为【未申请】
 | 
	
		
			
				|  |  |          tradeOrderUpdateService.updateOrderItemWhenAfterSaleCancel(afterSale.getOrderItemId());
 | 
	
	
		
			
				|  | @@ -413,12 +422,34 @@ public class AfterSaleServiceImpl implements AfterSaleService {
 | 
	
		
			
				|  |  |          AfterSaleLogUtils.setAfterSaleInfo(afterSale.getId(), afterSale.getStatus(),
 | 
	
		
			
				|  |  |                  AfterSaleStatusEnum.COMPLETE.getStatus());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        // TODO 发送售后消息
 | 
	
		
			
				|  |  | +        // 发送给微信用户售后消息
 | 
	
		
			
				|  |  | +        sentWcChatMessage(afterSale,true);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 更新交易订单项的售后状态为【已完成】
 | 
	
		
			
				|  |  |          tradeOrderUpdateService.updateOrderItemWhenAfterSaleSuccess(afterSale.getOrderItemId(), afterSale.getRefundPrice());
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 发送微信消息
 | 
	
		
			
				|  |  | +     * @param afterSale 售后订单
 | 
	
		
			
				|  |  | +     * @param afterStatus 是否同意退款
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void sentWcChatMessage(AfterSaleDO afterSale,Boolean afterStatus) {
 | 
	
		
			
				|  |  | +        List<String> params = new ArrayList<>();
 | 
	
		
			
				|  |  | +        params.add(afterSale.getNo());
 | 
	
		
			
				|  |  | +        params.add(afterSale.getSpuName());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        DecimalFormat df = new DecimalFormat("0.00");
 | 
	
		
			
				|  |  | +        String formattedPrice = df.format((double) afterSale.getRefundPrice() / 100);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        params.add("¥ " + formattedPrice);
 | 
	
		
			
				|  |  | +        params.add(afterStatus ? "商家确认退款" : "商家拒绝退款");
 | 
	
		
			
				|  |  | +        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  | +        params.add(LocalDateTime.now().format(formatter));
 | 
	
		
			
				|  |  | +        wcChatMessageUtils.sendWcChatMessage(afterSale.getUserId(), WcChatMessageTemplateIdEnum.AFTER_SALE_CHECK.getTemplateId(),
 | 
	
		
			
				|  |  | +                params, null, afterSale.getUserId(), afterSale.getId());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private void createPayRefund(String userIp, AfterSaleDO afterSale) {
 | 
	
		
			
				|  |  |          TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
 | 
	
		
			
				|  |  |  
 |