| package com.mzl.flower.web.customer; | 
|   | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.mzl.flower.base.BaseController; | 
| import com.mzl.flower.base.R; | 
| import com.mzl.flower.base.ReturnDataDTO; | 
| import com.mzl.flower.config.exception.ValidationException; | 
| import com.mzl.flower.dto.request.payment.OrderEvaluateDTO; | 
| import com.mzl.flower.dto.request.payment.OrderQueryDTO; | 
| import com.mzl.flower.dto.response.payment.CustomerOrderCountDTO; | 
| import com.mzl.flower.dto.response.payment.OrderDTO; | 
| import com.mzl.flower.dto.response.payment.OrderItemListDTO; | 
| import com.mzl.flower.dto.response.payment.OrderListDTO; | 
| import com.mzl.flower.entity.payment.Order; | 
| import com.mzl.flower.service.payment.OrderService; | 
| import com.mzl.flower.service.payment.UserPaymentV3Service; | 
| 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.http.ResponseEntity; | 
| import org.springframework.validation.annotation.Validated; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import java.util.List; | 
|   | 
| @RestController | 
| @RequestMapping("/api/customer/order") | 
| @Api(value = "订单管理-花店", tags = "订单管理-花店") | 
| @Validated | 
| @Slf4j | 
| public class OrderCustomerController extends BaseController { | 
|   | 
|     @Autowired | 
|     private OrderService orderService; | 
|   | 
|     @Autowired | 
|     private UserPaymentV3Service paymentV3Service; | 
|   | 
|     @GetMapping("/list") | 
|     @ApiOperation(value = "查询订单列表") | 
|     public ResponseEntity<ReturnDataDTO<Page<OrderListDTO>>> selectOrderList(Page page, OrderQueryDTO dto){ | 
|         return returnData(R.SUCCESS.getCode(), orderService.selectCustomerOrderList(page, dto)); | 
|     } | 
|   | 
|     @GetMapping("/list/view") | 
|     @ApiOperation(value = "订单详情") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<OrderDTO>> getOrderInfo(String id){ | 
|         return returnData(R.SUCCESS.getCode(), orderService.getOrderInfo(id)); | 
|     } | 
|   | 
|     @GetMapping("/item/list") | 
|     @ApiOperation(value = "订单商品明细") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<List<OrderItemListDTO>>> getPtCuOrderItems(String id){ | 
|         return returnData(R.SUCCESS.getCode(), orderService.getPtCuOrderItems(id)); | 
|     } | 
|   | 
|     @GetMapping("/receive/confirm") | 
|     @ApiOperation(value = "确认收货") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> confirmOrderReceive(String id){ | 
|         Order o = orderService.confirmOrderReceive(id); | 
|         orderService.processAfterReceive(o); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping("/payAgain") | 
|     @ApiOperation(value = "重新支付") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query") | 
|     }) | 
|     public ResponseEntity<ReturnDataDTO<?>> payAgain(String id){ | 
|         boolean f = paymentV3Service.checkOrderStatus(id, true); | 
|         if(f){ | 
|             throw new ValidationException("订单不可再支付"); | 
|         } | 
|         return returnData(R.SUCCESS.getCode(), paymentV3Service.payAgain(id)); | 
|     } | 
|   | 
|     @GetMapping(value = "/refund") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query"), | 
|     }) | 
|     @ApiOperation(value = "退款") | 
|     public ResponseEntity<ReturnDataDTO> refundOrder(String id) { | 
|         orderService.refundCheck(id); | 
|         paymentV3Service.refundOrder(id); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     /*@GetMapping(value = "/refund/check") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query"), | 
|     }) | 
|     @ApiOperation(value = "查询退款") | 
|     public ResponseEntity<ReturnDataDTO> refundQuery(String id) { | 
|         return returnData(R.SUCCESS.getCode(), paymentV3Service.refundQuery(id)); | 
|     }*/ | 
|   | 
|     @PostMapping("/evaluate") | 
|     @ApiOperation(value = "评价") | 
|     public ResponseEntity<ReturnDataDTO> evaluateOrder(@RequestBody OrderEvaluateDTO dto) { | 
|         orderService.evaluateOrder(dto); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping(value = "/count/{status}") | 
|     @ApiOperation(value = "订单数量") | 
|     public ResponseEntity<ReturnDataDTO<Integer>> getMyOrderStatusCount(@PathVariable String status) { | 
|         return returnData(R.SUCCESS.getCode(), orderService.getMyOrderStatusCount(status)); | 
|     } | 
|   | 
|     @GetMapping(value = "/statistics/count") | 
|     @ApiOperation(value = "订单数量统计") | 
|     public ResponseEntity<ReturnDataDTO<CustomerOrderCountDTO>> getCustomerOrderCount() { | 
|         return returnData(R.SUCCESS.getCode(), orderService.getCustomerOrderCount()); | 
|     } | 
|   | 
|     @GetMapping(value = "/cancel") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query"), | 
|     }) | 
|     @ApiOperation(value = "取消订单") | 
|     public ResponseEntity<ReturnDataDTO> cancelOrder(String id) { | 
|         boolean f = paymentV3Service.checkOrderStatus(id); | 
|         if(!f){ | 
|             paymentV3Service.cancelOrder(id); | 
|         } | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
|   | 
|     @GetMapping(value = "/delete") | 
|     @ApiImplicitParams({ | 
|             @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query"), | 
|     }) | 
|     @ApiOperation(value = "删除订单") | 
|     public ResponseEntity<ReturnDataDTO> deleteOrder(String id) { | 
|         orderService.deleteOrder(id); | 
|         return returnData(R.SUCCESS.getCode(), null); | 
|     } | 
| } |