From 9c791d431038fe79a111805762ee2f42c96b51c5 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 08 Nov 2021 17:03:15 +0800
Subject: [PATCH] fix

---
 zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java |  111 ++++++++++++-------------------------------------------
 1 files changed, 24 insertions(+), 87 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java
index c790239..b17b449 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java
@@ -1,6 +1,7 @@
 package com.matrix.system.shopXcx.action;
 
-import com.matrix.component.wechat.externalInterface.common.WechatConfigure;
+import com.matrix.component.asyncmessage.AsyncMessageManager;
+import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil;
 import com.matrix.core.anotations.RemoveRequestToken;
 import com.matrix.core.anotations.SaveRequestToken;
 import com.matrix.core.constance.MatrixConstance;
@@ -9,21 +10,22 @@
 import com.matrix.core.exception.GlobleException;
 import com.matrix.core.pojo.AjaxResult;
 import com.matrix.core.pojo.PaginationVO;
-import com.matrix.core.tools.*;
-import com.matrix.component.redis.RedisUserLoginUtils;
+import com.matrix.core.tools.LogUtil;
+import com.matrix.core.tools.ModelUtils;
+import com.matrix.core.tools.StringUtils;
+import com.matrix.core.tools.WebUtil;
 import com.matrix.system.common.bean.SysUsers;
 import com.matrix.system.common.constance.AppConstance;
-
-import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil;
+import com.matrix.system.common.dao.BusParameterSettingsDao;
 import com.matrix.system.hive.action.util.QueryUtil;
+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.ShopCouponRecordDao;
 import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao;
 import com.matrix.system.shopXcx.dao.ShopOrderDao;
 import com.matrix.system.shopXcx.dao.ShopRefundRecordDao;
-import com.matrix.component.tools.WxTempLateMsgUtil;
-import com.matrix.system.shopXcx.api.service.WXShopOrderService;
+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;
@@ -60,8 +62,7 @@
 	@Autowired
 	private ShopDeliveryInfoDao shopDeliveryInfoDao;
 	@Autowired
-	private RedisUserLoginUtils redisUserLoginUtils;
-
+	private AsyncMessageManager asyncMessageManager;
 	@Autowired
 	private ShopCouponRecordDao shopCouponRecordDao;
 
@@ -73,6 +74,12 @@
 
 	@Value("${wx_pay_debug_onoff}")
 	private boolean isDebug;
