admin
2022-09-30 ffc56f912da5d6d842142ae4ea1856bc56f8bcb9
app/src/main/java/com/yeshi/makemoney/app/service/impl/goldcorn/GoldCornSettleServiceImpl.java
@@ -1,5 +1,6 @@
package com.yeshi.makemoney.app.service.impl.goldcorn;
import com.google.gson.Gson;
import com.ks.lib.common.exception.ParamsException;
import com.ks.push.exception.BPushTaskException;
import com.yeshi.makemoney.app.dto.mq.GoldCornSettleMQMsg;
@@ -25,6 +26,8 @@
import com.yeshi.makemoney.app.utils.factory.msg.UserMsgFactory;
import com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil;
import com.yeshi.makemoney.app.utils.mq.CMQManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.yeshi.utils.ThreadUtil;
@@ -44,6 +47,7 @@
 */
@Service
public class GoldCornSettleServiceImpl implements GoldCornSettleService {
    Logger settleLogger= LoggerFactory.getLogger("settleLog");
    @Resource
    private GoldCornGetRecordService goldCornGetRecordService;
@@ -110,7 +114,9 @@
            List<Long> list = goldCornGetRecordService.getUidsByDay(day, i + 1, pageSize);
            for (Long uid : list) {
                //加入到CMQ
                CMQManager.getInstance().addGoldCornSettleMsg(new GoldCornSettleMQMsg(record.getId(), uid, day, System.currentTimeMillis()));
                GoldCornSettleMQMsg msg=  new GoldCornSettleMQMsg(record.getId(), uid, day, System.currentTimeMillis());
                settleLogger.info("加入结算队列:{}",new Gson().toJson(msg));
                CMQManager.getInstance().addGoldCornSettleMsg(msg);
            }
        }
@@ -123,6 +129,11 @@
        long cornNum = goldCornGetRecordService.getGoldCornByDay(uid, GoldCornUtil.convertFormatDay(day));
        //金币数量
        GoldCornConsumeRecord record = GoldCornConsumeRecordFactory.createExchange(uid, day, (int) cornNum, rate, settleId);
        if(goldCornConsumeRecordService.get(record.getId())!=null){
            //已经结算过了
            return;
        }
        try {
            UserMoneyRecord moneyRecord = UserMoneyRecordFactory.createGoldCornExchange(record);
            userMoneyService.addUserMoney(moneyRecord);