puzhibing
2023-02-22 a43a99043e8c7c63187a51a302333cb530dbe9c8
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
package com.supersavedriving.driver.modular.system.api;
 
import com.supersavedriving.driver.core.common.annotion.ServiceLog;
import com.supersavedriving.driver.modular.system.service.IDriverService;
import com.supersavedriving.driver.modular.system.service.IOrderService;
import com.supersavedriving.driver.modular.system.util.ResultUtil;
import com.supersavedriving.driver.modular.system.warpper.AddOrderWarpper;
import com.supersavedriving.driver.modular.system.warpper.HallOrderList;
import com.supersavedriving.driver.modular.system.warpper.ResponseWarpper;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import java.util.List;
 
/**
* 订单控制器
* @author pzb
* @Date 2023/2/16 15:02
*/
@RestController
@RequestMapping("")
public class OrderController {
 
    @Autowired
    private IOrderService orderService;
 
    @Autowired
    private IDriverService driverService;
 
 
 
 
    @ResponseBody
    @PostMapping("/api/order/queryDriverServerOrder")
    @ServiceLog(name = "获取司机服务中的订单id", url = "/api/order/queryDriverServerOrder")
    @ApiOperation(value = "获取司机服务中的订单id", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper<Long> queryDriverServerOrder(HttpServletRequest request){
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.tokenErr());
            }
            Long id = orderService.queryDriverServerOrder(uid);
            return ResponseWarpper.success(id);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
 
 
 
    @ResponseBody
    @PostMapping("/api/order/driverAddOrder")
    @ServiceLog(name = "司机代客下单", url = "/api/order/driverAddOrder")
    @ApiOperation(value = "司机代客下单", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper driverAddOrder(AddOrderWarpper addOrderWarpper, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.tokenErr());
            }
            ResultUtil resultUtil = orderService.driverAddOrder(uid, addOrderWarpper);
            return ResponseWarpper.success(resultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
 
 
 
    @ResponseBody
    @PostMapping("/api/order/queryOrderHall")
    @ServiceLog(name = "司机获取大厅订单列表", url = "/api/order/queryOrderHall")
    @ApiOperation(value = "司机获取大厅订单列表", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "页码,首页1", name = "pageNum", required = true, dataType = "int"),
            @ApiImplicitParam(value = "页条数", name = "pageSize", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper<List<HallOrderList>> queryOrderHall(Integer pageNum, Integer pageSize, HttpServletRequest request){
        if(null == pageNum){
            return ResponseWarpper.success(ResultUtil.paranErr("pageNum"));
        }
        if(null == pageSize){
            return ResponseWarpper.success(ResultUtil.paranErr("pageSize"));
        }
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.tokenErr());
            }
            List<HallOrderList> hallOrderLists = orderService.queryOrderHall(uid, pageNum, pageSize);
            return ResponseWarpper.success(hallOrderLists);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
 
 
 
 
    @ResponseBody
    @PostMapping("/api/order/rejectionOrder")
    @ServiceLog(name = "司机拒绝接单", url = "/api/order/rejectionOrder")
    @ApiOperation(value = "司机拒绝接单", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper rejectionOrder(Long orderId, HttpServletRequest request){
        if(null == orderId){
            return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
        }
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.tokenErr());
            }
            ResultUtil resultUtil = orderService.rejectionOrder(uid, orderId);
            return ResponseWarpper.success(resultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
 
 
 
 
 
    @ResponseBody
    @PostMapping("/api/order/receiveOrder")
    @ServiceLog(name = "司机接单操作", url = "/api/order/receiveOrder")
    @ApiOperation(value = "司机接单操作", tags = {"司机端-首页"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"),
            @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResponseWarpper receiveOrder(Long orderId, HttpServletRequest request){
        if(null == orderId){
            return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
        }
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.tokenErr());
            }
            ResultUtil resultUtil = orderService.receiveOrder(uid, orderId);
            return ResponseWarpper.success(resultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
 
 
 
    public ResponseWarpper<> queryOrderInfo(Long orderId, HttpServletRequest request){
        if(null == orderId){
            return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
        }
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.tokenErr());
            }
            ResultUtil resultUtil = orderService.receiveOrder(uid, orderId);
            return ResponseWarpper.success(resultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());
        }
    }
 
}