package com.doumee.api.web;
|
|
import com.doumee.core.annotation.LoginDriverRequired;
|
import com.doumee.core.annotation.LoginRequired;
|
import com.doumee.core.annotation.trace.Trace;
|
import com.doumee.config.jwt.JwtTokenUtil;
|
import com.doumee.core.model.ApiResponse;
|
import com.doumee.core.model.PageData;
|
import com.doumee.core.model.PageWrap;
|
import com.doumee.dao.business.model.DriverInfo;
|
import com.doumee.dao.dto.DriverActiveOrderDTO;
|
import com.doumee.dao.dto.DriverGrabOrderDTO;
|
import com.doumee.dao.dto.DriverLoginRequest;
|
import com.doumee.dao.dto.DriverDeliverDTO;
|
import com.doumee.dao.dto.DriverOrderPageDTO;
|
import com.doumee.dao.dto.DriverPickupDTO;
|
import com.doumee.dao.dto.DriverRegisterRequest;
|
import com.doumee.dao.dto.DriverVerifyRequest;
|
import com.doumee.dao.vo.AccountResponse;
|
import com.doumee.dao.vo.DriverActiveOrderCountVO;
|
import com.doumee.dao.vo.DriverCancelLimitVO;
|
import com.doumee.dao.vo.DriverCenterVO;
|
import com.doumee.dao.vo.DriverGrabOrderVO;
|
import com.doumee.dao.vo.DriverOrderDetailVO;
|
import com.doumee.service.business.DriverInfoService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.validation.Valid;
|
import java.util.List;
|
|
/**
|
* 司机验证码登录接口
|
* @author rk
|
* @date 2026/04/08
|
*/
|
@Api(tags = "司机业务接口")
|
@Trace(exclude = true)
|
@RestController
|
@RequestMapping("/web/driverInfo")
|
@Slf4j
|
public class DriverInfoApi extends ApiController {
|
|
@Autowired
|
private DriverInfoService driverInfoService;
|
|
@Trace
|
@ApiOperation(value = "发送验证码", notes = "司机验证码登录")
|
@GetMapping("/sendCode")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "query", dataType = "String", name = "telephone", value = "手机号", required = true)
|
})
|
public ApiResponse sendCode(@RequestParam String telephone) {
|
driverInfoService.sendRegisterCode(telephone);
|
return ApiResponse.success("验证码发送成功");
|
}
|
|
@Trace
|
@ApiOperation(value = "司机验证码登录", notes = "手机号+验证码,无账号自动注册并登录")
|
@PostMapping("/register")
|
public ApiResponse<AccountResponse> register(@RequestBody DriverRegisterRequest request) {
|
return ApiResponse.success("注册成功", driverInfoService.register(request));
|
}
|
|
@Trace
|
@ApiOperation(value = "司机登录", notes = "手机号+密码登录")
|
@PostMapping("/login")
|
public ApiResponse<AccountResponse> login(@RequestBody DriverLoginRequest request) {
|
return ApiResponse.success("登录成功", driverInfoService.login(request));
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "提交实名认证", notes = "初次提交或驳回后修改")
|
@PostMapping("/submitVerify")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse submitVerify(@RequestBody DriverVerifyRequest request) {
|
driverInfoService.submitVerify(this.getDriverId(), request);
|
return ApiResponse.success("提交成功");
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "查询实名认证详情", notes = "司机端查询")
|
@GetMapping("/verifyDetail")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse<DriverInfo> verifyDetail() {
|
return ApiResponse.success(driverInfoService.getVerifyDetail(this.getDriverId()));
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "切换接单状态", notes = "0=未接单;1=接单中")
|
@GetMapping("/updateAcceptingStatus")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true),
|
@ApiImplicitParam(paramType = "query", dataType = "int", name = "status", value = "接单状态:0=未接单;1=接单中", required = true)
|
})
|
public ApiResponse updateAcceptingStatus(@RequestParam Integer status) {
|
driverInfoService.updateAcceptingStatus(this.getDriverId(), status);
|
return ApiResponse.success("操作成功");
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "更新实时定位", notes = "司机端上报当前位置经纬度")
|
@GetMapping("/updateLocation")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true),
|
@ApiImplicitParam(paramType = "query", dataType = "Double", name = "longitude", value = "经度", required = true),
|
@ApiImplicitParam(paramType = "query", dataType = "Double", name = "latitude", value = "纬度", required = true)
|
})
|
public ApiResponse updateLocation(@RequestParam Double longitude, @RequestParam Double latitude) {
|
driverInfoService.updateLocation(this.getDriverId(), longitude, latitude);
|
return ApiResponse.success("操作成功");
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机端首页信息", notes = "姓名、头像、车牌号、评分、今日佣金、今日接单数、余额")
|
@GetMapping("/centerInfo")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse<DriverCenterVO> centerInfo() {
|
return ApiResponse.success("操作成功", driverInfoService.getDriverCenterInfo(this.getDriverId()));
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机累计统计", notes = "累计佣金、待结算佣金、订单总数、钱包余额")
|
@GetMapping("/stats")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse<com.doumee.dao.vo.DriverStatsVO> stats() {
|
return ApiResponse.success("操作成功", driverInfoService.getDriverStats(this.getDriverId()));
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机抢单大厅", notes = "分页查询可抢的异地寄存订单")
|
@PostMapping("/grabOrderHall")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse<PageData<DriverGrabOrderVO>> grabOrderHall(@RequestBody PageWrap<DriverGrabOrderDTO> pageWrap) {
|
return ApiResponse.success("操作成功", driverInfoService.grabOrderHall(this.getDriverId(), pageWrap));
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机抢单", notes = "对已寄存(status=2)的异地寄存订单发起抢单")
|
@GetMapping("/grabOrder")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true),
|
@ApiImplicitParam(paramType = "query", dataType = "Integer", name = "orderId", value = "订单主键", required = true)
|
})
|
public ApiResponse grabOrder(@RequestParam Integer orderId) {
|
driverInfoService.grabOrder(this.getDriverId(), orderId);
|
return ApiResponse.success("抢单成功");
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机进行中订单", notes = "查询已抢单(status=3)或派送中(status=4)的订单列表")
|
@PostMapping("/activeOrders")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse<List<DriverGrabOrderVO>> activeOrders(@RequestBody @Valid DriverActiveOrderDTO dto) {
|
return ApiResponse.success("操作成功", driverInfoService.activeOrders(this.getDriverId(), dto));
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机端订单详情", notes = "根据订单主键查询详情")
|
@GetMapping("/orderDetail")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true),
|
@ApiImplicitParam(paramType = "query", dataType = "Integer", name = "orderId", value = "订单主键", required = true)
|
})
|
public ApiResponse<DriverOrderDetailVO> orderDetail(@RequestParam Integer orderId) {
|
return ApiResponse.success("操作成功", driverInfoService.driverOrderDetail(this.getDriverId(), orderId));
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机取消订单", notes = "已接单(status=2)时取消,释放订单回抢单大厅")
|
@PostMapping("/cancelOrder")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse cancelOrder(@RequestParam Integer orderId,
|
@RequestParam(required = false) String reason) {
|
driverInfoService.cancelOrder(this.getDriverId(), orderId, reason);
|
return ApiResponse.success("取消成功");
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机完成取件", notes = "已接单(status=3)时确认取件,订单进入派送中(status=4)")
|
@PostMapping("/confirmPickup")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse confirmPickup(@RequestBody @Valid DriverPickupDTO dto) {
|
driverInfoService.confirmPickup(this.getDriverId(), dto);
|
return ApiResponse.success("操作成功");
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机确认送达", notes = "异地寄存无取件门店订单,派送中(status=4)时确认送达,订单进入已送达(status=5)")
|
@PostMapping("/confirmDeliver")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse confirmDeliver(@RequestBody @Valid DriverDeliverDTO dto) {
|
driverInfoService.confirmDeliver(this.getDriverId(), dto);
|
return ApiResponse.success("操作成功");
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机修改密码", notes = "新密码必须同时包含字母和数字,修改成功后需重新登录")
|
@GetMapping("/changePassword")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true),
|
})
|
public ApiResponse changePassword(@RequestParam String newPassword) {
|
String token = this.getRequest().getHeader(JwtTokenUtil.HEADER_KEY);
|
driverInfoService.changePassword(this.getDriverId(), newPassword, token);
|
return ApiResponse.success("密码修改成功,请重新登录");
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "进行中订单数量", notes = "返回已抢单和派送中的订单数量")
|
@GetMapping("/activeOrderCount")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse<DriverActiveOrderCountVO> activeOrderCount() {
|
return ApiResponse.success("操作成功", driverInfoService.getActiveOrderCount(this.getDriverId()));
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "司机订单分页", notes = "查询司机的全部/待取件/配送中/已完成订单")
|
@PostMapping("/orderPage")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse<PageData<DriverGrabOrderVO>> orderPage(@RequestBody PageWrap<DriverOrderPageDTO> pageWrap) {
|
return ApiResponse.success("操作成功", driverInfoService.driverOrderPage(this.getDriverId(), pageWrap));
|
}
|
|
@LoginDriverRequired
|
@Trace
|
@ApiOperation(value = "今日可取消次数", notes = "返回司机今日取消次数上限、已取消次数、剩余可取消次数")
|
@GetMapping("/cancelLimit")
|
@ApiImplicitParams({
|
@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true)
|
})
|
public ApiResponse<DriverCancelLimitVO> cancelLimit() {
|
return ApiResponse.success("操作成功", driverInfoService.getTodayCancelLimit(this.getDriverId()));
|
}
|
|
}
|