陶杰
2024-08-22 ee9032d9baf5f33e376d2d2699136e0a7b26bec7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package com.mzl.flower.web.payment;
 
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.constant.Constants;
import com.mzl.flower.dto.request.payment.OrderDeliveryNoDTO;
import com.mzl.flower.dto.request.payment.OrderQueryDTO;
import com.mzl.flower.dto.request.payment.OrderReduceDTO;
import com.mzl.flower.dto.response.payment.*;
import com.mzl.flower.service.payment.DeliveryOrderService;
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/order")
@Api(value = "订单管理-运营人员", tags = "订单管理-运营人员")
@Validated
@Slf4j
public class OrderController extends BaseController {
 
    @Autowired
    private OrderService orderService;
 
    @Autowired
    private UserPaymentV3Service paymentV3Service;
 
    @Autowired
    private DeliveryOrderService deliveryOrderService;
 
    @GetMapping("/status/count")
    @ApiOperation(value = "获取订单状态数量")
    public ResponseEntity<ReturnDataDTO<List<OrderStatusCountDTO>>> getOrderStatusCount(OrderQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), orderService.getOrderStatusCount(dto));
    }
 
    @GetMapping("/list")
    @ApiOperation(value = "查询订单列表")
    public ResponseEntity<ReturnDataDTO<Page<OrderPlatformListDTO>>> selectOrderList(Page page, OrderQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), orderService.selectOrderPlatformList(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<OrderItemPlatformListDTO>>> getPlatformOrderItems(String id){
        return returnData(R.SUCCESS.getCode(), orderService.getPlatformOrderItems(id));
    }
 
    @PostMapping("/list/send")
    @ApiOperation(value = "没有合伙人的花店上传快递号发货")
    public ResponseEntity<ReturnDataDTO> saveDeliveryNo(@RequestBody OrderDeliveryNoDTO dto) {
        orderService.saveDeliveryNo(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/list/abnormal/details")
    @ApiOperation(value = "异常订单明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<AbnormalOrderDTO>> getAbnormalOrderDetails(String id){
        return returnData(R.SUCCESS.getCode(), orderService.getAbnormalOrderDetails(id));
    }
 
    @GetMapping("/list/abnormal/process")
    @ApiOperation(value = "异常订单处理(不管有没有退款金额,建议都要处理)")
    public ResponseEntity<ReturnDataDTO> processLevelDown(String id) {
        orderService.processAbnormalOrder(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/list/check/info/reduce")
    @ApiOperation(value = "降级操作详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderItemId", value = "订单商品id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<OrderItemCheckReduceDTO>> getReduceCheck(String orderItemId){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getReduceCheck(orderItemId));
    }
 
    @GetMapping("/list/check/info/replace")
    @ApiOperation(value = "补货操作详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderItemId", value = "订单商品id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<OrderItemCheckNumDTO>> getReplaceCheck(String orderItemId){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getOtherCheck(orderItemId
                , Constants.CHECK_TYPE.replace.name()));
    }
 
    @GetMapping("/list/check/info/lack")
    @ApiOperation(value = "缺货操作详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderItemId", value = "订单商品id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<OrderItemCheckNumDTO>> getLackCheck(String orderItemId){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getOtherCheck(orderItemId
                , Constants.CHECK_TYPE.lack.name()));
    }
 
    @GetMapping("/list/check/info/agree")
    @ApiOperation(value = "审核通过")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "质检操作id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> agreeCheck(String id){
        String orderItemId = deliveryOrderService.setCheckAuditStatus(id, Constants.CHECK_AUDIT_STATUS.AGREED.name());
        deliveryOrderService.doAfterCheckAudit(orderItemId);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/list/check/info/reject")
    @ApiOperation(value = "审核不通过")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "质检操作id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<?>> rejectCheck(String id){
        String orderItemId = deliveryOrderService.setCheckAuditStatus(id, Constants.CHECK_AUDIT_STATUS.REJECTED.name());
        deliveryOrderService.doAfterCheckAudit(orderItemId);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    /*@PostMapping("/list/level/process")
    @ApiOperation(value = "处理降级商品订单打款")
    public ResponseEntity<ReturnDataDTO> processLevelDown(@RequestBody OrderReduceDTO dto) {
        orderService.processLevelDown(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }*/
 
    @GetMapping("/check/list")
    @ApiOperation(value = "查询订单清单列表")
    public ResponseEntity<ReturnDataDTO<List<OrderCheckListDTO>>> selectOrderCheckList(OrderQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), orderService.selectOrderCheckList(dto));
    }
 
    @PostMapping("/check/list")
    @ApiOperation(value = "查询订单清单列表")
    public ResponseEntity<ReturnDataDTO<List<OrderCheckListDTO>>> postOrderCheckList(@RequestBody OrderQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), orderService.selectOrderCheckList(dto));
    }
 
    @GetMapping(value = "/refund")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "String", paramType = "query"),
    })
    @ApiOperation(value = "退款")
    public ResponseEntity<ReturnDataDTO> refundOrder(String id) {
        orderService.refundCheckAdmin(id);
        paymentV3Service.refundOrder(id);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
}