| | |
| | | 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;
|
| | |
| | |
|
| | | 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;
|
| | | 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.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.exception.TaoBaoWeiQuanException;
|
| | | 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.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.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;
|
| | |
|
| | | 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();// 处理发送IOS消息
|
| | | doThreeSaleUserCouponJob();// 处理邀请队列
|
| | | doUserMoneyDebtJob();// 债务偿还
|
| | | initScheduler();// 启动商品更新定时任务
|
| | | doUpdateGoodsJob(); // 更新商品队列
|
| | | doJDOrderJob();// 京东订单处理
|
| | | doPDDOrderJob();// 拼多多订单处理
|
| | | doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 对象存储初始化
|
| | | */
|
| | | 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) {
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购
|
| | | // TODO 添加加金币事件
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享赚
|
| | | // TODO 添加加金币事件
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI
|
| | | || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级邀请赚
|
| | | // TODO 添加加金币事件
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI
|
| | | || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级邀请赚
|
| | | // TODO 添加加金币事件
|
| | | }
|
| | | }
|
| | | HongBaoRecieveCMQManager.getInstance()
|
| | | .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } finally {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | | /**
|
| | | * 对象存储初始化
|
| | | */
|
| | | 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);
|
| | | }
|
| | |
|
| | | }
|