From e19ce4be094d93f68bdb6ee1c28e9caa502bf2c4 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 10 十月 2019 11:17:12 +0800
Subject: [PATCH] utils包添加工具类,抖音广告修改

---
 fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java |  236 +++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 167 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 38a0908..dcbe47b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -17,7 +17,9 @@
 import org.yeshi.utils.tencentcloud.COSManager;
 import org.yeshi.utils.tencentcloud.entity.COSInitParams;
 
+import com.yeshi.fanli.dto.ad.DouYinDeviceActiveQueueDTO;
 import com.yeshi.fanli.dto.money.UserMoneyChangeDTO;
+import com.yeshi.fanli.entity.ad.DouYinClickEvent;
 import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo;
 import com.yeshi.fanli.entity.bus.user.HongBaoV2;
 import com.yeshi.fanli.entity.bus.user.Order;
@@ -27,29 +29,35 @@
 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.DeviceActive;
 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.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.jd.JDOrderService;
+import com.yeshi.fanli.service.inter.ad.DouYinClickEventService;
 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.money.extract.ExtractService;
 import com.yeshi.fanli.service.inter.order.CommonOrderService;
 import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
+import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
 import com.yeshi.fanli.service.inter.order.OrderProcessService;
-import com.yeshi.fanli.service.inter.pdd.PDDOrderService;
+import com.yeshi.fanli.service.inter.order.jd.JDOrderService;
+import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService;
+import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
+import com.yeshi.fanli.service.inter.push.DeviceActiveService;
 import com.yeshi.fanli.service.inter.push.IOSPushService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
-import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
-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.service.inter.user.integral.IntegralGetService;
+import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService;
+import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
+import com.yeshi.fanli.util.ad.DouYinAdUtil;
+import com.yeshi.fanli.util.cmq.DouYinDeviceActiveCMQManager;
 import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
 import com.yeshi.fanli.util.cmq.JDOrderCMQManager;
 import com.yeshi.fanli.util.cmq.PDDOrderCMQManager;
@@ -124,6 +132,12 @@
 	@Resource
 	private HongBaoOrderService hongBaoOrderService;
 
+	@Resource
+	private IntegralTaskRecordService integralTaskRecordService;
+
+	@Resource
+	private DeviceActiveService deviceActiveService;
+
 	private static boolean isInited = false;
 
 	public void onApplicationEvent(ContextRefreshedEvent arg0) {
@@ -158,10 +172,10 @@
 			doJDOrderJob();// 浜笢璁㈠崟澶勭悊
 			doPDDOrderJob();// 鎷煎澶氳鍗曞鐞�
 			doImportantTaoBaoGoodsUpdateJob();// 娣樺疂閲嶈鍟嗗搧鐨勪俊鎭洿鏂�
-			doHongBaoRecieveIntegralGetJob();// 杩斿埄鍒拌处锛岄噾甯佸鍔�
-			doPlaceOrderIntegralJob();// 涓嬪崟璧犻�侀噾甯佷换鍔�
+			// doHongBaoRecieveIntegralGetJob();// 杩斿埄鍒拌处锛岄噾甯佸鍔�
+			// doPlaceOrderIntegralJob();// 涓嬪崟璧犻�侀噾甯佷换鍔�
+			doDouYinDeviceActiveJob();// 鎶栭煶璁惧婵�娲诲箍鍛婄洃娴�
 		}
