完成超时问题解决,类目三级筛选,修改扣点和金额无效问题

This commit is contained in:
YiFei Kuang 2025-01-19 21:15:01 +08:00
parent 67f8738c5e
commit 5c54c87ea3
3 changed files with 60 additions and 31 deletions

View File

@ -163,35 +163,45 @@ public class WorkerController extends BaseController {
// 查询满足技能条件的师傅技能记录
List<Long> 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<GoodsCategory> subCategories = goodsCategoryService.selectGoodsCategoryList(param);
List<String> categoryIds = subCategories.stream()
// 1. 先查找二级类目
GoodsCategory param = new GoodsCategory();
param.setParentCategoryId(Long.valueOf(workerListRequest.getCategoryLevel1()));
List<GoodsCategory> secondCategories = goodsCategoryService.selectGoodsCategoryList(param);
// 2. 用二级类目查找三级类目
List<String> categoryIds = new ArrayList<>();
for (GoodsCategory secondCategory : secondCategories) {
param.setParentCategoryId(secondCategory.getGoodsCategoryId());
List<GoodsCategory> 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<GoodsCategory> subCategories = goodsCategoryService.selectGoodsCategoryList(param);
List<String> 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<GoodsCategory> subCategories = goodsCategoryService.selectGoodsCategoryList(param);
List<String> 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<WorkerGoodsCategory> workerGoodsCategoryList = workerGoodsCategoryService.getWorkerGoodsCategory(workerGoodsCategory);
workerIdsByCategory = workerGoodsCategoryList.stream()
.map(WorkerGoodsCategory::getWorkerId)
.collect(Collectors.toList());
.map(WorkerGoodsCategory::getWorkerId)
.collect(Collectors.toList());
}
// 两个list中的workerid取交集

View File

@ -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<Integer> timeoutOrderStatus;
private static final List<Integer> 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超时

View File

@ -62,6 +62,12 @@
#{goodsCategoryId}
</foreach>
</if>
<if test="categoryIds != null">
AND gc.goods_category_id in
<foreach collection="categoryIds" item="categoryId" open="(" separator="," close=")">
#{categoryId}
</foreach>
</if>
</where>
</select>