| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | | import org.yeshi.utils.tencentcloud.entity.COSInitParams;
|
| | |
|
| | | import com.yeshi.fanli.dto.money.UserMoneyChangeDTO;
|
| | | import com.yeshi.fanli.entity.bus.user.AlipayTransferResultInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | |
| | | import com.yeshi.fanli.service.inter.lable.BoutiqueAutoRuleService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFactoryService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDebtService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.push.IOSPushService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.cmq.ThreeSaleCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.UserMoneyChangeCMQManager;
|
| | |
|
| | | /**
|
| | | * 系统初始化
|
| | |
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyDebtService userMoneyDebtService;
|
| | |
|
| | | private static boolean isInited = false;
|
| | |
|
| | | public void onApplicationEvent(ContextRefreshedEvent arg0) {
|
| | |
| | | doPushIOS();// 处理发送IOS消息
|
| | | doThreeSaleUserCouponJob();// 处理邀请队列
|
| | | doUpdateGoodsJob();
|
| | | doUserMoneyDebtJob();// 债务偿还
|
| | | } else if (!Constant.IS_TEST) {
|
| | | initScheduler();// 启动定时任务
|
| | | //
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | boutiqueAutoRuleService.startScheduler();
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 更新精选库商品
|
| | | */
|
| | | public void doUpdateGoodsJob() {
|
| | |
|
| | | // 采用4个线程做更新
|
| | | 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();
|
| | | try {
|
| | | Long goodsId = map.get(key);
|
| | | List<Long> list = new ArrayList<>();
|
| | | list.add(goodsId);
|
| | | qualityFactoryService.updateGoodsFactory(list);
|
| | | CMQManager.getInstance().deleteNeedUpdateTaoBaoGoodsIdMsg(key);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | qualityFactoryService.updateQualityGoods(map.get(its.next()));
|
| | | CMQManager.getInstance().deleteNeedUpdateTaoBaoGoodsIdMsg(its.next());
|
| | | }
|
| | | }
|
| | | } 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());
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|