2024-04-23 12:23:43 +08:00
|
|
|
package com.sky.controller.user;
|
|
|
|
|
2024-08-07 14:11:29 +08:00
|
|
|
import com.sky.dto.OrdersPaymentDTO;
|
2024-04-23 12:23:43 +08:00
|
|
|
import com.sky.dto.OrdersSubmitDTO;
|
2024-08-13 09:29:47 +08:00
|
|
|
import com.sky.result.PageResult;
|
2024-04-23 12:23:43 +08:00
|
|
|
import com.sky.result.Result;
|
|
|
|
import com.sky.service.OrderService;
|
2024-08-07 14:11:29 +08:00
|
|
|
import com.sky.vo.OrderPaymentVO;
|
2024-04-23 12:23:43 +08:00
|
|
|
import com.sky.vo.OrderSubmitVO;
|
2024-08-13 09:29:47 +08:00
|
|
|
import com.sky.vo.OrderVO;
|
2024-04-23 12:23:43 +08:00
|
|
|
import io.swagger.annotations.Api;
|
2024-08-07 14:11:29 +08:00
|
|
|
import io.swagger.annotations.ApiOperation;
|
2024-04-23 12:23:43 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2024-08-07 14:11:29 +08:00
|
|
|
import org.springframework.web.bind.annotation.*;
|
2024-04-23 12:23:43 +08:00
|
|
|
|
|
|
|
@RestController
|
|
|
|
@Api("用户订单相关接口")
|
|
|
|
@Slf4j
|
|
|
|
@RequestMapping("/user/order")
|
|
|
|
public class OrderController {
|
|
|
|
@Autowired
|
|
|
|
private OrderService orderService;
|
|
|
|
@PostMapping("/submit")
|
2024-08-07 14:11:29 +08:00
|
|
|
@ApiOperation("提交订单")
|
2024-04-23 12:23:43 +08:00
|
|
|
public Result<OrderSubmitVO> submit(@RequestBody OrdersSubmitDTO ordersSubmitDTO){
|
|
|
|
OrderSubmitVO orderSubmitVO=orderService.submit(ordersSubmitDTO);
|
|
|
|
return Result.success(orderSubmitVO);
|
|
|
|
}
|
2024-08-07 14:11:29 +08:00
|
|
|
/**
|
|
|
|
* 订单支付
|
|
|
|
*
|
|
|
|
* @param ordersPaymentDTO
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PutMapping("/payment")
|
|
|
|
@ApiOperation("订单支付")
|
|
|
|
public Result<OrderPaymentVO> payment(@RequestBody OrdersPaymentDTO ordersPaymentDTO) throws Exception {
|
|
|
|
log.info("订单支付:{}", ordersPaymentDTO);
|
|
|
|
OrderPaymentVO orderPaymentVO = orderService.payment(ordersPaymentDTO);
|
|
|
|
log.info("生成预支付交易单:{}", orderPaymentVO);
|
|
|
|
orderService.paySuccess(ordersPaymentDTO.getOrderNumber());
|
|
|
|
return Result.success(orderPaymentVO);
|
|
|
|
}
|
2024-08-13 09:29:47 +08:00
|
|
|
|
|
|
|
@GetMapping("/historyOrders")
|
|
|
|
@ApiOperation("查询历史订单")
|
|
|
|
public Result<PageResult> page(int page,int pageSize,int status){
|
|
|
|
PageResult pageResult = orderService.pageQuery4User(page, pageSize, status);
|
|
|
|
return Result.success(pageResult);
|
|
|
|
}
|
|
|
|
@GetMapping("/orderDetail/{id}")
|
|
|
|
@ApiOperation("查询订单详情")
|
|
|
|
public Result<OrderVO> details(@PathVariable Integer id){
|
|
|
|
OrderVO orderVO=orderService.details(id);
|
|
|
|
return Result.success(orderVO);
|
|
|
|
}
|
|
|
|
@PutMapping("/cancel/{id}")
|
|
|
|
@ApiOperation("取消订单")
|
|
|
|
public Result cancel(@PathVariable Integer id) throws Exception {
|
|
|
|
orderService.cancel(id);
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 再来一单
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@PostMapping("/repetition/{id}")
|
|
|
|
@ApiOperation("再来一单")
|
|
|
|
public Result repetition(@PathVariable Long id) {
|
|
|
|
orderService.repetition(id);
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
|
2024-04-23 12:23:43 +08:00
|
|
|
}
|