Browse Source

修改配送状态

大大的豆芽 9 months ago
parent
commit
5da742bd42

+ 153 - 153
yiqi-api/src/main/java/com/yiqi/api/controller/order/WeAppOrderClothController.java

@@ -85,72 +85,72 @@ public class WeAppOrderClothController {
     @ApiOperation("获取预约洗送列表")
     @PostMapping(value = "findAppointmentPage")
     public R<List<WeAppOrderClothAppointmentVO>> findAppointmentPage(@RequestBody @Valid WeAppOrderClothAppointmentQueryDTO weAppOrderClothAppointmentQueryDTO)
-            throws Exception{
-        Page<OrderCloth> page = new Page<>(weAppOrderClothAppointmentQueryDTO.getPageNum(),weAppOrderClothAppointmentQueryDTO.getPageSize());
+            throws Exception {
+        Page<OrderCloth> page = new Page<>(weAppOrderClothAppointmentQueryDTO.getPageNum(), weAppOrderClothAppointmentQueryDTO.getPageSize());
         page.setSearchCount(false);
 
         LambdaQueryWrapper<OrderCloth> queryWrapper = new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getAppUserId,AuthHolder.userId())
-                .eq(OrderCloth::getRefundStatus,OrderRefundStatus.OK.getCode())
+                .eq(OrderCloth::getAppUserId, AuthHolder.userId())
+                .eq(OrderCloth::getRefundStatus, OrderRefundStatus.OK.getCode())
                 .and(orderClothLambdaQueryWrapper -> orderClothLambdaQueryWrapper
-                        .eq(OrderCloth::getTakeClothWay,TakeOrSendClothWay.DELIVERY.getCode())
-                        .or()
-                        .eq(OrderCloth::getSendClothWay,TakeOrSendClothWay.DELIVERY.getCode())
+                                .eq(OrderCloth::getTakeClothWay, TakeOrSendClothWay.DELIVERY.getCode())
+                                .or()
+                                .eq(OrderCloth::getSendClothWay, TakeOrSendClothWay.DELIVERY.getCode())
 //                        .or()
 //                        .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.HAS_WASH.getCode())
                 )
                 .and(orderClothLambdaQueryWrapper -> orderClothLambdaQueryWrapper
-                        .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.APPOINTMENT.getCode())
+                        .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.APPOINTMENT.getCode())
                         .or()
-                        .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WAITING_TO_DOOR.getCode())
+                        .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.WAITING_TO_DOOR.getCode())
                         .or()
-                        .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.HAS_TO_DOOR.getCode())
+                        .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.HAS_TO_DOOR.getCode())
                         .or()
-                        .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WAITING_TO_SEND.getCode())
+                        .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.WAITING_TO_SEND.getCode())
                         .or()
-                        .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.SENDING.getCode()));
-        if(StringUtils.isNotEmpty(weAppOrderClothAppointmentQueryDTO.getOrderStatus())){
-            queryWrapper.eq(OrderCloth::getOrderStatus,weAppOrderClothAppointmentQueryDTO.getOrderStatus());
+                        .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.SENDING.getCode()));
+        if (StringUtils.isNotEmpty(weAppOrderClothAppointmentQueryDTO.getOrderStatus())) {
+            queryWrapper.eq(OrderCloth::getOrderStatus, weAppOrderClothAppointmentQueryDTO.getOrderStatus());
         }
         queryWrapper.orderByDesc(BaseEntity::getCreateTime);
         List<OrderCloth> orderCloths = orderClothService.page(page
-                ,queryWrapper).getRecords();
-        if(orderCloths.size() == 0){
+                , queryWrapper).getRecords();
+        if (orderCloths.size() == 0) {
             return R.ok(new ArrayList<>());
         }
 
         List<OrderDelivery> list = orderDeliveryService.list(new QueryWrapper<OrderDelivery>().lambda()
                 .in(OrderDelivery::getOrderSn
-                        ,orderCloths.stream().map(OrderCloth::getOrderNo).collect(Collectors.toSet())));
-        Map<String,OrderDelivery> collectAddressMap = list.stream().filter(orderDelivery -> ClothOrderDeliveryType.collectCloth.getCode()
-                .equals(orderDelivery.getClothOrderType()))
-                .collect(Collectors.toMap(OrderDelivery::getOrderSn,OrderDelivery -> OrderDelivery));
-        Map<String,OrderDelivery> takeAddressMap = list.stream().filter(orderDelivery -> ClothOrderDeliveryType.takeCloth.getCode()
-                .equals(orderDelivery.getClothOrderType()))
-                .collect(Collectors.toMap(OrderDelivery::getOrderSn,OrderDelivery -> OrderDelivery));
-        Map<Long,SysOrg> storeOrgMap = new HashMap<>();
-        Map<Long,SysOrg> factoryOrgMap = new HashMap<>();
-        if(orderCloths.stream().filter(orderCloth -> SourceType.STORE.getCode().equals(orderCloth.getSourceType())).collect(Collectors.toList()).size() > 0){
+                        , orderCloths.stream().map(OrderCloth::getOrderNo).collect(Collectors.toSet())));
+        Map<String, OrderDelivery> collectAddressMap = list.stream().filter(orderDelivery -> ClothOrderDeliveryType.collectCloth.getCode()
+                        .equals(orderDelivery.getClothOrderType()))
+                .collect(Collectors.toMap(OrderDelivery::getOrderSn, OrderDelivery -> OrderDelivery));
+        Map<String, OrderDelivery> takeAddressMap = list.stream().filter(orderDelivery -> ClothOrderDeliveryType.takeCloth.getCode()
+                        .equals(orderDelivery.getClothOrderType()))
+                .collect(Collectors.toMap(OrderDelivery::getOrderSn, OrderDelivery -> OrderDelivery));
+        Map<Long, SysOrg> storeOrgMap = new HashMap<>();
+        Map<Long, SysOrg> factoryOrgMap = new HashMap<>();
+        if (orderCloths.stream().filter(orderCloth -> SourceType.STORE.getCode().equals(orderCloth.getSourceType())).collect(Collectors.toList()).size() > 0) {
             storeOrgMap = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().in(SysOrg::getId
-                    ,orderCloths.stream().filter(orderCloth -> SourceType.STORE.getCode().equals(orderCloth.getSourceType())).map(OrderCloth::getOrgId).collect(Collectors.toSet()))
-                    .eq(SysOrg::getSourceType,SourceType.STORE.getCode())).stream().collect(Collectors.toMap(SysOrg::getId,SysOrg -> SysOrg));
+                            , orderCloths.stream().filter(orderCloth -> SourceType.STORE.getCode().equals(orderCloth.getSourceType())).map(OrderCloth::getOrgId).collect(Collectors.toSet()))
+                    .eq(SysOrg::getSourceType, SourceType.STORE.getCode())).stream().collect(Collectors.toMap(SysOrg::getId, SysOrg -> SysOrg));
         }
