| | |
| | |
|
| | | 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.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | 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.ad.DouYinClickEventService;
|
| | | import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
|
| | |
| | | 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.cmq.DouYinDeviceActiveCMQManager;
|
| | | 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.util.cmq.order.JDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.order.PDDOrderCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.order.PlaceOrderCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.order.TeamOrderCMQManager;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | /**
|
| | |
| | | @Resource
|
| | | private DeviceActiveService deviceActiveService;
|
| | |
|
| | | @Resource
|
| | | private TeamDividentsManager teamDividentsManager;
|
| | |
|
| | | @Resource
|
| | | private TeamEincomeManager teamEincomeManager;
|
| | |
|
| | | private static boolean isInited = false;
|
| | |
|
| | | public void onApplicationEvent(ContextRefreshedEvent arg0) {
|
| | |
| | | doTaoBaoOrders();// 处理淘宝订单
|
| | | doTaoBaoNewOrders();// 处理淘宝订单(刚刚产生的)
|
| | | doOrderFanLiNew();// 新版返利
|
| | | doOrderTiChengFanLi();// 处理订单提成返利
|
| | |
|
| | | doOrderShareFanLi();
|
| | | doWeiQuanOrder();// 处理维权订单
|
| | | doPushIOS();// 处理发送IOS消息
|
| | | doThreeSaleUserCouponJob();// 处理邀请队列
|
| | | doUserMoneyDebtJob();// 债务偿还
|
| | | initScheduler();// 启动商品更新定时任务
|
| | | doUpdateGoodsJob(); // 更新商品队列
|
| | |
| | | doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加
|
| | | // doPlaceOrderIntegralJob();// 下单赠送金币任务
|
| | | // doDouYinDeviceActiveJob();// 抖音设备激活广告监测
|
| | | doOrderTeamIncomePreFanLi();// 处理订单提成返利
|
| | | doDividentsPreJob();
|
| | |
|
| | | doOrderTeamIncomeFanLi();
|
| | | doDividentsJob();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | try {
|
| | | HongBaoV2 hongbao = map.get(handler);
|
| | | if (hongbao != null) {
|
| | | String key = "hongbao-fanli-" + hongbao.getId();
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.hongBaoFanLi,
|
| | | hongbao.getId() + "");
|
| | | if (StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
|
| | | // 处理之后要隔2小时再次进行处理
|
| | | redisManager.cacheCommonString(key, "1", 60 * 60 * 2);
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 处理淘宝提成订单返利
|
| | | * 处理团队订单返利
|
| | | */
|
| | | public void doOrderTiChengFanLi() {
|
| | | public void doOrderTeamIncomePreFanLi() {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | try {
|
| | |
|
| | | Map<String, Long> map = CMQManager.getInstance().consumeFanLiTiChengMsg(16);
|
| | | 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 {
|
| | | orderProcessService.fanliInvaiteAndShare(map.get(handler));
|
| | | CMQManager.getInstance().deleteFanLiTiChengMsg(handler);
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | UidDateDTO dto = map.get(handler);
|
| | | orderProcessService.fanliPreInvaite(dto.getUid(), dto.getDate());
|
| | | TeamOrderCMQManager.getInstance().deleteTeamIncomePreMsg(handler);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | LogHelper.errorDetailInfo(e, map.get(handler).toString(), "");
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理团队订单返利
|
| | | */
|
| | | public void doOrderTeamIncomeFanLi() {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | 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);
|
| | | teamEincomeManager.addTeamIncomeTOUserAccount(dto.getDate(), dto.getUid());
|
| | | TeamOrderCMQManager.getInstance().deleteTeamIncomeMsg(handler);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, map.get(handler).toString(), "");
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理分享订单返利
|
| | | */
|
| | | public void doOrderShareFanLi() {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | 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(), "");
|
| | |
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 邀请关系变化后券的更新
|
| | | */
|
| | | 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());
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | 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<>();
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | HongBaoRecieveCMQManager.getInstance()
|
| | | .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
|
| | |
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | 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) {
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | // 分红
|
| | | public void doDividentsPreJob() {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | 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() {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | 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 {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | }
|