完成挂账管理相关需求

This commit is contained in:
谭凯凯 2024-11-27 16:04:30 +08:00 committed by Tankaikai
parent 1915c27b9b
commit 4f7004736a
3 changed files with 26 additions and 10 deletions

View File

@ -38,4 +38,7 @@ public interface TbShopTableBookingService extends IService<TbShopTableBooking>
Map<String, Object> summary(Integer shopId,String[] phoneNos);
void batchTimeout();
void autoCancel();
}

View File

@ -254,7 +254,7 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl<TbShopTableBookin
return result;
}
for (ShopTableBookingDTO dto : result) {
dto.setBookingInfo(list.stream().filter(item -> item.getShopTableId().equals(dto.getId())).findFirst().orElse(null));
dto.setBookingInfo(list.stream().filter(item -> item.getShopTableId().equals(dto.getId()) && item.getStatus() != -1).findFirst().orElse(null));
}
return result;
}
@ -274,14 +274,21 @@ public class TbShopTableBookingServiceImpl extends ServiceImpl<TbShopTableBookin
return result;
}
public static void main(String[] args) {
String s = IdUtil.nanoId();
String s1 = IdUtil.objectId();
System.out.println(s);
for (int i = 0; i < 100; i++) {
String s2 = IdUtil.getSnowflakeNextIdStr();
System.out.println(s2);
System.out.println(StrUtil.sub(s2, -5, s2.length()));
}
@Override
public void batchTimeout() {
baseMapper.update(Wrappers.<TbShopTableBooking>lambdaUpdate()
.set(TbShopTableBooking::getStatus, 999)
.eq(TbShopTableBooking::getStatus, 20)
.last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute"));
}
@Override
public void autoCancel() {
// 15分钟后自动取消
baseMapper.update(Wrappers.<TbShopTableBooking>lambdaUpdate()
.set(TbShopTableBooking::getStatus, -1)
.eq(TbShopTableBooking::getStatus, 999)
.last("and TIMESTAMPDIFF(MINUTE, booking_time, NOW()) >= timeout_minute+15"));
}
}

View File

@ -2,6 +2,7 @@ package cn.ysk.cashier.quartz.task;
import cn.ysk.cashier.dto.product.StockCountDTO;
import cn.ysk.cashier.mybatis.service.TbPointsExchangeRecordService;
import cn.ysk.cashier.mybatis.service.TbShopTableBookingService;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.product.TbProductStockDetail;
import cn.ysk.cashier.repository.order.StockCountRepository;
@ -46,6 +47,7 @@ public class TestTask {
private EntityManager entityManager;
@Autowired
private TbPointsExchangeRecordService tbPointsExchangeRecordService;
private TbShopTableBookingService tbShopTableBookingService;
private final TbCashierCartService tbCashierCartService;
private final TbOrderInfoService orderInfoService;
@ -103,6 +105,10 @@ public class TestTask {
public void cancelPointsExchangeOrder(){
log.info("积分商品订单取消定时任务执行");
tbPointsExchangeRecordService.authCancel();
log.info("预定订单超时定时任务执行");
tbShopTableBookingService.batchTimeout();
log.info("预定订单取消定时任务执行");
tbShopTableBookingService.autoCancel();
}
@Transactional(rollbackFor = Exception.class)