From 69bee82b81626b82b7f39f0e459e4f56b1699b51 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 13 三月 2019 12:02:16 +0800
Subject: [PATCH] 正式数据库修改

---
 fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java |   71 +++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 1 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 a77f401..a75cd85 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -17,11 +17,13 @@
 
 import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo;
 import com.yeshi.fanli.entity.bus.user.HongBaoV2;
+import com.yeshi.fanli.entity.bus.user.ThreeSale;
 import com.yeshi.fanli.entity.push.PushQueueRecord;
 import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
 import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
 import com.yeshi.fanli.exception.TaoBaoWeiQuanException;
 import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
 import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
 import com.yeshi.fanli.service.inter.lable.LabelService;
 import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
@@ -29,6 +31,7 @@
 import com.yeshi.fanli.service.inter.push.IOSPushService;
 import com.yeshi.fanli.service.inter.user.ExtractService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
+import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
 
 /**
  * 绯荤粺鍒濆鍖�
@@ -63,6 +66,12 @@
 	@Resource
 	private QualityFactoryService qualityFactoryService;
 
+	@Resource
+	private UserSystemCouponService userSystemCouponService;
+
+	@Resource
+	private ThreeSaleSerivce threeSaleSerivce;
+
 	private static boolean isInited = false;
 
 	public void onApplicationEvent(ContextRefreshedEvent arg0) {
@@ -89,6 +98,7 @@
 			doOrderTiChengFanLi();// 澶勭悊璁㈠崟鎻愭垚杩斿埄
 			doWeiQuanOrder();// 澶勭悊缁存潈璁㈠崟
 			doPushIOS();// 澶勭悊鍙戦�両OS娑堟伅
+			doThreeSaleUserCouponJob();// 澶勭悊閭�璇烽槦鍒�
 		} else if (!Constant.IS_TEST) {
 			initScheduler();// 鍚姩瀹氭椂浠诲姟
 			// doUpdateGoodsJob();
@@ -203,7 +213,7 @@
 									}
 								} catch (Exception e) {
 									try {
-										LogHelper.errorDetailInfo(e);
+										LogHelper.errorDetailInfo(e, "HongBaoV2-ID:" + map.get(handler).getId(), "");
 									} catch (Exception e1) {
 										e1.printStackTrace();
 									}
@@ -386,6 +396,65 @@
 					}
 				}
 			});
+	}
+
+	/**
+	 * 閭�璇峰叧绯诲彉鍖栧悗鍒哥殑鏇存柊
+	 */
+	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());
+
+						}
+					}
+				}
+			});
 
 	}
 }

--
Gitblit v1.8.0