From 5c03e2dd5afd65c483ef5da8346e78abc29dc7e3 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 01 四月 2020 14:39:54 +0800
Subject: [PATCH] 新增淘客接口,订单返利比例计算相关service修改

---
 fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java |  134 +++++++++++++++++++++-----------------------
 1 files changed, 65 insertions(+), 69 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java b/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
index 4c17f81..5133d26 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -35,6 +35,7 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
 import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
+import com.yeshi.fanli.exception.money.OrderMoneySettleException;
 import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.ad.DouYinClickEventService;
@@ -63,7 +64,6 @@
 import com.yeshi.fanli.util.cmq.JDOrderCMQManager;
 import com.yeshi.fanli.util.cmq.PDDOrderCMQManager;
 import com.yeshi.fanli.util.cmq.PlaceOrderCMQManager;
-import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager;
 import com.yeshi.fanli.util.cmq.UserMoneyChangeCMQManager;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 
@@ -164,9 +164,9 @@
 			doTaoBaoNewOrders();// 澶勭悊娣樺疂璁㈠崟锛堝垰鍒氫骇鐢熺殑锛�
 			doOrderFanLiNew();// 鏂扮増杩斿埄
 			doOrderTiChengFanLi();// 澶勭悊璁㈠崟鎻愭垚杩斿埄
+			doOrderTeamRewardFanLi();// 鍥㈤槦濂栧姳鍒拌处
 			doWeiQuanOrder();// 澶勭悊缁存潈璁㈠崟
 			doPushIOS();// 澶勭悊鍙戦�両OS娑堟伅
-			doThreeSaleUserCouponJob();// 澶勭悊閭�璇烽槦鍒�
 			doUserMoneyDebtJob();// 鍊哄姟鍋胯繕
 			initScheduler();// 鍚姩鍟嗗搧鏇存柊瀹氭椂浠诲姟
 			doUpdateGoodsJob(); // 鏇存柊鍟嗗搧闃熷垪
