package com.cdzy.user.controller; import com.cdzy.common.model.response.JsonResult; import com.cdzy.user.model.dto.EbikeUserCyclingDto; import com.cdzy.user.model.entity.EbikeOrder; import com.cdzy.user.model.vo.EbikeOrderVo; import com.cdzy.user.service.EbikeOrderService; import com.ebike.feign.model.dto.FeignEbikeDto; import com.ebike.feign.model.dto.FeignEbikeUserBikeInfo; import com.ebike.feign.model.dto.FeignOrderPaymentDto; import com.ebike.feign.model.vo.FeignEbikeBikeRadiusVo; import jakarta.annotation.Resource; import jakarta.validation.constraints.NotNull; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; /** * 用户订单 控制层 * * @author: yanglei * @since: 2025-10-15 17:15 */ @RestController @RequestMapping("/ebikeOrder") public class EbikeOrderController { @Resource private EbikeOrderService ebikeOrderService; /** * 开始骑行(生成订单、开锁) * * @param orderDto 骑行信息 (返回订单开始时间、开始点位) * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @PostMapping("saveRide") public JsonResult saveRide(@RequestBody @Validated EbikeUserCyclingDto orderDto) { EbikeOrderVo result = ebikeOrderService.saveRide(orderDto); return JsonResult.success(result); } /** * 查看用户是否有未完成订单。 * * @param userId 用户id * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("checkHistoryOrder") public JsonResult checkHistoryOrder(@Validated @NotNull(message = "用户id不能为空") @RequestParam("userId") Long userId) { EbikeOrder userOrders = ebikeOrderService.checkHistoryOrder(userId); return JsonResult.success(userOrders); } /** * 订单支付。 * * @param orderPaymentDto 支付信息 * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @PostMapping("payment") public JsonResult payment(@RequestBody @Validated FeignOrderPaymentDto orderPaymentDto) { ebikeOrderService.payment(orderPaymentDto); return JsonResult.success(); } /** * 订单退款申请。 * * @param orderId 订单ID * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("refundApply") public JsonResult refundApply(@RequestParam("orderId") Long orderId) { ebikeOrderService.refundApply(orderId); return JsonResult.success(); } /** * 订单退款。 * * @param orderId 订单ID * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("refund") public JsonResult refund(@RequestParam("orderId") Long orderId) { ebikeOrderService.refund(orderId); return JsonResult.success(); } /** * 订单退款完成。 * * @param orderId 订单ID * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("doneRefund") public JsonResult doneRefund(@RequestParam("orderId") Long orderId) { ebikeOrderService.doneRefund(orderId); return JsonResult.success(); } /** * 订单退款失败。 * * @param orderId 订单ID * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("failRefund") public JsonResult failRefund(@RequestParam("orderId") Long orderId) { ebikeOrderService.failRefund(orderId); return JsonResult.success(); } /** * 订单退款驳回。 * * @param orderId 订单ID * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("rejectRefund") public JsonResult rejectRefund(@RequestParam("orderId") Long orderId) { ebikeOrderService.rejectRefund(orderId); return JsonResult.success(); } /** * 根据用户订单表主键获取详细信。 * * @param orderId 用户订单表主键 * @ 用户订单表详情 */ @GetMapping("getInfo/{orderId}") public JsonResult getInfo(@PathVariable("orderId") Long orderId) { EbikeOrder userOrder = ebikeOrderService.getById(orderId); return JsonResult.success(userOrder); } /** * 车辆列表 * * @param feignEbikeBikeRadiusVo 坐标信息 * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @PostMapping("bikeList") public JsonResult bikeList(@RequestBody @Validated FeignEbikeBikeRadiusVo feignEbikeBikeRadiusVo) { List result = ebikeOrderService.userRadiusList(feignEbikeBikeRadiusVo); return JsonResult.success(result); } /** * 获取车辆基本信息 * * @param bikeCode 车辆编码 */ @GetMapping("queryBikeInfo") public JsonResult queryBikeInfo(@RequestParam("bikeCode") String bikeCode) { FeignEbikeUserBikeInfo result = ebikeOrderService.queryBikeInfo(bikeCode); return JsonResult.success(result); } }