陶杰
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
package com.mzl.flower.web.supplier;
 
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.dto.request.payment.DeliveryOrderArriveDTO;
import com.mzl.flower.dto.request.payment.DeliveryOrderQueryDTO;
import com.mzl.flower.dto.response.payment.*;
import com.mzl.flower.dto.response.supplier.SupplierOrderDTO;
import com.mzl.flower.service.payment.DeliveryOrderService;
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.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
 
@RestController
@RequestMapping("/api/supplier/delivery")
@Api(value = "配送管理-花农(供应商)", tags = "配送管理-花农(供应商)")
@Validated
@Slf4j
public class DeliverySupplierController extends BaseController {
 
    @Autowired
    private DeliveryOrderService deliveryOrderService;
 
    @GetMapping("/list")
    @ApiOperation(value = "获取配送单列表")
    public ResponseEntity<ReturnDataDTO<Page<DeliveryOrderListDTO>>> selectOrderList(Page page
            , DeliveryOrderQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectDeliveryOrderList(page, dto));
    }
 
    @GetMapping("/list/month")
    @ApiOperation(value = "获取当月配送单列表")
    public ResponseEntity<ReturnDataDTO<Page<DeliveryOrderListDTO>>> selectOrderListMonth(Page page
            , DeliveryOrderQueryDTO dto){
        LocalDateTime ffPm = LocalDate.now().withDayOfMonth(1).atTime(17, 0, 0).plusDays(-1);
        dto.setStartDate(ffPm);
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectDeliveryOrderList(page, dto));
    }
 
    @GetMapping("/list/today")
    @ApiOperation(value = "获取今日配送单列表")
    public ResponseEntity<ReturnDataDTO<Page<DeliveryOrderListDTO>>> selectOrderTodayList(Page page
            , DeliveryOrderQueryDTO dto){
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime towAm = LocalDate.now().atTime(2, 0, 0);
        LocalDateTime fivePm = LocalDate.now().atTime(17, 0, 0);
        if(now.isAfter(towAm)){
            dto.setStartDate(fivePm.plusDays(-1));
            dto.setEndDate(fivePm);
        } else {
            dto.setStartDate(fivePm.plusDays(-2));
            dto.setEndDate(fivePm.plusDays(-1));
        }
 
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectDeliveryOrderList(page, dto));
    }
 
    @GetMapping("/list/yesterday")
    @ApiOperation(value = "获取昨日配送单列表")
    public ResponseEntity<ReturnDataDTO<Page<DeliveryOrderListDTO>>> selectOrderYesterdayList(Page page
            , DeliveryOrderQueryDTO dto){
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime towAm = LocalDate.now().atTime(2, 0, 0);
        LocalDateTime fivePm = LocalDate.now().atTime(17, 0, 0);
        if(now.isAfter(towAm)){
            dto.setStartDate(fivePm.plusDays(-2));
            dto.setEndDate(fivePm.plusDays(-1));
        } else {
            dto.setStartDate(fivePm.plusDays(-3));
            dto.setEndDate(fivePm.plusDays(-2));
        }
 
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectDeliveryOrderList(page, dto));
    }
 
    @GetMapping("/list/items")
    @ApiOperation(value = "获取配送单明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "配送单id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<List<DeliveryOrderItemListDTO>>> getDeliveryOrderItems(String id){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getDeliveryOrderItems(id));
    }
 
    @GetMapping("/list/items/view")
    @ApiOperation(value = "获取商品详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "配送物品id", required = true, dataType = "String", paramType = "query")
    })
    public ResponseEntity<ReturnDataDTO<DeliveryOrderItemDTO>> getDeliveryOrderItem(String id){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getSupplierDeliveryOrderItem(id));
    }
 
    @PostMapping("/list/arrive")
    @ApiOperation(value = "确认入位")
    public ResponseEntity<ReturnDataDTO> arrived(@RequestBody DeliveryOrderArriveDTO dto) {
        deliveryOrderService.arrived(dto);
        return returnData(R.SUCCESS.getCode(), null);
    }
 
    @GetMapping("/statistics")
    @ApiOperation(value = "统计数据")
    public ResponseEntity<ReturnDataDTO<SupplierOrderDTO>> getCurrentSupplierOrderStatistics(){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getCurrentSupplierOrderStatistics());
    }
 
    @GetMapping("/mine/list")
    @ApiOperation(value = "我的配送单总计")
    public ResponseEntity<ReturnDataDTO<List<DeliveryOrderStatisticsDTO>>> selectSupplierDoStatistics(Page page){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectSupplierDoStatistics(page));
    }
 
    @GetMapping("/mine/list/flower")
    @ApiOperation(value = "我的配送单配送商品统计列表")
    public ResponseEntity<ReturnDataDTO<Page<DeliveryOrderItemStatisticsDTO>>> selectDoItemListByTime(Page page
            , String day){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectDoItemListByTime(page, day));
    }
 
    @GetMapping("/mine/list/settlement")
    @ApiOperation(value = "我的配送单结算明细")
    public ResponseEntity<ReturnDataDTO<Page<DeliveryOrderItemSettlementDTO>>> selectSettlementListByTime(Page page
            , String day){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectSettlementListByTime(page, day));
    }
 
}