mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
!320 秒杀活动相关
Merge pull request !320 from halfninety/feature/1.8.0-uniapp
This commit is contained in:
commit
f9b4874ee9
@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.mybatis.core.mapper;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -75,9 +76,13 @@ public interface BaseMapperX<T> extends BaseMapper<T> {
|
||||
return selectList(new LambdaQueryWrapper<T>().in(field, values));
|
||||
}
|
||||
|
||||
default List<T> selectList(SFunction<T, ?> leField, SFunction<T, ?> geField, Object value) {
|
||||
return selectList(new LambdaQueryWrapper<T>().le(leField, value).ge(geField, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* 逐条插入,适合少量数据插入,或者对性能要求不高的场景
|
||||
*
|
||||
* <p>
|
||||
* 如果大量,请使用 {@link com.baomidou.mybatisplus.extension.service.impl.ServiceImpl#saveBatch(Collection)} 方法
|
||||
* 使用示例,可见 RoleMenuBatchInsertMapper、UserRoleBatchInsertMapper 类
|
||||
*
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.*;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*;
|
||||
import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO;
|
@ -1,9 +1,9 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.seckill.seckilltime.SeckillTimeConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.seckill.seckilltime.SeckillTimeService;
|
||||
@ -20,7 +20,6 @@ import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
// TODO @halfninety:controller 可以都放在 seckill 包下;vo 下分成 actvity 和 time
|
||||
@Api(tags = "管理后台 - 秒杀时段")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/seckill-time")
|
||||
@ -65,20 +64,9 @@ public class SeckillTimeController {
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得所有秒杀时段列表")
|
||||
// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
||||
// TODO @halfninety:权限为啥注释掉呀?
|
||||
@PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
||||
public CommonResult<List<SeckillTimeRespVO>> getSeckillTimeList() {
|
||||
List<SeckillTimeDO> list = seckillTimeService.getSeckillTimeList();
|
||||
return success(SeckillTimeConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
// TODO @halfninety:不用的,可以删除掉
|
||||
// @GetMapping("/page")
|
||||
// @ApiOperation("获得秒杀时段分页")
|
||||
// @PreAuthorize("@ss.hasPermission('promotion:seckill-time:query')")
|
||||
// public CommonResult<PageResult<SeckillTimeRespVO>> getSeckillTimePage(@Valid SeckillTimePageReqVO pageVO) {
|
||||
// PageResult<SeckillTimeDO> pageResult = seckillTimeService.getSeckillTimePage(pageVO);
|
||||
// return success(SeckillTimeConvert.INSTANCE.convertPage(pageResult));
|
||||
// }
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo;
|
||||
|
||||
public class SeckillTimeSimpleRespVO {
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@ -14,9 +14,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
|
||||
|
||||
/**
|
||||
* 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
* 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class SeckillActivityBaseVO {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -7,12 +7,10 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
// TODO halfninety:检查下所有的 VO,需要保证 example 都写了哈。
|
||||
@ApiModel("管理后台 - 秒杀活动创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ -22,14 +20,13 @@ public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO {
|
||||
@ApiModelProperty(value = "备注", example = "限时秒杀活动")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "排序", required = true)
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
// TODO halfninety:直接使用数组接口。timeIds,
|
||||
@ApiModelProperty(value = "秒杀时段id", required = true)
|
||||
@NotBlank(message = "参与场次不能为空")
|
||||
private String timeId;
|
||||
@ApiModelProperty(value = "秒杀时段id", required = true, example = "1,3")
|
||||
@NotEmpty(message = "参与场次不能为空")
|
||||
private List<Long> timeIds;
|
||||
|
||||
/**
|
||||
* 商品列表
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
@ -11,7 +11,7 @@ import java.util.List;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillActivityDetailRespVO extends SeckillActivityRespVO{
|
||||
public class SeckillActivityDetailRespVO extends SeckillActivityRespVO {
|
||||
|
||||
/**
|
||||
* 商品列表
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@ -26,8 +26,8 @@ public class SeckillActivityPageReqVO extends PageParam {
|
||||
@ApiModelProperty(value = "活动状态", example = "进行中")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "秒杀时段id")
|
||||
private String timeId;
|
||||
@ApiModelProperty(value = "秒杀时段id", example = "1")
|
||||
private Long timeId;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("管理后台 - 秒杀活动 Response VO")
|
||||
@Data
|
||||
@ -14,22 +15,22 @@ import java.time.LocalDateTime;
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillActivityRespVO extends SeckillActivityBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "秒杀活动id", required = true, example = "1")
|
||||
@ApiModelProperty(value = "秒杀活动id", required = true, example = "1")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "付款订单数", required = true)
|
||||
@ApiModelProperty(value = "付款订单数", required = true, example = "1")
|
||||
private Integer orderCount;
|
||||
|
||||
@ApiModelProperty(value = "付款人数", required = true)
|
||||
@ApiModelProperty(value = "付款人数", required = true, example = "1")
|
||||
private Integer userCount;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "秒杀时段id", required = true)
|
||||
private String timeId;
|
||||
@ApiModelProperty(value = "秒杀时段id", required = true, example = "1,3")
|
||||
private List<Long> timeIds;
|
||||
|
||||
@ApiModelProperty(value = "排序", required = true)
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "备注", example = "限时秒杀活动")
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -24,13 +24,13 @@ public class SeckillActivityUpdateReqVO extends SeckillActivityBaseVO {
|
||||
@ApiModelProperty(value = "备注", example = "限时秒杀活动")
|
||||
private String remark;
|
||||
|
||||
@ApiModelProperty(value = "排序", required = true)
|
||||
@ApiModelProperty(value = "排序", required = true, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "秒杀时段id", required = true)
|
||||
@NotNull(message = "秒杀时段id不能为空")
|
||||
private String timeId;
|
||||
@ApiModelProperty(value = "秒杀时段id", required = true, example = "1,3")
|
||||
@NotEmpty(message = "秒杀时段id不能为空")
|
||||
private List<Long> timeIds;
|
||||
|
||||
/**
|
||||
* 商品列表
|
@ -1,31 +1,27 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 秒杀时段 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
* 秒杀时段 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class SeckillTimeBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "秒杀时段名称", required = true)
|
||||
@ApiModelProperty(value = "秒杀时段名称", required = true, example = "上午场")
|
||||
@NotNull(message = "秒杀时段名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "开始时间点", required = true)
|
||||
@ApiModelProperty(value = "开始时间点", required = true, example = "16:30:40")
|
||||
@NotNull(message = "开始时间点不能为空")
|
||||
private LocalTime startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间点", required = true)
|
||||
@ApiModelProperty(value = "结束时间点", required = true, example = "16:30:40")
|
||||
@NotNull(message = "结束时间点不能为空")
|
||||
private LocalTime endTime;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time;
|
||||
|
||||
import lombok.*;
|
||||
import io.swagger.annotations.*;
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@ -16,25 +16,15 @@ import java.time.LocalTime;
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillTimePageReqVO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "秒杀时段名称")
|
||||
@ApiModelProperty(value = "秒杀时段名称", example = "上午场")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "开始时间点")
|
||||
@ApiModelProperty(value = "开始时间点", example = "16:30:40")
|
||||
@DateTimeFormat(pattern = "HH:mm:ss")
|
||||
private LocalTime startTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间点")
|
||||
@ApiModelProperty(value = "结束时间点", example = "16:30:40")
|
||||
@DateTimeFormat(pattern = "HH:mm:ss")
|
||||
private LocalTime endTime;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// @ApiModelProperty(value = "创建时间")
|
||||
// @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
// private Date[] createTime;
|
||||
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.annotations.*;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ApiModel("管理后台 - 秒杀时段 Response VO")
|
||||
@Data
|
||||
@ -10,13 +14,13 @@ import io.swagger.annotations.*;
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillTimeRespVO extends SeckillTimeBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true)
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "秒杀活动数量", required = true)
|
||||
@ApiModelProperty(value = "秒杀活动数量", required = true, example = "1")
|
||||
private Integer seckillActivityCount;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo;
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -14,7 +14,7 @@ import javax.validation.constraints.NotNull;
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillTimeUpdateReqVO extends SeckillTimeBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "编号", required = true)
|
||||
@ApiModelProperty(value = "编号", required = true, example = "1")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
@ -2,7 +2,8 @@ package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.*;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO;
|
||||
import org.mapstruct.Mapper;
|
||||
@ -27,7 +28,7 @@ public interface SeckillActivityConvert {
|
||||
|
||||
SeckillActivityDO convert(SeckillActivityCreateReqVO bean);
|
||||
|
||||
default String map(Long[] value){
|
||||
default String map(Long[] value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@ -39,7 +40,7 @@ public interface SeckillActivityConvert {
|
||||
|
||||
PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page);
|
||||
|
||||
@Mappings({@Mapping(target = "products",source = "seckillProducts")})
|
||||
@Mappings({@Mapping(target = "products", source = "seckillProducts")})
|
||||
SeckillActivityDetailRespVO convert(SeckillActivityDO seckillActivity, List<SeckillProductDO> seckillProducts);
|
||||
|
||||
|
||||
@ -56,7 +57,6 @@ public interface SeckillActivityConvert {
|
||||
&& ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice())
|
||||
&& ObjectUtil.equals(productDO.getStock(), productVO.getStock())
|
||||
&& ObjectUtil.equals(productDO.getLimitBuyCount(), productVO.getLimitBuyCount());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,4 +74,10 @@ public interface SeckillActivityConvert {
|
||||
&& ObjectUtil.equals(productDO.getLimitBuyCount(), productVO.getLimitBuyCount());
|
||||
|
||||
}
|
||||
|
||||
default List<SeckillProductDO> convertList(List<SeckillActivityBaseVO.Product> products, SeckillActivityDO seckillActivity) {
|
||||
return CollectionUtils.convertList(products, product -> convert(product)
|
||||
.setActivityId(seckillActivity.getId()).setTimeIds(seckillActivity.getTimeIds()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO;
|
||||
|
@ -1,28 +1,29 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum;
|
||||
import lombok.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 秒杀活动 DO
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author halfninety
|
||||
*/
|
||||
@TableName("promotion_seckill_activity")
|
||||
@TableName(value = "promotion_seckill_activity", autoResultMap = true)
|
||||
@KeySequence("promotion_seckill_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SeckillActivityDO extends BaseDO {
|
||||
|
||||
/**
|
||||
@ -36,7 +37,7 @@ public class SeckillActivityDO extends BaseDO {
|
||||
private String name;
|
||||
/**
|
||||
* 活动状态
|
||||
*
|
||||
* <p>
|
||||
* 枚举 {@link PromotionActivityStatusEnum 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
@ -59,8 +60,8 @@ public class SeckillActivityDO extends BaseDO {
|
||||
/**
|
||||
* 秒杀时段 id
|
||||
*/
|
||||
// TODO @halfninety 可以使用 List 存储;看下别的模块怎么做的哈
|
||||
private String timeId;
|
||||
@TableField(typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> timeIds;
|
||||
/**
|
||||
* 付款订单数
|
||||
*/
|
||||
@ -69,10 +70,9 @@ public class SeckillActivityDO extends BaseDO {
|
||||
* 付款人数
|
||||
*/
|
||||
private Integer userCount;
|
||||
// TODO @halfninety 使用 Long 哈。单位是分
|
||||
/**
|
||||
* 订单实付金额,单位:分
|
||||
*/
|
||||
private BigDecimal totalPrice;
|
||||
private Long totalPrice;
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,25 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 秒杀参与商品
|
||||
*
|
||||
* @author halfninety
|
||||
* @TableName promotion_seckill_product
|
||||
*/
|
||||
@TableName(value ="promotion_seckill_product")
|
||||
@TableName(value = "promotion_seckill_product", autoResultMap = true)
|
||||
@KeySequence("promotion_seckill_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillProductDO extends BaseDO {
|
||||
/**
|
||||
* 秒杀参与商品编号
|
||||
@ -31,7 +35,8 @@ public class SeckillProductDO extends BaseDO {
|
||||
/**
|
||||
* 秒杀时段id
|
||||
*/
|
||||
private Long timeId;
|
||||
@TableField(typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> timeIds;
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
|
@ -4,7 +4,9 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalTime;
|
||||
|
||||
@ -18,9 +20,6 @@ import java.time.LocalTime;
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SeckillTimeDO extends BaseDO {
|
||||
|
||||
/**
|
||||
|
@ -1,28 +1,26 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 秒杀活动 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author halfninety
|
||||
*/
|
||||
@Mapper
|
||||
public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> {
|
||||
// TODO: 2022/11/28 halfninety 秒杀活动通过场次查询使用like会出现问题,查询活动场次编号为1,则活动场次编号为 1,11,......的都会被查出来
|
||||
default PageResult<SeckillActivityDO> selectPage(SeckillActivityPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<SeckillActivityDO>()
|
||||
.likeIfPresent(SeckillActivityDO::getName, reqVO.getName())
|
||||
.eqIfPresent(SeckillActivityDO::getStatus, reqVO.getStatus())
|
||||
.likeIfPresent(SeckillActivityDO::getTimeId, reqVO.getTimeId())
|
||||
// .like(StringUtils.hasText(reqVO.getTimeId()),SeckillActivityDO::getTimeId, reqVO.getTimeId() + ",")
|
||||
.betweenIfPresent(SeckillActivityDO::getCreateTime, reqVO.getCreateTime())
|
||||
.apply(ObjectUtil.isNotNull(reqVO.getTimeId()),"FIND_IN_SET(" + reqVO.getTimeId() + ",time_ids) > 0")
|
||||
.orderByDesc(SeckillActivityDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,35 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 秒杀活动商品 Mapper
|
||||
*
|
||||
* @author halfninety
|
||||
*/
|
||||
@Mapper
|
||||
public interface SeckillProductMapper extends BaseMapperX<SeckillProductDO> {
|
||||
|
||||
default List<SeckillProductDO> selectListByActivityId(Long id){
|
||||
return selectList(SeckillProductDO::getActivityId,id);
|
||||
default List<SeckillProductDO> selectListByActivityId(Long id) {
|
||||
return selectList(SeckillProductDO::getActivityId, id);
|
||||
}
|
||||
|
||||
default List<SeckillProductDO> selectListBySkuIds(Collection<Long> skuIds){
|
||||
return selectList(SeckillProductDO::getSkuId,skuIds);
|
||||
default List<SeckillProductDO> selectListBySkuIds(Collection<Long> skuIds) {
|
||||
return selectList(SeckillProductDO::getSkuId, skuIds);
|
||||
}
|
||||
|
||||
default void updateTimeIdsByActivityId(Long id, List<Long> timeIds) {
|
||||
new LambdaUpdateChainWrapper<>(this)
|
||||
.set(SeckillProductDO::getTimeIds, CollUtil.join(timeIds, ","))
|
||||
.eq(SeckillProductDO::getActivityId, id)
|
||||
.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -8,59 +7,31 @@ import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWra
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collections;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 秒杀时段 Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author halfninety
|
||||
*/
|
||||
@Mapper
|
||||
public interface SeckillTimeMapper extends BaseMapperX<SeckillTimeDO> {
|
||||
|
||||
// @TODO halfninety:){ 之间要有空格哈
|
||||
default List<SeckillTimeDO> selectListWithTime(LocalTime time){
|
||||
// TODO @halfninety:mapper 层,不做空判断,业务上面自己的保证
|
||||
if (time == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// TODO @halfninety:在 BaseMapperX 上,可以封装一个 2 个字段的检索哈
|
||||
return selectList(new LambdaQueryWrapper<SeckillTimeDO>()
|
||||
.le(SeckillTimeDO::getStartTime,time)
|
||||
.ge(SeckillTimeDO::getEndTime,time));
|
||||
default List<SeckillTimeDO> selectListByTime(LocalTime time) {
|
||||
return selectList(SeckillTimeDO::getStartTime, SeckillTimeDO::getEndTime, time);
|
||||
}
|
||||
|
||||
// TODO @halfninety:selectListByXXX,使用 By 作为查询条件。
|
||||
default List<SeckillTimeDO> selectListWithTime(LocalTime startTime, LocalTime endTime){
|
||||
// TODO @halfninety:mapper 层,不做空判断,业务上面自己的保证
|
||||
if (startTime == null && endTime == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
default List<SeckillTimeDO> selectListByTime(LocalTime startTime, LocalTime endTime) {
|
||||
return selectList(new LambdaQueryWrapper<SeckillTimeDO>()
|
||||
.ge(SeckillTimeDO::getStartTime,startTime)
|
||||
.le(SeckillTimeDO::getEndTime,endTime));
|
||||
.ge(SeckillTimeDO::getStartTime, startTime)
|
||||
.le(SeckillTimeDO::getEndTime, endTime));
|
||||
}
|
||||
|
||||
// TODO @halfninety:updateActivityCount + 和 -,可以执使用一个方法实现哈。多传递一个参数
|
||||
default void sekillActivityCountAdd(List<Long> ids){
|
||||
if (CollUtil.isEmpty(ids)){
|
||||
return;
|
||||
}
|
||||
new LambdaUpdateChainWrapper<SeckillTimeDO>(this)
|
||||
.in(SeckillTimeDO::getId,ids)
|
||||
.setSql("`seckill_activity_count` = `seckill_activity_count` + 1 ")
|
||||
default void updateActivityCount(Collection<Long> ids, String type, Integer count) {
|
||||
new LambdaUpdateChainWrapper<>(this)
|
||||
.in(SeckillTimeDO::getId, ids)
|
||||
.setSql("`seckill_activity_count` = `seckill_activity_count` " + type + count)
|
||||
.update();
|
||||
}
|
||||
|
||||
default void sekillActivityCountReduce(List<Long> ids){
|
||||
if (CollUtil.isEmpty(ids)){
|
||||
return;
|
||||
}
|
||||
new LambdaUpdateChainWrapper<SeckillTimeDO>(this)
|
||||
.in(SeckillTimeDO::getId,ids)
|
||||
.setSql("`seckill_activity_count` = `seckill_activity_count` - 1 ")
|
||||
.update();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity;
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO;
|
||||
@ -13,7 +13,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.
|
||||
/**
|
||||
* 秒杀活动 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author halfninety
|
||||
*/
|
||||
public interface SeckillActivityService {
|
||||
|
||||
@ -34,6 +34,7 @@ public interface SeckillActivityService {
|
||||
|
||||
/**
|
||||
* 关闭秒杀活动
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void closeSeckillActivity(Long id);
|
||||
@ -71,6 +72,7 @@ public interface SeckillActivityService {
|
||||
|
||||
/**
|
||||
* 通过活动编号获取活动商品
|
||||
*
|
||||
* @param id 活动编号
|
||||
* @return 活动商品列表
|
||||
*/
|
||||
|
@ -3,11 +3,10 @@ package cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityBaseVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityBaseVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO;
|
||||
@ -22,7 +21,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
@ -31,41 +29,34 @@ import static java.util.Arrays.asList;
|
||||
/**
|
||||
* 秒杀活动 Service 实现类
|
||||
*
|
||||
* @author 芋道源码 // TODO @halfninety:作者改成你自己哈
|
||||
* @author halfninety
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class SeckillActivityServiceImpl implements SeckillActivityService {
|
||||
|
||||
@Resource
|
||||
private SeckillActivityMapper seckillActivityMapper;
|
||||
@Resource
|
||||
private SeckillProductMapper seckillProductMapper;
|
||||
|
||||
@Resource
|
||||
private SeckillTimeService seckillTimeService;
|
||||
|
||||
@Override
|
||||
public Long createSeckillActivity(SeckillActivityCreateReqVO createReqVO) {
|
||||
// TODO @halfninety:多余的变量,需要删除
|
||||
List<Integer> statuses = asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus());
|
||||
// 校验商品是否冲突
|
||||
validateSeckillActivityProductConflicts(null, createReqVO.getProducts());
|
||||
// 校验秒杀时段是否存在
|
||||
seckillTimeService.validateSeckillTimeExists(createReqVO.getTimeIds());
|
||||
|
||||
// TODO halfninety:要校验下,秒杀时间段存在
|
||||
// 插入秒杀活动
|
||||
SeckillActivityDO seckillActivity = SeckillActivityConvert.INSTANCE.convert(createReqVO)
|
||||
.setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime()));
|
||||
seckillActivityMapper.insert(seckillActivity);
|
||||
// 插入商品
|
||||
// TODO @halfninety:是不是写成一个 convertList,通过 default 来处理下;这样可读性更好哈
|
||||
List<SeckillProductDO> productDOS = CollectionUtils.convertList(createReqVO.getProducts(),
|
||||
product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(seckillActivity.getId()));
|
||||
List<SeckillProductDO> productDOS = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), seckillActivity);
|
||||
seckillProductMapper.insertBatch(productDOS);
|
||||
|
||||
// TODO halfninety:最后在更新秒杀时间段的商品数量哈。【我已经改了】一般先做核心的逻辑,在做附件的逻辑。
|
||||
// 更新秒杀时段的秒杀活动数量
|
||||
seckillTimeService.sekillActivityCountAdd(StrUtils.splitToLong(createReqVO.getTimeId(),","));
|
||||
seckillTimeService.sekillActivityCountIncr(createReqVO.getTimeIds());
|
||||
return seckillActivity.getId();
|
||||
}
|
||||
|
||||
@ -79,53 +70,51 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
||||
// 校验商品是否冲突
|
||||
validateSeckillActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts());
|
||||
|
||||
// 更新秒杀时段的秒杀活动数量
|
||||
// TODO @halfninety:可以直接传递 seckillActivity 进去,不用重复查询;
|
||||
updateSeckillTimeActivityCount(updateReqVO.getId(), updateReqVO.getTimeId());
|
||||
// 更新活动
|
||||
SeckillActivityDO updateObj = SeckillActivityConvert.INSTANCE.convert(updateReqVO)
|
||||
.setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getStartTime(), updateReqVO.getEndTime()));
|
||||
seckillActivityMapper.updateById(updateObj);
|
||||
// 更新商品
|
||||
updateSeckillProduct(updateReqVO);
|
||||
// 更新秒杀时段的秒杀活动数量
|
||||
updateSeckillTimeActivityCount(seckillActivity, updateReqVO.getTimeIds());
|
||||
}
|
||||
|
||||
// TODO @halfninety:注释写全哈;
|
||||
|
||||
/**
|
||||
* 更新秒杀时段的秒杀活动数量
|
||||
*
|
||||
* @param id
|
||||
* @param timeId
|
||||
* @param seckillActivity 查询出的秒杀活动
|
||||
* @param updateTimeIds 更新后的秒杀时段id列表
|
||||
*/
|
||||
private void updateSeckillTimeActivityCount(Long id, String timeId) {
|
||||
List<Long> updateTimeIds = StrUtils.splitToLong(timeId, ",");
|
||||
// 查出自己的 timeIds
|
||||
SeckillActivityDO seckillActivityDO = seckillActivityMapper.selectById(id);
|
||||
List<Long> existsTimeIds = StrUtils.splitToLong(seckillActivityDO.getTimeId(), ",");
|
||||
private void updateSeckillTimeActivityCount(SeckillActivityDO seckillActivity, List<Long> updateTimeIds) {
|
||||
// 查询出 timeIds
|
||||
List<Long> existsTimeIds = seckillActivity.getTimeIds();
|
||||
// 需要减少的时间段
|
||||
// TODO @halfninety:可以使用 CollUtil.filterNew()
|
||||
List<Long> reduceIds = existsTimeIds.stream()
|
||||
.filter(existsTimeId -> !updateTimeIds.contains(existsTimeId))
|
||||
.collect(Collectors.toList());
|
||||
Collection<Long> reduceIds = CollUtil.filterNew(existsTimeIds, existsTimeId -> !updateTimeIds.contains(existsTimeId));
|
||||
// 需要添加的时间段
|
||||
// TODO @halfninety:IDEA 一般会有告警提示,下面可以 lambada 表达式优化下;通过 command + 回车
|
||||
updateTimeIds.removeIf(updateTimeId -> existsTimeIds.contains(updateTimeId));
|
||||
updateTimeIds.removeIf(existsTimeIds::contains);
|
||||
// 更新减少时间段和增加时间段
|
||||
// TODO @halfninety:判断非空才操作
|
||||
seckillTimeService.sekillActivityCountAdd(updateTimeIds);
|
||||
seckillTimeService.sekillActivityCountReduce(reduceIds);
|
||||
if (CollUtil.isNotEmpty(updateTimeIds)) {
|
||||
seckillTimeService.sekillActivityCountIncr(updateTimeIds);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(reduceIds)) {
|
||||
seckillTimeService.sekillActivityCountDecr(reduceIds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新秒杀商品
|
||||
* 后台查出的数据和前台查出的数据进行遍历,
|
||||
* 1. 对前台数据进行遍历:如果不存在于后台的 sku 中需要新增
|
||||
* 2. 对后台数据进行遍历:如果不存在于前台的 sku 中需要删除
|
||||
* 3. 最后对当前活动商品全部更新,更新秒杀时段id列表
|
||||
*
|
||||
* @param updateReqVO 更新的请求VO
|
||||
*/
|
||||
private void updateSeckillProduct(SeckillActivityUpdateReqVO updateReqVO) {
|
||||
List<SeckillProductDO> seckillProductDOS = seckillProductMapper.selectListByActivityId(updateReqVO.getId());
|
||||
List<SeckillActivityBaseVO.Product> products = updateReqVO.getProducts();
|
||||
// TODO halfninety:下面这段,其实可以放到注释哈
|
||||
// 对后台查出的数据和前台查出的数据进行遍历,
|
||||
// 1. 对前台数据进行遍历:如果不存在于后台的 sku 中需要新增
|
||||
// 2. 对后台数据进行遍历:如果不存在于前台的 sku 中需要删除
|
||||
|
||||
// 计算需要删除的数据
|
||||
List<Long> deleteIds = CollectionUtils.convertList(seckillProductDOS, SeckillProductDO::getId,
|
||||
@ -143,6 +132,9 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
||||
if (CollUtil.isNotEmpty(newSeckillProductDOs)) {
|
||||
seckillProductMapper.insertBatch(newSeckillProductDOs);
|
||||
}
|
||||
|
||||
//全量更新当前活动商品的秒杀时段id列表(timeIds)
|
||||
seckillProductMapper.updateTimeIdsByActivityId(updateReqVO.getId(), updateReqVO.getTimeIds());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -198,7 +190,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
||||
throw exception(SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END);
|
||||
}
|
||||
// 更新秒杀时段的秒杀活动数量
|
||||
seckillTimeService.sekillActivityCountReduce(StrUtils.splitToLong(seckillActivity.getTimeId(),","));
|
||||
seckillTimeService.sekillActivityCountDecr(seckillActivity.getTimeIds());
|
||||
// 删除
|
||||
seckillActivityMapper.deleteById(id);
|
||||
}
|
||||
|
@ -1,16 +1,17 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.seckill.seckilltime;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 秒杀时段 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author halfninety
|
||||
*/
|
||||
public interface SeckillTimeService {
|
||||
|
||||
@ -51,12 +52,19 @@ public interface SeckillTimeService {
|
||||
*/
|
||||
List<SeckillTimeDO> getSeckillTimeList();
|
||||
|
||||
/**
|
||||
* 校验秒杀时段是否存在
|
||||
*
|
||||
* @param timeIds 秒杀时段id集合
|
||||
*/
|
||||
void validateSeckillTimeExists(Collection<Long> timeIds);
|
||||
|
||||
/**
|
||||
* 秒杀时段列表的秒杀活动数量加 1
|
||||
*
|
||||
* @param ids 秒杀时段id列表
|
||||
*/
|
||||
void sekillActivityCountAdd(List<Long> ids);
|
||||
void sekillActivityCountIncr(Collection<Long> ids);
|
||||
|
||||
|
||||
/**
|
||||
@ -64,5 +72,5 @@ public interface SeckillTimeService {
|
||||
*
|
||||
* @param ids 秒杀时段id列表
|
||||
*/
|
||||
void sekillActivityCountReduce(List<Long> ids);
|
||||
void sekillActivityCountDecr(Collection<Long> ids);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.seckill.seckilltime;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.seckill.seckilltime.SeckillTimeConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime.SeckillTimeMapper;
|
||||
@ -11,6 +11,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -21,7 +22,7 @@ import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL
|
||||
/**
|
||||
* 秒杀时段 Service 实现类
|
||||
*
|
||||
* @author 芋道源码 // TODO @halfninety:作者改成你自己哈
|
||||
* @author halfninety
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@ -33,7 +34,7 @@ public class SeckillTimeServiceImpl implements SeckillTimeService {
|
||||
@Override
|
||||
public Long createSeckillTime(SeckillTimeCreateReqVO createReqVO) {
|
||||
// 校验时间段是否冲突
|
||||
validateSeckillTimeConflict(null,createReqVO.getStartTime(), createReqVO.getEndTime());
|
||||
validateSeckillTimeConflict(null, createReqVO.getStartTime(), createReqVO.getEndTime());
|
||||
// 插入
|
||||
SeckillTimeDO seckillTime = SeckillTimeConvert.INSTANCE.convert(createReqVO);
|
||||
seckillTimeMapper.insert(seckillTime);
|
||||
@ -74,10 +75,10 @@ public class SeckillTimeServiceImpl implements SeckillTimeService {
|
||||
*/
|
||||
private void validateSeckillTimeConflict(Long id, LocalTime startTime, LocalTime endTime) {
|
||||
//查询开始时间,结束时间,是否在别人的时间段内
|
||||
List<SeckillTimeDO> startTimeList = seckillTimeMapper.selectListWithTime(startTime);
|
||||
List<SeckillTimeDO> endTimeList = seckillTimeMapper.selectListWithTime(endTime);
|
||||
List<SeckillTimeDO> startTimeList = seckillTimeMapper.selectListByTime(startTime);
|
||||
List<SeckillTimeDO> endTimeList = seckillTimeMapper.selectListByTime(endTime);
|
||||
//查询自己时间段内是否有时间段
|
||||
List<SeckillTimeDO> startEndTimeList = seckillTimeMapper.selectListWithTime(startTime, endTime);
|
||||
List<SeckillTimeDO> startEndTimeList = seckillTimeMapper.selectListByTime(startTime, endTime);
|
||||
if (id != null) {
|
||||
//移除自己
|
||||
startTimeList.removeIf(seckillTime -> Objects.equals(seckillTime.getId(), id));
|
||||
@ -100,15 +101,24 @@ public class SeckillTimeServiceImpl implements SeckillTimeService {
|
||||
return seckillTimeMapper.selectList();
|
||||
}
|
||||
|
||||
// TODO @halfninety:updateActivityCount + 和 -,可以执使用一个方法实现哈。多传递一个参数
|
||||
@Override
|
||||
public void sekillActivityCountAdd(List<Long> ids) {
|
||||
seckillTimeMapper.sekillActivityCountAdd(ids);
|
||||
public void validateSeckillTimeExists(Collection<Long> timeIds) {
|
||||
if (CollUtil.isEmpty(timeIds)) {
|
||||
throw exception(SECKILL_TIME_NOT_EXISTS);
|
||||
}
|
||||
if (seckillTimeMapper.selectBatchIds(timeIds).size() != timeIds.size()) {
|
||||
throw exception(SECKILL_TIME_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sekillActivityCountReduce(List<Long> ids) {
|
||||
seckillTimeMapper.sekillActivityCountReduce(ids);
|
||||
public void sekillActivityCountIncr(Collection<Long> ids) {
|
||||
seckillTimeMapper.updateActivityCount(ids, "+", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sekillActivityCountDecr(Collection<Long> ids) {
|
||||
seckillTimeMapper.updateActivityCount(ids, "-", 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
<!-- TODO halfninety:不用的话,可以删除掉哈。 -->
|
||||
|
||||
</mapper>
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime.SeckillTimeMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
<!-- TODO halfninety:不用的话,可以删除掉哈。 -->
|
||||
|
||||
</mapper>
|
@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.promotion.service.seckillactivity;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckillactivity.vo.SeckillActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity.SeckillActivityMapper;
|
||||
import cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity.SeckillActivityServiceImpl;
|
||||
@ -107,7 +107,7 @@ public class SeckillActivityServiceImplTest extends BaseDbUnitTest {
|
||||
SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setStatus(null);
|
||||
o.setTimeId(null);
|
||||
o.setTimeIds(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
seckillActivityMapper.insert(dbSeckillActivity);
|
||||
@ -116,7 +116,7 @@ public class SeckillActivityServiceImplTest extends BaseDbUnitTest {
|
||||
// 测试 status 不匹配
|
||||
seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setStatus(null)));
|
||||
// 测试 timeId 不匹配
|
||||
seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeId(null)));
|
||||
seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeIds(null)));
|
||||
// 测试 createTime 不匹配
|
||||
seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
@ -141,7 +141,7 @@ public class SeckillActivityServiceImplTest extends BaseDbUnitTest {
|
||||
SeckillActivityDO dbSeckillActivity = randomPojo(SeckillActivityDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setStatus(null);
|
||||
o.setTimeId(null);
|
||||
o.setTimeIds(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
seckillActivityMapper.insert(dbSeckillActivity);
|
||||
@ -150,7 +150,7 @@ public class SeckillActivityServiceImplTest extends BaseDbUnitTest {
|
||||
// 测试 status 不匹配
|
||||
seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setStatus(null)));
|
||||
// 测试 timeId 不匹配
|
||||
seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeId(null)));
|
||||
seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setTimeIds(null)));
|
||||
// 测试 createTime 不匹配
|
||||
seckillActivityMapper.insert(cloneIgnoreId(dbSeckillActivity, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.seckilltime;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.seckilltime.vo.SeckillTimeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.time.SeckillTimeUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.service.seckill.seckilltime.SeckillTimeServiceImpl;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -51,10 +51,10 @@
|
||||
<dict-tag :type="DICT_TYPE.PROMOTION_ACTIVITY_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="参与场次" prop="timeId" width="250">
|
||||
<el-table-column label="参与场次" prop="timeIds" width="250">
|
||||
<template slot-scope="scope">
|
||||
<span v-for="item in seckillTimeList" :key="item.id"
|
||||
v-if="scope.row.timeId.indexOf(item.id) !== -1">
|
||||
v-if="scope.row.timeIds.includes(item.id)">
|
||||
<el-tag style="margin:4px;" size="small">{{ item.name }}</el-tag>
|
||||
</span>
|
||||
</template>
|
||||
@ -107,7 +107,7 @@
|
||||
<el-input type="textarea" v-model="form.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
<el-form-item label="场次选择">
|
||||
<el-select v-model="form.timeId" placeholder="请选择参与场次" clearable size="small" multiple filterable
|
||||
<el-select v-model="form.timeIds" placeholder="请选择参与场次" clearable size="small" multiple filterable
|
||||
style="width: 880px">
|
||||
<el-option v-for="item in seckillTimeList" :key="item.id" :label="item.name" :value="item.id">
|
||||
<span style="float: left">{{ item.name + ': { ' }} {{ item.startTime }} -- {{ item.endTime +
|
||||
@ -186,7 +186,7 @@
|
||||
|
||||
<script>
|
||||
import { getSkuOptionList } from "@/api/mall/product/sku";
|
||||
import { createSeckillActivity, updateSeckillActivity, closeSeckillActivity,deleteSeckillActivity, getSeckillActivity, getSeckillActivityPage, exportSeckillActivityExcel } from "@/api/mall/promotion/seckillActivity";
|
||||
import { createSeckillActivity, updateSeckillActivity, closeSeckillActivity, deleteSeckillActivity, getSeckillActivity, getSeckillActivityPage, exportSeckillActivityExcel } from "@/api/mall/promotion/seckillActivity";
|
||||
import { getSeckillTimeList } from "@/api/mall/promotion/seckillTime";
|
||||
import { deepClone } from "@/utils";
|
||||
|
||||
@ -223,7 +223,7 @@ export default {
|
||||
form: {
|
||||
skuIds: [], // 选中的 SKU
|
||||
products: [], // 商品信息
|
||||
timeId: [], //选中的秒杀场次id
|
||||
timeIds: [], //选中的秒杀场次id
|
||||
},
|
||||
// 商品 SKU 列表
|
||||
productSkus: [],
|
||||
@ -233,7 +233,7 @@ export default {
|
||||
status: [{ required: true, message: "活动状态不能为空", trigger: "blur" }],
|
||||
startAndEndTime: [{ required: true, message: "活动时间不能为空", trigger: "blur" }],
|
||||
sort: [{ required: true, message: "排序不能为空", trigger: "blur" }],
|
||||
timeId: [{ required: true, message: "秒杀场次不能为空", trigger: "blur" }],
|
||||
timeIds: [{ required: true, message: "秒杀场次不能为空", trigger: "blur" }],
|
||||
totalPrice: [{ required: true, message: "订单实付金额,单位:分不能为空", trigger: "blur" }],
|
||||
}
|
||||
};
|
||||
@ -241,12 +241,13 @@ export default {
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
watch:{
|
||||
watch: {
|
||||
$route: 'getList'
|
||||
},
|
||||
methods: {
|
||||
/** 查询列表 */
|
||||
getList() {
|
||||
// 从秒杀时段跳转过来并鞋带timeId参数进行查询
|
||||
const timeId = this.$route.params && this.$route.params.timeId;
|
||||
if (timeId) {
|
||||
this.queryParams.timeId = timeId
|
||||
@ -254,11 +255,13 @@ export default {
|
||||
this.loading = true;
|
||||
// 执行查询
|
||||
getSeckillActivityPage(this.queryParams).then(response => {
|
||||
console.log(response.data.list, "查询出的值");
|
||||
this.list = response.data.list;
|
||||
this.total = response.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
if (timeId) {
|
||||
//查询完成后设置为空
|
||||
this.$route.params.timeId = undefined
|
||||
}
|
||||
// 获得 SKU 商品列表
|
||||
@ -285,7 +288,7 @@ export default {
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
sort: undefined,
|
||||
timeId: [],
|
||||
timeIds: [],
|
||||
totalPrice: undefined,
|
||||
skuIds: [],
|
||||
products: [],
|
||||
@ -317,11 +320,9 @@ export default {
|
||||
this.reset();
|
||||
const id = row.id;
|
||||
getSeckillActivity(id).then(response => {
|
||||
var timeIdList = response.data.timeId.split(',')
|
||||
this.form = response.data;
|
||||
// 修改数据
|
||||
this.form.startAndEndTime = [response.data.startTime, response.data.endTime];
|
||||
this.form.timeId = timeIdList.map(item => parseInt(item))
|
||||
this.form.skuIds = response.data.products.map(item => item.skuId);
|
||||
this.form.products.forEach(product => {
|
||||
// 获得对应的 SKU 信息
|
||||
@ -334,7 +335,7 @@ export default {
|
||||
product.spuName = sku.spuName;
|
||||
product.price = sku.price;
|
||||
product.productStock = sku.stock;
|
||||
this.$set(product,'seckillStock',product.stock);
|
||||
this.$set(product, 'seckillStock', product.stock);
|
||||
product.seckillPrice = product.seckillPrice !== undefined ? product.seckillPrice / 100 : undefined;
|
||||
|
||||
});
|
||||
@ -353,7 +354,6 @@ export default {
|
||||
const data = deepClone(this.form);
|
||||
data.startTime = this.form.startAndEndTime[0];
|
||||
data.endTime = this.form.startAndEndTime[1];
|
||||
data.timeId = data.timeId.toString();
|
||||
data.products.forEach(product => {
|
||||
product.stock = product.seckillStock;
|
||||
product.seckillPrice = product.seckillPrice !== undefined ? product.seckillPrice * 100 : undefined;
|
||||
|
Loading…
Reference in New Issue
Block a user