Loki
2 years ago
9 changed files with 138 additions and 255 deletions
@ -0,0 +1,34 @@
|
||||
package co.yixiang.job; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; |
||||
import co.yixiang.enums.OrderInfoEnum; |
||||
import co.yixiang.modules.order.domain.YxStoreOrder; |
||||
import co.yixiang.modules.order.service.YxStoreOrderService; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Component("autoReceiptJob") |
||||
public class AutoReceiptJob implements JobHandler { |
||||
|
||||
@Autowired |
||||
private YxStoreOrderService storeOrderService; |
||||
|
||||
@Override |
||||
public String execute(String param) throws Exception { |
||||
// 每隔30分钟查询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,create_time,CURRENT_DATE) > 7 ") |
||||
); |
||||
orders.forEach(yxStoreOrder -> { |
||||
storeOrderService.takeOrder(yxStoreOrder.getOrderId(),null); |
||||
}); |
||||
|
||||
return StrUtil.format("自动收货订单{}条",orders.size()); |
||||
} |
||||
} |
@ -0,0 +1,42 @@
|
||||
package co.yixiang.job; |
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil; |
||||
import cn.hutool.core.util.StrUtil; |
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; |
||||
import co.yixiang.enums.OrderInfoEnum; |
||||
import co.yixiang.modules.order.domain.YxStoreOrder; |
||||
import co.yixiang.modules.order.service.YxStoreOrderService; |
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.time.LocalDateTime; |
||||
import java.time.temporal.ChronoUnit; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 订单自动取消 |
||||
*/ |
||||
@Component("orderCancal") |
||||
@Slf4j |
||||
public class OrderCancalJob implements JobHandler { |
||||
|
||||
@Autowired |
||||
private YxStoreOrderService storeOrderService; |
||||
|
||||
@Override |
||||
public String execute(String param) throws Exception { |
||||
// 每隔30分钟 查找30分钟之前 未支付的订单
|
||||
List<YxStoreOrder> orders = storeOrderService.list(new LambdaQueryWrapper<YxStoreOrder>() |
||||
.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue()) |
||||
.lt(YxStoreOrder::getCreateTime, LocalDateTimeUtil.offset(LocalDateTime.now(),-30, ChronoUnit.MINUTES)) |
||||
); |
||||
//
|
||||
orders.forEach(yxStoreOrder -> { |
||||
storeOrderService.cancelOrder(yxStoreOrder.getOrderId(),null); |
||||
}); |
||||
|
||||
return StrUtil.format("取消订单{}条",orders.size()); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package co.yixiang.job; |
||||
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; |
||||
import co.yixiang.enums.OrderInfoEnum; |
||||
import co.yixiang.modules.activity.domain.YxStorePink; |
||||
import co.yixiang.modules.activity.service.YxStorePinkService; |
||||
import co.yixiang.modules.order.service.YxStoreOrderService; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class PinkCancalJob implements JobHandler { |
||||
|
||||
@Autowired |
||||
private YxStoreOrderService storeOrderService; |
||||
|
||||
@Autowired |
||||
private YxStorePinkService storePinkService; |
||||
|
||||
@Override |
||||
public String execute(String param) throws Exception { |
||||
|
||||
|
||||
//拼团过期取消
|
||||
/** |
||||
if(body.contains(ShopConstants.REDIS_PINK_CANCEL_KEY)) { |
||||
body = body.replace(ShopConstants.REDIS_PINK_CANCEL_KEY, ""); |
||||
log.info("body:{}",body); |
||||
String pinkId = body; |
||||
YxStorePink storePink = storePinkService.getOne(Wrappers.<YxStorePink>lambdaQuery() |
||||
.eq(YxStorePink::getId,pinkId) |
||||
.eq(YxStorePink::getStatus,OrderInfoEnum.PINK_STATUS_1.getValue()) |
||||
.eq(YxStorePink::getIsRefund,OrderInfoEnum.PINK_REFUND_STATUS_0.getValue())); |
||||
|
||||
//取消拼团
|
||||
if(storePink != null){ |
||||
storePinkService.removePink(storePink.getUid(),storePink.getCid(),storePink.getId()); |
||||
log.info("拼团订单id:{},未在规定时间完成取消成功",body); |
||||
} |
||||
} |
||||
*/ |
||||
|
||||
|
||||
List<YxStorePink> pinkOrders = storePinkService.list(Wrappers.<YxStorePink>lambdaQuery() |
||||
.eq(YxStorePink::getStatus, OrderInfoEnum.PINK_STATUS_1.getValue()) |
||||
.eq(YxStorePink::getIsRefund, OrderInfoEnum.PINK_REFUND_STATUS_0.getValue())); |
||||
return null; |
||||
} |
||||
} |
@ -1,32 +0,0 @@
|
||||
///**
|
||||
// * Copyright (C) 2018-2022
|
||||
// * All rights reserved, Designed By www.yixiang.co
|
||||
// * 注意:
|
||||
// * 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||
// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||
// * 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||
// */
|
||||
//package co.yixiang.message.redis.config;
|
||||
//
|
||||
//
|
||||
//import lombok.Data;
|
||||
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * reids相关配置
|
||||
// * @author hupeng
|
||||
// * @since 2020-02-27
|
||||
// */
|
||||
//@Data
|
||||
//@Configuration(proxyBeanMethods = false)
|
||||
//@ConfigurationProperties(prefix = "spring.redis")
|
||||
//public class RedisConfigProperties {
|
||||
//
|
||||
// private String host = "host";
|
||||
// private String port = "port";
|
||||
// private String password = "password";
|
||||
// private String database = "database";
|
||||
//
|
||||
//}
|
@ -1,59 +0,0 @@
|
||||
///**
|
||||
// * Copyright (C) 2018-2022
|
||||
// * All rights reserved, Designed By www.yixiang.co
|
||||
// * 注意:
|
||||
// * 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||
// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||
// * 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||
// */
|
||||
//package co.yixiang.message.redis.config;
|
||||
//
|
||||
//import co.yixiang.modules.shop.domain.YxSystemConfig;
|
||||
//import co.yixiang.modules.shop.service.YxSystemConfigService;
|
||||
//import co.yixiang.utils.RedisUtils;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.boot.CommandLineRunner;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//
|
||||
///**
|
||||
// * api服务启动初始化reids
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
//public class RedisKeyInitialization implements CommandLineRunner {
|
||||
//
|
||||
//
|
||||
// private final YxSystemConfigService systemConfigService;
|
||||
//
|
||||
//
|
||||
// private final RedisUtils redisUtils;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 初始化redis
|
||||
// */
|
||||
// private void redisKeyInitialization(){
|
||||
// try {
|
||||
// List<YxSystemConfig> systemConfigs = systemConfigService.list();
|
||||
// for (YxSystemConfig systemConfig : systemConfigs) {
|
||||
// redisUtils.set(systemConfig.getMenuName(),systemConfig.getValue());
|
||||
// }
|
||||
//
|
||||
// log.info("---------------redisKey初始化成功---------------");
|
||||
// }catch (Exception e){
|
||||
// log.error("redisKey初始化失败: {}",e.getMessage());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void run(String... args) throws Exception {
|
||||
// this.redisKeyInitialization();
|
||||
// }
|
||||
//}
|
@ -1,49 +0,0 @@
|
||||
///**
|
||||
// * Copyright (C) 2018-2022
|
||||
// * All rights reserved, Designed By www.yixiang.co
|
||||
// * 注意:
|
||||
// * 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||
// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||
// * 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||
// */
|
||||
//package co.yixiang.message.redis.config;
|
||||
//
|
||||
//
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import co.yixiang.message.redis.listener.RedisKeyExpirationListener;
|
||||
//import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
//import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||
//import lombok.AllArgsConstructor;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.data.redis.listener.PatternTopic;
|
||||
//import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
//
|
||||
///**
|
||||
// * redis监听配置
|
||||
// * @author hupeng
|
||||
// * @since 2020-02-27
|
||||
// */
|
||||
//
|
||||
//@Configuration(proxyBeanMethods = false)
|
||||
//@AllArgsConstructor
|
||||
//public class RedisListenerConfig {
|
||||
//
|
||||
// private final RedisTemplate<String, String> stringRedisTemplate;
|
||||
// private final RedisConfigProperties redisConfigProperties;
|
||||
// private final YxStoreOrderService storeOrderService;
|
||||
// private final YxStorePinkService storePinkService;
|
||||
//
|
||||
// @Bean
|
||||
// RedisMessageListenerContainer container(RedisConnectionFactory factory) {
|
||||
// String topic =StrUtil.format("__keyevent@{}__:expired", redisConfigProperties.getDatabase());
|
||||
// RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
// container.setConnectionFactory(factory);
|
||||
// container.addMessageListener(new RedisKeyExpirationListener(stringRedisTemplate,redisConfigProperties
|
||||
// ,storeOrderService,storePinkService), new PatternTopic(topic));
|
||||
// return container;
|
||||
// }
|
||||
//}
|
||||
//
|
@ -1,109 +0,0 @@
|
||||
///**
|
||||
// * Copyright (C) 2018-2022
|
||||
// * All rights reserved, Designed By www.yixiang.co
|
||||
// * 注意:
|
||||
// * 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||
// * 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||
// * 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||
// */
|
||||
//package co.yixiang.message.redis.listener;
|
||||
//
|
||||
//
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import co.yixiang.constant.ShopConstants;
|
||||
//import co.yixiang.enums.OrderInfoEnum;
|
||||
//import co.yixiang.message.redis.config.RedisConfigProperties;
|
||||
//import co.yixiang.modules.activity.domain.YxStorePink;
|
||||
//import co.yixiang.modules.activity.service.YxStorePinkService;
|
||||
//import co.yixiang.modules.order.domain.YxStoreOrder;
|
||||
//import co.yixiang.modules.order.service.YxStoreOrderService;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.data.redis.connection.Message;
|
||||
//import org.springframework.data.redis.connection.MessageListener;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * redis过期监听
|
||||
// * @author hupeng
|
||||
// * @since 2020-02-27
|
||||
// */
|
||||
//@Component
|
||||
//@Slf4j
|
||||
//public class RedisKeyExpirationListener implements MessageListener {
|
||||
//
|
||||
// private RedisTemplate<String, String> redisTemplate;
|
||||
// private RedisConfigProperties redisConfigProperties;
|
||||
// private YxStoreOrderService storeOrderService;
|
||||
// private YxStorePinkService storePinkService;
|
||||
//
|
||||
// public RedisKeyExpirationListener(RedisTemplate<String, String> redisTemplate,
|
||||
// RedisConfigProperties redisConfigProperties,
|
||||
// YxStoreOrderService storeOrderService,
|
||||
// YxStorePinkService storePinkService){
|
||||
// this.redisTemplate = redisTemplate;
|
||||
// this.redisConfigProperties = redisConfigProperties;
|
||||
// this.storeOrderService = storeOrderService;
|
||||
// this.storePinkService = storePinkService;
|
||||
// }
|
||||
// @Override
|
||||
// public void onMessage(Message message, byte[] bytes) {
|
||||
// RedisSerializer<?> serializer = redisTemplate.getValueSerializer();
|
||||
// String channel = String.valueOf(serializer.deserialize(message.getChannel()));
|
||||
// String body = String.valueOf(serializer.deserialize(message.getBody()));
|
||||
// //key过期监听
|
||||
// if(StrUtil.format("__keyevent@{}__:expired", redisConfigProperties.getDatabase()).equals(channel)){
|
||||
// //订单自动取消
|
||||
// if(body.contains(ShopConstants.REDIS_ORDER_OUTTIME_UNPAY)) {
|
||||
// body = body.replace(ShopConstants.REDIS_ORDER_OUTTIME_UNPAY, "");
|
||||
// log.info("body:{}",body);
|
||||
// String orderId = body;
|
||||
// YxStoreOrder order = storeOrderService.getOne(new LambdaQueryWrapper<YxStoreOrder>()
|
||||
// .eq(YxStoreOrder::getId, orderId)
|
||||
// .eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_0.getValue()));
|
||||
// //只有待支付的订单能取消
|
||||
// if(order != null){
|
||||
// storeOrderService.cancelOrder(order.getOrderId(),null);
|
||||
// log.info("订单id:{},未在规定时间支付取消成功",body);
|
||||
// }
|
||||
// }
|
||||
// //订单自动收货
|
||||
// if(body.contains(ShopConstants.REDIS_ORDER_OUTTIME_UNCONFIRM)) {
|
||||
// body = body.replace(ShopConstants.REDIS_ORDER_OUTTIME_UNCONFIRM, "");
|
||||
// log.info("body:{}",body);
|
||||
// String orderId = body;
|
||||
// YxStoreOrder order = storeOrderService.getOne(new LambdaQueryWrapper<YxStoreOrder>()
|
||||
// .eq(YxStoreOrder::getId, orderId)
|
||||
// .eq(YxStoreOrder::getPaid,OrderInfoEnum.PAY_STATUS_1.getValue())
|
||||
// .eq(YxStoreOrder::getStatus,OrderInfoEnum.STATUS_1.getValue()));
|
||||
//
|
||||
// //只有待收货的订单能收货
|
||||
// if(order != null){
|
||||
// storeOrderService.takeOrder(order.getOrderId(),null);
|
||||
// log.info("订单id:{},自动收货成功",body);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //拼团过期取消
|
||||
// if(body.contains(ShopConstants.REDIS_PINK_CANCEL_KEY)) {
|
||||
// body = body.replace(ShopConstants.REDIS_PINK_CANCEL_KEY, "");
|
||||
// log.info("body:{}",body);
|
||||
// String pinkId = body;
|
||||
// YxStorePink storePink = storePinkService.getOne(Wrappers.<YxStorePink>lambdaQuery()
|
||||
// .eq(YxStorePink::getId,pinkId)
|
||||
// .eq(YxStorePink::getStatus,OrderInfoEnum.PINK_STATUS_1.getValue())
|
||||
// .eq(YxStorePink::getIsRefund,OrderInfoEnum.PINK_REFUND_STATUS_0.getValue()));
|
||||
//
|
||||
// //取消拼团
|
||||
// if(storePink != null){
|
||||
// storePinkService.removePink(storePink.getUid(),storePink.getCid(),storePink.getId());
|
||||
// log.info("拼团订单id:{},未在规定时间完成取消成功",body);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//}
|
Loading…
Reference in new issue