+	@Value("${evn}")
+	private  String evn;
+
+
+	@Autowired
+	BusParameterSettingsDao parameterSettingsDao;
 
 	/**
 	 * 列表显示
@@ -133,9 +140,6 @@
 		modifyMap.put("handingTime", new Date());
 		int i = shopRefundRecordDao.updateByMap(modifyMap);
 		if (i > 0) {
-			//同意退款后发送微信提醒填写物流单号
-			ShopRefundRecord fundRecord = shopRefundRecordDao.selectById(shopRefundRecord.getId());
-			sendRefundLogisticsInfoToUser(fundRecord);
 			return new AjaxResult(AjaxResult.STATUS_SUCCESS, "操作成功", "退款记录表");
 		} else {
 			throw new GlobleException("操作失败");
@@ -182,8 +186,6 @@
 			modifyOrder.put("id", record.getOrderId());
 			shopOrderDao.updateByMap(modifyOrder);
 		}
-		//退款拒绝后发送微信提醒
-		sendFailedRefundInfoToUser(record);
 		if (i > 0) {
 			return new AjaxResult(AjaxResult.STATUS_SUCCESS, "操作成功", "退款记录表");
 		} else {
@@ -246,7 +248,7 @@
 					if(flag){
 						//退款成功后发送微信提醒
 						ShopRefundRecord fundRecord = shopRefundRecordDao.selectById(oldShopRefundRecord.getId());
-						sendRefundInfoToUser(fundRecord);
+
 					}
 				}
 
@@ -270,7 +272,7 @@
 				if(flag){
 					//退款成功后发送微信提醒
 					ShopRefundRecord fundRecord = shopRefundRecordDao.selectById(oldShopRefundRecord.getId());
-					sendRefundInfoToUser(fundRecord);
+
 				}
 			}
 
@@ -390,7 +392,7 @@
 					if(flag){
 						//退款成功后发送微信提醒
 						ShopRefundRecord fundRecord = shopRefundRecordDao.selectById(Integer.valueOf(id));
-						sendRefundInfoToUser(fundRecord);
+
 						refundRecordService.updateGroupBuyStatus(Long.parseLong(id));
 					}
 				}
@@ -416,7 +418,7 @@
 				if(flag){
 					//退款成功后发送微信提醒
 					ShopRefundRecord fundRecord = shopRefundRecordDao.selectById(Integer.valueOf(id));
-					sendRefundInfoToUser(fundRecord);
+
 					refundRecordService.updateGroupBuyStatus(Long.parseLong(id));
 				}
 			}
@@ -488,8 +490,7 @@
 				//退款成功后同时把优惠券退回到用户的账号中
 				if (shopOrder.getDiscountAmount() != null && shopOrder.getDiscountAmount().compareTo(BigDecimal.ZERO) == 0) {
 					ShopCouponRecord shopCouponRecord = new ShopCouponRecord();
-					String userIds = shopRefundRecord.getUserId();
-					shopCouponRecord.setUserId(userIds);
+					shopCouponRecord.setUserId(shopRefundRecord.getUserId());
 					shopCouponRecord.setOrderId(shopOrder.getId());
 					List<ShopCouponRecord> recordList = shopCouponRecordDao.selectByModel(shopCouponRecord);
 					if (CollectionUtils.isNotEmpty(recordList)) {
@@ -522,6 +523,9 @@
 				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());
+
 			}catch (Exception e){
 				LogUtil.debug("退款成功,修改退款表和订单表状态出错。。。", id);
 				e.printStackTrace();
@@ -530,73 +534,6 @@
 		return flag;
 	}
 
-	//退款成功后发送微信提醒
-	private 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);
-		msg.add("商品名称");
-		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;
-	}
 
-	//退款拒绝后发送微信提醒
-	private int sendFailedRefundInfoToUser(ShopRefundRecord shopRefundRecord) {
-		ShopOrder order = shopOrderDao.selectById(shopRefundRecord.getOrderId());
-		if (order == null) {
-			throw new GlobleException("没有找到拒绝退款的订单信息");
-		}
-		List<String> msg = new ArrayList<>();
-		//退款说明
-		String remarks = "如有疑问请联系客服";
-		msg.add(order.getOrderNo());
-		msg.add("商品名称");
-		msg.add(shopRefundRecord.getRefundRefuseReason());
-		msg.add(shopRefundRecord.getRefundCause());
-		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=2" + "&&inform=1";
-		int res = WxTempLateMsgUtil.sendWxTemplateMsg(msg, order.getUserId(),
-				page, WxTempLateMsgUtil.REFUND_FAILED, formId);
-		return res;
-	}
 
-	//同意退款后发送微信提醒填写物流单号
-	private int sendRefundLogisticsInfoToUser(ShopRefundRecord shopRefundRecord) {
-		ShopOrder order = shopOrderDao.selectById(shopRefundRecord.getOrderId());
-		if (order == null) {
-			throw new GlobleException("没有找到发送微信提醒的订单信息");
-		}
-		List<String> msg = new ArrayList<>();
-		//退款说明
-		String remarks = "申请退款已审核通过,请尽快填写退货物流信息";
-		msg.add(order.getOrderNo());
-		msg.add("商品名称");
-		msg.add("待退回");
-		msg.add(remarks);
-		String formId = order.getWxOrderNo().split("=")[1];
-		String page = "pages/refunding/refunding?id=" + shopRefundRecord.getId() + "&&inform=1";
-		int res = WxTempLateMsgUtil.sendWxTemplateMsg(msg, order.getUserId(),
-				page, WxTempLateMsgUtil.WRITE_LOGISTICS, formId);
-		return res;
-	}
 }
\ No newline at end of file

--
Gitblit v1.9.1