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.EbikeOrderTransaction; import com.cdzy.user.service.EbikeOrderTransactionService; import jakarta.annotation.Resource; import jakarta.validation.constraints.NotBlank; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** * 用户订单 控制层 * * @author: yanglei * @since: 2025-10-15 17:15 */ @RestController @RequestMapping("/ebikeOrderTransaction") public class EbikeOrderTransactionController { @Resource private EbikeOrderTransactionService ebikeOrderTransactionService; /** * 开始骑行(生成订单、开锁) * * @param orderDto 骑行信息 * @ {@code 200} 添加成功,{@code 500} 添加失败 */ // @PostMapping("saveRide") // public JsonResult saveRide(@RequestBody @Validated EbikeUserCyclingDto orderDto) { // Long orderId = ebikeOrderTransactionService.saveRide(orderDto); // return JsonResult.success(orderId); // } /** * 查看用户是否有未完成订单。 * * @param userId 用户id * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("checkHistoryOrder") public JsonResult checkHistoryOrder(@Validated @NotBlank(message = "用户id不能为空") @RequestParam("userId") Long userId) { EbikeOrderTransaction userOrders = ebikeOrderTransactionService.checkHistoryOrder(userId); return JsonResult.success(userOrders); } /** * 订单退款。 * * @param orderId 订单ID * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("refund") public JsonResult refund(@RequestParam("orderId") String orderId) { ebikeOrderTransactionService.refund(orderId); return JsonResult.success(); } /** * 订单退款完成。 * * @param orderId 订单ID * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("doneRefund") public JsonResult doneRefund(@RequestParam("orderId") String orderId) { ebikeOrderTransactionService.doneRefund(orderId); return JsonResult.success(); } /** * 订单退款失败。 * * @param orderId 订单ID * @ {@code 200} 添加成功,{@code 500} 添加失败 */ @GetMapping("failRefund") public JsonResult failRefund(@RequestParam("orderId") String orderId) { ebikeOrderTransactionService.failRefund(orderId); return JsonResult.success(); } }