!131 优化自动生成秒杀活动

Merge pull request !131 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2022-02-18 12:27:53 +00:00 committed by Gitee
commit 1c6c009f14
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 24 additions and 5 deletions

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

@ -62,14 +62,16 @@ public class PromotionEverydayExecute implements EveryDayExecute {
/**
* 添加秒杀活动
* 从系统设置中获取秒杀活动的配置
* 添加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);
boolean result = seckillService.savePromotions(seckill);
log.info("生成秒杀活动参数:{},结果:{}", seckill, result);
}
}
}

View File

@ -1,6 +1,5 @@
package cn.lili.modules.promotion.entity.dos;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.lili.modules.promotion.entity.vos.SeckillVO;
@ -59,8 +58,8 @@ public class Seckill extends BasePromotions {
public Seckill(int day, String hours, String seckillRule) {
//默认创建*天后的秒杀活动
DateTime dateTime = DateUtil.beginOfDay(DateUtil.offset(new DateTime(), DateField.DAY_OF_YEAR, day));
this.applyEndTime = dateTime;
DateTime dateTime = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), day));
this.applyEndTime = DateUtil.offsetHour(new Date(), Integer.parseInt(hours) - 1);
this.hours = hours;
this.seckillRule = seckillRule;
this.goodsNum = 0;