| | |
| | | import com.yeshi.fanli.entity.jd.JDOrder;
|
| | | import com.yeshi.fanli.entity.pdd.PDDOrder;
|
| | | import com.yeshi.fanli.entity.push.PushQueueRecord;
|
| | | import com.yeshi.fanli.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.exception.order.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.service.inter.jd.JDOrderService;
|
| | | import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelService;
|
| | |
| | | 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.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | /**
|
| | | * 系统初始化
|
| | |
| | | @Resource
|
| | | private PDDOrderService pddOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | |
|
| | | private static boolean isInited = false;
|
| | |
|
| | | public void onApplicationEvent(ContextRefreshedEvent arg0) {
|
| | |
| | | doUserMoneyDebtJob();// 债务偿还
|
| | | initScheduler();// 启动商品更新定时任务
|
| | | doUpdateGoodsJob(); // 更新商品队列
|
| | | doJDOrderJob();// 京东订单处理
|
| | | doPDDOrderJob();// 拼多多订单处理
|
| | | doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新
|
| | | doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加
|
| | | }
|
| | |
|
| | | doJDOrderJob();// 京东订单处理
|
| | | doPDDOrderJob();// 拼多多订单处理
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | public void run() {
|
| | | while (true) {
|
| | | try {
|
| | |
|
| | | // 取16个订单
|
| | | List<String> orderIds = CMQManager.getInstance().consumeTaoBaoOrderMsg(16);
|
| | | Map<String, List<TaoBaoOrder>> map = new HashMap<>();
|
| | | 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);
|
| | |
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("还款出错:" + e.getMessage());
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | PDDOrderCMQManager.getInstance().deletePDDOrder(key);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("拼多多订单:" + e.getMessage());
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 重要的淘宝商品信息更新
|
| | | */
|
| | | public void doImportantTaoBaoGoodsUpdateJob() {
|
| | | // 开启2个线程做更新
|
| | | for (int i = 0; i < 2; i++)
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | Map<String, Long> map = CMQManager.getInstance().consumeTBImpGoodsUpdateMsg(16);
|
| | | if (map != null) {
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | try {
|
| | | long startTime = System.currentTimeMillis();
|
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.searchGoodsDetail(map.get(key));
|
| | | // 更新一条数据需要的时间
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(goods);
|
| | | long time = System.currentTimeMillis() - startTime;
|
| | | LogHelper.test("淘宝重要商品库更新时间:" + time);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } finally {
|
| | | CMQManager.getInstance().deleteTBImpGoodsUpdateMsg(key);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 红包到账后的金币获取
|
| | | */
|
| | | public void doHongBaoRecieveIntegralGetJob() {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | while (true) {
|
| | | Map<String, Long> map = HongBaoRecieveCMQManager.getInstance()
|
| | | .consumeQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, 16);
|
| | | if (map != null) {
|
| | | Iterator<String> its = map.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | Long hongBaoId = map.get(key);
|
| | | try {
|
| | | HongBaoV2 hongBaoV2 = hongBaoV2Service.selectByPrimaryKey(hongBaoId);
|
| | | if (hongBaoV2 != null && hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU
|
| | | && hongBaoV2.getMoney().compareTo(new BigDecimal(0)) > 0) {
|
| | | if (hongBaoV2.getType() == HongBaoV2.TYPE_ZIGOU) {// 自购
|
| | | integralGetService.addRebateOrder(hongBaoV2.getUserInfo().getId());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_GOODS) {// 分享赚
|
| | | integralGetService.addShareOrder(hongBaoV2.getUserInfo().getId());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_YIJI
|
| | | || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级邀请赚
|
| | | integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId());
|
| | | } else if (hongBaoV2.getType() == HongBaoV2.TYPE_ERJI
|
| | | || hongBaoV2.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级邀请赚
|
| | | integralGetService.addInviteOrderLevelOne(hongBaoV2.getUserInfo().getId());
|
| | | }
|
| | | }
|
| | | HongBaoRecieveCMQManager.getInstance()
|
| | | .deleteQueueMsg(HongBaoRecieveCMQManager.QUEUE_INTEGRAL, key);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } finally {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | }
|
| | |
|
| | | }
|