package com.supersavedriving.driver.modular.system.api;
|
|
import com.supersavedriving.driver.modular.system.model.Driver;
|
import com.supersavedriving.driver.modular.system.util.rongyun.RongYunUtil;
|
import com.supersavedriving.driver.modular.system.util.rongyun.model.CloudRecordingCallback;
|
import com.supersavedriving.driver.modular.system.warpper.*;
|
import com.supersavedriving.driver.core.util.ToolUtil;
|
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.OrderInfoWarpper;
|
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;
|
import java.util.Map;
|
|
/**
|
* 订单控制器
|
* @author pzb
|
* @Date 2023/2/16 15:02
|
*/
|
@RestController
|
@RequestMapping("")
|
public class OrderController {
|
|
@Autowired
|
private IOrderService orderService;
|
|
@Autowired
|
private IDriverService driverService;
|
|
@Autowired
|
private RongYunUtil rongYunUtil;
|
|
|
|
|
@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<Map<String, Object>> queryDriverServerOrder(){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
Map<String, Object> map = orderService.queryDriverServerOrder(uid);
|
return ResponseWarpper.success(map);
|
}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<Integer> driverAddOrder(AddOrderWarpper addOrderWarpper){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.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){
|
if(null == pageNum){
|
return ResponseWarpper.success(ResultUtil.paranErr("pageNum"));
|
}
|
if(null == pageSize){
|
return ResponseWarpper.success(ResultUtil.paranErr("pageSize"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.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){
|
if(null == orderId){
|
return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.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){
|
if(null == orderId){
|
return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = orderService.receiveOrder(uid, orderId);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
@ResponseBody
|
@PostMapping("/api/order/queryOrderInfo")
|
// @ServiceLog(name = "获取订单详情", url = "/api/order/queryOrderInfo")
|
@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<OrderInfoWarpper> queryOrderInfo(Long orderId){
|
if(null == orderId){
|
return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
OrderInfoWarpper orderInfoWarpper = orderService.queryOrderInfo(uid, orderId);
|
return ResponseWarpper.success(orderInfoWarpper);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
|
|
@ResponseBody
|
@PostMapping("/api/order/driverProcessOperations")
|
// @ServiceLog(name = "司机走订单流程", url = "/api/order/driverProcessOperations")
|
@ApiOperation(value = "司机走订单流程", tags = {"司机端-服务中"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper driverProcessOperations(ProcessOperationsWarpper processOperationsWarpper){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = orderService.driverProcessOperations(uid, processOperationsWarpper);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
@ResponseBody
|
@PostMapping("/api/order/transferOrder")
|
// @ServiceLog(name = "司机转单操作", url = "/api/order/transferOrder")
|
@ApiOperation(value = "司机转单操作", tags = {"司机端-服务中"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"),
|
@ApiImplicitParam(value = "原因", name = "cause", required = true, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper transferOrder(Long orderId, String cause){
|
if(ToolUtil.isEmpty(orderId)){
|
return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
|
}
|
if(ToolUtil.isEmpty(cause)){
|
return ResponseWarpper.success(ResultUtil.paranErr("cause"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = orderService.transferOrder(uid, orderId, cause);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/order/setOrderEndAddress")
|
// @ServiceLog(name = "司机修改订单终点", url = "/api/order/setOrderEndAddress")
|
@ApiOperation(value = "司机修改订单终点", tags = {"司机端-服务中"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper setOrderEndAddress(OrderEndAddressWarpper orderEndAddressWarpper){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = orderService.setOrderEndAddress(uid, orderEndAddressWarpper);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/order/cancelTransferOrder")
|
// @ServiceLog(name = "司机取消转单操作", url = "/api/order/cancelTransferOrder")
|
@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 cancelTransferOrder(Long orderId){
|
if(ToolUtil.isEmpty(orderId)){
|
return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = orderService.cancelTransferOrder(uid, orderId);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/order/driverCancelOrder")
|
// @ServiceLog(name = "司机取消订单操作", url = "/api/order/driverCancelOrder")
|
@ApiOperation(value = "司机取消订单操作", tags = {"司机端-服务中"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"),
|
@ApiImplicitParam(value = "原因", name = "cause", required = true, dataType = "string"),
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper driverCancelOrder(Long orderId, String cause){
|
if(ToolUtil.isEmpty(orderId)){
|
return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
|
}
|
if(ToolUtil.isEmpty(cause)){
|
return ResponseWarpper.success(ResultUtil.paranErr("cause"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = orderService.driverCancelOrder(uid, orderId, cause);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/order/queryOrderPrice")
|
// @ServiceLog(name = "获取订单费用明细", url = "/api/order/queryOrderPrice")
|
@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<OrderPriceWarpper> queryOrderPrice(Long orderId){
|
if(ToolUtil.isEmpty(orderId)){
|
return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
OrderPriceWarpper orderPriceWarpper = orderService.queryOrderPrice(uid, orderId);
|
return ResponseWarpper.success(orderPriceWarpper);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/order/setOrderStatus")
|
// @ServiceLog(name = "服务完成后修改订单状态", url = "/api/order/setOrderStatus")
|
@ApiOperation(value = "服务完成后修改订单状态", tags = {"司机端-服务中"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "long"),
|
@ApiImplicitParam(value = "107(线上支付),108(完成线下支付)", name = "state", required = true, dataType = "int"),
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper setOrderStatus(Long orderId, Integer state){
|
if(ToolUtil.isEmpty(orderId)){
|
return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
|
}
|
if(ToolUtil.isEmpty(state)){
|
return ResponseWarpper.success(ResultUtil.paranErr("state"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = orderService.setOrderStatus(uid, orderId, state);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
|
@ResponseBody
|
@PostMapping("/api/order/queryDriverOrderList")
|
// @ServiceLog(name = "获取司机订单列表", url = "/api/order/queryDriverOrderList")
|
@ApiOperation(value = "获取司机订单列表", tags = {"司机端-个人中心"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "订单状态(107=未支付,109=已完成,301=已取消)", name = "state", required = true, dataType = "int"),
|
@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<DriverOrderListWarpper>> queryDriverOrderList(Integer state, Integer pageNum, Integer pageSize){
|
if(null == pageNum){
|
return ResponseWarpper.success(ResultUtil.paranErr("pageNum"));
|
}
|
if(null == pageSize){
|
return ResponseWarpper.success(ResultUtil.paranErr("pageSize"));
|
}
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
List<DriverOrderListWarpper> driverOrderListWarppers = orderService.queryDriverOrderList(uid, state, pageNum, pageSize);
|
return ResponseWarpper.success(driverOrderListWarppers);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
/**
|
* 服务录音回调
|
* @param request
|
*/
|
@ResponseBody
|
@PostMapping("/base/order/cloudRecordingCallback")
|
public void cloudRecordingCallback(HttpServletRequest request){
|
CloudRecordingCallback cloudRecordingCallback = RongYunUtil.cloudRecordingCallback(request);
|
System.err.println("-------------------云端录制状态回调!-------------------");
|
if(null == cloudRecordingCallback){
|
System.err.println("云端录制状态回调解析出错!");
|
return;
|
}
|
Integer type = cloudRecordingCallback.getType();
|
if(4 == type){//文件上传
|
String fileUrl = cloudRecordingCallback.getOutput().getFileUrl();
|
System.err.println("文件上传完毕:" + fileUrl);
|
}
|
}
|
|
|
@ResponseBody
|
@PostMapping("/api/order/openOrderQRCode")
|
// @ServiceLog(name = "打开下单二维码操作", url = "/api/order/openOrderQRCode")
|
@ApiOperation(value = "打开下单二维码操作", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper openOrderQRCode(){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = driverService.openOrderQRCode(uid);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
|
|
|
@ResponseBody
|
@PostMapping("/api/order/closeOrderQRCode")
|
// @ServiceLog(name = "关闭下单二维码操作", url = "/api/order/closeOrderQRCode")
|
@ApiOperation(value = "关闭下单二维码操作", tags = {"司机端-首页"}, notes = "")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
|
})
|
public ResponseWarpper closeOrderQRCode(){
|
try {
|
Integer uid = driverService.getUserByRequest();
|
if(null == uid){
|
return ResponseWarpper.tokenErr();
|
}
|
ResultUtil resultUtil = driverService.closeOrderQRCode(uid);
|
return ResponseWarpper.success(resultUtil);
|
}catch (Exception e){
|
e.printStackTrace();
|
return new ResponseWarpper(500, e.getMessage());
|
}
|
}
|
}
|