admin
2022-09-30 ffc56f912da5d6d842142ae4ea1856bc56f8bcb9
app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornSettleRecordAdminController.java
@@ -2,12 +2,15 @@
import com.google.gson.*;
import com.ks.lib.common.exception.ParamsException;
import com.yeshi.makemoney.app.dto.mq.GoldCornSettleMQMsg;
import com.yeshi.makemoney.app.entity.goldcorn.GoldCornConsumeType;
import com.yeshi.makemoney.app.exception.goldcorn.GoldCornSettleRecordException;
import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornConsumeRecordService;
import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService;
import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornSettleService;
import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornConsumeRecordQuery;
import com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil;
import com.yeshi.makemoney.app.utils.mq.CMQManager;
import com.yeshi.makemoney.app.vo.AcceptAdminData;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@@ -42,6 +45,9 @@
    @Resource
    private GoldCornConsumeRecordService goldCornConsumeRecordService;
    @Resource
    private GoldCornGetRecordService goldCornGetRecordService;
    private Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@@ -138,4 +144,31 @@
    }
    @ResponseBody
    @RequestMapping("retry")
    public String retry(String id, AcceptAdminData acceptAdminData) {
        if (id == null) {
            return JsonUtil.loadFalseResult("ID不能为空");
        }
        GoldCornSettleRecord record = goldCornSettleRecordService.get(id);
        if (record == null) {
            return JsonUtil.loadFalseResult("记录不存在");
        }
        long count = goldCornGetRecordService.countUidsByDay(record.getDay());
        int pageSize = 1000;
        int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
        for (int i = 0; i < page; i++) {
            List<Long> list = goldCornGetRecordService.getUidsByDay(record.getDay(), i + 1, pageSize);
            for (Long uid : list) {
                //加入到CMQ
                CMQManager.getInstance().addGoldCornSettleMsg(new GoldCornSettleMQMsg(record.getId(), uid, record.getDay(), System.currentTimeMillis()));
            }
        }
        return JsonUtil.loadTrueResult(gson.toJson(record));
    }
}