| | |
| | | package com.yeshi.fanli.service.manger; |
| | | |
| | | 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.dto.push.PushContentDetailDTO; |
| | | import com.yeshi.fanli.entity.ad.DouYinClickEvent; |
| | | import com.yeshi.fanli.entity.bus.user.*; |
| | | 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.suning.SuningOrderInfo; |
| | | 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.impl.JobThreadExecutorServiceImpl; |
| | | import com.yeshi.fanli.service.inter.ad.DouYinClickEventService; |
| | | import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService; |
| | | 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.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.HWPushService; |
| | | import com.yeshi.fanli.service.inter.push.IOSPushService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; |
| | | 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.CMQManager; |
| | | import com.yeshi.fanli.util.RedisKeyEnum; |
| | | import com.yeshi.fanli.util.RedisManager; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | 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.PushCMQManager; |
| | | import com.yeshi.fanli.util.mq.cmq.UserMoneyChangeCMQManager; |
| | | import com.yeshi.fanli.util.mq.cmq.order.*; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.core.task.TaskExecutor; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.NumberUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.lang.reflect.Method; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class JobManager { |
| | | |
| | | Logger orderMoneyLog= LoggerFactory.getLogger("orderMoneyLog"); |
| | | Logger orderMoneyLog = LoggerFactory.getLogger("orderMoneyLog"); |
| | | |
| | | @Resource |
| | | private BoutiqueAutoRuleService boutiqueAutoRuleService; |
| | | |
| | | @Resource |
| | | private ExtractService extractService; |
| | | |
| | | @Resource |
| | | private IOSPushService iosPushService; |
| | | |
| | | @Resource(name = "taskExecutor") |
| | | private TaskExecutor executor; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; |
| | | |
| | | @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; |
| | | |
| | | @Resource |
| | | private DeviceActiveService deviceActiveService; |
| | | |
| | | @Resource |
| | | private TeamDividentsManager teamDividentsManager; |
| | | |
| | | @Resource |
| | | private TeamEincomeManager teamEincomeManager; |
| | | |
| | | @Resource |
| | | private VipShopOrderService vipShopOrderService; |
| | | |
| | | @Resource |
| | | private SuningOrderService suningOrderService; |
| | | |
| | | @Resource |
| | | private HWPushService hwPushService; |
| | |
| | | * 开始任务 |
| | | */ |
| | | public void start() { |
| | | doExtractResult();// 处理提现结果 |
| | | doTaoBaoOrders();// 处理淘宝订单 |
| | | doTaoBaoNewOrders();// 处理淘宝订单(刚刚产生的) |
| | | doOrderFanLiNew();// 新版返利 |
| | | doOrderShareFanLi(); |
| | | doWeiQuanOrder();// 处理维权订单 |
| | | doPushIOS();// 处理发送IOS消息 |
| | | doUserMoneyDebtJob();// 债务偿还 |
| | | initScheduler();// 启动商品更新定时任务 |
| | | doUpdateGoodsJob(); // 更新商品队列 |
| | | doJDOrderJob();// 京东订单处理 |
| | | doPDDOrderJob();// 拼多多订单处理 |
| | | doVipShopOrderJob();// 唯品会订单处理 |
| | | doSuningOrderJob();// 苏宁订单处理 |
| | | doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新 |
| | | doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加 |
| | | // doPlaceOrderIntegralJob();// 下单赠送金币任务 |
| | | // doDouYinDeviceActiveJob();// 抖音设备激活广告监测 |
| | | doOrderTeamIncomePreFanLi();// 处理订单提成返利 |
| | | doDividentsPreJob(); |
| | | |
| | | doOrderTeamRewardFanLi(); |
| | | doDividentsJob(); |
| | | |
| | | //华为推送 |
| | | doHWPushJob(); |
| | | } |
| | | |
| | | /** |
| | |
| | | return thread.getStackTrace()[2].getMethodName(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 处理提现结果的队列 |
| | | */ |
| | | public void doExtractResult() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | // 同时开启3个线程处理 |
| | | for (int i = 0; i < 3; i++) { |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | // 同时开启3个线程处理 |
| | | for (int i = 0; i < 1; i++) { |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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 = RedisKeyEnum.getRedisKey(RedisKeyEnum.hongBaoFanLi, |
| | | 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 doOrderTeamIncomePreFanLi() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | try { |
| | | Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance() |
| | | .consumeFanLiTeamIncomePreMsg(16); |
| | | if (map != null) { |
| | | Iterator<String> its = map.keySet().iterator(); |
| | | while (its.hasNext()) { |
| | | String handler = its.next(); |
| | | try { |
| | | UidDateDTO dto = map.get(handler); |
| | | orderProcessService.fanliPreInvaite(dto.getUid(), dto.getDate()); |
| | | TeamOrderCMQManager.getInstance().deleteTeamIncomePreMsg(handler); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(map.get(handler)).toString(), ""); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 处理团队奖金返利 |
| | | */ |
| | | public void doOrderTeamRewardFanLi() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | try { |
| | | Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance().consumeFanLiTeamIncomeMsg(16); |
| | | if (map != null) { |
| | | Iterator<String> its = map.keySet().iterator(); |
| | | while (its.hasNext()) { |
| | | String handler = its.next(); |
| | | try { |
| | | UidDateDTO dto = map.get(handler); |
| | | orderMoneyLog.info("团队收益结算开始处理:日期-{} Uid-{}",TimeUtil.getGernalTime(dto.getDate().getTime(),"yyyy-MM-dd"),dto.getUid()); |
| | | teamEincomeManager.addTeamRewardTOUserAccount(dto.getDate(), dto.getUid()); |
| | | orderMoneyLog.info("团队收益结算处理成功:日期-{} Uid-{}",TimeUtil.getGernalTime(dto.getDate().getTime(),"yyyy-MM-dd"),dto.getUid()); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, map.get(handler).toString(), ""); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | //无论结算是否成功都删除消息 |
| | | TeamOrderCMQManager.getInstance().deleteTeamIncomeMsg(handler); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 处理分享订单返利 |
| | | */ |
| | | public void doOrderShareFanLi() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | try { |
| | | Map<String, UidDateDTO> map = CMQManager.getInstance().consumeFanLiShareMsg(16); |
| | | if (map != null) { |
| | | Iterator<String> its = map.keySet().iterator(); |
| | | while (its.hasNext()) { |
| | | String handler = its.next(); |
| | | try { |
| | | UidDateDTO dto = map.get(handler); |
| | | orderProcessService.fanliShare(dto.getUid(), dto.getDate()); |
| | | CMQManager.getInstance().deleteFanLiShareMsg(handler); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e, map.get(handler).toString(), ""); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 处理淘宝订单维权 |
| | | */ |
| | | public void doWeiQuanOrder() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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()执行自动爬取 |
| | | */ |
| | |
| | | boutiqueAutoRuleService.startScheduler(); |
| | | } |
| | | |
| | | /** |
| | | * 更新精选库商品 |
| | | */ |
| | | public void doUpdateGoodsJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | for (int i = 0; i < 1; i++) |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | try { |
| | | Map<String, String> map = CMQManager.getInstance().consumeNeedUpdateTaoBaoGoodsIdMsg(16); |
| | | if (map != null) { |
| | | Iterator<String> its = map.keySet().iterator(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | taoBaoGoodsUpdateService.updateByTaoKeGoodsDetail(map.get(key)); |
| | | CMQManager.getInstance().deleteNeedUpdateTaoBaoGoodsIdMsg(key); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | LogHelper.error("更新商品出错:" + e.getMessage()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 用户借贷处理 |
| | | */ |
| | | public void doUserMoneyDebtJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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(); |
| | | LogHelper.test("拼多多订单处理开始:" + key); |
| | | 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); |
| | | LogHelper.test("拼多多订单处理成功:" + key); |
| | | } catch (Exception e) { |
| | | LogHelper.test("拼多多订单处理失败:" + key); |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.error("拼多多订单:" + e.getMessage()); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | public void doVipShopOrderJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | try { |
| | | Map<String, String> map = VipShopOrderCMQManager.getInstance().consumeVipShopOrder(16); |
| | | if (map != null) { |
| | | Iterator<String> its = map.keySet().iterator(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | try { |
| | | String orderId = map.get(key); |
| | | LogHelper.test("唯品会订单消费:" + orderId); |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | List<VipShopOrder> orderList = vipShopOrderService.listDetailByOrderSn(orderId); |
| | | if (orderList != null) |
| | | for (VipShopOrder order : orderList) |
| | | orderProcessService.processVipShopOrder(order); |
| | | } |
| | | VipShopOrderCMQManager.getInstance().deleteVipShopOrder(key); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | public void doSuningOrderJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | try { |
| | | Map<String, String> map = SuningOrderCMQManager.getInstance().consumeSuningOrder(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<SuningOrderInfo> orderList = suningOrderService.listByOrderCode(orderId); |
| | | if (orderList != null) |
| | | for (SuningOrderInfo order : orderList) |
| | | orderProcessService.processSuningOrder(order); |
| | | } |
| | | SuningOrderCMQManager.getInstance().deleteSuningOrder(key); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 重要的淘宝商品信息更新 |
| | | */ |
| | | public void doImportantTaoBaoGoodsUpdateJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | // 开启2个线程做更新 |
| | | for (int i = 0; i < 2; i++) |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | Map<String, String> 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() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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) { |
| | | // 到账送金币 |
| | | fanliGetIntegral(hongBaoV2); |
| | | HongBaoRecieveCMQManager.getInstance() |
| | | .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key); |
| | | |
| | | // 返利不足0.01元送金币 |
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购 |
| | | // 判断是否为该用户的首笔红包 |
| | | List<Integer> typeList = new ArrayList<>(); |
| | | typeList.add(HongBaoV2.TYPE_ZIGOU); |
| | | HongBaoV2 firstHongBao = hongBaoV2Service.getFirstValidHongBaoByTypeAndUid( |
| | | typeList, hongBaoV2.getUserInfo().getId()); |
| | | if (firstHongBao != null |
| | | && firstHongBao.getId().longValue() == hongBaoV2.getId()) {// 自购首单到账 |
| | | // 查询下级红包 |
| | | BigDecimal firstLevelMoney = new BigDecimal(0); |
| | | BigDecimal secondLevelMoney = new BigDecimal(0); |
| | | // 获取改单下面的红包 |
| | | List<HongBaoV2> hongBaoList = new ArrayList<>(); |
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService |
| | | .selectDetailByHongBaoId(hongBaoV2.getId()); |
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {// 计算改订单号下面的所有返利金额 |
| | | CommonOrder commonOrder = hongBaoOrder.getCommonOrder(); |
| | | List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId( |
| | | commonOrder.getSourceType(), commonOrder.getOrderNo()); |
| | | for (CommonOrder co : list) { |
| | | HongBaoOrder hbo = hongBaoOrderService |
| | | .selectDetailByCommonOrderId(co.getId()); |
| | | if (hbo != null && hbo.getHongBaoV2() != null) |
| | | hongBaoList.add(hbo.getHongBaoV2()); |
| | | } |
| | | } |
| | | |
| | | for (HongBaoV2 hb : hongBaoList) { |
| | | List<HongBaoV2> children = hongBaoV2Service |
| | | .listChildrenById(hb.getId()); |
| | | if (children != null) |
| | | for (HongBaoV2 child : children) |
| | | if (child.getType() == HongBaoV2.TYPE_YIJI) { |
| | | firstLevelMoney = firstLevelMoney.add(child.getMoney()); |
| | | } else if (child.getType() == HongBaoV2.TYPE_ERJI) { |
| | | secondLevelMoney = secondLevelMoney.add(child.getMoney()); |
| | | } |
| | | } |
| | | |
| | | // 查询下级的生效时间 |
| | | ThreeSale threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState( |
| | | hongBaoV2.getUserInfo().getId(), ThreeSale.STATE_SUCCESS); |
| | | if (threeSale != null && threeSale.getSucceedTime() != null && threeSale |
| | | .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前 |
| | | // 成功时间要大于20190910日才开始送金币 |
| | | if (threeSale.getSucceedTime() > TimeUtil.convertToTimeTemp("20190901", |
| | | "yyyyMMdd")) { |
| | | if (firstLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 一级返利小于0.01 |
| | | integralTaskRecordService.firstRebateOrderRewardBoss( |
| | | threeSale.getBoss().getId(), |
| | | hongBaoV2.getUserInfo().getId(), null); |
| | | LogHelper.test("自购-一级用户-" + threeSale.getBoss().getId() |
| | | + "-hongBaoId:" + hongBaoV2.getId()); |
| | | } |
| | | } |
| | | } |
| | | // 查询下下级生效时间 |
| | | if (threeSale != null) { |
| | | threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState( |
| | | threeSale.getBoss().getId(), ThreeSale.STATE_SUCCESS); |
| | | if (threeSale != null && threeSale.getSucceedTime() != null && threeSale |
| | | .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前 |
| | | // 成功时间要大于20190910日才开始送金币 |
| | | if (threeSale.getSucceedTime() > TimeUtil |
| | | .convertToTimeTemp("20190901", "yyyyMMdd")) { |
| | | if (secondLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 二级返利小于0.01 |
| | | integralTaskRecordService.firstRebateOrderRewardBossSuper( |
| | | threeSale.getBoss().getId(), |
| | | hongBaoV2.getUserInfo().getId(), null); |
| | | LogHelper.test("自购-二级用户-" + threeSale.getBoss().getId() |
| | | + "-hongBaoId:" + hongBaoV2.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享赚 |
| | | // 判断是否为该用户的首笔红包 |
| | | List<Integer> typeList = new ArrayList<>(); |
| | | typeList.add(HongBaoV2.TYPE_SHARE_GOODS); |
| | | HongBaoV2 firstHongBao = hongBaoV2Service.getFirstValidHongBaoByTypeAndUid( |
| | | typeList, hongBaoV2.getUserInfo().getId()); |
| | | if (firstHongBao != null |
| | | && firstHongBao.getId().longValue() == hongBaoV2.getId()) // 分享首笔到账 |
| | | { |
| | | |
| | | // 查询下级红包 |
| | | BigDecimal firstLevelMoney = new BigDecimal(0); |
| | | // 获取改单下面的红包 |
| | | List<HongBaoV2> hongBaoList = new ArrayList<>(); |
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService |
| | | .selectDetailByHongBaoId(hongBaoV2.getId()); |
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {// 计算改订单号下面的所有返利金额 |
| | | CommonOrder commonOrder = hongBaoOrder.getCommonOrder(); |
| | | List<CommonOrder> list = commonOrderService.listBySourceTypeAndOrderId( |
| | | commonOrder.getSourceType(), commonOrder.getOrderNo()); |
| | | for (CommonOrder co : list) { |
| | | HongBaoOrder hbo = hongBaoOrderService |
| | | .selectDetailByCommonOrderId(co.getId()); |
| | | if (hbo != null && hbo.getHongBaoV2() != null) |
| | | hongBaoList.add(hbo.getHongBaoV2()); |
| | | } |
| | | } |
| | | |
| | | for (HongBaoV2 hb : hongBaoList) { |
| | | List<HongBaoV2> children = hongBaoV2Service |
| | | .listChildrenById(hb.getId()); |
| | | if (children != null) |
| | | for (HongBaoV2 child : children) |
| | | if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) { |
| | | firstLevelMoney = firstLevelMoney.add(child.getMoney()); |
| | | } |
| | | } |
| | | |
| | | ThreeSale threeSale = threeSaleSerivce.selectLatestByWorkerIdAndState( |
| | | hongBaoV2.getUserInfo().getId(), ThreeSale.STATE_SUCCESS); |
| | | if (threeSale != null && threeSale.getSucceedTime() != null && threeSale |
| | | .getSucceedTime() < hongBaoV2.getCreateTime().getTime()) {// 邀请成功的时间是否在下单的时间之前 |
| | | // 成功时间要大于20190910日才开始送金币 |
| | | if (threeSale.getSucceedTime() > TimeUtil.convertToTimeTemp("20190901", |
| | | "yyyyMMdd")) { |
| | | if (firstLevelMoney.compareTo(new BigDecimal("0.01")) < 0) {// 一级返利小于0.01 |
| | | integralTaskRecordService.firstSharerOrderRewardBoss( |
| | | threeSale.getBoss().getId(), |
| | | hongBaoV2.getUserInfo().getId(), null); |
| | | LogHelper.test("分享-一级用户-" + threeSale.getBoss().getId() |
| | | + "-hongBaoId:" + hongBaoV2.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } finally { |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void fanliGetIntegral(HongBaoV2 hongBaoV2) { |
| | | |
| | | if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU |
| | | && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) { |
| | | // 查询对应的订单号 |
| | | Long mainHongBaoId = hongBaoV2.getId(); |
| | | if (hongBaoV2.getParent() != null && hongBaoV2.getParent().getId() != null) |
| | | mainHongBaoId = hongBaoV2.getParent().getId(); |
| | | |
| | | HongBaoOrder hongbaoOrder = hongBaoOrderService.selectDetailByHongBaoId(mainHongBaoId); |
| | | if (hongbaoOrder == null || hongbaoOrder.getCommonOrder() == null) |
| | | return; |
| | | CommonOrder commonOrder = hongbaoOrder.getCommonOrder(); |
| | | |
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购订单 |
| | | integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(), |
| | | commonOrder.getSourceType()); |
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享订单 |
| | | integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(), |
| | | commonOrder.getSourceType()); |
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级邀请 |
| | | integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(), |
| | | commonOrder.getSourceType()); |
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级邀请 |
| | | integralGetService.addInviteOrderLevelTwo(hongBaoV2.getUserInfo().getId(), commonOrder.getOrderNo(), |
| | | commonOrder.getSourceType()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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); |
| | | // 是否是首单 |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | PlaceOrderCMQManager.getInstance().deleteQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, |
| | | key); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 抖音广告监控 |
| | | public void doPlaceOrderAdJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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 抖音的数据回调 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Resource |
| | | private DouYinClickEventService douYinClickEventService; |
| | | |
| | | // 抖音 |
| | | public void doDouYinDeviceActiveJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | LogHelper.test("开始执行:doDouYinDeviceActiveJob"); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | 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 && !StringUtil.isNullOrEmpty(event.getUuid())) { |
| | | 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 && !StringUtil.isNullOrEmpty(deviceActive.getImei())) { |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 分红 |
| | | public void doDividentsPreJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance().consumeTeamDividentsPreMsg(16); |
| | | if (map != null) { |
| | | Iterator<String> its = map.keySet().iterator(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | UidDateDTO dto = map.get(key); |
| | | try { |
| | | teamDividentsManager.addToTeamEincome(dto.getUid(), dto.getDate()); |
| | | TeamOrderCMQManager.getInstance().deleteTeamDividentsPreMsg(key); |
| | | } catch (TeamDividentsRecordException e1) { |
| | | if (e1.getCode() == TeamDividentsRecordException.CODE_EXIST) { |
| | | TeamOrderCMQManager.getInstance().deleteTeamDividentsPreMsg(key); |
| | | } else { |
| | | try { |
| | | LogHelper.errorDetailInfo(e1); |
| | | } catch (Exception e2) { |
| | | e2.printStackTrace(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } finally { |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 分红 |
| | | public void doDividentsJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | Map<String, UidDateDTO> map = TeamOrderCMQManager.getInstance().consumeTeamDividentsMsg(16); |
| | | if (map != null) { |
| | | Iterator<String> its = map.keySet().iterator(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | UidDateDTO dto = map.get(key); |
| | | try { |
| | | teamEincomeManager.addTeamDividentsTOUserAccount(dto.getDate(), dto.getUid()); |
| | | TeamOrderCMQManager.getInstance().deleteTeamDividentsMsg(key); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } finally { |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | // 华为推送 |
| | | public void doHWPushJob() { |
| | | String methodName = getMethodName(Thread.currentThread()); |
| | | new JobThreadExecutorServiceImpl().run(new MyRunnable(methodName) { |
| | | @Override |
| | | public void run() { |
| | | super.run(); |
| | | Map<String, PushContentDetailDTO> map = PushCMQManager.getInstance().consumeHWPush(16); |
| | | if (map != null) { |
| | | Iterator<String> its = map.keySet().iterator(); |
| | | while (its.hasNext()) { |
| | | String key = its.next(); |
| | | PushContentDetailDTO dto = map.get(key); |
| | | LogHelper.pushHW("接受到消息:" + new Gson().toJson(dto)); |
| | | |
| | | try { |
| | | hwPushService.push(dto); |
| | | PushCMQManager.getInstance().deleteHWPush(key); |
| | | } catch (Exception e) { |
| | | try { |
| | | LogHelper.errorDetailInfo(e); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | } finally { |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | } |