From 2ba431be9c12a79783e0f9ef249292b7fa95f2a1 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 25 一月 2021 19:13:58 +0800
Subject: [PATCH] 拼多多备案调整

---
 fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java |  916 ++++----------------------------------------------------
 1 files changed, 79 insertions(+), 837 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 e4a2e53..9f8776f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -1,6 +1,7 @@
 package com.yeshi.fanli.util;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -9,15 +10,25 @@
 
 import javax.annotation.Resource;
 
+import com.yeshi.fanli.dto.push.PushContentDetailDTO;
+import com.yeshi.fanli.service.impl.JobThreadExecutorServiceImpl;
+import com.yeshi.fanli.service.inter.push.HWPushService;
+import com.yeshi.fanli.service.manger.JobManager;
+import com.yeshi.fanli.util.mq.cmq.PushCMQManager;
 import org.springframework.context.ApplicationListener;
 import org.springframework.context.event.ContextRefreshedEvent;
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.stereotype.Component;
 import org.yeshi.utils.NumberUtil;
+import org.yeshi.utils.TimeUtil;
 import org.yeshi.utils.tencentcloud.COSManager;
 import org.yeshi.utils.tencentcloud.entity.COSInitParams;
 
+import com.google.gson.Gson;
+import com.yeshi.fanli.dto.ad.DouYinDeviceActiveQueueDTO;
 import com.yeshi.fanli.dto.money.UserMoneyChangeDTO;
+import com.yeshi.fanli.dto.mq.UidDateDTO;
+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,870 +38,101 @@
 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.suning.SuningOrderInfo;
+import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
 import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
+import com.yeshi.fanli.entity.vipshop.VipShopOrder;
 import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
+import com.yeshi.fanli.exception.order.dividents.TeamDividentsRecordException;
 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.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.suning.SuningOrderService;
