admin
2019-09-29 6f14a131b39c8fc44b29b6130c4e2002bbf2d3ca
fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -173,10 +173,9 @@
         doPDDOrderJob();// 拼多多订单处理
         doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新
         doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加
         doPlaceOrderIntegralJob();// 下单赠送金币任务
         // doPlaceOrderIntegralJob();// 下单赠送金币任务
         doDouYinDeviceActiveJob();// 抖音设备激活广告监测
      }
   }
   /**
@@ -792,78 +791,82 @@
               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())) {
                           // 统计订单下的用户所获得的返利金额
                           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);
                           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);
                              }
                           }
                        } 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);
                              // 获取上两级数据
                              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);
                                 }
                              }
                           }
                           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);
                           } 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);
                                    }
                                 }
                              }
                           }
                        }
@@ -909,9 +912,11 @@
   // 抖音
   public void doDouYinDeviceActiveJob() {
      LogHelper.test("开始执行:doDouYinDeviceActiveJob");
      executor.execute(new Runnable() {
         @Override
         public void run() {
            LogHelper.test("开始执行:doDouYinDeviceActiveJob-run");
            while (true) {
               Map<String, DouYinDeviceActiveQueueDTO> map = DouYinDeviceActiveCMQManager.getInstance()
                     .consume(16);
@@ -921,34 +926,45 @@
                     String key = its.next();
                     DouYinDeviceActiveQueueDTO active = map.get(key);
                     if (active.getType() == DouYinDeviceActiveQueueDTO.TYPE_AD) {// 抖音
                        DeviceActive deviceActive = deviceActiveService.getFirstActiveInfo(active.getDevice());
                        if (deviceActive != null) {
                           DouYinClickEvent event = douYinClickEventService.selectByAid(active.getAid());
                           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());
                        DouYinClickEvent event = douYinClickEventService.selectByAid(active.getAid());
                        if (event != null) {
                           if (event.getOs() == 0) {
                              DeviceActive deviceActive = deviceActiveService
                                    .getFirstActiveInfoByImei(event.getUuid());
                              if (deviceActive != null) {
                                 if (event != null) {
                                    if (event.getOs() == 0)
                                       DouYinAdUtil.activeAndroid(event.getCallback(), event.getImei(),
                                             deviceActive.getCreateTime().getTime());
                                    else if (event.getOs() == 1)
                                       DouYinAdUtil.activeIOS(event.getCallback(), event.getIdfa(),
                                             deviceActive.getCreateTime().getTime());
                                 }
                              }
                           } else {// TODO 处理IOS
                           }
                        }
                     } else if (active.getType() == DouYinDeviceActiveQueueDTO.TYPE_DEVICE) {// 设备
                        // TODO 兼容IOS
                        if (active.getPlatform() == 1) {
                           DouYinClickEvent event = douYinClickEventService
                                 .selectByAndroidId(active.getDevice());
                           if (event != null) {// 回调
                              DeviceActive deviceActive = deviceActiveService
                                    .getFirstActiveInfo(active.getDevice());
                              if (deviceActive != null)
                                 DouYinAdUtil.activeAndroid(event.getCallback(), event.getImei(),
                                       deviceActive.getCreateTime().getTime());
                           }
                        }
                        if (active.getPlatform() == 1) {
                           DeviceActive deviceActive = deviceActiveService
                                 .getFirstActiveInfo(active.getDevice());
                           if (deviceActive != null && deviceActive.getImei() != null) {
                              DouYinClickEvent event = douYinClickEventService
                                    .selectByUuid(deviceActive.getImei());
                              if (event != null) {// 回调
                                 if (deviceActive != null)
                                    DouYinAdUtil.activeAndroid(event.getCallback(), event.getImei(),
                                          deviceActive.getCreateTime().getTime());
                              }
                           }
                        } else {
                           // TODO 兼容IOS
                        }
                     }
                     DouYinDeviceActiveCMQManager.getInstance().delete(key);
                  }
               }
            }