From 84680b272137a7e44363bcd49832b5831931dc0e Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期四, 12 九月 2019 09:53:01 +0800
Subject: [PATCH] 智能搜索领取 30分钟改为60秒
---
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java | 267 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 256 insertions(+), 11 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 39e5a7a..e4a2e53 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -20,19 +20,29 @@
import com.yeshi.fanli.dto.money.UserMoneyChangeDTO;
import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
+import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.jd.JDOrder;
+import com.yeshi.fanli.entity.order.CommonOrder;
+import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.pdd.PDDOrder;
import com.yeshi.fanli.entity.push.PushQueueRecord;
+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.TaoBaoWeiQuanException;
+import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
+import com.yeshi.fanli.service.inter.integral.IntegralGetService;
+import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService;
import com.yeshi.fanli.service.inter.jd.JDOrderService;
import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
import com.yeshi.fanli.service.inter.lable.LabelService;
import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
+import com.yeshi.fanli.service.inter.order.CommonOrderService;
+import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
import com.yeshi.fanli.service.inter.order.OrderProcessService;
import com.yeshi.fanli.service.inter.pdd.PDDOrderService;
import com.yeshi.fanli.service.inter.push.IOSPushService;
@@ -41,10 +51,13 @@
import com.yeshi.fanli.service.inter.user.ExtractService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
+import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
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;
/**
* 绯荤粺鍒濆鍖�
@@ -100,6 +113,21 @@
@Resource
private PDDOrderService pddOrderService;
+ @Resource
+ private HongBaoV2Service hongBaoV2Service;
+
+ @Resource
+ private IntegralGetService integralGetService;
+
+ @Resource
+ private CommonOrderService commonOrderService;
+
+ @Resource
+ private HongBaoOrderService hongBaoOrderService;
+
+ @Resource
+ private IntegralTaskRecordService integralTaskRecordService;
+
private static boolean isInited = false;
public void onApplicationEvent(ContextRefreshedEvent arg0) {
@@ -131,10 +159,13 @@
doUserMoneyDebtJob();// 鍊哄姟鍋胯繕
initScheduler();// 鍚姩鍟嗗搧鏇存柊瀹氭椂浠诲姟
doUpdateGoodsJob(); // 鏇存柊鍟嗗搧闃熷垪
+ doJDOrderJob();// 浜笢璁㈠崟澶勭悊
+ doPDDOrderJob();// 鎷煎澶氳鍗曞鐞�
+ doImportantTaoBaoGoodsUpdateJob();// 娣樺疂閲嶈鍟嗗搧鐨勪俊鎭洿鏂�
+ doHongBaoRecieveIntegralGetJob();// 杩斿埄鍒拌处锛岄噾甯佸鍔�
+ doPlaceOrderIntegralJob();// 涓嬪崟璧犻�侀噾甯佷换鍔�
}
- doJDOrderJob();// 浜笢璁㈠崟澶勭悊
- doPDDOrderJob();// 鎷煎澶氳鍗曞鐞�
}
/**
@@ -202,12 +233,13 @@
public void run() {
while (true) {
try {
+
// 鍙�16涓鍗�
List<String> orderIds = CMQManager.getInstance().consumeTaoBaoOrderMsg(16);
- Map<String, List<TaoBaoOrder>> map = new HashMap<>();
if (orderIds != null) {
for (String orderId : orderIds) {
if (NumberUtil.isNumeric(orderId.trim())) {
+ Map<String, List<TaoBaoOrder>> map = new HashMap<>();
List<TaoBaoOrder> orderList = taoBaoOrderService
.getTaoBaoOrderByOrderId(orderId);
map.put(orderId, orderList);
@@ -566,7 +598,6 @@
}
} catch (Exception e) {
LogHelper.error("杩樻鍑洪敊:" + e.getMessage());
-
}
}
}
@@ -631,21 +662,235 @@
}
PDDOrderCMQManager.getInstance().deletePDDOrder(key);
} catch (Exception e) {
- try {
- LogHelper.errorDetailInfo(e);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
+ LogHelper.errorDetailInfo(e);
}
}
}
} catch (Exception e) {
LogHelper.error("鎷煎澶氳鍗�:" + e.getMessage());
-
}
}
}
});
}
+
+ /**
+ * 閲嶈鐨勬窐瀹濆晢鍝佷俊鎭洿鏂�
+ */
+ public void doImportantTaoBaoGoodsUpdateJob() {
+ // 寮�鍚�2涓嚎绋嬪仛鏇存柊
+ for (int i = 0; i < 2; i++)
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ Map<String, Long> map = CMQManager.getInstance().consumeTBImpGoodsUpdateMsg(16);
+ if (map != null) {
+ Iterator<String> its = map.keySet().iterator();
+ while (its.hasNext()) {
+ String key = its.next();
+ try {
+ long startTime = System.currentTimeMillis();
+ TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(map.get(key));
+ // 鏇存柊涓�鏉℃暟鎹渶瑕佺殑鏃堕棿
+ taoBaoGoodsUpdateService.updateTaoBaoGoods(goods);
+ long time = System.currentTimeMillis() - startTime;
+ LogHelper.test("娣樺疂閲嶈鍟嗗搧搴撴洿鏂版椂闂�:" + time);
+ } catch (Exception e) {
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ } finally {
+ CMQManager.getInstance().deleteTBImpGoodsUpdateMsg(key);
+ }
+ }
+ }
+ }
+ }
+ });
+
+ }
+
+ /**
+ * 绾㈠寘鍒拌处鍚庣殑閲戝竵鑾峰彇
+ */
+ public void doHongBaoRecieveIntegralGetJob() {
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ Map<String, Long> map = HongBaoRecieveCMQManager.getInstance()
+ .consumeQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, 16);
+ if (map != null) {
+ Iterator<String> its = map.keySet().iterator();
+ while (its.hasNext()) {
+ String key = its.next();
+ Long hongBaoId = map.get(key);
+ try {
+ HongBaoV2 hongBaoV2 = hongBaoV2Service.selectByPrimaryKey(hongBaoId);
+ if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
+ && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
+ if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 鑷喘
+ integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId());
+ } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 鍒嗕韩璧�
+ integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId());
+ } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI
+ || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 涓�绾ч個璇疯禋
+ integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId());
+ } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI
+ || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 浜岀骇閭�璇疯禋
+ integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId());
+ }
+ }
+ HongBaoRecieveCMQManager.getInstance()
+ .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
+ } catch (Exception e) {
+ try {
+ LogHelper.errorDetailInfo(e);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+ } finally {
+
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
+ private boolean isFirstValidOrder(String orderId, int sourceType, Long uid) {
+ CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid);
+ if (commonOrder != null && commonOrder.getOrderNo().equalsIgnoreCase(orderId)
+ && sourceType == commonOrder.getSourceType())
+ return true;
+ else
+ return false;
+ }
+
+ // 涓嬪崟鑾峰彇閲戝竵浠诲姟
+ public void doPlaceOrderIntegralJob() {
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ Map<String, Order> map = PlaceOrderCMQManager.getInstance()
+ .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, 16);
+ if (map != null) {
+ // 鏄惁鏄鍗�
+ for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
+ try {
+ String key = its.next();
+ Order order = map.get(key);
+ // 缁熻璁㈠崟涓嬬殑鐢ㄦ埛鎵�鑾峰緱鐨勮繑鍒╅噾棰�
+ List<CommonOrder> list = commonOrderService
+ .listBySourceTypeAndOrderId(order.getOrderType(), order.getOrderId());
+ Map<Long, BigDecimal> hongBaoMoney = new HashMap<>();
+ if (list != null)
+ for (CommonOrder commonOrder : list) {
+ HongBaoOrder hongBaoOrder = hongBaoOrderService
+ .selectDetailByCommonOrderId(commonOrder.getId());
+ if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
+ Long mainUid = hongBaoOrder.getHongBaoV2().getUserInfo().getId();
+ if (hongBaoMoney.get(mainUid) == null)
+ hongBaoMoney.put(mainUid, new BigDecimal(0));
+ hongBaoMoney.put(mainUid, hongBaoMoney.get(mainUid)
+ .add(hongBaoOrder.getHongBaoV2().getMoney()));
+ // 鏌ヨ涓婄骇
+ List<HongBaoV2> children = hongBaoV2Service
+ .listChildrenById(hongBaoOrder.getHongBaoV2().getId());
+ if (children != null) {
+ for (HongBaoV2 hongBao : children) {
+ Long uid = hongBao.getUserInfo().getId();
+ if (hongBaoMoney.get(uid) == null)
+ hongBaoMoney.put(uid, new BigDecimal(0));
+ hongBaoMoney.put(uid,
+ hongBaoMoney.get(uid).add(hongBao.getMoney()));
+ }
+ }
+ }
+ }
+
+ if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
+ order.getUserInfo().getId())) {// 鏈夋晥鐨勯鍗�
+ if (hongBaoMoney.get(order.getUserInfo().getId()) == null || hongBaoMoney
+ .get(order.getUserInfo().getId()).compareTo(new BigDecimal("0")) <= 0) {
+ // 鍒嗕韩濂栭噾鏄�0
+ integralTaskRecordService.firstShareOrderReward(order.getUserInfo().getId(),
+ null);
+ }
+
+ // 鑾峰彇涓婁袱绾ф暟鎹�
+ UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
+ if (boss != null) {// 鍒ゆ柇涓婄骇鐨勭孩鍖�
+ if (hongBaoMoney.get(boss.getId()) == null
+ || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
+ // 琛ュ伩閲戝竵
+ integralTaskRecordService.firstSharerOrderRewardBoss(boss.getId(),
+ order.getUserInfo().getId(), null);
+ }
+ }
+
+ } else {// 鑷喘璁㈠崟
+ UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId());
+ if (boss != null) {// 鍒ゆ柇涓婄骇鐨勭孩鍖�
+ if (hongBaoMoney.get(boss.getId()) == null
+ || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
+ // 琛ュ伩閲戝竵1绾�
+ integralTaskRecordService.firstRebateOrderRewardBoss(boss.getId(),
+ order.getUserInfo().getId(), null);
+ }
+ }
+
+ boss = threeSaleSerivce.getBoss(boss.getId());
+ if (boss != null) {// 鍒ゆ柇涓婄骇鐨勭孩鍖�
+ if (hongBaoMoney.get(boss.getId()) == null
+ || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
+ // 琛ュ伩閲戝竵2绾�
+ integralTaskRecordService.firstRebateOrderRewardBossSuper(boss.getId(),
+ order.getUserInfo().getId(), null);
+ }
+ }
+ }
+ PlaceOrderCMQManager.getInstance().deleteQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL,
+ key);
+ } catch (Exception e) {
+ LogHelper.errorDetailInfo(e);
+ }
+ }
+
+ }
+ }
+ }
+ });
+ }
+
+ // 鎶栭煶骞垮憡鐩戞帶
+ public void doPlaceOrderAdJob() {
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ while (true) {
+ Map<String, Order> map = PlaceOrderCMQManager.getInstance()
+ .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_AD, 16);
+ if (map != null) {
+ // 鏄惁鏄鍗�
+ for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
+ String key = its.next();
+ Order order = map.get(key);
+ if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
+ order.getUserInfo().getId())) {// 鏈夋晥鐨勯鍗�
+ // TODO 鎶栭煶鐨勬暟鎹洖璋�
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
}
--
Gitblit v1.8.0