|
@@ -16,18 +16,20 @@ import com.yiqi.common.enums.OrderRefundStatus;
|
|
|
import com.yiqi.common.enums.SourceType;
|
|
|
import com.yiqi.common.exception.ServiceException;
|
|
|
import com.yiqi.common.utils.StringUtils;
|
|
|
-import com.yiqi.order.domain.OrderCloth;
|
|
|
-import com.yiqi.order.domain.OrderClothDeliveryAddress;
|
|
|
-import com.yiqi.order.domain.OrderClothStatusRecord;
|
|
|
+import com.yiqi.order.domain.*;
|
|
|
import com.yiqi.order.domain.dto.weapp.AppOrderClothDeliveryChangeStatusDTO;
|
|
|
import com.yiqi.order.domain.dto.weapp.AppOrderClothDeliveryManQueryDTO;
|
|
|
import com.yiqi.order.domain.vo.OrderClothVO;
|
|
|
+import com.yiqi.order.domain.vo.OrderDeliveryVO;
|
|
|
import com.yiqi.order.domain.vo.weapp.WeAppOrderClothAppointmentVO;
|
|
|
import com.yiqi.order.service.IOrderClothDeliveryAddressService;
|
|
|
import com.yiqi.order.service.IOrderClothService;
|
|
|
import com.yiqi.order.service.IOrderClothStatusRecordService;
|
|
|
+import com.yiqi.order.service.IOrderDeliveryService;
|
|
|
import com.yiqi.system.domain.SysOrg;
|
|
|
+import com.yiqi.system.domain.SysStore;
|
|
|
import com.yiqi.system.service.ISysOrgService;
|
|
|
+import com.yiqi.system.service.ISysStoreService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
@@ -58,84 +60,48 @@ public class WeAppOrderClothDeliveryManController {
|
|
|
@Autowired
|
|
|
private ISysOrgService sysOrgService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysStoreService sysStoreService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IOrderClothService orderClothService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrderDeliveryService orderDeliveryService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IOrderClothStatusRecordService orderClothStatusRecordService;
|
|
|
|
|
|
@ApiOperation("配送员查询订单列表")
|
|
|
@PostMapping(value = "findDeliveryPage")
|
|
|
- public R<List<OrderClothVO>> findDeliveryManPage(@RequestBody @Valid AppOrderClothDeliveryManQueryDTO appOrderClothDeliveryManQueryDTO) throws Exception{
|
|
|
- Page<OrderCloth> page = new Page<>(appOrderClothDeliveryManQueryDTO.getPageNum()
|
|
|
+ public R<List<OrderDeliveryVO>> findDeliveryManPage(@RequestBody @Valid AppOrderClothDeliveryManQueryDTO appOrderClothDeliveryManQueryDTO) throws Exception{
|
|
|
+ Page<OrderDelivery> page = new Page<>(appOrderClothDeliveryManQueryDTO.getPageNum()
|
|
|
,appOrderClothDeliveryManQueryDTO.getPageSize());
|
|
|
page.setSearchCount(false);
|
|
|
|
|
|
- LambdaQueryWrapper<OrderCloth> queryWrapper = new QueryWrapper<OrderCloth>().lambda()
|
|
|
- .eq(OrderCloth::getRefundStatus,OrderRefundStatus.OK.getCode())
|
|
|
- .and(orderClothLambdaQueryWrapper -> orderClothLambdaQueryWrapper
|
|
|
- .eq(OrderCloth::getSendClothAppUserId,AuthHolder.userId())
|
|
|
- .or()
|
|
|
- .eq(OrderCloth::getTakeClothAppUserId,AuthHolder.userId())
|
|
|
- )
|
|
|
-// .and(orderClothLambdaQueryWrapper -> orderClothLambdaQueryWrapper
|
|
|
-// .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WAITING_TO_DOOR.getCode())
|
|
|
-// .or()
|
|
|
-// .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.HAS_TO_DOOR.getCode())
|
|
|
-// .or()
|
|
|
-// .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.WAITING_TO_SEND.getCode())
|
|
|
-// .or()
|
|
|
-// .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.SENDING.getCode())
|
|
|
-// .or()
|
|
|
-// .eq(OrderCloth::getOrderStatus,ClothOrderStatusType.FINISH.getCode()))
|
|
|
- ;
|
|
|
- if(StringUtils.isNotEmpty(appOrderClothDeliveryManQueryDTO.getOrderStatus())){
|
|
|
- queryWrapper.eq(OrderCloth::getOrderStatus,appOrderClothDeliveryManQueryDTO.getOrderStatus());
|
|
|
- }
|
|
|
+ LambdaQueryWrapper<OrderDelivery> queryWrapper = new LambdaQueryWrapper<OrderDelivery>();
|
|
|
+ queryWrapper.eq(OrderDelivery::getDeliveryManId,AuthHolder.userId());
|
|
|
+ queryWrapper.eq(OrderDelivery::getDeliveryStatus,appOrderClothDeliveryManQueryDTO.getDeliveryStatus());
|
|
|
queryWrapper.orderByDesc(BaseEntity::getCreateTime);
|
|
|
- List<OrderCloth> orderCloths = orderClothService.page(page
|
|
|
+ List<OrderDelivery> orderDeliveryList = orderDeliveryService.page(page
|
|
|
,queryWrapper).getRecords();
|
|
|
- if(orderCloths.size() == 0){
|
|
|
+ if(orderDeliveryList.size() == 0){
|
|
|
return R.ok(new ArrayList<>());
|
|
|
}
|
|
|
-
|
|
|
- List<OrderClothDeliveryAddress> list = orderClothDeliveryAddressService.list(new QueryWrapper<OrderClothDeliveryAddress>().lambda()
|
|
|
- .in(OrderClothDeliveryAddress::getOrderId
|
|
|
- ,orderCloths.stream().map(OrderCloth::getId).collect(Collectors.toSet())));
|
|
|
- Map<Long,OrderClothDeliveryAddress> collectAddressMap = list.stream().filter(orderClothDeliveryAddress -> ClothOrderDeliveryType.collectCloth.getCode()
|
|
|
- .equals(orderClothDeliveryAddress.getClothOrderType()))
|
|
|
- .collect(Collectors.toMap(OrderClothDeliveryAddress::getOrderId,OrderClothDeliveryAddress -> OrderClothDeliveryAddress));
|
|
|
- Map<Long,OrderClothDeliveryAddress> takeAddressMap = list.stream().filter(orderClothDeliveryAddress -> ClothOrderDeliveryType.takeCloth.getCode()
|
|
|
- .equals(orderClothDeliveryAddress.getClothOrderType()))
|
|
|
- .collect(Collectors.toMap(OrderClothDeliveryAddress::getOrderId,OrderClothDeliveryAddress -> OrderClothDeliveryAddress));
|
|
|
- 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));
|
|
|
- }
|
|
|
- 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())))
|
|
|
- .eq(SysOrg::getSourceType,SourceType.FACTORY.getCode())).stream().collect(Collectors.toMap(SysOrg::getId,SysOrg -> SysOrg));
|
|
|
- }
|
|
|
- List<OrderClothVO> orderClothVOS = new ArrayList<>();
|
|
|
- for (OrderCloth orderCloth : orderCloths) {
|
|
|
- OrderClothVO orderClothVO = new OrderClothVO();
|
|
|
- BeanUtils.copyProperties(orderCloth,orderClothVO);
|
|
|
- orderClothVO.setCollectClothDeliverInfo(collectAddressMap.get(orderCloth.getId()));
|
|
|
- orderClothVO.setTakeClothDeliverInfo(takeAddressMap.get(orderCloth.getId()));
|
|
|
- if(SourceType.FACTORY.getCode().equals(orderCloth.getSourceType())){
|
|
|
- orderClothVO.setSysOrg(factoryOrgMap.get(orderCloth.getOrgId()));
|
|
|
- }else if(SourceType.STORE.getCode().equals(orderCloth.getSourceType())){
|
|
|
- orderClothVO.setSysOrg(storeOrgMap.get(orderCloth.getOrgId()));
|
|
|
- }else{
|
|
|
- orderClothVO.setSysOrg(SysOrg.buildManagerOrg());
|
|
|
+ List<OrderDeliveryVO> orderDeliveryVOList = new ArrayList<>();
|
|
|
+ for(OrderDelivery orderDelivery : orderDeliveryList){
|
|
|
+ OrderDeliveryVO orderDeliveryVO = new OrderDeliveryVO();
|
|
|
+ BeanUtils.copyProperties(orderDelivery,orderDeliveryVO);
|
|
|
+ //门店不为空
|
|
|
+ if(orderDelivery.getStoreId()!=null){
|
|
|
+ SysStore store = sysStoreService.getById(orderDelivery.getStoreId());
|
|
|
+ orderDeliveryVO.setStoreName(store.getName());
|
|
|
+ StoreAddressVO storeAddressVO = new StoreAddressVO();
|
|
|
+ BeanUtils.copyProperties(store,storeAddressVO);
|
|
|
}
|
|
|
- orderClothVOS.add(orderClothVO);
|
|
|
+ orderDeliveryVOList.add(orderDeliveryVO);
|
|
|
}
|
|
|
- return R.ok(orderClothVOS);
|
|
|
+ return R.ok(orderDeliveryVOList);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|