From a217652d33c75df23202828000d82d0ca8555ac2 Mon Sep 17 00:00:00 2001
From: Administrator <1101184511@qq.com>
Date: 星期一, 21 四月 2025 02:13:59 +0800
Subject: [PATCH] 初步完成积分后台管理相关页面

---
 src/main/java/com/taoke/autopay/controller/admin/AdminAgentSettleController.java |  200 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 196 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/taoke/autopay/controller/admin/AdminAgentSettleController.java b/src/main/java/com/taoke/autopay/controller/admin/AdminAgentSettleController.java
index 6c5245c..baf88e8 100644
--- a/src/main/java/com/taoke/autopay/controller/admin/AdminAgentSettleController.java
+++ b/src/main/java/com/taoke/autopay/controller/admin/AdminAgentSettleController.java
@@ -1,12 +1,18 @@
 package com.taoke.autopay.controller.admin;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.read.listener.ReadListener;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.TypeAdapter;
+import com.google.gson.reflect.TypeToken;
 import com.google.gson.stream.JsonReader;
 import com.google.gson.stream.JsonWriter;
 import com.taoke.autopay.dao.agent.ChannelAgentMapper;
 import com.taoke.autopay.dao.agent.ChannelAgentSettleRecordMapper;
+import com.taoke.autopay.dto.admin.AgentSettleExcelDataDto;
+import com.taoke.autopay.dto.admin.OrderExcelDataDto;
 import com.taoke.autopay.entity.OrderChannelEnum;
 import com.taoke.autopay.entity.SystemConfigKeyEnum;
 import com.taoke.autopay.entity.agent.ChannelAgent;
@@ -21,20 +27,30 @@
 import com.taoke.autopay.service.agent.ChannelAgentSettingService;
 import com.taoke.autopay.service.agent.ChannelAgentSettleService;
 import com.taoke.autopay.service.agent.ChannelAgentSharingRatioService;
+import com.taoke.autopay.utils.Constant;
 import com.taoke.autopay.utils.TimeUtil;
 import com.taoke.autopay.vo.admin.AdminChannelAgentVO;
 import com.taoke.autopay.vo.admin.AgentSearchVO;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
+import org.apache.commons.codec.digest.DigestUtils;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
 import org.yeshi.utils.JsonUtil;
+import org.yeshi.utils.NumberUtil;
 import org.yeshi.utils.StringUtil;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Type;
 import java.math.BigDecimal;
+import java.net.URLEncoder;
 import java.util.*;
 
 /**
@@ -61,6 +77,20 @@
         public Date read(JsonReader in) throws IOException {
             return new Date();
         }
+    }).registerTypeAdapter(BigDecimal.class, new TypeAdapter<BigDecimal>() {
+        @Override
+        public void write(JsonWriter out, BigDecimal value) throws IOException {
+            if (value != null) {
+                out.value(value.toString());
+            } else {
+                out.value("");
+            }
+        }
+
+        @Override
+        public BigDecimal read(JsonReader in) throws IOException {
+            return new BigDecimal("0.00");
+        }
     }).create();
 
     @Resource
@@ -72,10 +102,11 @@
 
     @ResponseBody
     @RequestMapping("list")
-    public String listAgent(String key, String day, int page, int limit) {
+    public String listAgent(String key, String startDay,String endDay, int page, int limit) {
         //鍏堟煡璇㈡墍鏈夌殑鏁版嵁
         ChannelAgentSettleRecordMapper.DaoQuery query = new ChannelAgentSettleRecordMapper.DaoQuery();
-        query.settleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(day)?null:day;
+        query.minSettleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(startDay)?null:startDay;
+        query.maxSettleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(endDay)?null:endDay;
         query.sortList = Arrays.asList(new String[]{"_create_time desc"});
         query.start = (long) (page - 1) * limit;
         query.count = limit;
@@ -96,14 +127,175 @@
         return JsonUtil.loadTrueResult("");
     }
 
+    /**
+     * @author hxh 
+     * @description 寮�濮嬬粨绠�
+     * @date 0:28 2024/10/14
+     * @param: startDay 寮�濮嬫棩鏈�
+     * @param: endDay 缁撴潫鏃ユ湡
+     * @return java.lang.String
+     **/
     @ResponseBody
     @RequestMapping("startSettle")