-        if(orderCloths.stream().filter(orderCloth -> SourceType.FACTORY.getCode().equals(orderCloth.getSourceType())).collect(Collectors.toList()).size() > 0){
+        if (orderCloths.stream().filter(orderCloth -> SourceType.FACTORY.getCode().equals(orderCloth.getSourceType())).collect(Collectors.toList()).size() > 0) {
             factoryOrgMap = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().in(SysOrg::getId
-                    ,orderCloths.stream().filter(orderCloth -> SourceType.FACTORY.getCode().equals(orderCloth.getSourceType())).map(OrderCloth::getOrgId).collect(Collectors.toSet()))
-                    .eq(SysOrg::getSourceType,SourceType.FACTORY.getCode())).stream().collect(Collectors.toMap(SysOrg::getId,SysOrg -> SysOrg));
+                            , orderCloths.stream().filter(orderCloth -> SourceType.FACTORY.getCode().equals(orderCloth.getSourceType())).map(OrderCloth::getOrgId).collect(Collectors.toSet()))
+                    .eq(SysOrg::getSourceType, SourceType.FACTORY.getCode())).stream().collect(Collectors.toMap(SysOrg::getId, SysOrg -> SysOrg));
         }
         List<WeAppOrderClothAppointmentVO> weAppOrderClothAppointmentVOS = new ArrayList<>();
         for (OrderCloth orderCloth : orderCloths) {
             WeAppOrderClothAppointmentVO weAppOrderClothAppointmentVO = new WeAppOrderClothAppointmentVO();
-            BeanUtils.copyProperties(orderCloth,weAppOrderClothAppointmentVO);
+            BeanUtils.copyProperties(orderCloth, weAppOrderClothAppointmentVO);
             weAppOrderClothAppointmentVO.setCollectClothDeliverInfo(collectAddressMap.get(orderCloth.getId()));
             weAppOrderClothAppointmentVO.setTakeClothDeliverInfo(takeAddressMap.get(orderCloth.getId()));
-            if(SourceType.FACTORY.getCode().equals(orderCloth.getSourceType())){
+            if (SourceType.FACTORY.getCode().equals(orderCloth.getSourceType())) {
                 weAppOrderClothAppointmentVO.setSysOrg(factoryOrgMap.get(orderCloth.getOrgId()));
-            }else if(SourceType.STORE.getCode().equals(orderCloth.getSourceType())){
+            } else if (SourceType.STORE.getCode().equals(orderCloth.getSourceType())) {
                 weAppOrderClothAppointmentVO.setSysOrg(storeOrgMap.get(orderCloth.getOrgId()));
-            }else{
+            } else {
                 weAppOrderClothAppointmentVO.setSysOrg(SysOrg.buildManagerOrg());
             }
             weAppOrderClothAppointmentVOS.add(weAppOrderClothAppointmentVO);
@@ -160,15 +160,15 @@ public class WeAppOrderClothController {
 
     @ApiOperation("预约洗衣")
     @PostMapping(value = "appointment")
-    public R appointment(@RequestBody @Valid OrderClothAppointmentDTO orderClothAppointmentDTO) throws Exception{
+    public R appointment(@RequestBody @Valid OrderClothAppointmentDTO orderClothAppointmentDTO) throws Exception {
         AppUserAddress appUserAddress = appUserAddressService.getOne(new QueryWrapper<AppUserAddress>().lambda()
-                .eq(AppUserAddress::getId,orderClothAppointmentDTO.getAddressId())
-                .eq(AppUserAddress::getAppUserId,AuthHolder.userId()));
-        if(appUserAddress == null){
+                .eq(AppUserAddress::getId, orderClothAppointmentDTO.getAddressId())
+                .eq(AppUserAddress::getAppUserId, AuthHolder.userId()));
+        if (appUserAddress == null) {
             throw new ServiceException("未查询到地址");
         }
         OrderCloth orderCloth = new OrderCloth();
-        BeanUtils.copyProperties(orderClothAppointmentDTO,orderCloth);
+        BeanUtils.copyProperties(orderClothAppointmentDTO, orderCloth);
         orderCloth.setCreateTime(DateUtils.getNowDate());
         orderCloth.setTakeClothWay(TakeOrSendClothWay.DELIVERY.getCode());
         orderCloth.setAppUserId(AuthHolder.userId());
@@ -177,14 +177,14 @@ public class WeAppOrderClothController {
         // 预约单
         orderCloth.setIsAppointment(SysBoolType.YES.getCode());
         orderCloth.setOrderNo(orderNoUtils.getClothOrderNo());
-        if(ClothOrderType.normal.equals(orderCloth.getOrderType())){
+        if (ClothOrderType.normal.equals(orderCloth.getOrderType())) {
             SysStore sysStore = storeService.selectSysStoreById(orderClothAppointmentDTO.getOrgId());
             orderCloth.setFactoryId(sysStore.getFactoryId());
         }
 
         //云洗订单或者第三方订单
-        if(ClothOrderType.online.getCode().equals(orderCloth.getOrderType())
-                || ClothOrderType.thirdPart.getCode().equals(orderCloth.getOrderType())){
+        if (ClothOrderType.online.getCode().equals(orderCloth.getOrderType())
+                || ClothOrderType.thirdPart.getCode().equals(orderCloth.getOrderType())) {
         }
         orderClothService.save(orderCloth);
         // 预创建配送单
@@ -193,7 +193,7 @@ public class WeAppOrderClothController {
         orderDelivery.setOrderSn(orderCloth.getOrderNo());
         orderDelivery.setClothOrderType(ClothOrderDeliveryType.collectCloth.getCode());
         orderDelivery.setCreateTime(DateUtils.getNowDate());
-        orderDelivery.setDeliveryStatus(OrderDeliveryStatusEnum.ORIGIN_STATUS.getCode());
+        orderDelivery.setDeliveryStatus(OrderDeliveryStatusEnum.WAIT_DELIVERY.getCode());
         orderDelivery.setDeliveryWay(ClothOrderDeliveryWay.delivery.getCode());
         orderDeliveryService.save(orderDelivery);
         return R.ok();
@@ -201,113 +201,113 @@ public class WeAppOrderClothController {
 
     @ApiOperation("查询洗衣订单列表")
     @PostMapping(value = "findPage")
-    public R<List<OrderClothVO>> findPage(@RequestBody @Valid OrderClothAppQueryDTO orderClothAppQueryDTO) throws Exception{
+    public R<List<OrderClothVO>> findPage(@RequestBody @Valid OrderClothAppQueryDTO orderClothAppQueryDTO) throws Exception {
         LambdaQueryWrapper<OrderCloth> queryWrapper = new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getAppUserId,AuthHolder.userId())
-                .ne(OrderCloth::getRefundStatus,OrderRefundStatus.REFUND_SUCCESS.getCode())
-                .eq(OrderCloth::getDelFlag,DeleteStatus.OK.getCode());
-        if(orderClothAppQueryDTO.getStartDate() != null){
-            queryWrapper.ge(BaseEntity::getCreateTime,orderClothAppQueryDTO.getStartDate());
+                .eq(OrderCloth::getAppUserId, AuthHolder.userId())
+                .ne(OrderCloth::getRefundStatus, OrderRefundStatus.REFUND_SUCCESS.getCode())
+                .eq(OrderCloth::getDelFlag, DeleteStatus.OK.getCode());
+        if (orderClothAppQueryDTO.getStartDate() != null) {
+            queryWrapper.ge(BaseEntity::getCreateTime, orderClothAppQueryDTO.getStartDate());
         }
-        if(orderClothAppQueryDTO.getEndDate() != null){
-            queryWrapper.lt(BaseEntity::getCreateTime,DateUtils.addDays(orderClothAppQueryDTO.getEndDate(),1));
+        if (orderClothAppQueryDTO.getEndDate() != null) {
+            queryWrapper.lt(BaseEntity::getCreateTime, DateUtils.addDays(orderClothAppQueryDTO.getEndDate(), 1));
         }
-        if("0".equals(orderClothAppQueryDTO.getOrderStatus())
-                || "1".equals(orderClothAppQueryDTO.getOrderStatus())){
-            queryWrapper.eq(OrderCloth::getOrderStatus,ClothOrderStatusType.APPOINTMENT.getCode());
+        if ("0".equals(orderClothAppQueryDTO.getOrderStatus())
+                || "1".equals(orderClothAppQueryDTO.getOrderStatus())) {
+            queryWrapper.eq(OrderCloth::getOrderStatus, ClothOrderStatusType.APPOINTMENT.getCode());
         }
-        if("2".equals(orderClothAppQueryDTO.getOrderStatus())){
+        if ("2".equals(orderClothAppQueryDTO.getOrderStatus())) {
             queryWrapper.and(orderClothLambdaQueryWrapper -> orderClothLambdaQueryWrapper
-                    .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.HAS_TO_DOOR.getCode())
+                    .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.HAS_TO_DOOR.getCode())
                     .or()
-                    .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.HAS_TAKING.getCode()));
+                    .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.HAS_TAKING.getCode()));
         }
-        if("3".equals(orderClothAppQueryDTO.getOrderStatus())){
+        if ("3".equals(orderClothAppQueryDTO.getOrderStatus())) {
             queryWrapper.and(orderClothLambdaQueryWrapper -> orderClothLambdaQueryWrapper
-                    .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WAITING_FOR_PAY.getCode())
+                    .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.WAITING_FOR_PAY.getCode())
                     .or()
-                    .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WAIT_FACTORY.getCode())
+                    .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.WAIT_FACTORY.getCode())
                     .or()
-                    .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WASHING.getCode()));
+                    .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.WASHING.getCode()));
         }
-        if("4".equals(orderClothAppQueryDTO.getOrderStatus())){
+        if ("4".equals(orderClothAppQueryDTO.getOrderStatus())) {
             queryWrapper.and(orderClothLambdaQueryWrapper -> orderClothLambdaQueryWrapper
-                    .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.HAS_WASH.getCode())
+                    .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.HAS_WASH.getCode())
                     .or()
-                    .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WAITING_TO_DOOR.getCode()));
+                    .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.WAITING_TO_DOOR.getCode()));
         }
