admin
2022-10-28 0e9b6603d4ae9d11c1fbc90257ce816c5807b8ff
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;
@@ -23,6 +26,7 @@
import javax.servlet.http.HttpSession;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -42,6 +46,9 @@
    @Resource
    private GoldCornConsumeRecordService goldCornConsumeRecordService;
    @Resource
    private GoldCornGetRecordService goldCornGetRecordService;
    private Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
@@ -91,6 +98,9 @@
        } catch (ParamsException e) {
            e.printStackTrace();
            return JsonUtil.loadFalseResult(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return JsonUtil.loadFalseResult(e.getMessage());
        }
    }
@@ -138,4 +148,36 @@
    }
    @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 = 16;
        int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
        try {
            for (int i = 0; i < page; i++) {
                List<Long> list = goldCornGetRecordService.getUidsByDay(record.getDay(), i + 1, pageSize);
                List<GoldCornSettleMQMsg> msgList = new ArrayList<>();
                for (Long uid : list) {
                    msgList.add(new GoldCornSettleMQMsg(record.getId(), uid, record.getDay(), System.currentTimeMillis()));
                }
                //加入到CMQ
                CMQManager.getInstance().addGoldCornSettleMsg(msgList);
            }
        } catch (Exception e) {
            return JsonUtil.loadFalseResult(e.getMessage());
        }
        return JsonUtil.loadTrueResult(gson.toJson(record));
    }
}