2025-10-15 17:38:13 +08:00
|
|
|
|
package com.cdzy.user.controller;
|
|
|
|
|
|
|
2026-01-07 15:27:07 +08:00
|
|
|
|
import com.cdzy.common.enums.Code;
|
|
|
|
|
|
import com.cdzy.common.ex.EbikeException;
|
2025-11-17 16:03:28 +08:00
|
|
|
|
import com.cdzy.common.model.request.PageParam;
|
2025-10-16 11:39:47 +08:00
|
|
|
|
import com.cdzy.common.model.response.JsonResult;
|
2025-10-31 17:02:53 +08:00
|
|
|
|
import com.cdzy.user.model.dto.EbikeUserCyclingDto;
|
2025-11-11 15:59:49 +08:00
|
|
|
|
import com.cdzy.user.model.dto.EbikeUserCyclingEndDto;
|
2025-10-29 17:01:46 +08:00
|
|
|
|
import com.cdzy.user.model.entity.EbikeOrder;
|
2025-12-12 10:06:46 +08:00
|
|
|
|
import com.cdzy.user.model.vo.EbikeBikeInfoVo;
|
2026-01-15 13:38:35 +08:00
|
|
|
|
import com.cdzy.user.model.vo.EbikeOrderDetailVo;
|
2025-11-28 14:28:42 +08:00
|
|
|
|
import com.cdzy.user.model.vo.EbikeRevenueStatisticsVo;
|
2025-11-17 14:35:22 +08:00
|
|
|
|
import com.cdzy.user.model.vo.EbikeUserAllOrdersVo;
|
2025-10-29 17:01:46 +08:00
|
|
|
|
import com.cdzy.user.service.EbikeOrderService;
|
2026-01-07 15:27:07 +08:00
|
|
|
|
import com.ebike.feign.clients.PaymentFeignClient;
|
2025-11-07 17:41:57 +08:00
|
|
|
|
import com.ebike.feign.model.dto.FeignEbikeDto;
|
2026-01-16 15:37:45 +08:00
|
|
|
|
import com.ebike.feign.model.dto.FeignEbikeOrderStatisticsDto;
|
2026-02-09 16:08:40 +08:00
|
|
|
|
import com.ebike.feign.model.dto.FeignEbikePaymentAmountDto;
|
2025-11-07 17:41:57 +08:00
|
|
|
|
import com.ebike.feign.model.vo.FeignEbikeBikeRadiusVo;
|
2026-01-16 15:37:45 +08:00
|
|
|
|
import com.ebike.feign.model.vo.FeignEbikeOrderStatisticsVo;
|
2026-01-07 15:27:07 +08:00
|
|
|
|
import com.ebike.feign.model.vo.FeignEbikeWxHandleNotifyVo;
|
2025-11-17 16:03:28 +08:00
|
|
|
|
import com.mybatisflex.core.paginate.Page;
|
2025-10-15 17:38:13 +08:00
|
|
|
|
import jakarta.annotation.Resource;
|
2025-11-10 16:29:17 +08:00
|
|
|
|
import jakarta.validation.constraints.NotNull;
|
2025-10-16 11:39:47 +08:00
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
2026-01-06 10:45:00 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
2025-10-15 17:38:13 +08:00
|
|
|
|
|
2025-11-07 17:41:57 +08:00
|
|
|
|
import java.util.List;
|
2025-10-29 16:10:00 +08:00
|
|
|
|
|
2025-10-15 17:38:13 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 用户订单 控制层
|
|
|
|
|
|
*
|
2025-11-13 09:57:37 +08:00
|
|
|
|
* @author yanglei
|
|
|
|
|
|
* @since 2025-10-15 17:15
|
2025-10-15 17:38:13 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
2025-10-29 17:01:46 +08:00
|
|
|
|
@RequestMapping("/ebikeOrder")
|
|
|
|
|
|
public class EbikeOrderController {
|
2025-10-15 17:38:13 +08:00
|
|
|
|
|
|
|
|
|
|
@Resource
|
2025-10-31 17:02:53 +08:00
|
|
|
|
private EbikeOrderService ebikeOrderService;
|
2025-10-15 17:38:13 +08:00
|
|
|
|
|
2026-01-07 15:27:07 +08:00
|
|
|
|
@Resource
|
|
|
|
|
|
private PaymentFeignClient paymentFeignClient;
|
|
|
|
|
|
|
2025-11-11 15:59:49 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 车辆列表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param feignEbikeBikeRadiusVo 坐标信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("bikeList")
|
|
|
|
|
|
public JsonResult<?> bikeList(@RequestBody @Validated FeignEbikeBikeRadiusVo feignEbikeBikeRadiusVo) {
|
|
|
|
|
|
List<FeignEbikeDto> result = ebikeOrderService.userRadiusList(feignEbikeBikeRadiusVo);
|
|
|
|
|
|
return JsonResult.success(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取车辆基本信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param bikeCode 车辆编码
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("queryBikeInfo")
|
|
|
|
|
|
public JsonResult<?> queryBikeInfo(@RequestParam("bikeCode") String bikeCode) {
|
2025-12-12 10:06:46 +08:00
|
|
|
|
EbikeBikeInfoVo result = ebikeOrderService.queryBikeInfo(bikeCode);
|
2025-11-11 15:59:49 +08:00
|
|
|
|
return JsonResult.success(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-28 09:40:32 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 开始骑行(生成订单、开锁)
|
|
|
|
|
|
*
|
2025-11-10 16:29:17 +08:00
|
|
|
|
* @param orderDto 骑行信息 (返回订单开始时间、开始点位)
|
2025-10-28 09:40:32 +08:00
|
|
|
|
*/
|
2025-10-31 17:02:53 +08:00
|
|
|
|
@PostMapping("saveRide")
|
|
|
|
|
|
public JsonResult<?> saveRide(@RequestBody @Validated EbikeUserCyclingDto orderDto) {
|
2025-11-11 15:59:49 +08:00
|
|
|
|
EbikeOrder result = ebikeOrderService.saveRide(orderDto);
|
2025-11-10 16:29:17 +08:00
|
|
|
|
return JsonResult.success(result);
|
2025-10-31 17:02:53 +08:00
|
|
|
|
}
|
2025-10-28 09:40:32 +08:00
|
|
|
|
|
2025-10-16 11:39:47 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查看用户是否有未完成订单。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param userId 用户id
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("checkHistoryOrder")
|
2025-11-10 16:29:17 +08:00
|
|
|
|
public JsonResult<?> checkHistoryOrder(@Validated @NotNull(message = "用户id不能为空") @RequestParam("userId") Long userId) {
|
2026-01-16 17:13:24 +08:00
|
|
|
|
EbikeOrderDetailVo userOrders = ebikeOrderService.checkHistoryOrder(userId);
|
2025-10-16 11:39:47 +08:00
|
|
|
|
return JsonResult.success(userOrders);
|
|
|
|
|
|
}
|
2025-10-15 17:38:13 +08:00
|
|
|
|
|
2025-11-11 15:59:49 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 完成骑行(关锁还车)。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param endDto 骑行信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("doneRide")
|
|
|
|
|
|
public JsonResult<?> doneRide(@RequestBody @Validated EbikeUserCyclingEndDto endDto) {
|
2025-11-11 17:31:14 +08:00
|
|
|
|
Long orderId = ebikeOrderService.doneRide(endDto);
|
|
|
|
|
|
return JsonResult.success(orderId);
|
2025-11-11 15:59:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-29 16:10:00 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据用户订单表主键获取详细信。
|
|
|
|
|
|
*
|
2025-10-31 17:02:53 +08:00
|
|
|
|
* @param orderId 用户订单表主键
|
2025-10-29 16:10:00 +08:00
|
|
|
|
*/
|
2026-01-08 10:32:51 +08:00
|
|
|
|
@GetMapping("getInfo")
|
|
|
|
|
|
public JsonResult<?> getInfo(@RequestParam("orderId") Long orderId) {
|
2026-01-15 13:38:35 +08:00
|
|
|
|
EbikeOrderDetailVo userOrder = ebikeOrderService.getInfo(orderId);
|
2025-10-29 16:10:00 +08:00
|
|
|
|
return JsonResult.success(userOrder);
|
|
|
|
|
|
}
|
2025-11-17 14:35:22 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据用户订单表主键获取订单状态。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param orderId 用户订单表主键
|
|
|
|
|
|
*/
|
2026-01-08 10:32:51 +08:00
|
|
|
|
@GetMapping("getOrderStatus")
|
|
|
|
|
|
public JsonResult<?> getOrderStatus(@RequestParam("orderId") Long orderId) {
|
2025-11-17 14:35:22 +08:00
|
|
|
|
Integer orderStatus = ebikeOrderService.getOrderStatus(orderId);
|
|
|
|
|
|
return JsonResult.success(orderStatus);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-17 16:03:28 +08:00
|
|
|
|
* 根据用户id获取用户所有订单。
|
2025-11-17 14:35:22 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param userId 用户订单表主键
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("getUserAllOrder")
|
2025-11-20 11:28:24 +08:00
|
|
|
|
public JsonResult<?> getUserAllOrder(Long userId, Integer orderStatus, PageParam page) {
|
|
|
|
|
|
Page<EbikeUserAllOrdersVo> userAllOrders = ebikeOrderService.getUserAllOrder(userId, orderStatus, page);
|
2025-11-17 14:35:22 +08:00
|
|
|
|
return JsonResult.success(userAllOrders);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-28 14:28:42 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询营收统计。
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("getRevenueStatistics")
|
|
|
|
|
|
public JsonResult<?> getRevenueStatistics() {
|
|
|
|
|
|
List<EbikeRevenueStatisticsVo> revenueStatistics = ebikeOrderService.getRevenueStatistics();
|
|
|
|
|
|
return JsonResult.success(revenueStatistics);
|
|
|
|
|
|
}
|
2026-01-07 15:27:07 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通过商户(骑行)订单订单号查询支付订单状态
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param orderId 订单id
|
|
|
|
|
|
*/
|
2026-01-08 10:32:51 +08:00
|
|
|
|
@GetMapping("queryOrderStatus")
|
|
|
|
|
|
public JsonResult<?> queryOrderStatusById(@RequestParam("orderId") Long orderId) {
|
2026-01-07 15:27:07 +08:00
|
|
|
|
JsonResult<FeignEbikeWxHandleNotifyVo> jsonResult = paymentFeignClient.queryOrderStatusById(orderId);
|
|
|
|
|
|
if (jsonResult.getCode() != Code.SUCCESS) {
|
|
|
|
|
|
throw new EbikeException(jsonResult.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
return JsonResult.success(jsonResult.getData());
|
|
|
|
|
|
}
|
2026-01-16 15:37:45 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询不同运营商的订单数据及订单金额
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param dto 订单请求参数
|
|
|
|
|
|
* @return 订单数据及订单金额
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/api/getOrderStatistics")
|
|
|
|
|
|
public JsonResult<?> getOrderStatistics(@RequestBody @Validated FeignEbikeOrderStatisticsDto dto) {
|
2026-01-16 16:03:09 +08:00
|
|
|
|
FeignEbikeOrderStatisticsVo result = ebikeOrderService.getOrderStatistics(dto);
|
2026-01-16 15:37:45 +08:00
|
|
|
|
return JsonResult.success(result);
|
|
|
|
|
|
}
|
2026-02-09 16:08:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据车辆编号修改订单金额
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param paymentAmountDto 车辆编号
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/api/updateOrderAmount")
|
|
|
|
|
|
public JsonResult<?> updateOrderAmount(@RequestBody @Validated FeignEbikePaymentAmountDto paymentAmountDto) {
|
|
|
|
|
|
ebikeOrderService.updateOrderAmount(paymentAmountDto);
|
|
|
|
|
|
return JsonResult.success();
|
|
|
|
|
|
}
|
2025-10-15 17:38:13 +08:00
|
|
|
|
}
|