liujie
2 天以前 4ce148a6fc8dfca355ff676264c0d78a5ebf89df
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
package com.stylefeng.guns.modular.system.controller.specialTrain;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.beetl.ShiroExtUtil;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.core.util.SinataUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.dao.OrderCancelMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.*;
 
/**
 * 快车订单控制器
 *
 * @author fengshuonan
 * @Date 2020-09-02 17:28:59
 */
@Controller
@RequestMapping("/promotionInfo")
public class TPromotionOrderCarController extends BaseController {
 
    private String PREFIX = "/system/tPromotionOrderCar/";
 
    @Autowired
    private ITOrderPrivateCarService tOrderPrivateCarService;
 
    @Autowired
    private ShiroExtUtil shiroExtUtil;
 
 
    /**
     * 跳转到快车订单首页
     */
    @RequestMapping("")
    public String index(Model model) {
        List<Map<String, Object>> list=new ArrayList<>();
        list =  tOrderPrivateCarService.promotionInfoExport(null, null, null, null, null, null, null, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId());
        BigDecimal reduce = list.stream().map(e -> new BigDecimal(e.get("promotionMoney").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
        model.addAttribute("money",reduce);
        model.addAttribute("size",list.size());
 
        return PREFIX + "tPromotionOrder.html";
    }
 
 
    /**
     * 获取快车订单列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String insertTime,
                       String orderNum,
                       String userName,
                       String name,
                       String driverName){
        String beginTime = null;
        String endTime = null;
        if (SinataUtil.isNotEmpty(insertTime)) {
            String[] timeArray = insertTime.split(" - ");
            beginTime = timeArray[0];
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(tOrderPrivateCarService.promotionInfo(page, beginTime, endTime, orderNum, userName, name, driverName, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId()));
        return super.packForBT(page);
    }
 
 
 
    @GetMapping("/export")
    @ResponseBody
    public void export(String insertTime,
                       String orderNum,
                       String userName,
                       String name,
                       String driverName, HttpServletRequest request, HttpServletResponse response) {
        try {
            String beginTime = null;
            String endTime = null;
            if (SinataUtil.isNotEmpty(insertTime)) {
                String[] timeArray = insertTime.split(" - ");
                beginTime = timeArray[0];
                endTime = timeArray[1];
            }
            List<Map<String, Object>> list=new ArrayList<>();
            list =  tOrderPrivateCarService.promotionInfoExport(null, beginTime, endTime, orderNum, userName, name, driverName, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId());
 
 
            // 表格数据【封装】
            List<List<String>> dataList = new ArrayList<>();
 
            //第一行显示【封装】
            List<String> twoList = new ArrayList<String>();
            twoList.add("总计:");
            twoList.add(String.valueOf(list.size())+"条");
            dataList.add(twoList);
 
            // 列【封装】
            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("name"))){
                    shellList.add(object.get("name").toString());
                }else{
                    shellList.add("-");
                }
                if(SinataUtil.isNotEmpty(object.get("driverName"))){
                    shellList.add(object.get("driverName").toString());
                }else{
                    shellList.add("-");
                }
                if(SinataUtil.isNotEmpty(object.get("userName"))){
                    shellList.add(object.get("userName").toString());
                }else{
                    shellList.add("-");
                }
                if(SinataUtil.isNotEmpty(object.get("orderNum"))){
                    shellList.add(object.get("orderNum").toString());
                }else{
                    shellList.add("-");
                }
                if(SinataUtil.isNotEmpty(object.get("money"))){
                    shellList.add(object.get("money").toString());
                }else{
                    shellList.add("-");
                }
                if(SinataUtil.isNotEmpty(object.get("promotionMoney"))){
                    shellList.add(object.get("promotionMoney").toString());
                }else{
                    shellList.add("-");
                }
 
                if(SinataUtil.isNotEmpty(object.get("successTime"))){
                    shellList.add(DateUtil.formatDate(DateUtil.parse(object.get("successTime").toString(),"YYYY-MM-dd HH:mm:ss.S"), "YYYY-MM-dd HH:mm:ss"));
                }else{
                    shellList.add("-");
                }
 
 
 
                dataList.add(shellList);
            }
            try {
                // 调用工具类进行导出
                ExcelExportUtil.easySheet("推广收益明细导出记录"+DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "推广收益明细导出记录", dataList,request, response);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    @PostMapping("/list1")
    @ResponseBody
    public Object list1(String insertTime,
                       String orderNum,
                       String userName,
                       String name,
                       String driverName) {
            String beginTime = null;
            String endTime = null;
            if (SinataUtil.isNotEmpty(insertTime)) {
                String[] timeArray = insertTime.split(" - ");
                beginTime = timeArray[0];
                endTime = timeArray[1];
            }
            List<Map<String, Object>> list=new ArrayList<>();
            list =  tOrderPrivateCarService.promotionInfoExport(null, beginTime, endTime, orderNum, userName, name, driverName, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId());
        HashMap<String, Object> map = new HashMap<>();
        BigDecimal reduce = list.stream().map(e -> new BigDecimal(e.get("promotionMoney").toString())).reduce(BigDecimal.ZERO, BigDecimal::add);
        map.put("money", reduce);
        map.put("size", list.size());
        return map;
    }
 
 
 
}