| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | */ |
| | | @Service |
| | | public class GoldCornSettleServiceImpl implements GoldCornSettleService { |
| | | Logger settleLogger= LoggerFactory.getLogger("settleLog"); |
| | | |
| | | @Resource |
| | | private GoldCornGetRecordService goldCornGetRecordService; |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | |
| | | 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); |