diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java b/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java index e96e1beb..186b638e 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/worker/WorkerController.java @@ -163,35 +163,45 @@ public class WorkerController extends BaseController { // 查询满足技能条件的师傅技能记录 List workerIdsByCategory = new ArrayList<>(); + WorkerGoodsCategory workerGoodsCategory = new WorkerGoodsCategory(); if(workerListRequest.getGoodsCategoryId() != null){ - WorkerGoodsCategory workerGoodsCategory = new WorkerGoodsCategory(); workerGoodsCategory.setGoodsCategoryId(workerListRequest.getGoodsCategoryId()); - // 如果选择了上级类目但未选择最终类目,则查询该类目下所有子类目 - if(StringUtils.isNotEmpty(workerListRequest.getCategoryLevel1()) + } + // 如果选择了上级类目但未选择最终类目,则查询该类目下所有子类目 + if(StringUtils.isNotEmpty(workerListRequest.getCategoryLevel1()) && workerListRequest.getGoodsCategoryId() == null) { - GoodsCategory param = new GoodsCategory(); - param.setParentCategoryId(Long.valueOf(workerListRequest.getCategoryLevel1())); - List subCategories = goodsCategoryService.selectGoodsCategoryList(param); - List categoryIds = subCategories.stream() + // 1. 先查找二级类目 + GoodsCategory param = new GoodsCategory(); + param.setParentCategoryId(Long.valueOf(workerListRequest.getCategoryLevel1())); + List secondCategories = goodsCategoryService.selectGoodsCategoryList(param); + + // 2. 用二级类目查找三级类目 + List categoryIds = new ArrayList<>(); + for (GoodsCategory secondCategory : secondCategories) { + param.setParentCategoryId(secondCategory.getGoodsCategoryId()); + List thirdCategories = goodsCategoryService.selectGoodsCategoryList(param); + categoryIds.addAll(thirdCategories.stream() + .map(x->x.getGoodsCategoryId().toString()) + .collect(Collectors.toList())); + } + workerGoodsCategory.setCategoryIds(categoryIds); + } + // 如果选择了二级类目但未选择三级类目 + else if(StringUtils.isNotEmpty(workerListRequest.getCategoryLevel2()) + && workerListRequest.getGoodsCategoryId() == null) { + GoodsCategory param = new GoodsCategory(); + param.setParentCategoryId(Long.valueOf(workerListRequest.getCategoryLevel2())); + List subCategories = goodsCategoryService.selectGoodsCategoryList(param); + List categoryIds = subCategories.stream() .map(x->x.getGoodsCategoryId().toString()) .collect(Collectors.toList()); - workerGoodsCategory.setCategoryIds(categoryIds); - } - // 如果选择了二级类目但未选择三级类目 - else if(StringUtils.isNotEmpty(workerListRequest.getCategoryLevel2()) - && workerListRequest.getGoodsCategoryId() == null) { - GoodsCategory param = new GoodsCategory(); - param.setParentCategoryId(Long.valueOf(workerListRequest.getCategoryLevel2())); - List subCategories = goodsCategoryService.selectGoodsCategoryList(param); - List categoryIds = subCategories.stream() - .map(x->x.getGoodsCategoryId().toString()) - .collect(Collectors.toList()); - workerGoodsCategory.setCategoryIds(categoryIds); - } + workerGoodsCategory.setCategoryIds(categoryIds); + } + if(CollectionUtils.isNotEmpty(workerGoodsCategory.getCategoryIds()) || workerGoodsCategory.getGoodsCategoryId() != null){ List workerGoodsCategoryList = workerGoodsCategoryService.getWorkerGoodsCategory(workerGoodsCategory); workerIdsByCategory = workerGoodsCategoryList.stream() - .map(WorkerGoodsCategory::getWorkerId) - .collect(Collectors.toList()); + .map(WorkerGoodsCategory::getWorkerId) + .collect(Collectors.toList()); } // 两个list中的workerid取交集 diff --git a/ghy-quartz/src/main/java/com/ghy/quartz/service/impl/OrderServiceImpl.java b/ghy-quartz/src/main/java/com/ghy/quartz/service/impl/OrderServiceImpl.java index 751b3ec3..308a2fc4 100644 --- a/ghy-quartz/src/main/java/com/ghy/quartz/service/impl/OrderServiceImpl.java +++ b/ghy-quartz/src/main/java/com/ghy/quartz/service/impl/OrderServiceImpl.java @@ -42,7 +42,7 @@ public class OrderServiceImpl implements OrderService { * * @see OrderStatus */ - @Value("${order.timeout.status:-4,-3,-2,0,1,2,3}") + @Value("${order.timeout.status:-4,-3,0,1,3}") private List timeoutOrderStatus; private static final List orderMasterTimeoutStatus = Arrays.asList(0, 1); @@ -84,7 +84,7 @@ public class OrderServiceImpl implements OrderService { } @Transactional(rollbackFor = Exception.class) - void checkTimeout(OrderMaster order) { + public void checkTimeout(OrderMaster order) { Date now = new Date(); // 待接单状态的超时逻辑 if (ZERO.equals(order.getOrderStatus())) { @@ -93,9 +93,9 @@ public class OrderServiceImpl implements OrderService { Date overTime1h = getOverTime(createTime, 30 * 60 * 1000); boolean flag; if(order.getUpdateTime() != null){ - flag = getOverTime(order.getUpdateTime(), 40 * 60 * 1000).before(now); + flag = getOverTime(order.getUpdateTime(), 45 * 60 * 1000).before(now); }else { - flag = getOverTime(createTime, 40 * 60 * 1000).before(now); + flag = getOverTime(createTime, 45 * 60 * 1000).before(now); } // 是否已经超时 boolean timeout = ONE.equals(order.getTimeout()); @@ -103,14 +103,14 @@ public class OrderServiceImpl implements OrderService { if (overTime30min.before(now) && overTime1h.after(now)) { // 30min未接单为超时 log.info("主订单[{}]超时30分钟", order.getId()); -// orderMasterService.updateTimeout(order.getId(), 1); + orderMasterService.updateTimeout(order.getId(), 1); timeout = true; } } if (flag && order.getWorkerId() != null) { log.info("主订单[{}]超时60分钟", order.getId()); - // 已超时 60min后取消超时状态 清空workerId -// orderMasterService.updateTimeout(order.getId(), 0); + // 已超时 45min后取消超时状态 清空workerId + orderMasterService.updateTimeout(order.getId(), 0); orderMasterService.removeWorker(order.getId()); } return; @@ -129,7 +129,7 @@ public class OrderServiceImpl implements OrderService { if (overTime30min.before(now)) { // 30min未接单为超时 log.info("主订单[{}]超时30分钟", order.getId()); -// orderMasterService.updateTimeout(order.getId(), 1); + orderMasterService.updateTimeout(order.getId(), 1); timeout = true; } } @@ -165,13 +165,26 @@ public class OrderServiceImpl implements OrderService { * @param order 订单信息 */ @Transactional(rollbackFor = Exception.class) - void checkTimeout(OrderDetail order) { + public void checkTimeout(OrderDetail order) { Date now = new Date(); // 是否超时 boolean timeout = ONE.equals(order.getTimeout()); // 超时扣款次数 Integer times = order.getTimeoutFineTimes(); if (!timeout) { + // 待上门超时 + if(order.getOrderStatus().equals(OrderStatus.GOING.code())){ + // 服务中状态要按预计上门时间计算4h超时 + Date overTime = getOverTime(order.getExpectTimeStart(), 30 * 60 * 1000); + if (overTime.before(now)) { + log.info("订单[{}]待上门状态超时30分钟", order.getId()); + OrderTimeoutRecord record = new OrderTimeoutRecord(order.getId(), order.getWorkerId(), order.getDeptId(), order.getOrderStatus()); + record.setPayMoney(getFineMoney(order)); + record.setFineStatus(0); +// orderFineRecordMapper.insert(record); + orderDetailService.updateTimeout(order.getId(), 1, 1); + } + } // 未超时的单 if (order.getOrderStatus().equals(OrderStatus.SERVER.code())) { // 服务中状态要按预计上门时间计算4h超时 diff --git a/ghy-worker/src/main/resources/mapper/worker/WorkerGoodsCategoryMapper.xml b/ghy-worker/src/main/resources/mapper/worker/WorkerGoodsCategoryMapper.xml index 44db3292..35fb20e8 100644 --- a/ghy-worker/src/main/resources/mapper/worker/WorkerGoodsCategoryMapper.xml +++ b/ghy-worker/src/main/resources/mapper/worker/WorkerGoodsCategoryMapper.xml @@ -62,6 +62,12 @@ #{goodsCategoryId} + + AND gc.goods_category_id in + + #{categoryId} + +