@@ -329,7 +329,8 @@
 								try {
 									HongBaoV2 hongbao = map.get(handler);
 									if (hongbao != null) {
-										String key = "hongbao-fanli-" + hongbao.getId();
+										String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.hongBaoFanLi,
+												hongbao.getId() + "");
 										if (StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
 											// 澶勭悊涔嬪悗瑕侀殧2灏忔椂鍐嶆杩涜澶勭悊
 											redisManager.cacheCommonString(key, "1", 60 * 60 * 2);
@@ -380,6 +381,47 @@
 									orderProcessService.fanliInvaiteAndShare(map.get(handler));
 									CMQManager.getInstance().deleteFanLiTiChengMsg(handler);
 								} catch (TaoBaoWeiQuanException e) {
+									try {
+										LogHelper.errorDetailInfo(e);
+									} catch (Exception e1) {
+										e1.printStackTrace();
+									}
+								} catch (Exception e) {
+									try {
+										LogHelper.errorDetailInfo(e, map.get(handler).toString(), "");
+									} catch (Exception e1) {
+										e1.printStackTrace();
+									}
+								}
+							}
+						}
+					} catch (Exception e) {
+
+					}
+				}
+			}
+		});
+	}
+
+	/**
+	 * 璁㈠崟鍥㈤槦濂栧姳鍒拌处
+	 */
+	public void doOrderTeamRewardFanLi() {
+		executor.execute(new Runnable() {
+			@Override
+			public void run() {
+				while (true) {
+					try {
+
+						Map<String, Long> map = CMQManager.getInstance().consumeOrderTeamRewardMsg(16);
+						if (map != null) {
+							Iterator<String> its = map.keySet().iterator();
+							while (its.hasNext()) {
+								String handler = its.next();
+								try {
+									orderProcessService.fanliOrderTeamReward(map.get(handler));
+									CMQManager.getInstance().deleteOrderTeamRewardMsg(handler);
+								} catch (OrderMoneySettleException e) {
 									try {
 										LogHelper.errorDetailInfo(e);
 									} catch (Exception e1) {
@@ -513,66 +555,6 @@
 					}
 				}
 			});
-	}
-
-	/**
-	 * 閭�璇峰叧绯诲彉鍖栧悗鍒哥殑鏇存柊
-	 */
-	public void doThreeSaleUserCouponJob() {
-
-		// 閲囩敤2涓嚎绋嬪仛鏇存柊
-		for (int i = 0; i < 2; i++)
-			executor.execute(new Runnable() {
-				@Override
-				public void run() {
-
-					while (true) {
-						try {
-							Map<String, ThreeSale> map = ThreeSaleCMQManager.getInstance()
-									.consumeQueueMsg(ThreeSaleCMQManager.QUEUE_USER_COUPON, 16);
-							if (map != null) {
-
-								Iterator<String> its = map.keySet().iterator();
-								while (its.hasNext()) {
-									String key = its.next();
-									try {
-										ThreeSale threeSale = map.get(key);
-										if (threeSale != null)
-											threeSale = threeSaleSerivce.selectByPrimaryKey(threeSale.getId());
-										if (threeSale != null) {
-											if (threeSale.getState() != null && threeSale.getState() == true) {
-												// 閭�璇锋垚鍔� - 鍒告縺娲荤敓鏁�
-												LogHelper.test("doThreeSaleUserCouponJob-" + threeSale.getId());
-
-												Long bossId = threeSale.getBoss().getId();
-												// 涓嬬骇鏄电О
-
-												String workerNickName = userInfoService
-														.selectByPKey(threeSale.getWorker().getId()).getNickName();
-
-												userSystemCouponService.activatedWelfareFreeCoupon(bossId,
-														workerNickName);
-											}
-										}
-										ThreeSaleCMQManager.getInstance()
-												.deleteQueueMsg(ThreeSaleCMQManager.QUEUE_USER_COUPON, key);
-									} catch (Exception e) {
-										try {
-											LogHelper.errorDetailInfo(e);
-										} catch (Exception e1) {
-											e1.printStackTrace();
-										}
-									}
-								}
-							}
-						} catch (Exception e) {
-							LogHelper.error("鏇存柊鍟嗗搧鍑洪敊:" + e.getMessage());
-
-						}
-					}
-				}
-			});
-
 	}
 
 	/**
@@ -747,8 +729,8 @@
 									fanliGetIntegral(hongBaoV2);
 									HongBaoRecieveCMQManager.getInstance()
 											.deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
-									
-									//杩斿埄涓嶈冻0.01鍏冮�侀噾甯�
+
+									// 杩斿埄涓嶈冻0.01鍏冮�侀噾甯�
 									if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 鑷喘
 										// 鍒ゆ柇鏄惁涓鸿鐢ㄦ埛鐨勯绗旂孩鍖�
 										List<Integer> typeList = new ArrayList<>();
@@ -902,14 +884,28 @@
 	private void fanliGetIntegral(HongBaoV2 hongBaoV2) {
 		if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
 				&& hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
+			// 鏌ヨ瀵瑰簲鐨勮鍗曞彿
+			Long mainHongBaoId = hongBaoV2.getId();
+			if (hongBaoV2.getParent() != null && hongBaoV2.getParent().getId() != null)
+				mainHongBaoId = hongBaoV2.getParent().getId();
+
+			HongBaoOrder hongbaoOrder = hongBaoOrderService.selectDetailByHongBaoId(mainHongBaoId);
+			if (hongbaoOrder == null || hongbaoOrder.getCommonOrder() == null)
+				return;
+			CommonOrder commonOrder = hongbaoOrder.getCommonOrder();
+
 			if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 鑷喘璁㈠崟
-				integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId());
+				integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
+						commonOrder.getSourceType());
 			} else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 鍒嗕韩璁㈠崟
-				integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId());
+				integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
+						commonOrder.getSourceType());
 			} else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 涓�绾ч個璇�
-				integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId());
+				integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
+						commonOrder.getSourceType());
 			} else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 浜岀骇閭�璇�
-				integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId());
+				integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(),
+						commonOrder.getSourceType());
 			}
 		}
 	}

--
Gitblit v1.8.0