-
 	}
 
 	/**
@@ -777,70 +791,89 @@
 					Map<String, Order> map = PlaceOrderCMQManager.getInstance()
 							.consumeQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, 16);
 					if (map != null) {
-						// 鏄惁鏄鍗�
+
 						for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
-							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()));
+							try {
+								String key = its.next();
+								Order order = map.get(key);
+								// 鏄惁鏄鍗�
+								if (isFirstValidOrder(order.getOrderId(), order.getOrderType(),
+										order.getUserInfo().getId())) {
+									// 缁熻璁㈠崟涓嬬殑鐢ㄦ埛鎵�鑾峰緱鐨勮繑鍒╅噾棰�
+									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);
+												}
 											}
 										}
 									}
 								}
-
-							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) {
-									// TODO 鍒嗕韩濂栭噾鏄�0
-								}
-
-								// 鑾峰彇涓婁袱绾ф暟鎹�
-								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) {
-										// TODO 琛ュ伩璧勯噾
-									}
-								}
-
-							} 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) {
-										// TODO 琛ュ伩璧勯噾1绾�
-									}
-								}
-
-								boss = threeSaleSerivce.getBoss(boss.getId());
-								if (boss != null) {// 鍒ゆ柇涓婄骇鐨勭孩鍖�
-									if (hongBaoMoney.get(boss.getId()) == null
-											|| hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) {
-										// TODO 琛ュ伩璧勯噾2绾�
-									}
-								}
+								PlaceOrderCMQManager.getInstance().deleteQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL,
+										key);
+							} catch (Exception e) {
+								LogHelper.errorDetailInfo(e);
 							}
 						}
 
@@ -874,4 +907,69 @@
 		});
 	}
 
+	@Resource
+	private DouYinClickEventService douYinClickEventService;
+
+	// 鎶栭煶
+	public void doDouYinDeviceActiveJob() {
+		LogHelper.test("寮�濮嬫墽琛�:doDouYinDeviceActiveJob");
+		executor.execute(new Runnable() {
+			@Override
+			public void run() {
+				LogHelper.test("寮�濮嬫墽琛�:doDouYinDeviceActiveJob-run");
+				while (true) {
+					Map<String, DouYinDeviceActiveQueueDTO> map = DouYinDeviceActiveCMQManager.getInstance()
+							.consume(16);
+					if (map != null) {
+						// 鏄惁鏄鍗�
+						for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) {
+							String key = its.next();
+							DouYinDeviceActiveQueueDTO active = map.get(key);
+							if (active.getType() == DouYinDeviceActiveQueueDTO.TYPE_AD) {// 鎶栭煶
+								DouYinClickEvent event = douYinClickEventService.selectByCallback(active.getCallback());
+								if (event != null) {
+									if (event.getOs() == 0) {
+										DeviceActive deviceActive = deviceActiveService
+												.getFirstActiveInfoByImei(event.getUuid());
+										if (deviceActive != null) {
+											if (event != null) {
+												if (event.getOs() == 0)
+													DouYinAdUtil.activeAndroid(event.getCallback(), event.getImei(),
+															deviceActive.getCreateTime().getTime());
+												else if (event.getOs() == 1)
+													DouYinAdUtil.activeIOS(event.getCallback(), event.getIdfa(),
+															deviceActive.getCreateTime().getTime());
+											}
+										}
+									} else {// TODO 澶勭悊IOS
+
+									}
+								}
+
+							} else if (active.getType() == DouYinDeviceActiveQueueDTO.TYPE_DEVICE) {// 璁惧
+
+								if (active.getPlatform() == 1) {
+									DeviceActive deviceActive = deviceActiveService
+											.getFirstActiveInfo(active.getDevice());
+									if (deviceActive != null && deviceActive.getImei() != null) {
+										DouYinClickEvent event = douYinClickEventService
+												.selectByUuid(deviceActive.getImei());
+										if (event != null) {// 鍥炶皟
+											if (deviceActive != null)
+												DouYinAdUtil.activeAndroid(event.getCallback(), event.getImei(),
+														deviceActive.getCreateTime().getTime());
+										}
+									}
+								} else {
+									// TODO 鍏煎IOS
+								}
+							}
+							DouYinDeviceActiveCMQManager.getInstance().delete(key);
+						}
+					}
+				}
+			}
+		});
+	}
+
 }

--
Gitblit v1.8.0