初始化秒杀活动
This commit is contained in:
parent
a159c0d0db
commit
10dbed04b6
@ -98,7 +98,7 @@ public class PromotionEverydayExecute implements EveryDayExecute {
|
|||||||
private void addSeckill() {
|
private void addSeckill() {
|
||||||
Setting setting = settingService.get(SettingEnum.SECKILL_SETTING.name());
|
Setting setting = settingService.get(SettingEnum.SECKILL_SETTING.name());
|
||||||
SeckillSetting seckillSetting = new Gson().fromJson(setting.getSettingValue(), SeckillSetting.class);
|
SeckillSetting seckillSetting = new Gson().fromJson(setting.getSettingValue(), SeckillSetting.class);
|
||||||
Seckill seckill = new Seckill(seckillSetting.getHours(), seckillSetting.getSeckillRule());
|
Seckill seckill = new Seckill(30,seckillSetting.getHours(), seckillSetting.getSeckillRule());
|
||||||
seckillService.saveSeckill(seckill);
|
seckillService.saveSeckill(seckill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package cn.lili.modules.order.order.entity.dto;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author liushuai(liushuai711 @ gmail.com)
|
|
||||||
* @version v4.1
|
|
||||||
* @Description:
|
|
||||||
* @since 2021/6/13 2:37 下午
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class ExcelDTO {
|
|
||||||
|
|
||||||
private String sn;
|
|
||||||
private String logisticsName;
|
|
||||||
private String logisticsNo;
|
|
||||||
}
|
|
@ -54,9 +54,9 @@ public class Seckill extends BasePromotion {
|
|||||||
@ApiModelProperty(value = "商品数量")
|
@ApiModelProperty(value = "商品数量")
|
||||||
private Integer goodsNum;
|
private Integer goodsNum;
|
||||||
|
|
||||||
public Seckill(String hours,String seckillRule){
|
public Seckill(int day,String hours,String seckillRule){
|
||||||
//默认创建30天后的秒杀活动
|
//默认创建*天后的秒杀活动
|
||||||
DateTime dateTime= DateUtil.beginOfDay(DateUtil.offset(new DateTime(), DateField.DAY_OF_YEAR, 30));
|
DateTime dateTime= DateUtil.beginOfDay(DateUtil.offset(new DateTime(), DateField.DAY_OF_YEAR, day));
|
||||||
this.applyEndTime=dateTime;
|
this.applyEndTime=dateTime;
|
||||||
this.hours=hours;
|
this.hours=hours;
|
||||||
this.seckillRule=seckillRule;
|
this.seckillRule=seckillRule;
|
||||||
@ -70,6 +70,5 @@ public class Seckill extends BasePromotion {
|
|||||||
setEndTime(DateUtil.endOfDay(dateTime));
|
setEndTime(DateUtil.endOfDay(dateTime));
|
||||||
setPromotionStatus(PromotionStatusEnum.NEW.name());
|
setPromotionStatus(PromotionStatusEnum.NEW.name());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -42,6 +42,12 @@ public interface SeckillService extends IService<Seckill> {
|
|||||||
*/
|
*/
|
||||||
SeckillVO getSeckillByIdFromMongo(String id);
|
SeckillVO getSeckillByIdFromMongo(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化秒杀活动,默认开启三十天的秒杀活动
|
||||||
|
*
|
||||||
|
* @return 是否保存成功
|
||||||
|
*/
|
||||||
|
void init();
|
||||||
/**
|
/**
|
||||||
* 保存秒杀活动
|
* 保存秒杀活动
|
||||||
*
|
*
|
||||||
|
@ -26,6 +26,10 @@ import cn.lili.modules.promotion.service.SeckillApplyService;
|
|||||||
import cn.lili.modules.promotion.service.SeckillService;
|
import cn.lili.modules.promotion.service.SeckillService;
|
||||||
import cn.lili.modules.promotion.tools.PromotionTools;
|
import cn.lili.modules.promotion.tools.PromotionTools;
|
||||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||||
|
import cn.lili.modules.system.entity.dos.Setting;
|
||||||
|
import cn.lili.modules.system.entity.dto.SeckillSetting;
|
||||||
|
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||||
|
import cn.lili.modules.system.service.SettingService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
@ -33,6 +37,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||||
import org.springframework.data.mongodb.core.query.Criteria;
|
import org.springframework.data.mongodb.core.query.Criteria;
|
||||||
@ -71,6 +76,9 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
|
|||||||
//秒杀申请
|
//秒杀申请
|
||||||
@Autowired
|
@Autowired
|
||||||
private SeckillApplyService seckillApplyService;
|
private SeckillApplyService seckillApplyService;
|
||||||
|
//设置
|
||||||
|
@Autowired
|
||||||
|
private SettingService settingService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<Seckill> getSeckillByPageFromMysql(SeckillSearchParams queryParam, PageVO pageVo) {
|
public IPage<Seckill> getSeckillByPageFromMysql(SeckillSearchParams queryParam, PageVO pageVo) {
|
||||||
@ -100,6 +108,16 @@ public class SeckillServiceImpl extends ServiceImpl<SeckillMapper, Seckill> impl
|
|||||||
return this.checkSeckillExist(id);
|
return this.checkSeckillExist(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
Setting setting = settingService.get(SettingEnum.SECKILL_SETTING.name());
|
||||||
|
SeckillSetting seckillSetting = new Gson().fromJson(setting.getSettingValue(), SeckillSetting.class);
|
||||||
|
for (int i=1;i<=30;i++){
|
||||||
|
Seckill seckill = new Seckill(i,seckillSetting.getHours(), seckillSetting.getSeckillRule());
|
||||||
|
this.saveSeckill(seckill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveSeckill(Seckill seckill) {
|
public boolean saveSeckill(Seckill seckill) {
|
||||||
|
|
||||||
|
@ -35,15 +35,10 @@ public class SeckillManagerController {
|
|||||||
private SeckillApplyService seckillApplyService;
|
private SeckillApplyService seckillApplyService;
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "添加秒杀活动")
|
@ApiOperation(value = "添加秒杀活动(初始化方法,默认初始化30天内的活动)")
|
||||||
@PostMapping
|
@GetMapping
|
||||||
public ResultMessage<Seckill> addSeckill(SeckillVO seckillVO) {
|
public void addSeckill() {
|
||||||
AuthUser currentUser = UserContext.getCurrentUser();
|
seckillService.init();
|
||||||
seckillVO.setStoreId(currentUser.getId());
|
|
||||||
seckillVO.setStoreName(currentUser.getUsername());
|
|
||||||
seckillVO.setSeckillApplyStatus(SeckillApplyStatusEnum.NOT_APPLY.name());
|
|
||||||
seckillService.saveSeckill(seckillVO);
|
|
||||||
return ResultUtil.data(seckillVO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user