| | |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.ThreadUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | */ |
| | | @Service |
| | | public class GoldCornSettleServiceImpl implements GoldCornSettleService { |
| | | Logger settleLogger= LoggerFactory.getLogger("settleLog"); |
| | | Logger settleLogger = LoggerFactory.getLogger("settleLog"); |
| | | |
| | | @Resource |
| | | private GoldCornGetRecordService goldCornGetRecordService; |
| | |
| | | private GoldCornSettleRecordService goldCornSettleRecordService; |
| | | |
| | | @Override |
| | | public void startSettle(Date date, String remarks, SystemEnum system) throws GoldCornSettleRecordException, ParamsException { |
| | | public void startSettle(Date date, String remarks, SystemEnum system) throws Exception { |
| | | String day = GoldCornUtil.getFormatDay(date); |
| | | |
| | | if (GoldCornUtil.convertFormatDay(day).getTime() >= GoldCornUtil.convertFormatDay(GoldCornUtil.getFormatDay(new Date())).getTime()) { |
| | |
| | | record.setSettledUserCount(0L); |
| | | goldCornSettleRecordService.add(record); |
| | | |
| | | int pageSize = 1000; |
| | | int pageSize = 16; |
| | | int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | for (int i = 0; i < page; i++) { |
| | | List<Long> list = goldCornGetRecordService.getUidsByDay(day, i + 1, pageSize); |
| | | List<Long> list = goldCornGetRecordService.getUidsByDay(record.getDay(), i + 1, pageSize); |
| | | List<GoldCornSettleMQMsg> msgList = new ArrayList<>(); |
| | | for (Long uid : list) { |
| | | //加入到CMQ |
| | | GoldCornSettleMQMsg msg= new GoldCornSettleMQMsg(record.getId(), uid, day, System.currentTimeMillis()); |
| | | settleLogger.info("加入结算队列:{}",new Gson().toJson(msg)); |
| | | CMQManager.getInstance().addGoldCornSettleMsg(msg); |
| | | GoldCornSettleMQMsg msg = new GoldCornSettleMQMsg(record.getId(), uid, day, System.currentTimeMillis()); |
| | | msgList.add(msg); |
| | | settleLogger.info("加入结算队列:{}", new Gson().toJson(msg)); |
| | | } |
| | | //加入到CMQ |
| | | CMQManager.getInstance().addGoldCornSettleMsg(msgList); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | long cornNum = goldCornGetRecordService.getGoldCornByDay(uid, GoldCornUtil.convertFormatDay(day)); |
| | | //金币数量 |
| | | GoldCornConsumeRecord record = GoldCornConsumeRecordFactory.createExchange(uid, day, (int) cornNum, rate, settleId); |
| | | if(goldCornConsumeRecordService.get(record.getId())!=null){ |
| | | if (goldCornConsumeRecordService.get(record.getId()) != null) { |
| | | //已经结算过了 |
| | | return; |
| | | } |