-        if("5".equals(orderClothAppQueryDTO.getOrderStatus())){
-            queryWrapper.eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WAITING_TO_SEND.getCode());
+        if ("5".equals(orderClothAppQueryDTO.getOrderStatus())) {
+            queryWrapper.eq(OrderCloth::getOrderStatus, ClothOrderStatusType.WAITING_TO_SEND.getCode());
         }
-        if("6".equals(orderClothAppQueryDTO.getOrderStatus())){
-            queryWrapper.eq(OrderCloth::getOrderStatus,ClothOrderStatusType.HAS_WASH.getCode());
+        if ("6".equals(orderClothAppQueryDTO.getOrderStatus())) {
+            queryWrapper.eq(OrderCloth::getOrderStatus, ClothOrderStatusType.HAS_WASH.getCode());
         }
-        if("7".equals(orderClothAppQueryDTO.getOrderStatus())){
-            queryWrapper.eq(OrderCloth::getOrderStatus,ClothOrderStatusType.SENDING.getCode());
+        if ("7".equals(orderClothAppQueryDTO.getOrderStatus())) {
+            queryWrapper.eq(OrderCloth::getOrderStatus, ClothOrderStatusType.SENDING.getCode());
         }
-        if("8".equals(orderClothAppQueryDTO.getOrderStatus())){
+        if ("8".equals(orderClothAppQueryDTO.getOrderStatus())) {
             queryWrapper.and(orderClothLambdaQueryWrapper -> orderClothLambdaQueryWrapper
-                    .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WAITING_FOR_COMMENT.getCode()).or()
-                    .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.FINISH.getCode()));
+                    .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.WAITING_FOR_COMMENT.getCode()).or()
+                    .eq(OrderCloth::getOrderStatus, ClothOrderStatusType.FINISH.getCode()));
         }
 
         queryWrapper.orderByDesc(BaseEntity::getCreateTime);
         List<OrderCloth> orderCloths = orderClothService.page(new Page<>(orderClothAppQueryDTO.getPageNum()
-                ,orderClothAppQueryDTO.getPageSize(),false),queryWrapper).getRecords();
+                , orderClothAppQueryDTO.getPageSize(), false), queryWrapper).getRecords();
         List<OrderClothVO> orderClothVOS = new ArrayList<>();
-        if(orderCloths.size() == 0){
+        if (orderCloths.size() == 0) {
             return R.ok(orderClothVOS);
         }
 
-        Map<Long,AppUser> takeClothUserMap = new HashMap<>();
-        if(orderCloths.stream().filter(orderCloth -> orderCloth.getTakeClothAppUserId() != null)
-                .map(OrderCloth::getAppUserId).collect(Collectors.toSet()).size() > 0){
+        Map<Long, AppUser> takeClothUserMap = new HashMap<>();
+        if (orderCloths.stream().filter(orderCloth -> orderCloth.getTakeClothAppUserId() != null)
+                .map(OrderCloth::getAppUserId).collect(Collectors.toSet()).size() > 0) {
             takeClothUserMap = appUserService.list(new QueryWrapper<AppUser>().lambda()
-                    .in(AppUser::getId,orderCloths.stream().filter(orderCloth -> orderCloth.getTakeClothAppUserId() != null)
-                            .map(OrderCloth::getAppUserId).collect(Collectors.toSet())))
-                    .stream().collect(Collectors.toMap(AppUser::getId,AppUser -> AppUser));
+                            .in(AppUser::getId, orderCloths.stream().filter(orderCloth -> orderCloth.getTakeClothAppUserId() != null)
+                                    .map(OrderCloth::getAppUserId).collect(Collectors.toSet())))
+                    .stream().collect(Collectors.toMap(AppUser::getId, AppUser -> AppUser));
         }
 
-        Map<Long,AppUser> sendClothUserMap = new HashMap<>();
-        if(orderCloths.stream().filter(orderCloth -> orderCloth.getSendClothAppUserId() != null)
-                .map(OrderCloth::getAppUserId).collect(Collectors.toSet()).size() > 0){
+        Map<Long, AppUser> sendClothUserMap = new HashMap<>();
+        if (orderCloths.stream().filter(orderCloth -> orderCloth.getSendClothAppUserId() != null)
+                .map(OrderCloth::getAppUserId).collect(Collectors.toSet()).size() > 0) {
             sendClothUserMap = appUserService.list(new QueryWrapper<AppUser>().lambda()
-                    .in(AppUser::getId,orderCloths.stream().filter(orderCloth -> orderCloth.getSendClothAppUserId() != null)
-                            .map(OrderCloth::getAppUserId).collect(Collectors.toSet())))
-                    .stream().collect(Collectors.toMap(AppUser::getId,AppUser -> AppUser));
+                            .in(AppUser::getId, orderCloths.stream().filter(orderCloth -> orderCloth.getSendClothAppUserId() != null)
+                                    .map(OrderCloth::getAppUserId).collect(Collectors.toSet())))
+                    .stream().collect(Collectors.toMap(AppUser::getId, AppUser -> AppUser));
         }
         Map<Long, SysOrg> storeOrgMap = new HashMap<>();
         Map<Long, SysOrg> factoryOrgMap = new HashMap<>();
-        if(orderCloths.stream().filter(orderCloth -> SourceType.STORE.getCode()
-                .equals(orderCloth.getSourceType())).collect(Collectors.toList()).size() > 0){
+        if (orderCloths.stream().filter(orderCloth -> SourceType.STORE.getCode()
+                .equals(orderCloth.getSourceType())).collect(Collectors.toList()).size() > 0) {
             storeOrgMap = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSourceType
-                    ,SourceType.STORE.getCode()).in(SysOrg::getId,orderCloths.stream()
-                    .map(OrderCloth::getOrgId).collect(Collectors.toSet()))).stream()
-                    .collect(Collectors.toMap(SysOrg::getId,SysOrg -> SysOrg));
+                            , SourceType.STORE.getCode()).in(SysOrg::getId, orderCloths.stream()
+                            .map(OrderCloth::getOrgId).collect(Collectors.toSet()))).stream()
+                    .collect(Collectors.toMap(SysOrg::getId, SysOrg -> SysOrg));
         }
