use of cn.lili.modules.system.entity.dto.SeckillSetting in project lilishop by lilishop.
the class SeckillServiceImpl method init.
@Override
@Transactional(rollbackFor = Exception.class)
public void init() {
// 清除演示数据
List<Seckill> seckillList = this.list();
for (Seckill seckill : seckillList) {
seckill.setStartTime(null);
seckill.setEndTime(null);
this.updateEsGoodsIndex(seckill);
}
this.remove(new QueryWrapper<>());
Setting setting = settingService.get(SettingEnum.SECKILL_SETTING.name());
SeckillSetting seckillSetting = new Gson().fromJson(setting.getSettingValue(), SeckillSetting.class);
for (int i = 1; i <= PRE_CREATION; i++) {
Seckill seckill = new Seckill(i, seckillSetting.getHours(), seckillSetting.getSeckillRule());
this.savePromotions(seckill);
}
}
use of cn.lili.modules.system.entity.dto.SeckillSetting in project lilishop by lilishop.
the class PromotionEverydayExecute method addSeckill.
/**
* 添加秒杀活动
* 从系统设置中获取秒杀活动的配置
* 添加明天后的秒杀活动
*/
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());
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);
}
}
}
use of cn.lili.modules.system.entity.dto.SeckillSetting in project lilishop by lilishop.
the class SeckillTest method add.
@Test
void add() {
Setting setting = settingService.get(SettingEnum.SECKILL_SETTING.name());
System.out.println(setting);
SeckillSetting seckillSetting = new Gson().fromJson(setting.getSettingValue(), SeckillSetting.class);
System.out.println(seckillSetting);
boolean result = true;
for (int i = 1; i <= SeckillService.PRE_CREATION; i++) {
Seckill seckill = new Seckill(i, seckillSetting.getHours(), seckillSetting.getSeckillRule());
seckillService.savePromotions(seckill);
}
Assertions.assertTrue(result);
}
Aggregations