From a44f2c3b5db92069ea2813ecf8cb12a6ab3b2203 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 19 五月 2022 17:04:07 +0800
Subject: [PATCH] 管理员权限雁验证

---
 app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornSettleRecordAdminController.java |   51 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornSettleRecordAdminController.java b/app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornSettleRecordAdminController.java
index d422f20..0fddf80 100644
--- a/app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornSettleRecordAdminController.java
+++ b/app/src/main/java/com/yeshi/makemoney/app/controller/admin/goldcorn/GoldCornSettleRecordAdminController.java
@@ -2,8 +2,11 @@
 
 import com.google.gson.*;
 import com.ks.lib.common.exception.ParamsException;
+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.GoldCornSettleService;
+import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornConsumeRecordQuery;
 import com.yeshi.makemoney.app.utils.goldcorn.GoldCornUtil;
 import com.yeshi.makemoney.app.vo.AcceptAdminData;
 import net.sf.json.JSONArray;
@@ -19,6 +22,7 @@
 import javax.annotation.Resource;
 import javax.servlet.http.HttpSession;
 import java.lang.reflect.Type;
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -36,19 +40,24 @@
     @Resource
     private GoldCornSettleService goldCornSettleService;
 
+    @Resource
+    private GoldCornConsumeRecordService goldCornConsumeRecordService;
+
+    private Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
+
+        @Override
+        public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
+            return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm"));
+        }
+    }).create();
+
     @ResponseBody
     @RequestMapping("list")
     public String list(GoldCornSettleRecordQuery query, int page, int limit) {
         List<GoldCornSettleRecord> list = goldCornSettleRecordService.list(query, page, limit);
         long count = goldCornSettleRecordService.count(query);
         JSONObject data = new JSONObject();
-        Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
 
-            @Override
-            public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
-                return date == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(date.getTime(), "yyyy.MM.dd HH:mm"));
-            }
-        }).create();
 
         data.put("list", gson.toJson(list));
         data.put("count", count);
@@ -100,20 +109,32 @@
 
 
     @ResponseBody
-    @RequestMapping("update")
-    public String update(GoldCornSettleRecord bean, HttpSession session) {
-        if (bean.getId() == null) {
+    @RequestMapping("refresh")
+    public String refresh(String id, AcceptAdminData acceptAdminData) {
+        if (id == null) {
             return JsonUtil.loadFalseResult("ID涓嶈兘涓虹┖");
-
         }
-        try {
-            goldCornSettleRecordService.update(bean);
-        } catch (Exception e) {
-            return JsonUtil.loadFalseResult(e.getMessage());
 
+        GoldCornSettleRecord record = goldCornSettleRecordService.get(id);
+        if (record == null) {
+            return JsonUtil.loadFalseResult("璁板綍涓嶅瓨鍦�");
         }
-        return JsonUtil.loadTrueResult("");
 
+        GoldCornConsumeRecordQuery query = new GoldCornConsumeRecordQuery();
+        query.setType(GoldCornConsumeType.changeMoney);
+        query.setEventId(id);
+
+        BigDecimal money = goldCornConsumeRecordService.sumMoney(query);
+        Long userCount = goldCornConsumeRecordService.count(query);
+
+        GoldCornSettleRecord update = new GoldCornSettleRecord();
+        update.setId(id);
+        update.setTotalMoney(money);
+        update.setSettledUserCount(userCount);
+        goldCornSettleRecordService.update(update);
+        record.setTotalMoney(money);
+        record.setSettledUserCount(userCount);
+        return JsonUtil.loadTrueResult(gson.toJson(record));
     }
 
 

--
Gitblit v1.8.0