| | |
| | | package com.yeshi.makemoney.app; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.yeshi.makemoney.app.dto.mq.ExtractTransferResultMQMsg; |
| | | import com.yeshi.makemoney.app.dto.mq.GoldCornSettleMQMsg; |
| | | import com.yeshi.makemoney.app.exception.goldcorn.GoldCornConsumeRecordException; |
| | | import com.yeshi.makemoney.app.exception.goldcorn.GoldCornMoneyExchangeRateRecordException; |
| | | import com.yeshi.makemoney.app.exception.money.UserMoneyRecordException; |
| | | import com.yeshi.makemoney.app.exception.user.UserInfoException; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornSettleService; |
| | | import com.yeshi.makemoney.app.service.inter.money.ExtractService; |
| | | import com.yeshi.makemoney.app.utils.Constant; |
| | | import com.yeshi.makemoney.app.utils.LogUtil; |
| | | import com.yeshi.makemoney.app.utils.mq.CMQManager; |
| | | import org.mybatis.spring.annotation.MapperScan; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | import org.yeshi.utils.tencentcloud.COSManager; |
| | | import org.yeshi.utils.tencentcloud.entity.COSInitParams; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.MultipartConfigElement; |
| | | import java.io.File; |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | import java.util.Properties; |
| | | |
| | | //不引入数据库 |
| | |
| | | @EnableTransactionManagement |
| | | //@EnableDubbo(scanBasePackages = "com.ks.push.service.remote") |
| | | public class Application implements ApplicationListener<ContextRefreshedEvent> { |
| | | Logger settleLogger= LoggerFactory.getLogger("settleLog"); |
| | | private final static Logger logger = LoggerFactory.getLogger(Application.class); |
| | | |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(Application.class, args); |
| | | logger.info(Constant.wxTransferConfig.toString()); |
| | | logger.info("应用启动成功"); |
| | | } |
| | | |
| | |
| | | logger.info("容器加载完毕"); |
| | | initMQMsgConsumer(); |
| | | initCOS(); |
| | | LogUtil.settleLogger.info("test123"); |
| | | |
| | | } |
| | | |
| | | @Resource |
| | | private GoldCornSettleService goldCornSettleService; |
| | | |
| | | @Resource |
| | | private ExtractService extractService; |
| | | |
| | | private void initMQMsgConsumer() { |
| | | final int THREAD_NUM = 3; |
| | |
| | | @Override |
| | | public void run() { |
| | | |
| | | Map<String, GoldCornSettleMQMsg> map = CMQManager.getInstance().consumeGoldCornSettleMsg(10); |
| | | if (map != null) { |
| | | for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) { |
| | | String key = its.next(); |
| | | GoldCornSettleMQMsg msg = map.get(key); |
| | | try { |
| | | settleLogger.info("消费结算消息开始:{}",new Gson().toJson(msg)); |
| | | goldCornSettleService.settle(msg.getUid(), msg.getDay(),msg.getSettleId()); |
| | | CMQManager.getInstance().deleteGoldCornSettleMsg(key); |
| | | settleLogger.info("消费结算消息成功:{}",new Gson().toJson(msg)); |
| | | } catch (UserInfoException e) { |
| | | e.printStackTrace(); |
| | | settleLogger.error("消费结算消息异常:{} ",new Gson().toJson(msg),e); |
| | | } catch (GoldCornMoneyExchangeRateRecordException e) { |
| | | e.printStackTrace(); |
| | | settleLogger.error("消费结算消息异常:{} ",new Gson().toJson(msg),e); |
| | | } catch (UserMoneyRecordException e) { |
| | | e.printStackTrace(); |
| | | settleLogger.error("消费结算消息异常:{} ",new Gson().toJson(msg),e); |
| | | } catch (GoldCornConsumeRecordException e) { |
| | | e.printStackTrace(); |
| | | settleLogger.error("消费结算消息异常:{} ",new Gson().toJson(msg),e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | settleLogger.error("消费结算消息异常:{} ",new Gson().toJson(msg),e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //处理提现结果 |
| | | new JobThreadExecutorServiceImpl().run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Map<String, ExtractTransferResultMQMsg> map = CMQManager.getInstance().consumeExtractResultMsg(1); |
| | | if (map != null) { |
| | | for (Iterator<String> its = map.keySet().iterator(); its.hasNext(); ) { |
| | | String key = its.next(); |
| | | ExtractTransferResultMQMsg msg = map.get(key); |
| | | try { |
| | | extractService.processExtractResult(msg); |
| | | CMQManager.getInstance().deleteExtractResultMsg(key); |
| | | } catch (ParamsException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | |