From 8dc8133fb93405c6fc34c9c3c6c6bbce09ebe7f0 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 24 十二月 2019 10:52:52 +0800
Subject: [PATCH] 品牌商品更新调整 订单维权修改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java |   80 +++++++++++++++++++++-------------------
 1 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java
index 538ba34..d4d5d56 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderMoneySettleServiceImpl.java
@@ -28,7 +28,8 @@
 import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
 import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
 import com.yeshi.fanli.dto.HongBao;
-import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
+import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
+import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
 import com.yeshi.fanli.entity.bus.user.HongBaoV2;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
 import com.yeshi.fanli.entity.money.UserMoneyDetail;
@@ -59,6 +60,7 @@
 import com.yeshi.fanli.util.TimeUtil;
 import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
 import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
+import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
 import com.yeshi.fanli.util.rocketmq.MQTopicName;
 import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil;
 
@@ -112,7 +114,7 @@
 	@Resource
 	private HongBaoV2SettleTempService hongBaoV2SettleTempService;
 
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	@Override
 	public void inviteSettleTB(Long uid) throws OrderMoneySettleException {
 		// 鏌ヨUID鐨勪竴浜岀骇閭�璇疯禋
@@ -152,9 +154,10 @@
 		}
 
 		// 閭�璇疯禋鍒拌处浜嬪姟娑堟伅
-		OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_INVITE, uid,
-				sourceType, null, null, new Date());
-		Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
+		OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_INVITE, uid,
+				sourceType, null, null, new Date(), 0);
+
+		Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
 		String taskKey = getTaskKey(uid);
 		msg.setKey(taskKey);
 		// 娣诲姞浜嬪姟娑堟伅
@@ -173,9 +176,10 @@
 		} catch (Exception e) {
 			LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
 		}
+		System.out.println(new Gson().toJson(mqMsg));
 	}
 
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	@Override
 	public void inviteSettleJD(Long uid) throws OrderMoneySettleException {
 		// 鏌ヨUID鐨勪竴浜岀骇閭�璇疯禋
@@ -215,9 +219,9 @@
 		}
 
 		// 閭�璇疯禋鍒拌处浜嬪姟娑堟伅
-		OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_INVITE, uid,
-				sourceType, null, null, new Date());
-		Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
+		OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_INVITE, uid,
+				sourceType, null, null, new Date(), 0);
+		Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
 		String taskKey = getTaskKey(uid);
 		msg.setKey(taskKey);
 		// 娣诲姞浜嬪姟娑堟伅
@@ -234,7 +238,7 @@
 		}
 	}
 
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	@Override
 	public void inviteSettlePDD(Long uid) throws OrderMoneySettleException {
 		// 鏌ヨUID鐨勪竴浜岀骇閭�璇疯禋
@@ -274,9 +278,9 @@
 		}
 
 		// 閭�璇疯禋鍒拌处浜嬪姟娑堟伅
-		OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_INVITE, uid,
-				sourceType, null, null, new Date());
-		Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
+		OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_INVITE, uid,
+				sourceType, null, null, new Date(), 0);
+		Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
 		String taskKey = getTaskKey(uid);
 		msg.setKey(taskKey);
 		// 娣诲姞浜嬪姟娑堟伅
