Browse Source

👍 修复自动确认收货的逻辑,后台手动传递确认时限

sj
Loki 2 years ago
parent
commit
9152b81092
  1. 16
      zsw-bxg/src/main/java/co/yixiang/job/AutoReceiptJob.java
  2. 8
      zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java
  3. 4
      zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java
  4. 11
      zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java

16
zsw-bxg/src/main/java/co/yixiang/job/AutoReceiptJob.java

@ -27,28 +27,24 @@ public class AutoReceiptJob implements JobHandler {
@Override @Override
public String execute(String param) throws Exception { public String execute(String param) throws Exception {
Integer day = Integer.valueOf(param);
List<TenantDO> tenants = tenantService.getTenantList(new TenantExportReqVO()); List<TenantDO> tenants = tenantService.getTenantList(new TenantExportReqVO());
AtomicReference<Integer> num = new AtomicReference<>(0); AtomicReference<Integer> num = new AtomicReference<>(0);
tenants.forEach(tenantDO -> { tenants.forEach(tenantDO -> {
TenantContextHolder.setTenantId(tenantDO.getId()); TenantContextHolder.setTenantId(tenantDO.getId());
// 10天未启动收货的订单
List<YxStoreOrder> orders = storeOrderService.listTimeoutOrders(day);
// 每隔30分钟查询7天之前的订单 ,准备自动收获
// 测试环境3分钟 TIMESTAMPDIFF(minute,pay_time,{0}) > 3
// 线上环境7天 TIMESTAMPDIFF(dat,pay_time,{0}) > 7
List<YxStoreOrder> orders = storeOrderService.list(new LambdaQueryWrapper<YxStoreOrder>()
.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 -> { orders.forEach(yxStoreOrder -> {
storeOrderService.takeOrder(yxStoreOrder.getOrderId(), null); storeOrderService.takeOrder(yxStoreOrder.getOrderId(), null);
}); });
TenantContextHolder.setTenantId(null); TenantContextHolder.setTenantId(null);
}); });
return StrUtil.format("合计处理{}个租户,自动收货订单{}条", tenants.size(), num); return StrUtil.format("合计处理{}个租户,按照{}天自动收货订单{}条", tenants.size(), day, num);
} }
} }

8
zsw-bxg/src/main/java/co/yixiang/modules/order/service/YxStoreOrderService.java

@ -320,4 +320,12 @@ public interface YxStoreOrderService extends BaseService<YxStoreOrder>{
YxStoreOrderDto getOrderDetailByOrderId(Long orderId); YxStoreOrderDto getOrderDetailByOrderId(Long orderId);
/**
* 获取收货超时的订单
* @param day 天数
* @return
*/
List<YxStoreOrder> listTimeoutOrders(Integer day);
} }

4
zsw-bxg/src/main/java/co/yixiang/modules/order/service/impl/YxStoreOrderServiceImpl.java

@ -3084,4 +3084,8 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
} }
@Override
public List<YxStoreOrder> listTimeoutOrders(Integer day) {
return storeOrderMapper.listTimeoutOrders(day);
}
} }

11
zsw-bxg/src/main/java/co/yixiang/modules/order/service/mapper/StoreOrderMapper.java

@ -75,4 +75,15 @@ public interface StoreOrderMapper extends CoreMapper<YxStoreOrder> {
" GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') " + " GROUP BY DATE_FORMAT(create_time,'%Y-%m-%d') " +
" ORDER BY create_time ASC") " ORDER BY create_time ASC")
List<ChartDataDto> chartListT(@Param("time") Date time); List<ChartDataDto> 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<YxStoreOrder> listTimeoutOrders(@Param("day") Integer day);
} }

Loading…
Cancel
Save