gongzuming
2024-09-19 a768dc3daa04d35fedfbe75c0a59b9b2545b85c4
src/main/java/com/mzl/flower/web/payment/DeliveryOrderController.java
@@ -4,11 +4,13 @@
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.constant.Constants;
import com.mzl.flower.dto.request.payment.*;
import com.mzl.flower.dto.response.flower.StationStatisticDTO;
import com.mzl.flower.dto.response.payment.*;
import com.mzl.flower.service.payment.DeliveryOrderService;
import io.micrometer.core.instrument.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -35,20 +37,31 @@
    @GetMapping("/station/list")
    @ApiOperation(value = "查询我的集货站列表")
    public ResponseEntity<ReturnDataDTO<List<StationStatisticDTO>>> statisticStationList(String name){
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime towAm = LocalDate.now().atTime(2, 0, 0);
        LocalDateTime fivePm = LocalDate.now().atTime(17, 0, 0);
    public ResponseEntity<ReturnDataDTO<List<StationStatisticDTO>>> statisticStationList(String name
            , String status, String date){
        /*if(StringUtils.isEmpty(date)){
            throw new ValidationException("请选择日期");
        }*/
        LocalDateTime startDate;
        LocalDateTime endDate;
        if(now.isAfter(towAm)){
            startDate = fivePm.plusDays(-1);
            endDate = fivePm;
        LocalDate localDate = deliveryOrderService.parseLocalDate(date);
        if(localDate != null){
            endDate = localDate.atTime(17, 0, 0);
            startDate = endDate.plusDays(-1);
        } else {
            startDate = fivePm.plusDays(-2);
            endDate = fivePm.plusDays(-1);
            LocalDateTime now = LocalDateTime.now();
            LocalDateTime towAm = LocalDate.now().atTime(2, 0, 0);
            LocalDateTime fivePm = LocalDate.now().atTime(17, 0, 0);
            if(now.isAfter(towAm)){
                startDate = fivePm.plusDays(-1);
                endDate = fivePm;
            } else {
                startDate = fivePm.plusDays(-2);
                endDate = fivePm.plusDays(-1);
            }
        }
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.statisticStationList(name,startDate,endDate));
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.statisticStationList(name, startDate, endDate, status));
    }
@@ -131,12 +144,22 @@
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getDeliveryOrderItem(id));
    }
    @PostMapping("/list/items/views")
    @ApiOperation(value = "获取商品详情列表")
    public ResponseEntity<ReturnDataDTO<List<DeliveryOrderItemDTO>>> getDeliveryOrderItem(@RequestBody PostQueryDTO dto){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getDeliveryOrderItems(dto));
    }
    //////////////////////////////////////////////////////////新接口
    @GetMapping("/check/list")
    @ApiOperation(value = "查询集货站供应商配送列表")
    public ResponseEntity<ReturnDataDTO<Page<DeliveryOrderList4CheckDTO>>> selectSupplierDoList4Check(Page page
            , DeliveryOrderStationQueryDTO dto){
        LocalDate localDate = deliveryOrderService.parseLocalDate(dto.getDate());
        String date = dto.getDate();
        if(StringUtils.isEmpty(date)){
            throw new ValidationException("请选择日期");
        }
        LocalDate localDate = deliveryOrderService.parseLocalDate(date);
        if(localDate != null){
            LocalDateTime end = localDate.atTime(17, 0, 0);
            LocalDateTime begin = end.plusDays(-1);
@@ -187,7 +210,11 @@
    @ApiOperation(value = "查询供应商配送单列表")
    public ResponseEntity<ReturnDataDTO<Page<DeliveryOrder4CheckDTO>>> selectSupplierDoInfo4Check(Page page
            , DeliveryOrderInfoSpQueryDTO dto){
        LocalDate localDate = deliveryOrderService.parseLocalDate(dto.getDate());
        String date = dto.getDate();
        if(StringUtils.isEmpty(date)){
            throw new ValidationException("请选择日期");
        }
        LocalDate localDate = deliveryOrderService.parseLocalDate(date);
        if(localDate != null){
            LocalDateTime end = localDate.atTime(17, 0, 0);
            LocalDateTime begin = end.plusDays(-1);
@@ -244,14 +271,14 @@
    @ApiOperation(value = "补货操作详情")
    public ResponseEntity<ReturnDataDTO<OrderItemCheckNumDTO>> getReplaceCheck(String orderItemId){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getOtherCheck(orderItemId
                , Constants.CHECK_TYPE.replace.name()));
                , Constants.CHECK_TYPE.replace.name(), false));
    }
    @GetMapping("/check/info/lack")
    @ApiOperation(value = "缺货操作详情")
    public ResponseEntity<ReturnDataDTO<OrderItemCheckNumDTO>> getLackCheck(String orderItemId){
        return returnData(R.SUCCESS.getCode(), deliveryOrderService.getOtherCheck(orderItemId
                , Constants.CHECK_TYPE.lack.name()));
                , Constants.CHECK_TYPE.lack.name(), false));
    }
    @PostMapping("/check/info/do/reduce")
@@ -320,11 +347,34 @@
    }
    @GetMapping("/check/list/complete")
    @ApiOperation(value = "一键质检(只能完成当天的,且必须点一下才会修改订单状态)")
    @ApiOperation(value = "一键质检")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "供应商id", required = true, dataType = "Long", paramType = "query")
            @ApiImplicitParam(name = "id", value = "供应商id", required = true, dataType = "Long", paramType = "query"),
            @ApiImplicitParam(name = "date", value = "日期(yyyy-MM-dd)", required = true, dataType = "String", paramType = "query"),
    })
    public ResponseEntity<ReturnDataDTO> completeCheck(Long id) {
    public ResponseEntity<ReturnDataDTO> completeCheck(Long id, String date) {
        if(StringUtils.isEmpty(date)){
            throw new ValidationException("请选择日期");
        }
        LocalDateTime startDate = null;
        LocalDateTime endDate = null;
        LocalDate localDate = deliveryOrderService.parseLocalDate(date);
        if(localDate != null){
            endDate = localDate.atTime(17, 0, 0);
            startDate = endDate.plusDays(-1);
        }
        List<String> orderIds = deliveryOrderService.completeSupplierCheck(id, startDate, endDate);
        deliveryOrderService.checkOrdersStatus(orderIds);
        return returnData(R.SUCCESS.getCode(), null);
    }
    @GetMapping("/check/list/complete/today")
    @ApiOperation(value = "一键质检(今日)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "供应商id", required = true, dataType = "Long", paramType = "query"),
    })
    public ResponseEntity<ReturnDataDTO> completeCheckToday(Long id) {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime towAm = LocalDate.now().atTime(2, 0, 0);
        LocalDateTime fivePm = LocalDate.now().atTime(17, 0, 0);
@@ -337,7 +387,6 @@
            startDate = fivePm.plusDays(-2);
            endDate = fivePm.plusDays(-1);
        }
        List<String> orderIds = deliveryOrderService.completeSupplierCheck(id, startDate, endDate);
        deliveryOrderService.checkOrdersStatus(orderIds);
        return returnData(R.SUCCESS.getCode(), null);