+import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
+import com.yeshi.fanli.service.inter.order.vipshop.VipShopOrderService;
+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.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.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.service.manger.money.TeamEincomeManager;
+import com.yeshi.fanli.service.manger.order.TeamDividentsManager;
+import com.yeshi.fanli.util.ad.DouYinAdUtil;
+import com.yeshi.fanli.util.mq.cmq.DouYinDeviceActiveCMQManager;
+import com.yeshi.fanli.util.mq.cmq.HongBaoRecieveCMQManager;
+import com.yeshi.fanli.util.mq.cmq.UserMoneyChangeCMQManager;
+import com.yeshi.fanli.util.mq.cmq.order.JDOrderCMQManager;
+import com.yeshi.fanli.util.mq.cmq.order.PDDOrderCMQManager;
+import com.yeshi.fanli.util.mq.cmq.order.PlaceOrderCMQManager;
+import com.yeshi.fanli.util.mq.cmq.order.SuningOrderCMQManager;
+import com.yeshi.fanli.util.mq.cmq.order.TeamOrderCMQManager;
+import com.yeshi.fanli.util.mq.cmq.order.VipShopOrderCMQManager;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 
 /**
  * 绯荤粺鍒濆鍖�
- * 
- * @author Administrator
  *
+ * @author Administrator
  */
 @Component
 public class SpringContext implements ApplicationListener<ContextRefreshedEvent> {
+    @Resource
+    private JobManager jobManager;
 
-	@Resource
-	private UserInfoService userInfoService;
+    private static boolean isInited = false;
 
-	@Resource
-	private BoutiqueAutoRuleService boutiqueAutoRuleService;
+    public void onApplicationEvent(ContextRefreshedEvent arg0) {
+        if (arg0.getApplicationContext().getParent() != null) {
+            System.out.println(System.currentTimeMillis());
+            onApplication(arg0);
+        }
+    }
 
-	@Resource
-	private ExtractService extractService;
+    private synchronized void onApplication(ContextRefreshedEvent context) {
+        if (!isInited) {
+            isInited = true;
+            System.out.println("绯荤粺鍒濆鍖栧畬鎴�");
+            init(context);
+        }
+    }
 
-	@Resource
-	private IOSPushService iosPushService;
+    private void init(ContextRefreshedEvent arg0) {
+        initCOS();
+        if (Constant.IS_TASK) {
+            jobManager.start();
+        }
+    }
 
-	@Resource
-	private LabelService labelService;
-
-	@Resource(name = "taskExecutor")
-	private TaskExecutor executor;
-
-	@Resource
-	private OrderProcessService orderProcessService;
-
-	@Resource
-	private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
-
-	@Resource
-	private UserSystemCouponService userSystemCouponService;
-
-	@Resource
-	private ThreeSaleSerivce threeSaleSerivce;
-
-	@Resource
-	private TaoBaoOrderService taoBaoOrderService;
-
-	@Resource
-	private RedisManager redisManager;
-
-	@Resource
-	private UserMoneyDebtService userMoneyDebtService;
-
-	@Resource
-	private JDOrderService jdOrderService;
-
-	@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) {
-		if (arg0.getApplicationContext().getParent() != null) {
-			System.out.println(System.currentTimeMillis());
-			onApplication(arg0);
-		}
-	}
-
-	private synchronized void onApplication(ContextRefreshedEvent context) {
-		if (!isInited) {
-			isInited = true;
-			System.out.println("绯荤粺鍒濆鍖栧畬鎴�");
-			init(context);
-		}
-	}
-
-	private void init(ContextRefreshedEvent arg0) {
-		initCOS();
-		if (Constant.IS_TASK) {
-			doExtractResult();// 澶勭悊鎻愮幇缁撴灉
-			doTaoBaoOrders();// 澶勭悊娣樺疂璁㈠崟
-			doTaoBaoNewOrders();// 澶勭悊娣樺疂璁㈠崟锛堝垰鍒氫骇鐢熺殑锛�
-			doOrderFanLiNew();// 鏂扮増杩斿埄
-			doOrderTiChengFanLi();// 澶勭悊璁㈠崟鎻愭垚杩斿埄
-			doWeiQuanOrder();// 澶勭悊缁存潈璁㈠崟
-			doPushIOS();// 澶勭悊鍙戦�両OS娑堟伅
-			doThreeSaleUserCouponJob();// 澶勭悊閭�璇烽槦鍒�
-			doUserMoneyDebtJob();// 鍊哄姟鍋胯繕
-			initScheduler();// 鍚姩鍟嗗搧鏇存柊瀹氭椂浠诲姟
-			doUpdateGoodsJob(); // 鏇存柊鍟嗗搧闃熷垪
-			doJDOrderJob();// 浜笢璁㈠崟澶勭悊
-			doPDDOrderJob();// 鎷煎澶氳鍗曞鐞�
-			doImportantTaoBaoGoodsUpdateJob();// 娣樺疂閲嶈鍟嗗搧鐨勪俊鎭洿鏂�
-			doHongBaoRecieveIntegralGetJob();// 杩斿埄鍒拌处锛岄噾甯佸鍔�
-			doPlaceOrderIntegralJob();// 涓嬪崟璧犻�侀噾甯佷换鍔�
-		}
-
-	}
-
-	/**
-	 * 瀵硅薄瀛樺偍鍒濆鍖�
-	 */
-	public static void initCOS() {
-		// 杞藉叆cos鍙傛暟
-		Properties ps = org.yeshi.utils.PropertiesUtil
-				.getProperties(SpringContext.class.getClassLoader().getResourceAsStream("cos.properties"));
-		COSInitParams params = new COSInitParams();
-		params.setAppId(Long.parseLong(ps.getProperty("appId")));
-		params.setBucketName(ps.getProperty("bucketName"));
-		params.setRegion(ps.getProperty("region"));
-		params.setSecretId(ps.getProperty("secretId"));
-		params.setSecretKey(ps.getProperty("secretKey"));
-		// 鍒濆鍖�
-		COSManager.getInstance().init(params);
-	}
-
-	/**
-	 * 澶勭悊鎻愮幇缁撴灉鐨勯槦鍒�
-	 */
-	public void doExtractResult() {
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				while (true) {
-
-					try {
-
-						Map<String, AlipayTransferResultInfo> map = CMQManager.getInstance().consumeExtractResultMsg(1);
-
-						if (map != null) {
-							Iterator<String> its = map.keySet().iterator();
-							while (its.hasNext()) {
-
-								String key = its.next();
-								try {
-									extractService.processExtractResult(map.get(key));
-									CMQManager.getInstance().deleteExtractResultMsg(key);
-								} catch (Exception e) {
-									try {
-										LogHelper.errorDetailInfo(e);
-									} catch (Exception e1) {
-										e1.printStackTrace();
-									}
-								}
-							}
-						}
-					} catch (Exception e) {
-					}
-				}
-			}
-		});
-	}
-
-	/**
-	 * 澶勭悊娣樺疂璁㈠崟
-	 */
-	public void doTaoBaoOrders() {
-		// 鍚屾椂寮�鍚�3涓嚎绋嬪鐞�
-		for (int i = 0; i < 3; i++) {
-			executor.execute(new Runnable() {
-				@Override
-				public void run() {
-					while (true) {
-						try {
-
-							// 鍙�16涓鍗�
-							List<String> orderIds = CMQManager.getInstance().consumeTaoBaoOrderMsg(16);
-							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);
-										LogHelper.orderInfo("寮�濮嬪鐞嗚鍗�:" + orderId);
-										orderProcessService.processOrder(map);
-										LogHelper.orderInfo("缁撴潫澶勭悊璁㈠崟:" + orderId);
-									}
-								}
-							}
-						} catch (Exception e) {
-							try {
-								LogHelper.errorDetailInfo(e);
-							} catch (Exception e1) {
-
-							}
-						}
-					}
-				}
-			});
-		}
-	}
-
-	/**
-	 * 鍒氬垰浜х敓鐨勮鍗�
-	 */
-	public void doTaoBaoNewOrders() {
-		// 鍚屾椂寮�鍚�3涓嚎绋嬪鐞�
-		for (int i = 0; i < 1; i++) {
-			executor.execute(new Runnable() {
-				@Override
-				public void run() {
-					while (true) {
-						try {
-							// 鍙�16涓鍗�
-							List<String> orderIds = CMQManager.getInstance().consumeTaoBaoNewOrderMsg(16);
-							Map<String, List<TaoBaoOrder>> map = new HashMap<>();
-							if (orderIds != null) {
-								for (String orderId : orderIds) {
-									List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
-									map.put(orderId, orderList);
-
-									LogHelper.orderInfo("鏂拌鍗�-寮�濮嬪鐞嗚鍗�:" + orderId);
-									long startTime = System.currentTimeMillis();
-									orderProcessService.processOrder(map);
-									LogHelper.orderInfo("鏂拌鍗�-缁撴潫澶勭悊璁㈠崟:" + orderId + "-  澶勭悊鏃堕棿:"
-											+ (System.currentTimeMillis() - startTime));
-								}
-							}
-						} catch (Exception e) {
-							try {
-								LogHelper.errorDetailInfo(e);
-							} catch (Exception e1) {
-
-							}
-						}
-					}
-				}
-			});
-		}
-	}
-
-	/**
-	 * 澶勭悊鏂扮増娣樺疂璁㈠崟杩斿埄
-	 */
-	public void doOrderFanLiNew() {
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				while (true) {
-					try {
-						Map<String, HongBaoV2> map = CMQManager.getInstance().consumeFanLiMsgNew(16);
-						if (map != null) {
-							Iterator<String> its = map.keySet().iterator();
-							while (its.hasNext()) {
-								String handler = its.next();
-								try {
-									HongBaoV2 hongbao = map.get(handler);
-									if (hongbao != null) {
-										String key = "hongbao-fanli-" + hongbao.getId();
-										if (StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
-											// 澶勭悊涔嬪悗瑕侀殧2灏忔椂鍐嶆杩涜澶勭悊
-											redisManager.cacheCommonString(key, "1", 60 * 60 * 2);
-											orderProcessService.fanli(map.get(handler));
-										}
-									}
-									CMQManager.getInstance().deleteFanLiMsgNew(handler);
-								} catch (TaoBaoWeiQuanException e) {
-									try {
-										LogHelper.errorDetailInfo(e);
-									} catch (Exception e1) {
-										e1.printStackTrace();
-									}
-								} catch (Exception e) {
-									try {
-										LogHelper.errorDetailInfo(e, "HongBaoV2-ID:" + map.get(handler).getId(), "");
-									} catch (Exception e1) {
-										e1.printStackTrace();
-									}
-								}
-							}
-						}
-
-					} catch (Exception e) {
-
-					}
-				}
-			}
-		});
-	}
-
-	/**
-	 * 澶勭悊娣樺疂鎻愭垚璁㈠崟杩斿埄
-	 */
-	public void doOrderTiChengFanLi() {
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				while (true) {
-					try {
-
-						Map<String, Long> map = CMQManager.getInstance().consumeFanLiTiChengMsg(16);
-						if (map != null) {
-							Iterator<String> its = map.keySet().iterator();
-							while (its.hasNext()) {
-								String handler = its.next();
-								try {
-									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 doWeiQuanOrder() {
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				while (true) {
-					try {
-
-						Map<String, TaoBaoWeiQuanOrder> map = CMQManager.getInstance().consumeWeiQuanOrderMsg(16);
-						if (map != null) {
-							Iterator<String> its = map.keySet().iterator();
-							while (its.hasNext()) {
-								String handler = its.next();
-								try {
-									orderProcessService.weiQuanOrder(map.get(handler));
-									CMQManager.getInstance().deleteWeiQuanOrderMsg(handler);
-								} catch (Exception e) {
-									try {
-										LogHelper.errorDetailInfo(e);
-									} catch (Exception e1) {
-										e1.printStackTrace();
-									}
-								}
-							}
-						}
-					} catch (Exception e) {
-
-					}
-				}
-			}
-		});
-	}
-
-	/**
-	 * IOS 鎺ㄩ�佹秷鎭�
-	 */
-	public void doPushIOS() {
-
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-
-				while (true) {
-					try {
-
-						Map<String, PushQueueRecord> map = CMQManager.getInstance().consumeIOSPushMsg(10);
-
-						if (map != null) {
-
-							Iterator<String> its = map.keySet().iterator();
-							while (its.hasNext()) {
-
-								String key = its.next();
-								try {
-									iosPushService.readyPushIOS(map.get(key));
-
-									CMQManager.getInstance().deleteIOSPushMsg(key);
-
-								} catch (Exception e) {
-									try {
-										LogHelper.errorDetailInfo(e);
-									} catch (Exception e1) {
-										e1.printStackTrace();
-									}
-								}
-							}
-						}
-					} catch (Exception e) {
-						LogHelper.errorDetailInfo(e);
-					}
-				}
-			}
-		});
-
-	}
-
-	/**
-	 * 鍒涘缓Scheduler()鎵ц鑷姩鐖彇
-	 */
-	private void initScheduler() {
-		boutiqueAutoRuleService.startScheduler();
-	}
-
-	/**
-	 * 鏇存柊绮鹃�夊簱鍟嗗搧
-	 */
-	public void doUpdateGoodsJob() {
-		for (int i = 0; i < 1; i++)
-			executor.execute(new Runnable() {
-				@Override
-				public void run() {
-					while (true) {
-						try {
-							Map<String, Long> map = CMQManager.getInstance().consumeNeedUpdateTaoBaoGoodsIdMsg(16);
-							if (map != null) {
-								Iterator<String> its = map.keySet().iterator();
-								while (its.hasNext()) {
-									String key = its.next();
-									taoBaoGoodsUpdateService.updateByTaoKeGoodsDetail(Long.parseLong(key));
-									CMQManager.getInstance().deleteNeedUpdateTaoBaoGoodsIdMsg(key);
-								}
-							}
-						} catch (Exception e) {
-							e.printStackTrace();
-							LogHelper.error("鏇存柊鍟嗗搧鍑洪敊:" + e.getMessage());
-						}
-					}
-				}
-			});
-	}
-
-	/**
-	 * 閭�璇峰叧绯诲彉鍖栧悗鍒哥殑鏇存柊
-	 */
-	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());
-
-						}
-					}
-				}
-			});
-
-	}
-
-	/**
-	 * 鐢ㄦ埛鍊熻捶澶勭悊
-	 */
-	public void doUserMoneyDebtJob() {
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				while (true) {
-					try {
-						Map<String, UserMoneyChangeDTO> map = UserMoneyChangeCMQManager.getInstance()
-								.consumeQueueMsg(UserMoneyChangeCMQManager.QUEUE_DEBT, 16);
-						if (map != null) {
-
-							Iterator<String> its = map.keySet().iterator();
-							while (its.hasNext()) {
-								String key = its.next();
-								try {
-									UserMoneyChangeDTO dto = map.get(key);
-									if (dto != null && dto.getChangeMoney().compareTo(new BigDecimal(0)) > 0) {
-										userMoneyDebtService.repayDebt(dto.getUid());
-									}
-									UserMoneyChangeCMQManager.getInstance()
-											.deleteQueueMsg(UserMoneyChangeCMQManager.QUEUE_DEBT, key);
-								} catch (Exception e) {
-									try {
-										LogHelper.errorDetailInfo(e);
-									} catch (Exception e1) {
-										e1.printStackTrace();
-									}
-								}
-							}
-						}
-					} catch (Exception e) {
-						LogHelper.error("杩樻鍑洪敊:" + e.getMessage());
-					}
-				}
-			}
-		});
-	}
-
-	public void doJDOrderJob() {
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				while (true) {
-					try {
-						Map<String, String> map = JDOrderCMQManager.getInstance().consumeJDOrder(16);
-						if (map != null) {
-							Iterator<String> its = map.keySet().iterator();
-							while (its.hasNext()) {
-								String key = its.next();
-								try {
-									String orderId = map.get(key);
-									if (!StringUtil.isNullOrEmpty(orderId)) {
-										JDOrder order = jdOrderService.selectDetailByOrderId(Long.parseLong(orderId));
-										orderProcessService.processJDOrder(order);
-									}
-									JDOrderCMQManager.getInstance().deleteJDOrder(key);
-								} catch (Exception e) {
-									try {
-										LogHelper.errorDetailInfo(e);
-									} catch (Exception e1) {
-										e1.printStackTrace();
-									}
-								}
-							}
-						}
-					} catch (Exception e) {
-						LogHelper.error("鎷煎澶氳鍗曞嚭閿�:" + e.getMessage());
-
-					}
-				}
-			}
-		});
-
-	}
-
-	public void doPDDOrderJob() {
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				while (true) {
-					try {
-						Map<String, String> map = PDDOrderCMQManager.getInstance().consumePDDOrder(16);
-						if (map != null) {
-							Iterator<String> its = map.keySet().iterator();
-							while (its.hasNext()) {
-								String key = its.next();
-								try {
-									String orderId = map.get(key);
-									if (!StringUtil.isNullOrEmpty(orderId)) {
-										List<PDDOrder> orderList = pddOrderService.selectByOrderSn(orderId);
-										if (orderList != null)
-											for (PDDOrder order : orderList)
-												orderProcessService.processPDDOrder(order);
-									}
-									PDDOrderCMQManager.getInstance().deletePDDOrder(key);
-								} catch (Exception e) {
-									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 鎶栭煶鐨勬暟鎹洖璋�
-							}
-						}
-					}
-				}
-			}
-		});
-	}
+    /**
+     * 瀵硅薄瀛樺偍鍒濆鍖�
+     */
+    public static void initCOS() {
+        // 杞藉叆cos鍙傛暟
+        Properties ps = org.yeshi.utils.PropertiesUtil
+                .getProperties(SpringContext.class.getClassLoader().getResourceAsStream("cos.properties"));
+        COSInitParams params = new COSInitParams();
+        params.setAppId(Long.parseLong(ps.getProperty("appId")));
+        params.setBucketName(ps.getProperty("bucketName"));
+        params.setRegion(ps.getProperty("region"));
+        params.setSecretId(ps.getProperty("secretId"));
+        params.setSecretKey(ps.getProperty("secretKey"));
+        // 鍒濆鍖�
+        COSManager.getInstance().init(params);
+    }
 
 }

--
Gitblit v1.8.0