-        if(orderCloths.stream().filter(orderCloth -> SourceType.FACTORY.getCode()
-                .equals(orderCloth.getSourceType())).collect(Collectors.toList()).size() > 0){
+        if (orderCloths.stream().filter(orderCloth -> SourceType.FACTORY.getCode()
+                .equals(orderCloth.getSourceType())).collect(Collectors.toList()).size() > 0) {
             factoryOrgMap = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSourceType
-                    ,SourceType.FACTORY.getCode()).in(SysOrg::getId,orderCloths.stream()
-                    .map(OrderCloth::getOrgId).collect(Collectors.toSet()))).stream()
-                    .collect(Collectors.toMap(SysOrg::getId,SysOrg -> SysOrg));
+                            , SourceType.FACTORY.getCode()).in(SysOrg::getId, orderCloths.stream()
+                            .map(OrderCloth::getOrgId).collect(Collectors.toSet()))).stream()
+                    .collect(Collectors.toMap(SysOrg::getId, SysOrg -> SysOrg));
         }
         for (OrderCloth record : orderCloths) {
             OrderClothVO orderClothVO = new OrderClothVO();
-            BeanUtils.copyProperties(record,orderClothVO);
-            if(record.getTakeClothAppUserId() != null && takeClothUserMap.containsKey(record.getTakeClothAppUserId())){
+            BeanUtils.copyProperties(record, orderClothVO);
+            if (record.getTakeClothAppUserId() != null && takeClothUserMap.containsKey(record.getTakeClothAppUserId())) {
                 AppUserVO appUserVO = new AppUserVO();
-                BeanUtils.copyProperties(takeClothUserMap.get(record.getTakeClothAppUserId()),appUserVO);
+                BeanUtils.copyProperties(takeClothUserMap.get(record.getTakeClothAppUserId()), appUserVO);
                 orderClothVO.setTakeClothUserVO(appUserVO);
             }
-            if(record.getSendClothAppUserId() != null && sendClothUserMap.containsKey(record.getSendClothAppUserId())){
+            if (record.getSendClothAppUserId() != null && sendClothUserMap.containsKey(record.getSendClothAppUserId())) {
                 AppUserVO appUserVO = new AppUserVO();
-                BeanUtils.copyProperties(sendClothUserMap.get(record.getSendClothAppUserId()),appUserVO);
+                BeanUtils.copyProperties(sendClothUserMap.get(record.getSendClothAppUserId()), appUserVO);
                 orderClothVO.setSendClothUserVO(appUserVO);
             }
-            if(SourceType.STORE.getCode().equals(orderClothVO.getSourceType())){
+            if (SourceType.STORE.getCode().equals(orderClothVO.getSourceType())) {
                 orderClothVO.setSysOrg(storeOrgMap.get(orderClothVO.getOrgId()));
-            }else if(SourceType.FACTORY.getCode().equals(orderClothVO.getSourceType())){
+            } else if (SourceType.FACTORY.getCode().equals(orderClothVO.getSourceType())) {
                 orderClothVO.setSysOrg(factoryOrgMap.get(orderClothVO.getOrgId()));
             }
             orderClothVOS.add(orderClothVO);
@@ -317,34 +317,34 @@ public class WeAppOrderClothController {
 
     @ApiOperation("查询洗衣订单明细")
     @GetMapping(value = "getInfoById")
-    public R<OrderClothVO> getInfoById(@RequestParam @ApiParam("订单ID") Long orderId) throws Exception{
+    public R<OrderClothVO> getInfoById(@RequestParam @ApiParam("订单ID") Long orderId) throws Exception {
         OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getId,orderId).eq(OrderCloth::getAppUserId,AuthHolder.userId()));
-        if(orderCloth == null){
+                .eq(OrderCloth::getId, orderId).eq(OrderCloth::getAppUserId, AuthHolder.userId()));
+        if (orderCloth == null) {
             throw new ServiceException("未查询到订单信息");
         }
 
         OrderClothVO orderClothVO = new OrderClothVO();
-        BeanUtils.copyProperties(orderCloth,orderClothVO);
-        orderClothVO.setSysOrg(sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getId,orderCloth.getOrgId())
-                .eq(SysOrg::getSourceType,orderCloth.getSourceType())));
+        BeanUtils.copyProperties(orderCloth, orderClothVO);
+        orderClothVO.setSysOrg(sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getId, orderCloth.getOrgId())
+                .eq(SysOrg::getSourceType, orderCloth.getSourceType())));
 
         orderClothVO.setOrderClothItemVOS(
                 orderClothItemService.buildWeAppOrderClothItemDetail(
-                orderClothItemService.list(new QueryWrapper<OrderClothItem>().lambda()
-                        .eq(OrderClothItem::getOrderId,orderCloth.getId()))));
+                        orderClothItemService.list(new QueryWrapper<OrderClothItem>().lambda()
+                                .eq(OrderClothItem::getOrderId, orderCloth.getId()))));
 
