diff --git a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Seckill.java b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Seckill.java index 5410d247..65c7fe55 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Seckill.java +++ b/framework/src/main/java/cn/lili/modules/promotion/entity/dos/Seckill.java @@ -54,9 +54,6 @@ public class Seckill extends BasePromotion { @ApiModelProperty(value = "商品数量") private Integer goodsNum; - @ApiModelProperty(value = "店铺数量") - private Integer storeNum; - public Seckill(String hours,String seckillRule){ //默认创建30天后的秒杀活动 DateTime dateTime= DateUtil.beginOfDay(DateUtil.offset(new DateTime(), DateField.DAY_OF_YEAR, 30)); @@ -64,7 +61,6 @@ public class Seckill extends BasePromotion { this.hours=hours; this.seckillRule=seckillRule; this.goodsNum=0; - this.storeNum=0; //BasePromotion setStoreName("platform"); diff --git a/framework/src/main/java/cn/lili/modules/promotion/mapper/SeckillMapper.java b/framework/src/main/java/cn/lili/modules/promotion/mapper/SeckillMapper.java index 6a207cc6..9491fc6d 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/mapper/SeckillMapper.java +++ b/framework/src/main/java/cn/lili/modules/promotion/mapper/SeckillMapper.java @@ -2,6 +2,7 @@ package cn.lili.modules.promotion.mapper; import cn.lili.modules.promotion.entity.dos.Seckill; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Update; /** * 秒杀活动数据处理层 @@ -11,4 +12,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; */ public interface SeckillMapper extends BaseMapper { + @Update("UPDATE li_seckill SET goods_num =( SELECT count( id ) FROM li_seckill_apply WHERE seckill_id = #{seckillId} ) WHERE id = #{seckillId}") + void updateSeckillGoodsNum(String seckillId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/service/SeckillService.java b/framework/src/main/java/cn/lili/modules/promotion/service/SeckillService.java index fc1d43a4..729d0a72 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/service/SeckillService.java +++ b/framework/src/main/java/cn/lili/modules/promotion/service/SeckillService.java @@ -93,4 +93,11 @@ public interface SeckillService extends IService { * @return 可参与活动数量 */ Integer getApplyNum(); + + /** + * 更新秒杀活动的商品数量 + * @param seckillId 秒杀活动ID + * @return 更新结果 + */ + void updateSeckillGoodsNum(String seckillId); } \ No newline at end of file diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java index e3e662a2..659f77ca 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillApplyServiceImpl.java @@ -155,14 +155,10 @@ public class SeckillApplyServiceImpl extends ServiceImpl 0) { throw new ServiceException("商品[" + goodsSku.getGoodsName() + "]已经在重叠的时间段参加了拼团活动,不能参加秒杀活动"); diff --git a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java index 76ec2b28..8be37013 100644 --- a/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/promotion/serviceimpl/SeckillServiceImpl.java @@ -232,6 +232,11 @@ public class SeckillServiceImpl extends ServiceImpl impl return this.count(queryWrapper); } + @Override + public void updateSeckillGoodsNum(String seckillId) { + this.baseMapper.updateSeckillGoodsNum(seckillId); + } + /** * 添加秒杀活动延时任务 * @param seckill 秒杀活动 diff --git a/manager-api/src/main/java/cn/lili/controller/promotion/SeckillManagerController.java b/manager-api/src/main/java/cn/lili/controller/promotion/SeckillManagerController.java index fba5b74b..e4ecc423 100644 --- a/manager-api/src/main/java/cn/lili/controller/promotion/SeckillManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/promotion/SeckillManagerController.java @@ -14,6 +14,7 @@ import cn.lili.modules.promotion.service.SeckillApplyService; import cn.lili.modules.promotion.service.SeckillService; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -33,8 +34,9 @@ public class SeckillManagerController { @Autowired private SeckillApplyService seckillApplyService; - @PostMapping + @ApiOperation(value = "添加秒杀活动") + @PostMapping public ResultMessage addSeckill(SeckillVO seckillVO) { AuthUser currentUser = UserContext.getCurrentUser(); seckillVO.setStoreId(currentUser.getId()); @@ -44,8 +46,9 @@ public class SeckillManagerController { return ResultUtil.data(seckillVO); } - @PutMapping + @ApiOperation(value = "修改秒杀活动") + @PutMapping public ResultMessage updateSeckill(SeckillVO seckillVO) { AuthUser currentUser = UserContext.getCurrentUser(); seckillVO.setStoreId(currentUser.getId()); @@ -54,44 +57,48 @@ public class SeckillManagerController { return ResultUtil.data(seckillVO); } - @GetMapping(value = "/{id}") @ApiOperation(value = "通过id获取") + @ApiImplicitParam(name = "id", value = "秒杀活动ID", required = true, dataType = "String", paramType = "path") + @GetMapping(value = "/{id}") public ResultMessage get(@PathVariable String id) { Seckill seckill = seckillService.getById(id); return ResultUtil.data(seckill); } - @GetMapping @ApiOperation(value = "分页查询秒杀活动列表") + @GetMapping public ResultMessage> getAll(SeckillSearchParams param, PageVO pageVo) { pageVo.setNotConvert(true); IPage page = seckillService.getSeckillByPageFromMongo(param, pageVo); return ResultUtil.data(page); } - @DeleteMapping("/{id}") @ApiOperation(value = "删除一个秒杀活动") + @ApiImplicitParam(name = "id", value = "秒杀活动ID", required = true, dataType = "String", paramType = "path") + @DeleteMapping("/{id}") public ResultMessage deleteSeckill(@PathVariable String id) { seckillService.deleteSeckill(id); return ResultUtil.success(); } - @PutMapping("/close/{id}") @ApiOperation(value = "关闭一个秒杀活动") + @ApiImplicitParam(name = "id", value = "秒杀活动ID", required = true, dataType = "String", paramType = "path") + @PutMapping("/close/{id}") public ResultMessage closeSeckill(@PathVariable String id) { seckillService.closeSeckill(id); return ResultUtil.success(); } + @ApiOperation(value = "开启一个秒杀活动") + @ApiImplicitParam(name = "id", value = "秒杀活动ID", required = true, dataType = "String", paramType = "path") @PutMapping("/open/{id}") - @ApiOperation(value = "一个秒杀活动") public ResultMessage openSeckill(@PathVariable String id) { seckillService.openSeckill(id); return ResultUtil.success(); } - @GetMapping("/apply") @ApiOperation(value = "获取秒杀活动申请列表") + @GetMapping("/apply") public ResultMessage> getSeckillApply(SeckillSearchParams param, PageVO pageVo) { IPage seckillApply = seckillApplyService.getSeckillApplyFromMongo(param, pageVo); return ResultUtil.data(seckillApply);