admin
2022-05-10 2922e51a7a8e657a8467c818ae16700e41ddac77
app/src/main/java/com/yeshi/makemoney/app/Application.java
@@ -1,11 +1,15 @@
package com.yeshi.makemoney.app;
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.mq.CMQManager;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
@@ -40,6 +44,7 @@
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
        logger.info(Constant.wxTransferConfig.toString());
        logger.info("应用启动成功");
    }
@@ -53,6 +58,9 @@
    @Resource
    private GoldCornSettleService goldCornSettleService;
    @Resource
    private ExtractService extractService;
    private void initMQMsgConsumer() {
        final int THREAD_NUM = 3;
@@ -68,7 +76,7 @@
                            String key = its.next();
                            GoldCornSettleMQMsg msg = map.get(key);
                            try {
                                goldCornSettleService.settle(msg.getUid(), msg.getDay());
                                goldCornSettleService.settle(msg.getUid(), msg.getDay(),msg.getSettleId());
                                CMQManager.getInstance().deleteGoldCornSettleMsg(key);
                            } catch (UserInfoException e) {
                                e.printStackTrace();
@@ -78,7 +86,7 @@
                                e.printStackTrace();
                            } catch (GoldCornConsumeRecordException e) {
                                e.printStackTrace();
                            }catch (Exception e){
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
@@ -88,6 +96,27 @@
                }
            });
        }
        //处理提现结果
        new JobThreadExecutorServiceImpl().run(new Runnable() {
            @Override
            public void run() {
                Map<String, ExtractTransferResultMQMsg> map = CMQManager.getInstance().consumeExtractResultMsg(10);
                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();
                        }
                    }
                }
            }
        });
    }