-        if(TakeOrSendClothWay.DELIVERY.getCode().equals(orderCloth.getTakeClothWay())
-                || TakeOrSendClothWay.DELIVERY.getCode().equals(orderCloth.getSendClothWay())){
-            Map<String,OrderDelivery> orderDeliveryMap = orderDeliveryService.list(
-                    new QueryWrapper<OrderDelivery>().lambda()
-                            .eq(OrderDelivery::getOrderSn,orderCloth.getOrderNo()))
+        if (TakeOrSendClothWay.DELIVERY.getCode().equals(orderCloth.getTakeClothWay())
+                || TakeOrSendClothWay.DELIVERY.getCode().equals(orderCloth.getSendClothWay())) {
+            Map<String, OrderDelivery> orderDeliveryMap = orderDeliveryService.list(
+                            new QueryWrapper<OrderDelivery>().lambda()
+                                    .eq(OrderDelivery::getOrderSn, orderCloth.getOrderNo()))
                     .stream().collect(Collectors.toMap(OrderDelivery::getClothOrderType
-                            ,OrderDelivery -> OrderDelivery));
-            if(TakeOrSendClothWay.DELIVERY.getCode().equals(orderCloth.getTakeClothWay())){
+                            , OrderDelivery -> OrderDelivery));
+            if (TakeOrSendClothWay.DELIVERY.getCode().equals(orderCloth.getTakeClothWay())) {
                 orderClothVO.setCollectClothDeliverInfo(orderDeliveryMap.get(ClothOrderDeliveryType.collectCloth.getCode()));
             }
-            if(TakeOrSendClothWay.DELIVERY.getCode().equals(orderCloth.getSendClothWay())){
+            if (TakeOrSendClothWay.DELIVERY.getCode().equals(orderCloth.getSendClothWay())) {
                 orderClothVO.setTakeClothDeliverInfo(orderDeliveryMap.get(ClothOrderDeliveryType.takeCloth.getCode()));
             }
         }
@@ -354,7 +354,7 @@ public class WeAppOrderClothController {
     @Transactional(rollbackFor = Exception.class)
     @ApiOperation("洗衣订单配送订单下单")
     @PostMapping(value = "addSendClothDeliveryOrder")
-    public R addSendClothDeliveryOrder(@RequestBody @Valid UpdateOrderClothTakeClothWayDTO updateOrderClothTakeClothWayDTO) throws Exception{
+    public R addSendClothDeliveryOrder(@RequestBody @Valid UpdateOrderClothTakeClothWayDTO updateOrderClothTakeClothWayDTO) throws Exception {
 //        if(updateOrderClothTakeClothWayDTO.getAddressId() == null){
 //            throw new ServiceException("请先选择地址");
 //        }
@@ -467,76 +467,76 @@ public class WeAppOrderClothController {
     @Transactional(rollbackFor = Exception.class)
     @ApiOperation("衣服确认送达")
     @GetMapping(value = "confirmSend")
-    public R confirmSend(@RequestParam Long orderId) throws Exception{
+    public R confirmSend(@RequestParam Long orderId) throws Exception {
         OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getId,orderId)
-                .eq(OrderCloth::getAppUserId,AuthHolder.userId()));
-        if(orderCloth == null){
+                .eq(OrderCloth::getId, orderId)
+                .eq(OrderCloth::getAppUserId, AuthHolder.userId()));
+        if (orderCloth == null) {
             throw new ServiceException("未查询到订单信息");
         }
-        if(!ClothOrderStatusType.SENDING.getCode().equals(orderCloth.getOrderStatus())){
+        if (!ClothOrderStatusType.SENDING.getCode().equals(orderCloth.getOrderStatus())) {
             throw new ServiceException("当前订单状态为"
-                    + EnumUtils.getEnumByType(orderCloth.getOrderStatus(),ClothOrderStatusType.class)
+                    + EnumUtils.getEnumByType(orderCloth.getOrderStatus(), ClothOrderStatusType.class)
                     + ",无法进行确认送达操作");
         }
         orderCloth.setOrderStatus(ClothOrderStatusType.FINISH.getCode());
         orderClothService.updateById(orderCloth);
         orderClothItemService.update(new UpdateWrapper<OrderClothItem>().lambda()
-                .set(OrderClothItem::getFlowStatus,ClothOrderFlowStatus.hasTake.getCode())
-                .eq(OrderClothItem::getOrderId,orderId));
+                .set(OrderClothItem::getFlowStatus, ClothOrderFlowStatus.hasTake.getCode())
+                .eq(OrderClothItem::getOrderId, orderId));
         List<OrderClothItem> orderClothItems = orderClothItemService.list(new QueryWrapper<OrderClothItem>()
-                .lambda().eq(OrderClothItem::getOrderId,orderId));
-        orderClothItemFlowRecordService.addRecordBatch(orderClothItems,ClothOrderFlowStatus.hasTake.getCode());
+                .lambda().eq(OrderClothItem::getOrderId, orderId));
+        orderClothItemFlowRecordService.addRecordBatch(orderClothItems, ClothOrderFlowStatus.hasTake.getCode());
         return R.ok();
     }
 
     @ApiOperation("取消订单")
     @GetMapping(value = "cancel")
-    public R cancel(@RequestParam @ApiParam("订单ID") Long orderId) throws Exception{
+    public R cancel(@RequestParam @ApiParam("订单ID") Long orderId) throws Exception {
         OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getId,orderId).eq(OrderCloth::getAppUserId,AuthHolder.userId()));
-        if(orderCloth == null){
+                .eq(OrderCloth::getId, orderId).eq(OrderCloth::getAppUserId, AuthHolder.userId()));
+        if (orderCloth == null) {
             throw new ServiceException("未查询到订单");
         }
 
-        if(!(ClothOrderStatusType.APPOINTMENT.getCode().equals(orderCloth.getOrderStatus())
-                ||ClothOrderStatusType.WAITING_TO_DOOR.getCode().equals(orderCloth.getOrderStatus())
-                ||ClothOrderStatusType.HAS_TO_DOOR.getCode().equals(orderCloth.getOrderStatus())
-                ||ClothOrderStatusType.HAS_TAKING.getCode().equals(orderCloth.getOrderStatus())
-                ||ClothOrderStatusType.WAITING_FOR_PAY.getCode().equals(orderCloth.getOrderStatus()))){
+        if (!(ClothOrderStatusType.APPOINTMENT.getCode().equals(orderCloth.getOrderStatus())
+                || ClothOrderStatusType.WAITING_TO_DOOR.getCode().equals(orderCloth.getOrderStatus())
+                || ClothOrderStatusType.HAS_TO_DOOR.getCode().equals(orderCloth.getOrderStatus())
+                || ClothOrderStatusType.HAS_TAKING.getCode().equals(orderCloth.getOrderStatus())
+                || ClothOrderStatusType.WAITING_FOR_PAY.getCode().equals(orderCloth.getOrderStatus()))) {
             throw new ServiceException("订单状态不正确,无法取消");
         }
 
         orderClothService.update(new UpdateWrapper<OrderCloth>().lambda()
-                .set(OrderCloth::getOrderStatus,ClothOrderStatusType.CANCEL.getCode())
-                .set(BaseEntity::getUpdateTime,DateUtils.getNowDate()).eq(OrderCloth::getId,orderId));
+                .set(OrderCloth::getOrderStatus, ClothOrderStatusType.CANCEL.getCode())
+                .set(BaseEntity::getUpdateTime, DateUtils.getNowDate()).eq(OrderCloth::getId, orderId));
 
         orderClothItemService.update(new UpdateWrapper<OrderClothItem>().lambda()
-                .set(OrderClothItem::getFlowStatus,ClothOrderFlowStatus.refund.getCode())
-                .eq(OrderClothItem::getOrderId,orderId));
+                .set(OrderClothItem::getFlowStatus, ClothOrderFlowStatus.refund.getCode())
+                .eq(OrderClothItem::getOrderId, orderId));
         List<OrderClothItem> orderClothItems = orderClothItemService.list(new QueryWrapper<OrderClothItem>()
-                .lambda().eq(OrderClothItem::getOrderId,orderId));
-        orderClothItemFlowRecordService.addRecordBatch(orderClothItems,ClothOrderFlowStatus.refund.getCode());
+                .lambda().eq(OrderClothItem::getOrderId, orderId));
+        orderClothItemFlowRecordService.addRecordBatch(orderClothItems, ClothOrderFlowStatus.refund.getCode());
         return R.ok();
     }
 
     @ApiOperation("计算配送费金额")
     @GetMapping(value = "calculateDeliveryPirce")
