ClientAction.java
5.19 KB
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
package com.cjs.cms.action.report;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.cjs.cms.biz.report.ReportBiz;
import com.cjs.cms.dao.user.AgentInfoDao;
import com.cjs.cms.dao.user.account.ClientDao;
import com.cjs.cms.dao.user.account.ClientInfoDao;
import com.cjs.cms.model.user.AgentInfo;
import com.cjs.cms.util.lang.DateUtil;
import com.cjs.cms.util.lang.JsonUtil;
import com.cjs.cms.util.lang.PageUtils;
/**
* 会员
*
* @author tongyufu
*
*/
@RestController
@RequestMapping("/report/client")
public class ClientAction {
Logger log = LogManager.getLogger();
@Autowired
private ReportBiz reportBiz;
@Autowired
private ClientDao clientDao;
@Autowired
private AgentInfoDao agentDao;
@Autowired
private ClientInfoDao clientInfoDao;
/** 开户人数统计 */
@RequestMapping("search")
public String search(@RequestParam Map<String, Object> params) {
PageUtils.processOralcePage(params);
reportBiz.formatDate(params);
//开户人数统计
Map<String, Object> footer = new HashMap<String, Object>();
footer.put("OPEN_DATE", "汇总");
footer.put("USERS", clientDao.searchSum(params));
return JsonUtil.toPageJson(clientDao.search(params), clientDao.searchTotal(params), footer);
}
/**
* 会员导出
* @param params
* @param request
* @return
* @throws Exception
*/
@RequestMapping("exportClient")
public ResponseEntity<byte[]> exportClient(@RequestParam Map<String, Object> params,
HttpServletRequest request) throws Exception {
reportBiz.formatDate(params);
params.put("rows", 999999);
PageUtils.processOralcePage(params);
File targetFile = reportBiz.exportClient(params);
HttpHeaders head = new HttpHeaders();
head.setContentType(MediaType.APPLICATION_OCTET_STREAM);
// 下载的文件名
head.setContentDispositionFormData("attachment",
new String(targetFile.getName().getBytes("UTF-8"), "ISO8859-1"));
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(targetFile), head,
HttpStatus.CREATED);
}
/**会员等级*/
@RequestMapping("searchLevel")
public String searchLevel(@RequestParam Map<String, Object> params) {
PageUtils.processOralcePage(params);
return JsonUtil.toPageJson(clientDao.searchClient(params),
clientDao.searchClientCount(params));
}
/**下属会员统计*/
@RequestMapping("searchUnder")
public String searchUnder(@RequestParam Map<String, Object> params) {
PageUtils.processOralcePage(params);
DateUtil.formatHundsunDate(params);
//查询用户是否是代理商
if (params.containsKey("clientId")) {
AgentInfo agentInfo = agentDao.queryByFundAccount(params.get("clientId").toString());
if (agentInfo != null) {
params.put("clientId", agentInfo.getAgentNo());
}
}
return JsonUtil.toPageJson(clientDao.queryUnderInfo(params),
clientDao.queryUnderTotal(params));
}
/**下辖会员交易量统计*/
@RequestMapping("searchUnderCount")
public String searchUnderCount(@RequestParam Map<String, Object> params) {
PageUtils.processOralcePage(params);
DateUtil.formatHundsunDate(params);
Map<String, Object> footer = clientInfoDao.querySumCountTatal(params);
if (footer == null) {
footer = new HashMap<String, Object>();
}
footer.put("CLIENTID", "汇总");
return JsonUtil.toPageJson(clientInfoDao.queryclientUnderCount(params),
clientInfoDao.queryclientUnderCountTotal(params), footer);
}
/**导出下辖会员统计*/
@RequestMapping("exportUnderCount")
public ResponseEntity<byte[]> exportUnderCount(@RequestParam Map<String, Object> params,
HttpServletRequest request) throws Exception {
reportBiz.formatDate(params);
params.put("rows", 999999);
PageUtils.processOralcePage(params);
File targetFile = reportBiz.exportClientUnder(params);
HttpHeaders head = new HttpHeaders();
head.setContentType(MediaType.APPLICATION_OCTET_STREAM);
// 下载的文件名
head.setContentDispositionFormData("attachment",
new String(targetFile.getName().getBytes("UTF-8"), "ISO8859-1"));
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(targetFile), head,
HttpStatus.CREATED);
}
}