From d46dea27b6ec3e0fb32ec7d137699e9fc7d609b0 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 12 十二月 2019 14:18:11 +0800
Subject: [PATCH] 订单补贴消息修改

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java |   47 +++++++++++++++++++++++++++++++----------------
 1 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
index 469be0f..09ebb52 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java
@@ -20,7 +20,6 @@
 
 import com.aliyun.openservices.ons.api.Message;
 import com.aliyun.openservices.ons.api.Producer;
-import com.aliyun.openservices.ons.api.SendResult;
 import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
 import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
 import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
@@ -58,6 +57,7 @@
 import com.yeshi.fanli.exception.order.HongBaoException;
 import com.yeshi.fanli.exception.order.OrderItemException;
 import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
+import com.yeshi.fanli.exception.user.UserAccountException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
 import com.yeshi.fanli.service.inter.elme.ElmeOrderService;
@@ -77,6 +77,7 @@
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
 import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
 import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
+import com.yeshi.fanli.service.manger.HongBaoV2AddManager;
 import com.yeshi.fanli.util.CMQManager;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.MoneyBigDecimalUtil;
@@ -87,7 +88,7 @@
 import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
 import com.yeshi.fanli.util.jd.JDApiUtil;
 import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
-import com.yeshi.fanli.util.rocketmq.MQTagConstant;
+import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
 import com.yeshi.fanli.util.rocketmq.MQTopicName;
 
 @Service
@@ -158,6 +159,9 @@
 
 	@Resource
 	private OrderMoneySettleService orderMoneySettleService;
+
+	@Resource
+	private HongBaoV2AddManager hongBaoV2AddManager;
 
 	/**
 	 * 鏄惁鏄垎浜鍗�
@@ -417,10 +421,9 @@
 		// 鑷喘鍒拌处浜嬪姟娑堟伅
 		OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_ZIGOU,
 				mainUser.getId(), hongBaoOrder.getCommonOrder().getSourceType(),
-				hongBaoOrder.getCommonOrder().getOrderNo(), null, new Date());
+				hongBaoOrder.getCommonOrder().getOrderNo(), null, new Date(), 0);
 		mqMsg.setOrderFirst(first);
-		Message msg = new Message(MQTopicName.TOPIC_ORDER.name(), OrderTopicTagEnum.orderFanLiActual.name(),
-				new Gson().toJson(mqMsg).getBytes());
+		Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
 		String key = mainUser.getId() + "-" + UUID.randomUUID().toString();
 		msg.setKey(key);
 		try {
@@ -504,8 +507,10 @@
 		List<Long> inviteAndShareUids = hongBaoV2Mapper.listUidCanBanlanceShareAndInvite(1000);
 		Set<Long> uidSets = new HashSet<>();
 		if (inviteAndShareUids != null)
-			for (Long uid : inviteAndShareUids)
-				uidSets.add(uid);
+			for (Long uid : inviteAndShareUids) {
+				if (userInfoMapper.selectAvailableByPrimaryKey(uid) != null)
+					uidSets.add(uid);
+			}
 		// 鏍规嵁鐢ㄦ埛ID
 		Iterator<Long> its = uidSets.iterator();
 		while (its.hasNext()) {
@@ -528,15 +533,13 @@
 		} catch (OrderMoneySettleException e) {
 			e.printStackTrace();
 		}
-		if (1 > 0)
-			return;
-
+		//
 		try {
 			orderMoneySettleService.inviteSettleJD(uid);
 		} catch (OrderMoneySettleException e) {
 			e.printStackTrace();
 		}
-
+		//
 		try {
 			orderMoneySettleService.inviteSettlePDD(uid);
 		} catch (OrderMoneySettleException e) {
@@ -555,7 +558,7 @@
 		} catch (OrderMoneySettleException e) {
 			e.printStackTrace();
 		}
-
+		//
 		try {
 			orderMoneySettleService.shareSettlePDD(uid);
 		} catch (OrderMoneySettleException e) {
@@ -739,7 +742,11 @@
 		if (order.getValidCode() == 2)
 			return;
 
+		// 鏍规嵁ext1涓巗ubUnionId璺熷崟
 		String uidStr = order.getExt1();
+		if (StringUtil.isNullOrEmpty(uidStr))
+			uidStr = order.getOrderItemList().get(0).getSubUnionId();
+
 		Long uid = null;
 		if (!StringUtil.isNullOrEmpty(uidStr) && NumberUtil.isNumeric(uidStr))
 			uid = Long.parseLong(uidStr);
@@ -1206,19 +1213,27 @@
 		final List<CommonOrder> coList = convertCommonOrder(commonOrderList);
 		int resultCode = 0;
 		try {
-			resultCode = hongBaoV2Service.addHongBao(coList, hongBaoType);
+			long time = TimeUtil.convertToTimeTemp("2019-12-06", "yyyy-MM-dd");
+			if (!Constant.IS_TEST)
+				time = TimeUtil.convertToTimeTemp("2020-01-01", "yyyy-MM-dd");
+
+			if (coList.get(0).getThirdCreateTime().getTime() < time)
+				resultCode = hongBaoV2Service.addHongBao(coList, hongBaoType);
+			else
+				resultCode = hongBaoV2AddManager.addHongBao(coList, hongBaoType);
 		} catch (HongBaoException e) {
 			try {
 				LogHelper.errorDetailInfo(e, "addJDOrder鎴朼ddHongBao鍑洪敊", "璁㈠崟鍙�:" + orderId);
 			} catch (Exception e1) {
 				e1.printStackTrace();
 			}
+		} catch (UserAccountException e) {
+
 		}
 		if (resultCode == 1) {// 鍙彂閫佹柊澧炴秷鎭�
 			OrderMQMsg mqMsg = new OrderMQMsg(orderId, sourceType, uid, OrderMQMsg.HANDLE_TYPE_ADD,
-					isCommonOrderValid(coList));
-			Message msg = new Message(MQTopicName.TOPIC_ORDER.name(), OrderTopicTagEnum.orderStatistic.name(),
-					new Gson().toJson(mqMsg).getBytes());
+					isCommonOrderValid(coList), 0, new Date());
+			Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderStatistic, mqMsg);
 			producer.send(msg);
 		}
 	}

--
Gitblit v1.8.0