@@ -293,7 +297,7 @@
 		}
 	}
 
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	@Override
 	public void shareSettleTB(Long uid) throws OrderMoneySettleException {
 		/**
@@ -315,9 +319,9 @@
 				hongBaoList.addAll(tempHongBaoList);
 		}
 
-		OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_SHARE, uid,
-				sourceType, null, null, new Date());
-		Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
+		OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_SHARE, uid, sourceType,
+				null, null, new Date(), 0);
+		Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
 		String taskKey = getTaskKey(uid);
 		msg.setKey(taskKey);
 		// 娣诲姞浜嬪姟娑堟伅
@@ -338,7 +342,7 @@
 		}
 	}
 
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	@Override
 	public void shareSettleJD(Long uid) throws OrderMoneySettleException {
 		/**
@@ -360,9 +364,9 @@
 				hongBaoList.addAll(tempHongBaoList);
 		}
 
-		OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_SHARE, uid,
-				sourceType, null, null, new Date());
-		Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
+		OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_SHARE, uid, sourceType,
+				null, null, new Date(), 0);
+		Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
 		String taskKey = getTaskKey(uid);
 		msg.setKey(taskKey);
 		// 娣诲姞浜嬪姟娑堟伅
@@ -379,7 +383,7 @@
 		}
 	}
 
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	@Override
 	public void shareSettlePDD(Long uid) throws OrderMoneySettleException {
 		/**
@@ -401,9 +405,9 @@
 				hongBaoList.addAll(tempHongBaoList);
 		}
 
-		OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_SHARE, uid,
-				sourceType, null, null, new Date());
-		Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
+		OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_SHARE, uid, sourceType,
+				null, null, new Date(), 0);
+		Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
 		String taskKey = getTaskKey(uid);
 		msg.setKey(taskKey);
 		// 娣诲姞浜嬪姟娑堟伅
@@ -420,7 +424,7 @@
 		}
 	}
 
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	@Override
 	public void ziGouSettle(String orderId, int sourceType, String taskKey) throws OrderMoneySettleException {
 		// 鏌ヨ鍚屼竴璁㈠崟鍙风殑绾㈠寘
@@ -572,7 +576,7 @@
 		return hongBao;
 	}
 
-	@Transactional
+	@Transactional(rollbackFor = Exception.class)
 	private void fanliInviteTB(List<HongBaoV2> hongBaoList, Long uid, String key) throws TaoBaoWeiQuanException {
 		List<Long> hbIdList = new ArrayList<>();
 		BigDecimal invitemoney = new BigDecimal(0);
@@ -625,9 +629,9 @@
 				Date minDate = new Date(TimeUtil
 						.convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
 				long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
-						minDate, maxDate);
+						minDate, maxDate, Constant.SOURCE_TYPE_TAOBAO);
 				long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
-						minDate, maxDate);
+						minDate, maxDate, Constant.SOURCE_TYPE_TAOBAO);
 
 				UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, Constant.SOURCE_TYPE_TAOBAO,
 						(int) validCount, (int) weiQuanCount, invitemoney, new Date());
@@ -711,9 +715,9 @@
 				Date minDate = new Date(TimeUtil
 						.convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
 				long validCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
-						minDate, maxDate);
+						minDate, maxDate, sourceType);
 				long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
-						minDate, maxDate);
+						minDate, maxDate, sourceType);
 
 				UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, sourceType, (int) validCount,
 						(int) weiQuanCount, invitemoney, new Date());
@@ -809,9 +813,9 @@
 				Date minDate = new Date(TimeUtil
 						.convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
 				long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
-						minDate, maxDate);
+						minDate, maxDate, Constant.SOURCE_TYPE_TAOBAO);
 				long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
-						minDate, maxDate);
+						minDate, maxDate, Constant.SOURCE_TYPE_TAOBAO);
 
 				UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
 						(int) validCount, (int) weiQuanCount, sharemoney, new Date());
@@ -907,12 +911,12 @@
 				Date minDate = new Date(TimeUtil
 						.convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
 				long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
-						minDate, maxDate);
+						minDate, maxDate, sourceType);
 				long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
-						minDate, maxDate);
+						minDate, maxDate, sourceType);
 
-				UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
-						(int) validCount, (int) weiQuanCount, sharemoney, new Date());
+				UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, sourceType, (int) validCount,
+						(int) weiQuanCount, sharemoney, new Date());
 				// 娣诲姞璧勯噾
 				userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
 
@@ -952,7 +956,7 @@
 	 * @param orderId
 	 * @param sourceType
 	 */
-	@Transactional
+	@Transactional(rollbackFor=Exception.class)
 	@Override
 	public void inviteSubsidySettle(Long uid, String taskKey) throws OrderMoneySettleException {
 		// 鏌ヨkey

--
Gitblit v1.8.0