-    public String startSettle(String  day) {
+    public String startSettle(String  startDay, String endDay) {
+        if(StringUtil.isNullOrEmpty(startDay)||StringUtil.isNullOrEmpty(endDay)){
+            return JsonUtil.loadFalseResult("缁撶畻鏃ユ湡杈撳叆涓嶅畬鏁�");
+        }
+        if(Integer.parseInt(startDay.replace("-",""))>Integer.parseInt(endDay.replace("-",""))){
+            return JsonUtil.loadFalseResult("寮�濮嬫棩鏈熶笉鑳藉ぇ浜庣粨鏉熸棩鏈�");
+        }
+
+        long startTimeStamp =  TimeUtil.convertToTimeTemp(startDay,"yyyy-MM-dd");
+        long endTimeStamp =  TimeUtil.convertToTimeTemp(endDay,"yyyy-MM-dd");
+
+        List<String> days=new ArrayList<>();
+        for(int i=0;i<100;i++){
+          if(endTimeStamp< startTimeStamp + i*24*60*60*1000L){
+              break;
+          }
+          days.add(TimeUtil.getGernalTime(startTimeStamp + i*24*60*60*1000L,"yyyy-MM-dd"));
+       }
+
         try {
-           channelAgentSettleService.startSettle(day);
+            for(String day:days) {
+                channelAgentSettleService.startSettle(day);
+            }
             return JsonUtil.loadTrueResult("");
         } catch (ChannelAgentSettleException e) {
             return JsonUtil.loadFalseResult(e.getMessage());
         }
     }
+
+    /**
+     * @author hxh 
+     * @description 鎻愮幇鍒楄〃
+     * @date 13:14 2024/7/29
+     * @param: key
+     * @param: startTime
+     * @param: endTime
+     * @param: status
+     * @param: page
+     * @param: limit
+     * @return java.lang.String
+     **/
+    @ResponseBody
+    @RequestMapping("listWithdraw")
+    public String listWithdraw(String key, String startTime,String endTime, String status, int page, int limit) {
+        //鍏堟煡璇㈡墍鏈夌殑鏁版嵁
+        ChannelAgentSettleRecordMapper.DaoQuery query = new ChannelAgentSettleRecordMapper.DaoQuery();
+        query.agentId = !NumberUtil.isNumeric(key)?null:Long.parseLong(key);
+        query.minWithDrawApplyTime = StringUtil.isNullOrEmpty(startTime)?null:new Date(TimeUtil.convertToTimeTemp(startTime,"yyyy-MM-dd HH:mm:ss"));
+        query.maxWithDrawApplyTime = StringUtil.isNullOrEmpty(endTime)?null:new Date(TimeUtil.convertToTimeTemp(endTime,"yyyy-MM-dd HH:mm:ss"));
+        if(status==null||Integer.parseInt(status)<0){
+            query.statusList=Arrays.asList(new Integer[]{ ChannelAgentSettleRecord.STATUS_WITHDRAWING,ChannelAgentSettleRecord.STATUS_WITHDRAW_SUCCESS,ChannelAgentSettleRecord.STATUS_WITHDRAW_REJECTED});
+        }else{
+            query.status=Integer.parseInt(status);
+        }
+        query.sortList = Arrays.asList(new String[]{"_withdraw_apply_time desc"});
+        query.start = (long) (page - 1) * limit;
+        query.count = limit;
+        List<ChannelAgentSettleRecord> recordList = channelAgentSettleService.list(query);
+        long count = channelAgentSettleService.count(query);
+        JSONObject data = new JSONObject();
+        data.put("count", count);
+        data.put("list", gson.toJson(recordList));
+        return JsonUtil.loadTrueResult(data);
+    }
+
+    /**
+     * @author hxh 
+     * @description
+     * @date 13:23 2024/7/29
+     * @param: ids JSONARRAY
+     * @return java.lang.String
+     **/
+    @ResponseBody
+    @RequestMapping("pass")
+    public String passWithdraw(String ids) {
+       if(StringUtil.isNullOrEmpty(ids)){
+           return JsonUtil.loadFalseResult("璇蜂笂浼爄ds");
+       }
+        Type type=new TypeToken<List<Long>>(){}.getType();
+        try {
+            channelAgentSettleService.processWithdraw(gson.fromJson(ids,type), true);
+            return JsonUtil.loadTrueResult("");
+        } catch (ChannelAgentSettleException e) {
+            return JsonUtil.loadFalseResult(e.getMessage());
+        }
+    }
+
+    @ResponseBody
+    @RequestMapping("reject")
+    public String rejectWithdraw(String ids) {
+        if(StringUtil.isNullOrEmpty(ids)){
+            return JsonUtil.loadFalseResult("璇蜂笂浼爄ds");
+        }
+        Type type=new TypeToken<List<Long>>(){}.getType();
+        try {
+            channelAgentSettleService.processWithdraw(gson.fromJson(ids,type), false);
+            return JsonUtil.loadTrueResult("");
+        } catch (ChannelAgentSettleException e) {
+            return JsonUtil.loadFalseResult(e.getMessage());
+        }
+    }
+
+
+
+    @RequestMapping("downloadSettleTable")
+    public void downloadSettleTable(String startDay,String endDay, HttpServletResponse response) throws IOException {
+        ChannelAgentSettleRecordMapper.DaoQuery daoQuery=new ChannelAgentSettleRecordMapper.DaoQuery();
+        daoQuery.minSettleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(startDay)?null:startDay;
+        daoQuery.maxSettleDay = com.taoke.autopay.utils.StringUtil.isNullOrEmpty(endDay)?null:endDay;
+        daoQuery.count = 10000;
+        daoQuery.status =  ChannelAgentSettleRecord.STATUS_NOT_SETTLE;
+        List<ChannelAgentSettleRecord> list =   channelAgentSettleService.list(daoQuery);
+
+        List<AgentSettleExcelDataDto> dataList=new ArrayList<>();
+        for(ChannelAgentSettleRecord record:list){
+            AgentSettleExcelDataDto dto=AgentSettleExcelDataDto.builder()
+                    .id(record.getId())
+                    .agentId(record.getAgentId())
+                    .actualSettleMoney(record.getSettleMoney().toString())
+                    .settleMoney(record.getSettleMoney().toString())
+                    .day(record.getSettleDay())
+                    .build();
+            dataList.add(dto);
+        }
+
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setCharacterEncoding("utf-8");
+        // 杩欓噷URLEncoder.encode鍙互闃叉涓枃涔辩爜 褰撶劧鍜宔asyexcel娌℃湁鍏崇郴
+        String fileName="settle_"+URLEncoder.encode(TimeUtil.getGernalTime(System.currentTimeMillis(),"yyyyMMdd_HHmmss"),"UTF-8");
+        response.setHeader("Content-disposition","attachment;filename*=utf-8''"+fileName+".xlsx");
+        EasyExcel.write(response.getOutputStream(),AgentSettleExcelDataDto.class).sheet("缁撶畻纭鍗�").doWrite(dataList);
+    }
+
+
+    @ResponseBody
+    @RequestMapping("uploadSettleExcel")
+    public String uploadImg(@RequestParam("file") MultipartFile file, HttpSession session) throws IOException {
+        InputStream inputStream = file.getInputStream();
+        EasyExcel.read(inputStream, AgentSettleExcelDataDto.class, new ReadListener<AgentSettleExcelDataDto>() {
+            @Override
+            public void invoke(AgentSettleExcelDataDto o, AnalysisContext analysisContext) {
+                System.out.println("璇诲彇鍒版暟鎹�: " + o.getDay());
+                try {
+                    channelAgentSettleService.actualSettle(o.getId(),new BigDecimal(o.getActualSettleMoney()));
+                } catch (ChannelAgentSettleException e) {
+                    e.printStackTrace();
+                }
+            }
+
+            @Override
+            public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+
+            }
+        }).sheet().doRead();
+        return JsonUtil.loadTrueResult("");
+    }
+
+
+
+
+
 }

--
Gitblit v1.8.0