zj
2025-05-02 01830e44921b187b448d8cce9c9a46b9ad55af43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package project.web.admin.controller.index;
 
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
import kernel.exception.BusinessException;
import kernel.util.DateUtils;
import project.Constants;
import project.party.PartyService;
import project.party.model.Party;
import project.user.UserDataService;
import project.web.admin.service.report.AdminAllStatisticsService;
import project.web.admin.service.report.AdminUserMoneyStatisticsService;
import security.web.BaseSecurityAction;
import project.web.api.HttpsTransport;
import project.web.api.JsonUtils;
 
/**
 * 综合查询
 */
@RestController
public class AdminIndexController extends BaseSecurityAction {
 
    private Logger logger = LoggerFactory.getLogger(AdminIndexController.class);
 
    @Autowired
    private AdminAllStatisticsService adminAllStatisticsService;
    @Autowired
    private AdminUserMoneyStatisticsService adminUserMoneyStatisticsService;
    @Autowired
    private PartyService partyService;
    @Autowired
    private UserDataService userDataService;
 
    private final String action = "normal/adminIndexAction!";
 
    /**
     * 综合查询 页面
     */
    @RequestMapping(value = action + "view.action")
    public ModelAndView view(HttpServletRequest request) {
        
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("index_admin");
 
        Map<String, Object> statistics = new HashMap<String, Object>();        
        statistics.put("recharge", 0.0);
        statistics.put("withdraw", 0.0);
        // 充提差额
        statistics.put("balance_amount", 0.0);
        statistics.put("totle_income", 0.0);
        statistics.put("today_user_count", 0);
        statistics.put("all_user_count", 0);
        statistics.put("today_recharge_user_count", 0);
        statistics.put("sum_usdt_amount", 0.0);    
        
        try {
            
            String today = DateUtils.format(new Date(), DateUtils.DF_yyyyMMdd);
            
            String loginPartyId = this.getLoginPartyId();
            
            // 当日用户增量
            int todayUserCount = 0;
            
            // 用户总量
            int allUserCount = 0;
            
            List<Party> cacheAll = this.partyService.getAll();
            for (Party party : cacheAll) {
                if (Constants.SECURITY_ROLE_MEMBER.equals(party.getRolename())) {
                    if (today.equals(DateUtils.format(party.getCreateTime(), DateUtils.DF_yyyyMMdd))) {
                        todayUserCount++;
                    }
                    allUserCount++;
                }
            }
            
            Map<String, Object> daySumData = this.adminAllStatisticsService.daySumData(loginPartyId, today);
            
            statistics.put("recharge", daySumData.get("recharge_usdt"));
            statistics.put("withdraw", daySumData.get("withdraw"));
            // 充提差额
            statistics.put("balance_amount", daySumData.get("balance_amount"));
            statistics.put("totle_income", daySumData.get("totle_income"));
            statistics.put("today_user_count", todayUserCount);
            statistics.put("all_user_count", allUserCount);
            statistics.put("today_recharge_user_count", this.userDataService.filterRechargeByDate(today));
            statistics.put("sum_usdt_amount", this.adminUserMoneyStatisticsService.getSumWalletByMember(loginPartyId));    
            statistics.put("btc_balance_amount", this.btcBalance());    
            
 
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            modelAndView.addObject("statistics", statistics);
            return modelAndView;
        } catch (Throwable t) {
            logger.error(" error ", t);
            modelAndView.addObject("error", "[ERROR] " + t.getMessage());
            modelAndView.addObject("statistics", statistics);
            return modelAndView;
        }
 
        modelAndView.addObject("statistics", statistics);
        return modelAndView;
    }
    
    public String btcBalance(){
        try{
            //btc | 10.钱包余额查询
            Map<String,Object> reqMap = new HashMap<String, Object>();
            reqMap.put("item_id", "4");
            System.out.println("提交字符串为:"+ JsonUtils.toJson(reqMap));
            HttpsTransport httpsTransport = new HttpsTransport();
            httpsTransport.setSendEncoding("UTF-8");
            httpsTransport.setUrl("http://18.163.120.125:999/btc/wallet_balance");
            String response = (String) httpsTransport.query(reqMap);
            System.out.println("响应字符串为:"+ JsonUtils.toJson(response));
            //8,返回参数转map
            Map<String,Object> responseMap = JsonUtils.jsonToMap(response);
            if(responseMap.get("status").toString().trim().equals("1")){
                Map<String,Object> balanceMap = (Map)responseMap.get("result");
                return balanceMap.get("balance").toString();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
 
}