更新,BUG修改

This commit is contained in:
itheinjury@163.com
2022-03-02 15:17:06 +08:00
parent c62f31c387
commit a52b672e9b
78 changed files with 2499 additions and 178 deletions

View File

@@ -14,6 +14,7 @@ public class ConsumerApplication {
public static void main(String[] args) {
System.setProperty("es.set.netty.runtime.available.processors", "false");
System.setProperty("rocketmq.client.logUseSlf4j","true");
SpringApplication.run(ConsumerApplication.class, args);
}

View File

@@ -0,0 +1,18 @@
package cn.lili.sucurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.stereotype.Component;
/**
* @author paulG
* @since 2022/2/18
**/
@Component
public class ConsumerSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.formLogin().disable();
}
}

View File

@@ -8,6 +8,7 @@ import cn.lili.modules.system.entity.dto.SeckillSetting;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.SettingService;
import cn.lili.timetask.handler.EveryDayExecute;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -44,24 +45,40 @@ public class PromotionEverydayExecute implements EveryDayExecute {
*/
@Override
public void execute() {
//清除所以商品索引的无效促销活动
this.esGoodsIndexService.cleanInvalidPromotion();
//定时创建活动
addSeckill();
try {
//清除所有商品索引的无效促销活动
this.esGoodsIndexService.cleanInvalidPromotion();
} catch (Exception e) {
log.error("清楚商品索引中无效促销异常", e);
}
try {
//定时创建活动
addSeckill();
} catch (Exception e) {
log.error("秒杀活动添加异常", e);
}
}
/**
* 添加秒杀活动
* 从系统设置中获取秒杀活动的配置
* 添加30天后的秒杀活动
* 添加天后的秒杀活动
*/
private void addSeckill() {
Setting setting = settingService.get(SettingEnum.SECKILL_SETTING.name());
SeckillSetting seckillSetting = new Gson().fromJson(setting.getSettingValue(), SeckillSetting.class);
log.info("生成秒杀活动设置:{}", seckillSetting);
for (int i = 1; i <= SeckillService.PRE_CREATION; i++) {
Seckill seckill = new Seckill(i, seckillSetting.getHours(), seckillSetting.getSeckillRule());
seckillService.savePromotions(seckill);
LambdaQueryWrapper<Seckill> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Seckill::getStartTime, seckill.getStartTime());
//如果已经存在促销,则不再次保存
if (seckillService.list(lambdaQueryWrapper).isEmpty()) {
boolean result = seckillService.savePromotions(seckill);
log.info("生成秒杀活动参数:{},结果:{}", seckill, result);
}
}
}
}