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.*; import com.mzl.flower.dto.response.flower.StationStatisticDTO; import com.mzl.flower.dto.response.payment.*; 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/delivery") @Api(value = "配送质检管理-运营人员", tags = "配送质检管理-运营人员") @Validated @Slf4j public class DeliveryOrderController extends BaseController { @Autowired private DeliveryOrderService deliveryOrderService; @GetMapping("/station/list") @ApiOperation(value = "查询我的集货站列表") public ResponseEntity>> statisticStationList(String name){ LocalDateTime now = LocalDateTime.now(); LocalDateTime towAm = LocalDate.now().atTime(2, 0, 0); LocalDateTime fivePm = LocalDate.now().atTime(17, 0, 0); LocalDateTime startDate; LocalDateTime endDate; 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)); } /*@GetMapping("/list") @ApiOperation(value = "查询配送单列表") public ResponseEntity>> selectDoStationList(Page page , DeliveryOrderStationQueryDTO dto){ return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectDoStationList(page, dto)); } @GetMapping("/list/today") @ApiOperation(value = "查询今日配送单列表") public ResponseEntity>> selectDoStationTodayList(Page page , DeliveryOrderStationQueryDTO 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.selectDoStationList(page, dto)); } @GetMapping("/list/yesterday") @ApiOperation(value = "查询昨日配送单列表") public ResponseEntity>> selectDoStationYesterdayList(Page page , DeliveryOrderStationQueryDTO 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.selectDoStationList(page, dto)); }*/ @GetMapping("/list/view") @ApiOperation(value = "配送单详情") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "配送单id", required = true, dataType = "String", paramType = "query") }) public ResponseEntity> getDeliverOrderInfo(String id){ return returnData(R.SUCCESS.getCode(), deliveryOrderService.getDeliverOrderInfo(id)); } /*@PostMapping("/list/view/check") @ApiOperation(value = "质检操作") public ResponseEntity doCheck(@RequestBody OrderItemCheckDTO dto) { deliveryOrderService.doCheck(dto); return returnData(R.SUCCESS.getCode(), null); }*/ /*@GetMapping("/list/view/complete") @ApiOperation(value = "质检完成") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "配送单id", required = true, dataType = "String", paramType = "query") }) public ResponseEntity completeCheck(String id) { String orderId = deliveryOrderService.completeCheck(id); deliveryOrderService.checkOrderStatus(orderId); return returnData(R.SUCCESS.getCode(), null); }*/ @GetMapping("/list/items/view") @ApiOperation(value = "获取商品详情") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "配送物品id", required = true, dataType = "String", paramType = "query") }) public ResponseEntity> getDeliveryOrderItem(String id){ return returnData(R.SUCCESS.getCode(), deliveryOrderService.getDeliveryOrderItem(id)); } //////////////////////////////////////////////////////////新接口 @GetMapping("/check/list") @ApiOperation(value = "查询集货站供应商配送列表") public ResponseEntity>> selectSupplierDoList4Check(Page page , DeliveryOrderStationQueryDTO dto){ return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectSupplierDoList4Check(page, dto)); } @GetMapping("/check/list/today") @ApiOperation(value = "查询集货站供应商配送列表(今日)") public ResponseEntity>> selectSupplierDoList4CheckToday(Page page , DeliveryOrderStationQueryDTO 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.selectSupplierDoList4Check(page, dto)); } @GetMapping("/check/list/yesterday") @ApiOperation(value = "查询集货站供应商配送列表(昨日)") public ResponseEntity>> selectSupplierDoList4CheckYesterday(Page page , DeliveryOrderStationQueryDTO 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.selectSupplierDoList4Check(page, dto)); } @GetMapping("/check/info/list") @ApiOperation(value = "查询供应商配送单列表") public ResponseEntity>> selectSupplierDoInfo4Check(Page page , DeliveryOrderInfoSpQueryDTO dto){ return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectSupplierDoInfo4Check(page, dto)); } @GetMapping("/check/info/list/today") @ApiOperation(value = "查询供应商配送单列表(今日)") public ResponseEntity>> selectSupplierDoInfo4CheckToday(Page page , DeliveryOrderInfoSpQueryDTO 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.selectSupplierDoInfo4Check(page, dto)); } @GetMapping("/check/info/list/yesterday") @ApiOperation(value = "查询供应商配送单列表(昨日)") public ResponseEntity>> selectSupplierDoInfo4CheckYesterday(Page page , DeliveryOrderInfoSpQueryDTO 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.selectSupplierDoInfo4Check(page, dto)); } @GetMapping("/check/info/reduce") @ApiOperation(value = "降级操作详情") public ResponseEntity> getReduceCheck(String orderItemId){ return returnData(R.SUCCESS.getCode(), deliveryOrderService.getReduceCheck(orderItemId)); } @GetMapping("/check/info/replace") @ApiOperation(value = "补货操作详情") public ResponseEntity> getReplaceCheck(String orderItemId){ return returnData(R.SUCCESS.getCode(), deliveryOrderService.getOtherCheck(orderItemId , Constants.CHECK_TYPE.replace.name())); } @GetMapping("/check/info/lack") @ApiOperation(value = "缺货操作详情") public ResponseEntity> getLackCheck(String orderItemId){ return returnData(R.SUCCESS.getCode(), deliveryOrderService.getOtherCheck(orderItemId , Constants.CHECK_TYPE.lack.name())); } @PostMapping("/check/info/do/reduce") @ApiOperation(value = "降级操作") public ResponseEntity doReduceCheck(@RequestBody OrderItemCheckCommitReduceDTO dto) { deliveryOrderService.doReduceCheck(dto); String orderId = deliveryOrderService.checkOrderItemStatus(dto.getOrderItemId()); deliveryOrderService.checkOrderStatus(orderId); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/check/info/do/replace") @ApiOperation(value = "补货操作") public ResponseEntity doReplaceCheck(@RequestBody OrderItemCheckCommitDTO dto) { dto.setType(Constants.CHECK_TYPE.replace.name()); deliveryOrderService.doCheck(dto, null, null, null); String orderId = deliveryOrderService.checkOrderItemStatus(dto.getOrderItemId()); deliveryOrderService.checkOrderStatus(orderId); return returnData(R.SUCCESS.getCode(), null); } @PostMapping("/check/info/do/lack") @ApiOperation(value = "缺货操作") public ResponseEntity doLackCheck(@RequestBody OrderItemCheckCommitDTO dto) { dto.setType(Constants.CHECK_TYPE.lack.name()); deliveryOrderService.doCheck(dto, null, null, null); String orderId = deliveryOrderService.checkOrderItemStatus(dto.getOrderItemId()); deliveryOrderService.checkOrderStatus(orderId); return returnData(R.SUCCESS.getCode(), null); } @GetMapping("/check/info/delete/reduce") @ApiOperation(value = "删除降级信息") public ResponseEntity deleteReduce(String orderItemId){ deliveryOrderService.deleteCheckInfo(orderItemId, Constants.CHECK_TYPE.reduce.name()); String orderId = deliveryOrderService.checkOrderItemStatus(orderItemId); deliveryOrderService.checkOrderStatus(orderId); return returnData(R.SUCCESS.getCode(), null); } @GetMapping("/check/info/delete/replace") @ApiOperation(value = "删除补货信息") public ResponseEntity deleteReplace(String orderItemId){ deliveryOrderService.deleteCheckInfo(orderItemId, Constants.CHECK_TYPE.replace.name()); String orderId = deliveryOrderService.checkOrderItemStatus(orderItemId); deliveryOrderService.checkOrderStatus(orderId); return returnData(R.SUCCESS.getCode(), null); } @GetMapping("/check/info/delete/lack") @ApiOperation(value = "删除缺货信息") public ResponseEntity deleteLack(String orderItemId){ deliveryOrderService.deleteCheckInfo(orderItemId, Constants.CHECK_TYPE.lack.name()); String orderId = deliveryOrderService.checkOrderItemStatus(orderItemId); deliveryOrderService.checkOrderStatus(orderId); return returnData(R.SUCCESS.getCode(), null); } @GetMapping("/check/info/ok") @ApiOperation(value = "完成商品质检") public ResponseEntity setCheckOk(String orderItemId){ deliveryOrderService.setCheckOk(orderItemId); String orderId = deliveryOrderService.checkOrderItemStatus(orderItemId); deliveryOrderService.checkOrderStatus(orderId); return returnData(R.SUCCESS.getCode(), null); } @GetMapping("/check/list/complete") @ApiOperation(value = "一键质检(只能完成当天的,且必须点一下才会修改订单状态)") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "供应商id", required = true, dataType = "Long", paramType = "query") }) public ResponseEntity completeCheck(Long id) { LocalDateTime now = LocalDateTime.now(); LocalDateTime towAm = LocalDate.now().atTime(2, 0, 0); LocalDateTime fivePm = LocalDate.now().atTime(17, 0, 0); LocalDateTime startDate; LocalDateTime endDate; if(now.isAfter(towAm)){ startDate = fivePm.plusDays(-1); endDate = fivePm; } else { startDate = fivePm.plusDays(-2); endDate = fivePm.plusDays(-1); } List orderIds = deliveryOrderService.completeSupplierCheck(id, startDate, endDate); deliveryOrderService.checkOrdersStatus(orderIds); return returnData(R.SUCCESS.getCode(), null); } }