Pu Zhibing
2025-04-30 d1e1d0098fdbbf092a98332d30eb720926cd1823
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
package com.stylefeng.guns.modular.system.controller.general;
 
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.ExcelExportUtil;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.modular.system.service.ITOrderTaxiService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
/**
 * 财务报表
 * @author zhibing.pu
 * @Date 2025/4/22 10:55
 */
@Controller
@RequestMapping("/financialStatement")
public class FinancialStatementController extends BaseController {
    
    private String PREFIX = "/system/financialStatement/";
    
    @Resource
    private ITOrderTaxiService orderTaxiService;
    
    
    /**
     * 跳转支付订单统计页
     * @return
     */
    @GetMapping("/paymentOrderStatistics")
    public String paymentOrderStatistics(){
        return PREFIX + "paymentOrderStatistics/paymentOrderStatistics.html";
    }
    
    
    /**
     * 跳转线下订单统计页
     * @return
     */
    @GetMapping("/offlineOrderStatistics")
    public String offlineOrderStatistics(){
        return PREFIX + "offlineOrderStatistics/offlineOrderStatistics.html";
    }
    
    
    
    /**
     * 获取支付订单统计列表
     * @param paymentCode
     * @param orderCode
     * @param userPhone
     * @param driverPhone
     * @param createTime
     * @param paymentTime
     * @return
     */
    @ResponseBody
    @RequestMapping("/paymentOrderStatisticsList")
    public Object paymentOrderStatisticsList(String paymentCode, String orderCode, String userPhone,
                                             String driverPhone, String createTime, String paymentTime){
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        List<Map<String, Object>> list = orderTaxiService.paymentOrderStatisticsList(page, paymentCode, orderCode, userPhone, driverPhone, createTime, paymentTime);
        return super.packForBT(page.setRecords(list));
    }
    
    
    /**
     * 导出支付订单统计列表
     * @param paymentCode
     * @param orderCode
     * @param userPhone
     * @param driverPhone
     * @param createTime
     * @param paymentTime
     */
    @ResponseBody
    @RequestMapping("/paymentOrderStatisticsList_export")
    public void paymentOrderStatisticsList_export(String paymentCode, String orderCode, String userPhone,
                                                  String driverPhone, String createTime, String paymentTime, HttpServletRequest request, HttpServletResponse response){
        Page<Map<String, Object>> page = new Page(1, 9999);
        List<Map<String, Object>> list = orderTaxiService.paymentOrderStatisticsList(page, paymentCode, orderCode, userPhone, driverPhone, createTime, paymentTime);
        
        // 表格数据【封装】
        List<List<String>> dataList = new ArrayList<>();
        
        // 列【封装】
        List<String> shellList = new ArrayList<String>();
        shellList.add("支付流水号");
        shellList.add("订单号");
        shellList.add("支付用户手机号");
        shellList.add("支付金额");
        shellList.add("接单司机手机号");
        shellList.add("司机所属机构");
        shellList.add("扣除司机抽成");
        shellList.add("下单时间");
        shellList.add("支付时间");
        dataList.add(shellList);
        
        for (Map<String,Object> object : list){
            // 详细数据列【封装】
            shellList = new ArrayList<String>();
            if(SinataUtil.isNotEmpty(object.get("paymentCode"))){
                shellList.add(object.get("paymentCode").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("orderNum"))){
                shellList.add(object.get("orderNum").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("userPhone"))){
                shellList.add(object.get("userPhone").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("amount"))){
                shellList.add(object.get("amount").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("driverPhone"))){
                shellList.add(object.get("driverPhone").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("company"))){
                shellList.add(object.get("company").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("income"))){
                shellList.add(object.get("income").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("insertTime"))){
                shellList.add(object.get("insertTime").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("paymentTime"))){
                shellList.add(object.get("paymentTime").toString());
            }else{
                shellList.add("-");
            }
            dataList.add(shellList);
        }
        try {
            // 调用工具类进行导出
            ExcelExportUtil.easySheet("支付订单统计"+DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "支付订单统计", dataList,request, response);
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    
    /**
     * 获取线下订单统计
     * @param orderCode
     * @param userPhone
     * @param driverPhone
     * @param createTime
     * @param orderSource
     * @return
     */
    @ResponseBody
    @RequestMapping("/offlineOrderStatisticsList")
    public Object offlineOrderStatisticsList(String orderCode, String userPhone, String driverPhone,
                                             String createTime, Integer orderSource){
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        List<Map<String, Object>> list = orderTaxiService.offlineOrderStatisticsList(page, orderCode, userPhone, driverPhone, createTime, orderSource);
        return super.packForBT(page.setRecords(list));
    }
    
    
    /**
     * 导出线下订单统计
     * @param orderCode
     * @param userPhone
     * @param driverPhone
     * @param createTime
     * @param orderSource
     */
    @ResponseBody
    @RequestMapping("/offlineOrderStatisticsList_export")
    public void offlineOrderStatisticsList_export(String orderCode, String userPhone, String driverPhone,
                                                  String createTime, Integer orderSource, HttpServletRequest request, HttpServletResponse response){
        Page<Map<String, Object>> page = new Page(1, 9999);
        List<Map<String, Object>> list = orderTaxiService.offlineOrderStatisticsList(page, orderCode, userPhone, driverPhone, createTime, orderSource);
        
        // 表格数据【封装】
        List<List<String>> dataList = new ArrayList<>();
        
        // 列【封装】
        List<String> shellList = new ArrayList<String>();
        shellList.add("订单号");
        shellList.add("用户手机号");
        shellList.add("打车方式");
        shellList.add("接单司机手机号");
        shellList.add("司机所属机构");
        shellList.add("扣除司机抽成");
        shellList.add("下单时间");
        dataList.add(shellList);
        
        for (Map<String,Object> object : list){
            shellList = new ArrayList<String>();
            // 详细数据列【封装】
            if(SinataUtil.isNotEmpty(object.get("orderNum"))){
                shellList.add(object.get("orderNum").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("userPhone"))){
                shellList.add(object.get("userPhone").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("orderSource"))){
                shellList.add(object.get("orderSource").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("driverPhone"))){
                shellList.add(object.get("driverPhone").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("company"))){
                shellList.add(object.get("company").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("income"))){
                shellList.add(object.get("income").toString());
            }else{
                shellList.add("-");
            }
            if(SinataUtil.isNotEmpty(object.get("insertTime"))){
                shellList.add(object.get("insertTime").toString());
            }else{
                shellList.add("-");
            }
            dataList.add(shellList);
        }
        try {
            // 调用工具类进行导出
            ExcelExportUtil.easySheet("线下订单统计"+DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "线下订单统计", dataList,request, response);
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
}