From 734dfe9eb0a2176103dce8245c69b1194574c68e Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 29 七月 2024 20:16:15 +0800
Subject: [PATCH] 代理新功能完善

---
 src/main/java/com/taoke/autopay/controller/agent/AgentController.java |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 105 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/taoke/autopay/controller/agent/AgentController.java b/src/main/java/com/taoke/autopay/controller/agent/AgentController.java
index 8f44321..93a2553 100644
--- a/src/main/java/com/taoke/autopay/controller/agent/AgentController.java
+++ b/src/main/java/com/taoke/autopay/controller/agent/AgentController.java
@@ -6,31 +6,29 @@
 import com.google.gson.stream.JsonReader;
 import com.google.gson.stream.JsonWriter;
 import com.taoke.autopay.dao.KeyOrderMapper;
-import com.taoke.autopay.dao.agent.ChannelAgentMapper;
+import com.taoke.autopay.dao.agent.ChannelAgentSettleRecordMapper;
 import com.taoke.autopay.dto.ChannelOrderStatistic;
 import com.taoke.autopay.entity.KeyOrder;
 import com.taoke.autopay.entity.OrderChannelEnum;
 import com.taoke.autopay.entity.SystemConfigKeyEnum;
 import com.taoke.autopay.entity.agent.ChannelAgent;
-import com.taoke.autopay.entity.agent.ChannelAgentSettings;
-import com.taoke.autopay.entity.agent.ChannelAgentSharingRatio;
+import com.taoke.autopay.entity.agent.ChannelAgentSettleDetail;
+import com.taoke.autopay.entity.agent.ChannelAgentSettleRecord;
 import com.taoke.autopay.exception.ChannelAgentException;
-import com.taoke.autopay.factory.AgentFactory;
+import com.taoke.autopay.exception.ChannelAgentSettleException;
 import com.taoke.autopay.factory.OrderFactory;
 import com.taoke.autopay.service.KeyOrderService;
 import com.taoke.autopay.service.SystemConfigService;
 import com.taoke.autopay.service.agent.ChannelAgentService;
-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.AgentUtil;
 import com.taoke.autopay.utils.Constant;
 import com.taoke.autopay.utils.StringUtil;
 import com.taoke.autopay.utils.TimeUtil;
 import com.taoke.autopay.vo.AgentOrderFilter;
 import com.taoke.autopay.vo.AgentOrderVO;
-import com.taoke.autopay.vo.OrderFilter;
-import com.taoke.autopay.vo.admin.AdminChannelAgentVO;
-import com.taoke.autopay.vo.admin.AgentSearchVO;
-import net.sf.json.JSONArray;
+import com.taoke.autopay.vo.AgentWithdrawVO;
 import net.sf.json.JSONObject;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -75,6 +73,12 @@
 
     @Resource
     private ChannelAgentSharingRatioService channelAgentSharingRatioService;
+
+    @Resource
+    private ChannelAgentSettleService channelAgentSettleService;
+
+    @Resource
+    private SystemConfigService systemConfigService;
 
 
     @ResponseBody
@@ -176,4 +180,96 @@
     }
 
 
