From 9152b8109279abf8feb19db7d57f1ce790d8f8dd Mon Sep 17 00:00:00 2001 From: Loki <654612@qq.com> Date: Mon, 19 Dec 2022 11:17:40 +0800 Subject: [PATCH] =?UTF-8?q?:+1:=20=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=94=B6=E8=B4=A7=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E5=90=8E=E5=8F=B0=E6=89=8B=E5=8A=A8=E4=BC=A0=E9=80=92?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=97=B6=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/co/yixiang/job/AutoReceiptJob.java | 16 ++++++---------- .../order/service/YxStoreOrderService.java | 8 ++++++++ .../service/impl/YxStoreOrderServiceImpl.java | 4 ++++ .../order/service/mapper/StoreOrderMapper.java | 11 +++++++++++ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/zsw-bxg/src/main/java/co/yixiang/job/AutoReceiptJob.java b/zsw-bxg/src/main/java/co/yixiang/job/AutoReceiptJob.java index 62659846..26898505 100644 --- a/zsw-bxg/src/main/java/co/yixiang/job/AutoReceiptJob.java +++ b/zsw-bxg/src/main/java/co/yixiang/job/AutoReceiptJob.java @@ -27,28 +27,24 @@ public class AutoReceiptJob implements JobHandler { @Override public String execute(String param) throws Exception { + + Integer day = Integer.valueOf(param); + List tenants = tenantService.getTenantList(new TenantExportReqVO()); AtomicReference num = new AtomicReference<>(0); tenants.forEach(tenantDO -> { TenantContextHolder.setTenantId(tenantDO.getId()); + // 10天未启动收货的订单 + List orders = storeOrderService.listTimeoutOrders(day); - // 每隔30分钟查询7天之前的订单 ,准备自动收获 - // 测试环境3分钟 TIMESTAMPDIFF(minute,pay_time,{0}) > 3 - // 线上环境7天 TIMESTAMPDIFF(dat,pay_time,{0}) > 7 - List orders = storeOrderService.list(new LambdaQueryWrapper() - .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue()) - .eq(YxStoreOrder::getStatus, OrderInfoEnum.STATUS_1.getValue()) - .apply("TIMESTAMPDIFF(day,pay_time,{0}) > 7 ",LocalDateTime.now()) - ); - num.updateAndGet(v -> v + orders.size()); orders.forEach(yxStoreOrder -> { storeOrderService.takeOrder(yxStoreOrder.getOrderId(), null); }); TenantContextHolder.setTenantId(null); }); - return StrUtil.format("合计处理{}个租户,自动收货订单{}条", tenants.size(), num); + return StrUtil.format("合计处理{}个租户,按照{}天自动收货订单{}条", tenants.size(), day, num); } } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java index 5f71ff4a..e4667ff5 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java @@ -320,4 +320,12 @@ public interface YxStoreOrderService extends BaseService{ YxStoreOrderDto getOrderDetailByOrderId(Long orderId); + + /** + * 获取收货超时的订单 + * @param day 天数 + * @return + */ + List listTimeoutOrders(Integer day); + } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java index 22e6731d..32e593f6 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java @@ -3084,4 +3084,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl listTimeoutOrders(Integer day) { + return storeOrderMapper.listTimeoutOrders(day); + } } diff --git a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java index 38d0d854..01e1402d 100644 --- a/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java +++ b/zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java @@ -75,4 +75,15 @@ public interface StoreOrderMapper extends CoreMapper { " GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') " + " ORDER BY create_time ASC") List chartListT(@Param("time") Date time); + + @Select("SELECT yso.* FROM " + + " `yx_store_order` AS yso " + + " LEFT JOIN yx_store_order_status AS ysos ON ysos.oid = yso.id " + + "WHERE " + + " yso.`status` = 1 " + + " AND yso.paid = 1 " + + " AND ysos.change_type = 'delivery_goods' " + + " AND TIMESTAMPDIFF(day,ysos.change_time,now()) > #{day}") + List listTimeoutOrders(@Param("day") Integer day); + }