puzhibing
2023-02-25 4ba348b700fd7f461f754a283eaeeba3fc9ff36c
driver/guns-admin/src/main/java/com/supersavedriving/driver/modular/system/api/OrderController.java
@@ -1,13 +1,11 @@
package com.supersavedriving.driver.modular.system.api;
import com.supersavedriving.driver.core.common.annotion.ServiceLog;
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 com.supersavedriving.driver.modular.system.warpper.ResponseWarpper;
import com.supersavedriving.driver.modular.system.warpper.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@@ -119,7 +117,7 @@
    @ResponseBody
    @PostMapping("/api/order/rejectionOrder")
    @ServiceLog(name = "司机拒绝接单", url = "/api/order/rejectionOrder")
    @ApiOperation(value = "司机拒绝接单", tags = {"司机端-首页"}, notes = "")
    @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.....")
@@ -148,7 +146,7 @@
    @ResponseBody
    @PostMapping("/api/order/receiveOrder")
    @ServiceLog(name = "司机接单操作", url = "/api/order/receiveOrder")
    @ApiOperation(value = "司机接单操作", tags = {"司机端-首页"}, notes = "")
    @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.....")
@@ -176,7 +174,7 @@
    @ResponseBody
    @PostMapping("/api/order/queryOrderInfo")
    @ServiceLog(name = "获取订单详情", url = "/api/order/queryOrderInfo")
    @ApiOperation(value = "获取订单详情", tags = {"司机端-首页"}, notes = "")
    @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.....")
@@ -200,15 +198,193 @@
    public ResponseWarpper driverProcessOperations(Long orderId, Integer state, HttpServletRequest request){
        if(null == orderId){
    @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, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.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, HttpServletRequest request){
        if(ToolUtil.isEmpty(orderId)){
            return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
        }
        if(null == state){
        if(ToolUtil.isEmpty(cause)){
            return ResponseWarpper.success(ResultUtil.paranErr("cause"));
        }
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.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, HttpServletRequest request){
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.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, HttpServletRequest request){
        if(ToolUtil.isEmpty(orderId)){
            return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
        }
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.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, HttpServletRequest request){
        if(ToolUtil.isEmpty(orderId)){
            return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
        }
        if(ToolUtil.isEmpty(cause)){
            return ResponseWarpper.success(ResultUtil.paranErr("cause"));
        }
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.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, HttpServletRequest request){
        if(ToolUtil.isEmpty(orderId)){
            return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
        }
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.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, HttpServletRequest request){
        if(ToolUtil.isEmpty(orderId)){
            return ResponseWarpper.success(ResultUtil.paranErr("orderId"));
        }
        if(ToolUtil.isEmpty(state)){
            return ResponseWarpper.success(ResultUtil.paranErr("state"));
        }
        try {
            Integer uid = driverService.getUserByRequset(request);
            if(null == uid){
                return ResponseWarpper.success(ResultUtil.tokenErr());
            }
            ResultUtil resultUtil = orderService.setOrderStatus(uid, orderId, state);
            return ResponseWarpper.success(resultUtil);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseWarpper(500, e.getMessage());