From bbe0a2fd03063316e50cf141986bda984599bbda Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Tue, 22 Feb 2022 23:41:42 +0800
Subject: [PATCH] Merge branch 'developer'

---
 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java |   75 ++++++++++++++++++-------------------
 1 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java
index 6030d3e..6365343 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java
@@ -1,23 +1,25 @@
 package com.matrix.system.shopXcx.api.service.impl;
 
-import com.matrix.component.wechat.externalInterface.common.WechatConfigure;
-import com.matrix.core.exception.GlobleException;
-import com.matrix.core.tools.DateUtil;
-import com.matrix.core.tools.LogUtil;
-import com.matrix.system.common.constance.AppConstance;
+import com.matrix.component.asyncmessage.AsyncMessageManager;
 import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil;
-import com.matrix.system.shopXcx.bean.*;
-import com.matrix.system.shopXcx.dao.*;
-import com.matrix.component.tools.WxTempLateMsgUtil;
+import com.matrix.core.exception.GlobleException;
+import com.matrix.core.tools.DingDingRobotUtil;
+import com.matrix.core.tools.LogUtil;
+import com.matrix.core.tools.StringUtils;
+import com.matrix.system.common.bean.BusParameterSettings;
+import com.matrix.system.common.constance.AppConstance;
+import com.matrix.system.common.dao.BusParameterSettingsDao;
 import com.matrix.system.shopXcx.api.service.WXShopOrderService;
 import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService;
+import com.matrix.system.shopXcx.bean.*;
+import com.matrix.system.shopXcx.dao.*;
+import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -47,8 +49,17 @@
     @Autowired
     private ShopActivitiesGroupJoinDao shopActivitiesGroupJoinDao;
 
+    @Autowired
+    private BusParameterSettingsDao busParameterSettingsDao;
+
+    @Autowired
+    private AsyncMessageManager asyncMessageManager;
+
     @Value("${wx_pay_debug_onoff}")
     private boolean isDebug;
+
+
+
     @Override
     public Boolean refundToUser(String id, ShopRefundRecord shopRefundRecord) {
         LogUtil.debug("进入退款接口进行退款。。。", id);
@@ -101,7 +112,7 @@
                 //退款成功后同时把优惠券退回到用户的账号中
                 if (shopOrder.getDiscountAmount() != null && shopOrder.getDiscountAmount().compareTo(BigDecimal.ZERO) >0) {
                     ShopCouponRecord shopCouponRecord = new ShopCouponRecord();
-                    String userIds = shopRefundRecord.getUserId();
+                    Long userIds = shopRefundRecord.getUserId();
                     shopCouponRecord.setUserId(userIds);
                     shopCouponRecord.setOrderId(shopOrder.getId());
                     List<ShopCouponRecord> recordList = shopCouponRecordDao.selectByModel(shopCouponRecord);
@@ -134,6 +145,21 @@
                 modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_MONEYBACK_SUCCESS);
                 modifyMap.put("refundCharge", shopRefundRecord.getRefundMoney());
                 shopOrderDao.updateByMap(modifyMap);
+
+                asyncMessageManager.sendMsg(AsyncMessageRouting.SHOP_ORDER_REFUND ,"orderId=%s" , shopRefundRecord.getOrderId());
+
+
+                //发送退款通知
+                BusParameterSettings wxOrderNoticeDingdingToken = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WX_ORDER_NOTICE_DINGDING_TOKEN, shopOrder.getCompanyId());
+                if (wxOrderNoticeDingdingToken != null && StringUtils.isNotBlank(wxOrderNoticeDingdingToken.getParamValue())) {
+                    DingDingRobotUtil.sendText(wxOrderNoticeDingdingToken.getParamValue(),
+                            "订单退款,微商城订单编号 "+shopOrder.getOrderNo()
+                                    +"; 订单金额:¥"+shopOrder.getOrderMoney()
+                                    +";收货电话:"+ shopOrder.getUserTel()+",收货人:"+ shopOrder.getUserName()
+                            ,"");
+                }
+
+
             }catch (Exception e){
                 LogUtil.debug("退款成功,修改退款表和订单表状态出错。。。", id);
                 e.printStackTrace();
@@ -142,34 +168,7 @@
         return flag;
     }
 
-    /**
-     * 退款成功后发送微信提醒
-     * @param shopRefundRecord
-     * @return
-     */
-    @Override
-    public int sendRefundInfoToUser(ShopRefundRecord shopRefundRecord) {
-        ShopOrder order = shopOrderDao.selectById(shopRefundRecord.getOrderId());
-        if (order == null) {
-            throw new GlobleException("没有找到需要退款的订单信息");
-        }
-        List<String> msg = new ArrayList<>();
-        //退款说明
-        String refundExplain = "退款已经原路返回,具体到账时间可能会有1-3天延迟";
-        msg.add(order.getOrderNo());
-        msg.add(DateUtil.dateToString(shopRefundRecord.getRefundTime(),DateUtil.DATE_FORMAT_SS));
-        msg.add(refundExplain);
-        String formId = null;
-        if(AppConstance.REFUND_GOODS.equals(shopRefundRecord.getRefundType()) && null != shopRefundRecord.getRefundTransactionNo()){
-            formId = shopRefundRecord.getRefundTransactionNo();
-        }else {
-            formId = order.getWxOrderNo().split("=")[1];
-        }
-        String page = "pages/refunDetail/refunDetail?id=" + shopRefundRecord.getId() + "&&status=1" + "&&inform=1";
-        int res = WxTempLateMsgUtil.sendWxTemplateMsg(msg, order.getUserId(),
-                page, WxTempLateMsgUtil.REFUND_SUCCESS, formId);
-        return res;
-    }
+
 
     @Override
     public void updateGroupBuyStatus(Long orderId) {

--
Gitblit v1.9.1