-    public R<BigDecimal> calculateDeliveryPirce(@RequestParam Long orderId) throws Exception{
+    public R<BigDecimal> calculateDeliveryPirce(@RequestParam Long orderId) throws Exception {
         OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getId,orderId)
-                .eq(OrderCloth::getAppUserId,AuthHolder.userId()));
+                .eq(OrderCloth::getId, orderId)
+                .eq(OrderCloth::getAppUserId, AuthHolder.userId()));
         int freeDeliveryNum = 0;
-        if(orderCloth.getOrderClothPrice().doubleValue() >= 100){
+        if (orderCloth.getOrderClothPrice().doubleValue() >= 100) {
             freeDeliveryNum++;
         }
-        if(orderCloth.getOrderClothPrice().doubleValue() >= 200){
+        if (orderCloth.getOrderClothPrice().doubleValue() >= 200) {
             freeDeliveryNum++;
         }
-        if(ClothTakeWay.DELIVERY.getCode().equals(orderCloth.getTakeClothWay())){
+        if (ClothTakeWay.DELIVERY.getCode().equals(orderCloth.getTakeClothWay())) {
             freeDeliveryNum--;
         }
-        if(freeDeliveryNum > 0){
+        if (freeDeliveryNum > 0) {
             return R.ok(BigDecimal.ZERO);
         }
         return R.ok(new BigDecimal(sysConfigService.selectConfigByKey(SysConfigKey.OrderClothDeliveryPrice.getCode())));

+ 71 - 51
yiqi-api/src/main/java/com/yiqi/api/controller/order/WeAppOrderClothDeliveryManController.java

@@ -10,11 +10,9 @@ import com.yiqi.common.core.domain.AuthHolder;
 import com.yiqi.common.core.domain.BaseEntity;
 import com.yiqi.common.core.domain.PageVO;
 import com.yiqi.common.core.domain.R;
-import com.yiqi.common.enums.ClothOrderDeliveryType;
-import com.yiqi.common.enums.ClothOrderStatusType;
-import com.yiqi.common.enums.OrderRefundStatus;
-import com.yiqi.common.enums.SourceType;
+import com.yiqi.common.enums.*;
 import com.yiqi.common.exception.ServiceException;
+import com.yiqi.common.utils.DateUtils;
 import com.yiqi.common.utils.StringUtils;
 import com.yiqi.order.domain.*;
 import com.yiqi.order.domain.dto.weapp.AppOrderClothDeliveryChangeStatusDTO;
@@ -70,30 +68,30 @@ public class WeAppOrderClothDeliveryManController {
 
     @ApiOperation("配送员查询订单列表")
     @PostMapping(value = "findDeliveryPage")
-    public R<List<OrderDeliveryVO>> findDeliveryManPage(@RequestBody @Valid AppOrderClothDeliveryManQueryDTO appOrderClothDeliveryManQueryDTO) throws Exception{
+    public R<List<OrderDeliveryVO>> findDeliveryManPage(@RequestBody @Valid AppOrderClothDeliveryManQueryDTO appOrderClothDeliveryManQueryDTO) throws Exception {
         Page<OrderDelivery> page = new Page<>(appOrderClothDeliveryManQueryDTO.getPageNum()
-                ,appOrderClothDeliveryManQueryDTO.getPageSize());
+                , appOrderClothDeliveryManQueryDTO.getPageSize());
         page.setSearchCount(false);
 
         LambdaQueryWrapper<OrderDelivery> queryWrapper = new LambdaQueryWrapper<OrderDelivery>();
-        queryWrapper.eq(OrderDelivery::getDeliveryManId,AuthHolder.userId());
-        queryWrapper.eq(OrderDelivery::getDeliveryStatus,appOrderClothDeliveryManQueryDTO.getDeliveryStatus());
+        queryWrapper.eq(OrderDelivery::getDeliveryManId, AuthHolder.userId());
+        queryWrapper.eq(OrderDelivery::getDeliveryStatus, appOrderClothDeliveryManQueryDTO.getDeliveryStatus());
         queryWrapper.orderByDesc(BaseEntity::getCreateTime);
-        List<OrderDelivery> orderDeliveryList =  orderDeliveryService.page(page
-                ,queryWrapper).getRecords();
-        if(orderDeliveryList.size() == 0){
+        List<OrderDelivery> orderDeliveryList = orderDeliveryService.page(page
+                , queryWrapper).getRecords();
+        if (orderDeliveryList.size() == 0) {
             return R.ok(new ArrayList<>());
         }
         List<OrderDeliveryVO> orderDeliveryVOList = new ArrayList<>();
-        for(OrderDelivery orderDelivery : orderDeliveryList){
+        for (OrderDelivery orderDelivery : orderDeliveryList) {
             OrderDeliveryVO orderDeliveryVO = new OrderDeliveryVO();
-            BeanUtils.copyProperties(orderDelivery,orderDeliveryVO);
+            BeanUtils.copyProperties(orderDelivery, orderDeliveryVO);
             //门店不为空
-            if(orderDelivery.getStoreId()!=null){
+            if (orderDelivery.getStoreId() != null) {
                 SysStore store = sysStoreService.getById(orderDelivery.getStoreId());
                 orderDeliveryVO.setStoreName(store.getName());
                 StoreAddressVO storeAddressVO = new StoreAddressVO();
-                BeanUtils.copyProperties(store,storeAddressVO);
+                BeanUtils.copyProperties(store, storeAddressVO);
             }
             orderDeliveryVOList.add(orderDeliveryVO);
         }
@@ -103,99 +101,121 @@ public class WeAppOrderClothDeliveryManController {
     @Transactional(rollbackFor = Exception.class)
     @ApiOperation("上门取衣")
     @PostMapping(value = "toDoor")
-    public R toDoor(@RequestBody @Valid AppOrderClothDeliveryChangeStatusDTO appOrderClothDeliveryChangeStatusDTO) throws Exception{
+    public R toDoor(@RequestBody @Valid AppOrderClothDeliveryChangeStatusDTO appOrderClothDeliveryChangeStatusDTO) throws Exception {
         OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getId,appOrderClothDeliveryChangeStatusDTO.getOrderId()).eq(OrderCloth::getTakeClothAppUserId, AuthHolder.userId())
+                .eq(OrderCloth::getId, appOrderClothDeliveryChangeStatusDTO.getOrderId()).eq(OrderCloth::getTakeClothAppUserId, AuthHolder.userId())
                 .eq(OrderCloth::getRefundStatus, OrderRefundStatus.OK.getCode()));
-        if(orderCloth == null){
+        if (orderCloth == null) {
             throw new ServiceException("未查询到订单");
         }
 
-        if(!ClothOrderStatusType.WAITING_TO_DOOR.getCode().equals(orderCloth.getOrderStatus())){
+        if (!ClothOrderStatusType.WAITING_TO_DOOR.getCode().equals(orderCloth.getOrderStatus())) {
             throw new ServiceException("订单状态不是待上门状态,无法进行上门取衣操作");
         }
 
         orderClothService.update(new UpdateWrapper<OrderCloth>().lambda()
-                .set(OrderCloth::getOrderStatus,ClothOrderStatusType.HAS_TO_DOOR.getCode())
-                .eq(OrderCloth::getId,appOrderClothDeliveryChangeStatusDTO.getOrderId()));
-
-        orderClothStatusRecordService.addRecord(appOrderClothDeliveryChangeStatusDTO,orderCloth.getOrderNo()
-                ,ClothOrderStatusType.HAS_TO_DOOR.getCode(), AuthHolder.userId());
+                .set(OrderCloth::getOrderStatus, ClothOrderStatusType.HAS_TO_DOOR.getCode())
+                .eq(OrderCloth::getId, appOrderClothDeliveryChangeStatusDTO.getOrderId()));
+        //更新配送订单
+        OrderDelivery orderDelivery = orderDeliveryService.selectOrderDeliveryByOrderId(orderCloth.getId(), "1");
+        orderDelivery.setDeliveryStatus(OrderDeliveryStatusEnum.HAS_TO_DOOR.getCode());
+        orderDelivery.setFetchTime(DateUtils.getNowDate());
+        orderDeliveryService.updateById(orderDelivery);
+        orderClothStatusRecordService.addRecord(appOrderClothDeliveryChangeStatusDTO, orderCloth.getOrderNo()
+                , ClothOrderStatusType.HAS_TO_DOOR.getCode(), AuthHolder.userId());
         return R.ok();
     }
 
+    @Transactional(rollbackFor = Exception.class)
     @ApiOperation("送回到店")
     @PostMapping(value = "take")
-    public R take(@RequestBody @Valid AppOrderClothDeliveryChangeStatusDTO appOrderClothDeliveryChangeStatusDTO) throws Exception{
+    public R take(@RequestBody @Valid AppOrderClothDeliveryChangeStatusDTO appOrderClothDeliveryChangeStatusDTO) throws Exception {
         OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getId,appOrderClothDeliveryChangeStatusDTO.getOrderId()).eq(OrderCloth::getTakeClothAppUserId, AuthHolder.userId())
+                .eq(OrderCloth::getId, appOrderClothDeliveryChangeStatusDTO.getOrderId()).eq(OrderCloth::getTakeClothAppUserId, AuthHolder.userId())
                 .eq(OrderCloth::getRefundStatus, OrderRefundStatus.OK.getCode()));
-        if(orderCloth == null){
+        if (orderCloth == null) {
             throw new ServiceException("未查询到订单");
         }
 
-        if(!ClothOrderStatusType.HAS_TO_DOOR.getCode().equals(orderCloth.getOrderStatus())){
+        if (!ClothOrderStatusType.HAS_TO_DOOR.getCode().equals(orderCloth.getOrderStatus())) {
             throw new ServiceException("订单状态不是已上门状态,无法进行送回到店确认操作");
         }
-
         orderClothService.update(new UpdateWrapper<OrderCloth>().lambda()
-                .set(OrderCloth::getOrderStatus,ClothOrderStatusType.HAS_TAKING.getCode())
-                .eq(OrderCloth::getId,appOrderClothDeliveryChangeStatusDTO.getOrderId()));
+                .set(OrderCloth::getOrderStatus, ClothOrderStatusType.HAS_TAKING.getCode())
+                .eq(OrderCloth::getId, appOrderClothDeliveryChangeStatusDTO.getOrderId()));
 
-        orderClothStatusRecordService.addRecord(appOrderClothDeliveryChangeStatusDTO,orderCloth.getOrderNo()
-                ,ClothOrderStatusType.HAS_TO_DOOR.getCode(), AuthHolder.userId());
+        //更新配送订单
+        OrderDelivery orderDelivery = orderDeliveryService.selectOrderDeliveryByOrderId(orderCloth.getId(), "1");
+        orderDelivery.setDeliveryStatus(OrderDeliveryStatusEnum.SEND_FINISH.getCode());
+        orderDelivery.setFinishTime(DateUtils.getNowDate());
+        orderDeliveryService.updateById(orderDelivery);
+
+        orderClothStatusRecordService.addRecord(appOrderClothDeliveryChangeStatusDTO, orderCloth.getOrderNo()
+                , ClothOrderStatusType.HAS_TAKING.getCode(), AuthHolder.userId());
         return R.ok();
     }
 
     @ApiOperation("开始送衣")
     @PostMapping(value = "send")
-    public R send(@RequestBody @Valid AppOrderClothDeliveryChangeStatusDTO appOrderClothDeliveryChangeStatusDTO) throws Exception{
+    public R send(@RequestBody @Valid AppOrderClothDeliveryChangeStatusDTO appOrderClothDeliveryChangeStatusDTO) throws Exception {
         OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getId,appOrderClothDeliveryChangeStatusDTO.getOrderId()).eq(OrderCloth::getSendClothAppUserId, AuthHolder.userId())
+                .eq(OrderCloth::getId, appOrderClothDeliveryChangeStatusDTO.getOrderId()).eq(OrderCloth::getSendClothAppUserId, AuthHolder.userId())
                 .eq(OrderCloth::getRefundStatus, OrderRefundStatus.OK.getCode()));
-        if(orderCloth == null){
+        if (orderCloth == null) {
             throw new ServiceException("未查询到订单");
         }
 
-        if(!ClothOrderStatusType.WAITING_TO_SEND.getCode().equals(orderCloth.getOrderStatus())){
+        if (!ClothOrderStatusType.WAITING_TO_SEND.getCode().equals(orderCloth.getOrderStatus())) {
             throw new ServiceException("订单状态不是待送衣状态,无法进行送衣操作");
         }
 
         orderClothService.update(new UpdateWrapper<OrderCloth>().lambda()
-                .set(OrderCloth::getOrderStatus,ClothOrderStatusType.SENDING.getCode())
-                .eq(OrderCloth::getId,appOrderClothDeliveryChangeStatusDTO.getOrderId()));
+                .set(OrderCloth::getOrderStatus, ClothOrderStatusType.SENDING.getCode())
+                .eq(OrderCloth::getId, appOrderClothDeliveryChangeStatusDTO.getOrderId()));
+
+        //更新配送订单
+        OrderDelivery orderDelivery = orderDeliveryService.selectOrderDeliveryByOrderId(orderCloth.getId(), "2");
+        orderDelivery.setDeliveryStatus(OrderDeliveryStatusEnum.SENDING.getCode());
+        orderDelivery.setFetchTime(DateUtils.getNowDate());
+        orderDeliveryService.updateById(orderDelivery);
 
-        orderClothStatusRecordService.addRecord(appOrderClothDeliveryChangeStatusDTO,orderCloth.getOrderNo()
-                ,ClothOrderStatusType.HAS_TO_DOOR.getCode(), AuthHolder.userId());
+        orderClothStatusRecordService.addRecord(appOrderClothDeliveryChangeStatusDTO, orderCloth.getOrderNo()
+                , ClothOrderStatusType.SENDING.getCode(), AuthHolder.userId());
         return R.ok();
     }
 
     @ApiOperation("配送完成")
     @PostMapping(value = "finish")
-    public R finish(@RequestBody @Valid AppOrderClothDeliveryChangeStatusDTO appOrderClothDeliveryChangeStatusDTO) throws Exception{
+    public R finish(@RequestBody @Valid AppOrderClothDeliveryChangeStatusDTO appOrderClothDeliveryChangeStatusDTO) throws Exception {
         OrderCloth orderCloth = orderClothService.getOne(new QueryWrapper<OrderCloth>().lambda()
-                .eq(OrderCloth::getId,appOrderClothDeliveryChangeStatusDTO.getOrderId()).eq(OrderCloth::getSendClothAppUserId, AuthHolder.userId())
+                .eq(OrderCloth::getId, appOrderClothDeliveryChangeStatusDTO.getOrderId()).eq(OrderCloth::getSendClothAppUserId, AuthHolder.userId())
                 .eq(OrderCloth::getRefundStatus, OrderRefundStatus.OK.getCode()));
-        if(orderCloth == null){
+        if (orderCloth == null) {
             throw new ServiceException("未查询到订单");
         }
 
-        if(!ClothOrderStatusType.SENDING.getCode().equals(orderCloth.getOrderStatus())){
+        if (!ClothOrderStatusType.SENDING.getCode().equals(orderCloth.getOrderStatus())) {
             throw new ServiceException("订单状态不是送衣中状态,无法进行完成操作");
         }
 
         orderClothService.update(new UpdateWrapper<OrderCloth>().lambda()
-                .set(OrderCloth::getOrderStatus,ClothOrderStatusType.FINISH.getCode())
-                .eq(OrderCloth::getId,appOrderClothDeliveryChangeStatusDTO.getOrderId()));
+                .set(OrderCloth::getOrderStatus, ClothOrderStatusType.FINISH.getCode())
+                .eq(OrderCloth::getId, appOrderClothDeliveryChangeStatusDTO.getOrderId()));
+
+        //更新配送订单
+        OrderDelivery orderDelivery = orderDeliveryService.selectOrderDeliveryByOrderId(orderCloth.getId(), "2");
+        orderDelivery.setDeliveryStatus(OrderDeliveryStatusEnum.SEND_FINISH.getCode());
+        orderDelivery.setFinishTime(DateUtils.getNowDate());
+        orderDeliveryService.updateById(orderDelivery);
 
-        orderClothStatusRecordService.addRecord(appOrderClothDeliveryChangeStatusDTO,orderCloth.getOrderNo()
-                ,ClothOrderStatusType.HAS_TO_DOOR.getCode(), AuthHolder.userId());
+        orderClothStatusRecordService.addRecord(appOrderClothDeliveryChangeStatusDTO, orderCloth.getOrderNo()
+                , ClothOrderStatusType.FINISH.getCode(), AuthHolder.userId());
         return R.ok();
     }
 
     @ApiOperation("查询订单状态变更记录")
     @GetMapping(value = "getStatusRecordList")
-    public R<List<OrderClothStatusRecord>> getStatusRecordList(@RequestParam @ApiParam("订单ID") Long orderId) throws Exception{
-        return R.ok(orderClothStatusRecordService.list(new QueryWrapper<OrderClothStatusRecord>().lambda().eq(OrderClothStatusRecord::getOrderId,orderId)));
+    public R<List<OrderClothStatusRecord>> getStatusRecordList(@RequestParam @ApiParam("订单ID") Long orderId) throws Exception {
+        return R.ok(orderClothStatusRecordService.list(new QueryWrapper<OrderClothStatusRecord>().lambda().eq(OrderClothStatusRecord::getOrderId, orderId)));
     }
 }

+ 10 - 10
yiqi-common/src/main/java/com/yiqi/common/enums/OrderDeliveryStatusEnum.java

@@ -7,16 +7,16 @@ package com.yiqi.common.enums;
  */
 public enum OrderDeliveryStatusEnum {
 
-    ORIGIN_STATUS("0", "订单初始化"),
-    CREATE_ORDER_SUCCESS("10000", "订单创建成功"),
-    STORE_CANCEL("20000", "商家取消订单"),
-    DELIVERY_CANCEL("20001", "配送方取消订单"),
-    SENDER_RECEIVE("30000", "配送员接单"),
-    SENDER_ARRIVE_STORE("40000", "配送员到店"),
-    SENDING("50000", "配送中"),
-    SENDER_CANCEL("60000", "配送员撤单"),
-    SEND_FINISH("70000", "配送完成"),
-    SEND_ERROR("90000", "配送异常"),
+    WAIT_DELIVERY("0", "待派单"),
+    CREATE_ORDER_SUCCESS("1", "已派单"),
+    RECEIVE_ORDER("2", "已接单"),
+    HAS_TO_DOOR("3", "已上门"),
+    SENDING("4", "配送中"),
+    SEND_FINISH("9", "配送完成"),
+
+    STORE_CANCEL("100", "商家取消配送订单"),
+    DELIVERY_CANCEL("101", "配送员取消订单"),
+    SENDER_CANCEL("102", "配送员撤单"),
     ;
 
     private final String code;

+ 7 - 0
yiqi-common/src/main/java/com/yiqi/order/service/IOrderDeliveryService.java

@@ -15,6 +15,13 @@ import com.yiqi.order.domain.vo.OrderDeliveryVO;
  */
 public interface IOrderDeliveryService extends IService<OrderDelivery> {
 
+    /**
+     * 查询订单配送
+     * @param orderId
+     * @return
+     */
+    OrderDelivery selectOrderDeliveryByOrderId(Long orderId, String clothOrderType);
+
     /**
      * 查询订单配送列表
      *

+ 10 - 0
yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderDeliveryServiceImpl.java

@@ -2,6 +2,7 @@ package com.yiqi.order.service.impl;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.yiqi.common.utils.DateUtils;
 import com.yiqi.common.utils.SecurityUtils;
 import com.yiqi.order.domain.OrderDelivery;
@@ -22,9 +23,18 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class OrderDeliveryServiceImpl extends ServiceImpl<OrderDeliveryMapper, OrderDelivery> implements IOrderDeliveryService {
 
+    @Override
+    public OrderDelivery selectOrderDeliveryByOrderId(Long orderId, String clothOrderType) {
+        QueryWrapper<OrderDelivery> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("order_id", orderId);
+        queryWrapper.eq("cloth_order_type", clothOrderType);
+        return baseMapper.selectOne(queryWrapper);
+    }
+
     @Override
     public List<OrderDeliveryVO> selectOrderDeliveryList(OrderDeliveryRequestDTO requestDTO) {
         return baseMapper.selectOrderDeliveryList(requestDTO);
     }
 
+
 }