+    @ResponseBody
+    @RequestMapping("getConfig")
+    public String getConfig(HttpSession session) {
+        ChannelAgent agent = (ChannelAgent) session.getAttribute(Constant.SESSION_KEY_AGENT);
+        if (agent == null) {
+            return JsonUtil.loadFalseResult("灏氭湭鐧诲綍");
+        }
+        String baseSubmitKeyLink = systemConfigService.getValueCache(SystemConfigKeyEnum.AGENT_SUBMIT_KEY_LINK);
+        String submitKeyUrl = AgentUtil.getSubmitKeyUrl(baseSubmitKeyLink, agent.getAlias());
+        JSONObject data = new JSONObject();
+        data.put("submitKeyUrl", submitKeyUrl);
+        return JsonUtil.loadTrueResult(data);
+    }
+
+    @ResponseBody
+    @RequestMapping("withdrawList")
+    public String withdrawList(int page, HttpSession session) {
+        ChannelAgent agent = (ChannelAgent) session.getAttribute(Constant.SESSION_KEY_AGENT);
+        if (agent == null) {
+            return JsonUtil.loadFalseResult("灏氭湭鐧诲綍");
+        }
+
+        ChannelAgentSettleRecordMapper.DaoQuery daoQuery = new ChannelAgentSettleRecordMapper.DaoQuery();
+        daoQuery.statusList = Arrays.asList(new Integer[]{ChannelAgentSettleRecord.STATUS_SETTLED, ChannelAgentSettleRecord.STATUS_WITHDRAWING, ChannelAgentSettleRecord.STATUS_WITHDRAW_SUCCESS, ChannelAgentSettleRecord.STATUS_WITHDRAW_REJECTED});
+        daoQuery.sortList = Arrays.asList(new String[]{"_update_time desc"});
+        daoQuery.count = 20;
+        daoQuery.start = (page - 1) * 20;
+        List<ChannelAgentSettleRecord> recordList = channelAgentSettleService.list(daoQuery);
+        long count = channelAgentSettleService.count(daoQuery);
+        List<AgentWithdrawVO> voList = new ArrayList<>();
+        for (ChannelAgentSettleRecord record : recordList) {
+            long totalOrderCount = 0;
+            for (ChannelAgentSettleDetail d : record.getDetailList()) {
+                totalOrderCount += d.getPayOrderCount();
+            }
+            String statusDesc = "";
+            switch (record.getStatus()) {
+                case ChannelAgentSettleRecord.STATUS_SETTLED:
+                    statusDesc = "鏈彁鐜�";
+                    break;
+                case ChannelAgentSettleRecord.STATUS_WITHDRAWING:
+                    statusDesc = "姝e湪瀹℃牳";
+                    break;
+                case ChannelAgentSettleRecord.STATUS_WITHDRAW_SUCCESS:
+                    statusDesc = "鎻愮幇鎴愬姛";
+                    break;
+                case ChannelAgentSettleRecord.STATUS_WITHDRAW_REJECTED:
+                    statusDesc = "鎻愮幇澶辫触";
+                    break;
+            }
+
+            voList.add(AgentWithdrawVO.builder()
+                    .id(record.getId())
+                    .money(record.getActualSettleMoney().toString())
+                    .month(TimeUtil.getGernalTime(record.getSettleTime().getTime(), "yyyy骞碝M鏈�"))
+                    .status(record.getStatus())
+                    .statusDesc(statusDesc)
+                    .orderCount(totalOrderCount)
+                    .settleTime(TimeUtil.getGernalTime(record.getSettleTime().getTime(), "yyyy.MM.dd HH:mm:ss"))
+                    .build());
+        }
+
+
+        JSONObject data = new JSONObject();
+        data.put("list", voList);
+        data.put("count", count);
+        return JsonUtil.loadTrueResult(data);
+    }
+
+    @ResponseBody
+    @RequestMapping("withdraw")
+    public String withdraw(Long id, HttpSession session) {
+        ChannelAgent agent = (ChannelAgent) session.getAttribute(Constant.SESSION_KEY_AGENT);
+        if (agent == null) {
+            return JsonUtil.loadFalseResult("灏氭湭鐧诲綍");
+        }
+
+        if(StringUtil.isNullOrEmpty(agent.getAlipayName())||StringUtil.isNullOrEmpty(agent.getAlipayAccount()))
+        {
+            return JsonUtil.loadFalseResult("灏氭湭璁剧疆鏀粯瀹濅俊鎭�");
+        }
+
+        try {
+            channelAgentSettleService.applyWithdraw(id);
+            return JsonUtil.loadTrueResult("");
+        } catch (ChannelAgentSettleException e) {
+            e.printStackTrace();
+            return JsonUtil.loadFalseResult("灏氭湭鐧诲綍");
+        }
+    }
+
+
 }

--
Gitblit v1.8.0