Commit 405bf497ef5ae3f80fd76db6428895c28dccfee8
1 parent
96fc2523
mall:新增 discount 限时折扣、reward 满减送
Showing
24 changed files
with
313 additions
and
737 deletions
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/activity/MarketActivityStatusEnum.java renamed to yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionActivityStatusEnum.java
| 1 | -package cn.iocoder.yudao.module.market.enums.activity; | |
| 1 | +package cn.iocoder.yudao.module.market.enums.common; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Getter; | |
| 4 | 6 | |
| 5 | 7 | import java.util.Arrays; |
| 6 | 8 | |
| 7 | 9 | /** |
| 8 | - * 促销活动状态枚举 | |
| 10 | + * 促销活动的状态枚举 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 9 | 13 | */ |
| 10 | -public enum MarketActivityStatusEnum implements IntArrayValuable { | |
| 14 | +@AllArgsConstructor | |
| 15 | +@Getter | |
| 16 | +public enum PromotionActivityStatusEnum implements IntArrayValuable { | |
| 11 | 17 | |
| 12 | 18 | WAIT(10, "未开始"), |
| 13 | 19 | RUN(20, "进行中"), |
| 14 | 20 | END(30, "已结束"), |
| 15 | - /** | |
| 16 | - * 1. WAIT、RUN、END 可以转换成 INVALID 状态。 | |
| 17 | - * 2. INVALID 只可以转换成 DELETED 状态。 | |
| 18 | - */ | |
| 19 | - INVALID(40, "已撤销"), | |
| 20 | - DELETED(50, "已删除"), | |
| 21 | - ; | |
| 21 | + CLOSE(40, "已关闭"); | |
| 22 | 22 | |
| 23 | - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MarketActivityStatusEnum::getValue).toArray(); | |
| 23 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionActivityStatusEnum::getStatus).toArray(); | |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * 状态值 |
| 27 | 27 | */ |
| 28 | - private final Integer value; | |
| 28 | + private final Integer status; | |
| 29 | 29 | /** |
| 30 | 30 | * 状态名 |
| 31 | 31 | */ |
| 32 | 32 | private final String name; |
| 33 | 33 | |
| 34 | - MarketActivityStatusEnum(Integer value, String name) { | |
| 35 | - this.value = value; | |
| 36 | - this.name = name; | |
| 37 | - } | |
| 38 | - | |
| 39 | - public Integer getValue() { | |
| 40 | - return value; | |
| 41 | - } | |
| 42 | - | |
| 43 | - public String getName() { | |
| 44 | - return name; | |
| 45 | - } | |
| 46 | - | |
| 47 | 34 | @Override |
| 48 | 35 | public int[] array() { |
| 49 | 36 | return ARRAYS; |
| 50 | 37 | } |
| 38 | + | |
| 51 | 39 | } | ... | ... |
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionConditionTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.enums.common; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Getter; | |
| 6 | + | |
| 7 | +import java.util.Arrays; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 营销的条件类型枚举 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@AllArgsConstructor | |
| 15 | +@Getter | |
| 16 | +public enum PromotionConditionTypeEnum implements IntArrayValuable { | |
| 17 | + | |
| 18 | + PRICE(10, "满 N 元"), | |
| 19 | + COUNT(20, "满 N 件"); | |
| 20 | + | |
| 21 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionConditionTypeEnum::getType).toArray(); | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 类型值 | |
| 25 | + */ | |
| 26 | + private final Integer type; | |
| 27 | + /** | |
| 28 | + * 类型名 | |
| 29 | + */ | |
| 30 | + private final String name; | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public int[] array() { | |
| 34 | + return ARRAYS; | |
| 35 | + } | |
| 36 | + | |
| 37 | +} | ... | ... |
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionProductScopeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.enums.common; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Getter; | |
| 6 | + | |
| 7 | +import java.util.Arrays; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 营销的商品范围枚举 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Getter | |
| 15 | +@AllArgsConstructor | |
| 16 | +public enum PromotionProductScopeEnum implements IntArrayValuable { | |
| 17 | + | |
| 18 | + ALL(1, "全部商品参与"), | |
| 19 | + SPU(2, "指定商品参与"), | |
| 20 | + ; | |
| 21 | + | |
| 22 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionProductScopeEnum::getScope).toArray(); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 范围值 | |
| 26 | + */ | |
| 27 | + private final Integer scope; | |
| 28 | + /** | |
| 29 | + * 范围名 | |
| 30 | + */ | |
| 31 | + private final String name; | |
| 32 | + | |
| 33 | + @Override | |
| 34 | + public int[] array() { | |
| 35 | + return ARRAYS; | |
| 36 | + } | |
| 37 | + | |
| 38 | +} | ... | ... |
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionTypeEnum.java
| ... | ... | @@ -15,8 +15,8 @@ import java.util.Arrays; |
| 15 | 15 | @AllArgsConstructor |
| 16 | 16 | public enum PromotionTypeEnum implements IntArrayValuable { |
| 17 | 17 | |
| 18 | - TIME_LIMITED_DISCOUNT(1, "限时折扣"), | |
| 19 | - FULL_PRIVILEGE(2, "满减送"), | |
| 18 | + DISCOUNT(1, "限时折扣"), | |
| 19 | + REWARD(2, "满减送"), | |
| 20 | 20 | ; |
| 21 | 21 | |
| 22 | 22 | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray(); | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/MarketTestController.java deleted
| 1 | -package cn.iocoder.yudao.module.market.controller.admin; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | -import io.swagger.annotations.Api; | |
| 5 | -import io.swagger.annotations.ApiOperation; | |
| 6 | -import org.springframework.validation.annotation.Validated; | |
| 7 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 8 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 9 | -import org.springframework.web.bind.annotation.RestController; | |
| 10 | - | |
| 11 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 12 | - | |
| 13 | -@Api(tags = "管理后台 - 营销") | |
| 14 | -@RestController | |
| 15 | -@RequestMapping("/market/test") | |
| 16 | -@Validated | |
| 17 | -public class MarketTestController { | |
| 18 | - | |
| 19 | - @GetMapping("/get") | |
| 20 | - @ApiOperation("获取 market 信息") | |
| 21 | - public CommonResult<String> get() { | |
| 22 | - return success("true"); | |
| 23 | - } | |
| 24 | - | |
| 25 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/ActivityController.java deleted
| 1 | -package cn.iocoder.yudao.module.market.controller.admin.activity; | |
| 2 | - | |
| 3 | -import org.springframework.web.bind.annotation.*; | |
| 4 | -import javax.annotation.Resource; | |
| 5 | -import org.springframework.validation.annotation.Validated; | |
| 6 | -import org.springframework.security.access.prepost.PreAuthorize; | |
| 7 | -import io.swagger.annotations.*; | |
| 8 | -import javax.validation.*; | |
| 9 | -import java.util.*; | |
| 10 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 11 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 12 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 13 | -import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*; | |
| 14 | -import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO; | |
| 15 | -import cn.iocoder.yudao.module.market.convert.activity.ActivityConvert; | |
| 16 | -import cn.iocoder.yudao.module.market.service.activity.ActivityService; | |
| 17 | - | |
| 18 | -@Api(tags = "管理后台 - 促销活动") | |
| 19 | -@RestController | |
| 20 | -@RequestMapping("/market/activity") | |
| 21 | -@Validated | |
| 22 | -public class ActivityController { | |
| 23 | - | |
| 24 | - @Resource | |
| 25 | - private ActivityService activityService; | |
| 26 | - | |
| 27 | - @PostMapping("/create") | |
| 28 | - @ApiOperation("创建促销活动") | |
| 29 | - @PreAuthorize("@ss.hasPermission('market:activity:create')") | |
| 30 | - public CommonResult<Long> createActivity(@Valid @RequestBody ActivityCreateReqVO createReqVO) { | |
| 31 | - return success(activityService.createActivity(createReqVO)); | |
| 32 | - } | |
| 33 | - | |
| 34 | - @PutMapping("/update") | |
| 35 | - @ApiOperation("更新促销活动") | |
| 36 | - @PreAuthorize("@ss.hasPermission('market:activity:update')") | |
| 37 | - public CommonResult<Boolean> updateActivity(@Valid @RequestBody ActivityUpdateReqVO updateReqVO) { | |
| 38 | - activityService.updateActivity(updateReqVO); | |
| 39 | - return success(true); | |
| 40 | - } | |
| 41 | - | |
| 42 | - @DeleteMapping("/delete") | |
| 43 | - @ApiOperation("删除促销活动") | |
| 44 | - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | |
| 45 | - @PreAuthorize("@ss.hasPermission('market:activity:delete')") | |
| 46 | - public CommonResult<Boolean> deleteActivity(@RequestParam("id") Long id) { | |
| 47 | - activityService.deleteActivity(id); | |
| 48 | - return success(true); | |
| 49 | - } | |
| 50 | - | |
| 51 | - @GetMapping("/get") | |
| 52 | - @ApiOperation("获得促销活动") | |
| 53 | - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | |
| 54 | - @PreAuthorize("@ss.hasPermission('market:activity:query')") | |
| 55 | - public CommonResult<ActivityRespVO> getActivity(@RequestParam("id") Long id) { | |
| 56 | - ActivityDO activity = activityService.getActivity(id); | |
| 57 | - return success(ActivityConvert.INSTANCE.convert(activity)); | |
| 58 | - } | |
| 59 | - | |
| 60 | - @GetMapping("/list") | |
| 61 | - @ApiOperation("获得促销活动列表") | |
| 62 | - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | |
| 63 | - @PreAuthorize("@ss.hasPermission('market:activity:query')") | |
| 64 | - public CommonResult<List<ActivityRespVO>> getActivityList(@RequestParam("ids") Collection<Long> ids) { | |
| 65 | - List<ActivityDO> list = activityService.getActivityList(ids); | |
| 66 | - return success(ActivityConvert.INSTANCE.convertList(list)); | |
| 67 | - } | |
| 68 | - | |
| 69 | - @GetMapping("/page") | |
| 70 | - @ApiOperation("获得促销活动分页") | |
| 71 | - @PreAuthorize("@ss.hasPermission('market:activity:query')") | |
| 72 | - public CommonResult<PageResult<ActivityRespVO>> getActivityPage(@Valid ActivityPageReqVO pageVO) { | |
| 73 | - PageResult<ActivityDO> pageResult = activityService.getActivityPage(pageVO); | |
| 74 | - return success(ActivityConvert.INSTANCE.convertPage(pageResult)); | |
| 75 | - } | |
| 76 | - | |
| 77 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityBaseVO.java deleted
| 1 | -package cn.iocoder.yudao.module.market.controller.admin.activity.vo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | -import cn.iocoder.yudao.module.market.enums.activity.MarketActivityStatusEnum; | |
| 5 | -import cn.iocoder.yudao.module.market.enums.common.PromotionTypeEnum; | |
| 6 | -import lombok.*; | |
| 7 | -import java.util.*; | |
| 8 | -import io.swagger.annotations.*; | |
| 9 | -import javax.validation.constraints.*; | |
| 10 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 11 | - | |
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | - | |
| 14 | -/** | |
| 15 | -* 促销活动 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 16 | -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 17 | -*/ | |
| 18 | -@Data | |
| 19 | -public class ActivityBaseVO { | |
| 20 | - | |
| 21 | - @ApiModelProperty(value = "活动标题", required = true) | |
| 22 | - @NotNull(message = "活动标题不能为空") | |
| 23 | - private String title; | |
| 24 | - | |
| 25 | - @ApiModelProperty(value = "活动类型", required = true) | |
| 26 | - @NotNull(message = "活动类型不能为空") | |
| 27 | - @InEnum(PromotionTypeEnum.class) | |
| 28 | - private Integer activityType; | |
| 29 | - | |
| 30 | - @ApiModelProperty(value = "活动状态", required = true) | |
| 31 | - @NotNull(message = "活动状态不能为空") | |
| 32 | - @InEnum(MarketActivityStatusEnum.class) | |
| 33 | - private Integer status; | |
| 34 | - | |
| 35 | - @ApiModelProperty(value = "开始时间", required = true) | |
| 36 | - @NotNull(message = "开始时间不能为空") | |
| 37 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 38 | - private Date startTime; | |
| 39 | - | |
| 40 | - @ApiModelProperty(value = "结束时间", required = true) | |
| 41 | - @NotNull(message = "结束时间不能为空") | |
| 42 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 43 | - private Date endTime; | |
| 44 | - | |
| 45 | - @ApiModelProperty(value = "失效时间") | |
| 46 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 47 | - private Date invalidTime; | |
| 48 | - | |
| 49 | - @ApiModelProperty(value = "删除时间") | |
| 50 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 51 | - private Date deleteTime; | |
| 52 | - | |
| 53 | - @ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储") | |
| 54 | - private String timeLimitedDiscount; | |
| 55 | - | |
| 56 | - @ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储") | |
| 57 | - private String fullPrivilege; | |
| 58 | - | |
| 59 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.market.controller.admin.activity.vo; | |
| 2 | - | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.annotations.*; | |
| 6 | -import javax.validation.constraints.*; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * @author xia | |
| 10 | - */ | |
| 11 | -@ApiModel("管理后台 - 促销活动创建 Request VO") | |
| 12 | -@Data | |
| 13 | -@EqualsAndHashCode(callSuper = true) | |
| 14 | -@ToString(callSuper = true) | |
| 15 | -public class ActivityCreateReqVO extends ActivityBaseVO { | |
| 16 | - | |
| 17 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.market.controller.admin.activity.vo; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | -import cn.iocoder.yudao.module.market.enums.activity.MarketActivityStatusEnum; | |
| 5 | -import cn.iocoder.yudao.module.market.enums.common.PromotionTypeEnum; | |
| 6 | -import lombok.*; | |
| 7 | -import java.util.*; | |
| 8 | -import io.swagger.annotations.*; | |
| 9 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 10 | -import org.springframework.format.annotation.DateTimeFormat; | |
| 11 | - | |
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | - | |
| 14 | -@ApiModel("管理后台 - 促销活动分页 Request VO") | |
| 15 | -@Data | |
| 16 | -@EqualsAndHashCode(callSuper = true) | |
| 17 | -@ToString(callSuper = true) | |
| 18 | -public class ActivityPageReqVO extends PageParam { | |
| 19 | - | |
| 20 | - @ApiModelProperty(value = "活动标题") | |
| 21 | - private String title; | |
| 22 | - | |
| 23 | - @ApiModelProperty(value = "活动类型") | |
| 24 | - @InEnum(PromotionTypeEnum.class) | |
| 25 | - private Integer activityType; | |
| 26 | - | |
| 27 | - @ApiModelProperty(value = "活动状态") | |
| 28 | - @InEnum(MarketActivityStatusEnum.class) | |
| 29 | - private Integer status; | |
| 30 | - | |
| 31 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 32 | - @ApiModelProperty(value = "开始时间") | |
| 33 | - private Date[] startTime; | |
| 34 | - | |
| 35 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 36 | - @ApiModelProperty(value = "结束时间") | |
| 37 | - private Date[] endTime; | |
| 38 | - | |
| 39 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 40 | - @ApiModelProperty(value = "失效时间") | |
| 41 | - private Date[] invalidTime; | |
| 42 | - | |
| 43 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 44 | - @ApiModelProperty(value = "删除时间") | |
| 45 | - private Date[] deleteTime; | |
| 46 | - | |
| 47 | - @ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储") | |
| 48 | - private String timeLimitedDiscount; | |
| 49 | - | |
| 50 | - @ApiModelProperty(value = "限制折扣字符串,使用 JSON 序列化成字符串存储") | |
| 51 | - private String fullPrivilege; | |
| 52 | - | |
| 53 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 54 | - @ApiModelProperty(value = "创建时间") | |
| 55 | - private Date[] createTime; | |
| 56 | - | |
| 57 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.market.controller.admin.activity.vo; | |
| 2 | - | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.annotations.*; | |
| 6 | - | |
| 7 | -@ApiModel("管理后台 - 促销活动 Response VO") | |
| 8 | -@Data | |
| 9 | -@EqualsAndHashCode(callSuper = true) | |
| 10 | -@ToString(callSuper = true) | |
| 11 | -public class ActivityRespVO extends ActivityBaseVO { | |
| 12 | - | |
| 13 | - @ApiModelProperty(value = "活动编号", required = true) | |
| 14 | - private Long id; | |
| 15 | - | |
| 16 | - @ApiModelProperty(value = "创建时间", required = true) | |
| 17 | - private Date createTime; | |
| 18 | - | |
| 19 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/activity/vo/ActivityUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.market.controller.admin.activity.vo; | |
| 2 | - | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import io.swagger.annotations.*; | |
| 6 | -import javax.validation.constraints.*; | |
| 7 | - | |
| 8 | -@ApiModel("管理后台 - 促销活动更新 Request VO") | |
| 9 | -@Data | |
| 10 | -@EqualsAndHashCode(callSuper = true) | |
| 11 | -@ToString(callSuper = true) | |
| 12 | -public class ActivityUpdateReqVO extends ActivityBaseVO { | |
| 13 | - | |
| 14 | - @ApiModelProperty(value = "活动编号", required = true) | |
| 15 | - @NotNull(message = "活动编号不能为空") | |
| 16 | - private Long id; | |
| 17 | - | |
| 18 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/controller/admin/discount/package-info.java
0 → 100644
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/activity/ActivityConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.market.convert.activity; | |
| 2 | - | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | - | |
| 7 | -import org.mapstruct.Mapper; | |
| 8 | -import org.mapstruct.factory.Mappers; | |
| 9 | -import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*; | |
| 10 | -import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 促销活动 Convert | |
| 14 | - * | |
| 15 | - * @author 芋道源码 | |
| 16 | - */ | |
| 17 | -@Mapper | |
| 18 | -public interface ActivityConvert { | |
| 19 | - | |
| 20 | - ActivityConvert INSTANCE = Mappers.getMapper(ActivityConvert.class); | |
| 21 | - | |
| 22 | - ActivityDO convert(ActivityCreateReqVO bean); | |
| 23 | - | |
| 24 | - ActivityDO convert(ActivityUpdateReqVO bean); | |
| 25 | - | |
| 26 | - ActivityRespVO convert(ActivityDO bean); | |
| 27 | - | |
| 28 | - List<ActivityRespVO> convertList(List<ActivityDO> list); | |
| 29 | - | |
| 30 | - PageResult<ActivityRespVO> convertPage(PageResult<ActivityDO> page); | |
| 31 | - | |
| 32 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/discount/package-info.java
0 → 100644
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/activity/ActivityDO.java renamed to yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/discount/DiscountActivityDO.java
| 1 | -package cn.iocoder.yudao.module.market.dal.dataobject.activity; | |
| 1 | +package cn.iocoder.yudao.module.market.dal.dataobject.discount; | |
| 2 | 2 | |
| 3 | -import lombok.*; | |
| 4 | -import java.util.*; | |
| 5 | -import com.baomidou.mybatisplus.annotation.*; | |
| 6 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.module.market.enums.common.PromotionActivityStatusEnum; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.Data; | |
| 9 | +import lombok.EqualsAndHashCode; | |
| 10 | + | |
| 11 | +import java.util.Date; | |
| 7 | 12 | |
| 8 | 13 | /** |
| 9 | - * 促销活动 DO | |
| 14 | + * 限时折扣活动 DO | |
| 15 | + * | |
| 16 | + * 一个活动下,可以有 {@link DiscountProductDO} 商品; | |
| 17 | + * 一个商品,在指定时间段内,只能属于一个活动; | |
| 10 | 18 | * |
| 11 | 19 | * @author 芋道源码 |
| 12 | 20 | */ |
| 13 | -@TableName("market_activity") | |
| 21 | +@TableName(value = "promotion_discount_activity", autoResultMap = true) | |
| 22 | +@KeySequence("promotion_discount_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 14 | 23 | @Data |
| 15 | 24 | @EqualsAndHashCode(callSuper = true) |
| 16 | -@ToString(callSuper = true) | |
| 17 | -@Builder | |
| 18 | -@NoArgsConstructor | |
| 19 | -@AllArgsConstructor | |
| 20 | -public class ActivityDO extends BaseDO { | |
| 25 | +public class DiscountActivityDO extends BaseDO { | |
| 21 | 26 | |
| 22 | 27 | /** |
| 23 | - * 活动编号 | |
| 28 | + * 活动编号,主键自增 | |
| 24 | 29 | */ |
| 25 | 30 | @TableId |
| 26 | 31 | private Long id; |
| 27 | 32 | /** |
| 28 | 33 | * 活动标题 |
| 29 | 34 | */ |
| 30 | - private String title; | |
| 35 | + private String name; | |
| 31 | 36 | /** |
| 32 | - * 活动类型MarketActivityTypeEnum | |
| 33 | - */ | |
| 34 | - private Integer activityType; | |
| 35 | - /** | |
| 36 | - * 活动状态MarketActivityStatusEnum | |
| 37 | + * 状态 | |
| 38 | + * | |
| 39 | + * 枚举 {@link PromotionActivityStatusEnum} | |
| 37 | 40 | */ |
| 38 | 41 | private Integer status; |
| 39 | 42 | /** |
| ... | ... | @@ -45,20 +48,8 @@ public class ActivityDO extends BaseDO { |
| 45 | 48 | */ |
| 46 | 49 | private Date endTime; |
| 47 | 50 | /** |
| 48 | - * 失效时间 | |
| 49 | - */ | |
| 50 | - private Date invalidTime; | |
| 51 | - /** | |
| 52 | - * 删除时间 | |
| 53 | - */ | |
| 54 | - private Date deleteTime; | |
| 55 | - /** | |
| 56 | - * 限制折扣字符串,使用 JSON 序列化成字符串存储 | |
| 57 | - */ | |
| 58 | - private String timeLimitedDiscount; | |
| 59 | - /** | |
| 60 | - * 限制折扣字符串,使用 JSON 序列化成字符串存储 | |
| 51 | + * 备注 | |
| 61 | 52 | */ |
| 62 | - private String fullPrivilege; | |
| 53 | + private String remark; | |
| 63 | 54 | |
| 64 | 55 | } | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/discount/DiscountProductDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.dal.dataobject.discount; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import lombok.Data; | |
| 8 | +import lombok.EqualsAndHashCode; | |
| 9 | + | |
| 10 | +import java.util.Date; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 限时折扣商品 DO | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@TableName(value = "promotion_discount_product", autoResultMap = true) | |
| 18 | +@KeySequence("promotion_discount_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 19 | +@Data | |
| 20 | +@EqualsAndHashCode(callSuper = true) | |
| 21 | +public class DiscountProductDO extends BaseDO { | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 编号,主键自增 | |
| 25 | + */ | |
| 26 | + @TableId | |
| 27 | + private Long id; | |
| 28 | + /** | |
| 29 | + * 限时折扣活动的编号 | |
| 30 | + * | |
| 31 | + * 关联 {@link DiscountActivityDO#getId()} | |
| 32 | + */ | |
| 33 | + private Long activityId; | |
| 34 | + /** | |
| 35 | + * 商品 SPU 编号 | |
| 36 | + * | |
| 37 | + * 关联 ProductSpuDO 的 id 编号 | |
| 38 | + */ | |
| 39 | + private Long spuId; | |
| 40 | + /** | |
| 41 | + * 商品 SKU 编号 | |
| 42 | + * | |
| 43 | + * 关联 ProductSkuDO 的 id 编号 | |
| 44 | + */ | |
| 45 | + private Long skuId; | |
| 46 | + /** | |
| 47 | + * 开始时间 | |
| 48 | + */ | |
| 49 | + private Date startTime; | |
| 50 | + /** | |
| 51 | + * 结束时间 | |
| 52 | + */ | |
| 53 | + private Date endTime; | |
| 54 | + /** | |
| 55 | + * 销售价格,单位:分 | |
| 56 | + * | |
| 57 | + * 冗余 ProductSkuDO 的 price 字段 | |
| 58 | + */ | |
| 59 | + private Integer originalPrice; | |
| 60 | + /** | |
| 61 | + * 优惠价格,单位:分 | |
| 62 | + */ | |
| 63 | + private Integer promotionPrice; | |
| 64 | + | |
| 65 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/dataobject/reward/RewardActivityDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.market.dal.dataobject.reward; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.market.enums.common.PromotionActivityStatusEnum; | |
| 5 | +import cn.iocoder.yudao.module.market.enums.common.PromotionConditionTypeEnum; | |
| 6 | +import cn.iocoder.yudao.module.market.enums.common.PromotionProductScopeEnum; | |
| 7 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 9 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 10 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 11 | +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; | |
| 12 | +import lombok.Data; | |
| 13 | +import lombok.EqualsAndHashCode; | |
| 14 | + | |
| 15 | +import java.util.Date; | |
| 16 | +import java.util.List; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * 满减送活动 DO | |
| 20 | + * | |
| 21 | + * @author 芋道源码 | |
| 22 | + */ | |
| 23 | +@TableName(value = "promotion_reward_activity", autoResultMap = true) | |
| 24 | +@KeySequence("promotion_reward_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 25 | +@Data | |
| 26 | +@EqualsAndHashCode(callSuper = true) | |
| 27 | +public class RewardActivityDO extends BaseDO { | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 活动编号,主键自增 | |
| 31 | + */ | |
| 32 | + @TableId | |
| 33 | + private Long id; | |
| 34 | + /** | |
| 35 | + * 活动标题 | |
| 36 | + */ | |
| 37 | + private String name; | |
| 38 | + /** | |
| 39 | + * 状态 | |
| 40 | + * | |
| 41 | + * 枚举 {@link PromotionActivityStatusEnum} | |
| 42 | + */ | |
| 43 | + private Integer status; | |
| 44 | + /** | |
| 45 | + * 开始时间 | |
| 46 | + */ | |
| 47 | + private Date startTime; | |
| 48 | + /** | |
| 49 | + * 结束时间 | |
| 50 | + */ | |
| 51 | + private Date endTime; | |
| 52 | + /** | |
| 53 | + * 备注 | |
| 54 | + */ | |
| 55 | + private String remark; | |
| 56 | + /** | |
| 57 | + * 条件类型 | |
| 58 | + * | |
| 59 | + * 枚举 {@link PromotionConditionTypeEnum} | |
| 60 | + */ | |
| 61 | + private Integer conditionType; | |
| 62 | + /** | |
| 63 | + * 商品范围 | |
| 64 | + * | |
| 65 | + * 枚举 {@link PromotionProductScopeEnum} | |
| 66 | + */ | |
| 67 | + private Integer productScope; | |
| 68 | + /** | |
| 69 | + * 商品 SPU 编号的数组 | |
| 70 | + */ | |
| 71 | + @TableField(typeHandler = JacksonTypeHandler.class) | |
| 72 | + private List<Long> spuIds; | |
| 73 | + /** | |
| 74 | + * 优惠规则的数组 | |
| 75 | + */ | |
| 76 | + @TableField(typeHandler = JacksonTypeHandler.class) | |
| 77 | + private List<Rule> rules; | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * 优惠规则 | |
| 81 | + */ | |
| 82 | + @Data | |
| 83 | + public static class Rule { | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * 优惠门槛 | |
| 87 | + * | |
| 88 | + * 1. 满 N 元,单位:分 | |
| 89 | + * 2. 满 N 件 | |
| 90 | + */ | |
| 91 | + private Integer limit; | |
| 92 | + /** | |
| 93 | + * 优惠价格,单位:分 | |
| 94 | + */ | |
| 95 | + private Integer promotionPrice; | |
| 96 | + /** | |
| 97 | + * 是否包邮 | |
| 98 | + */ | |
| 99 | + private Boolean freeDelivery; | |
| 100 | + /** | |
| 101 | + * 赠送的积分 | |
| 102 | + */ | |
| 103 | + private Integer integral; | |
| 104 | + /** | |
| 105 | + * 赠送的优惠劵编号的数组 | |
| 106 | + */ | |
| 107 | + private List<Long> couponIds; | |
| 108 | + /** | |
| 109 | + * 赠送的优惠卷数量的数组 | |
| 110 | + */ | |
| 111 | + private List<Integer> couponCounts; | |
| 112 | + | |
| 113 | + } | |
| 114 | + | |
| 115 | + | |
| 116 | +} | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/mysql/activity/ActivityMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.market.dal.mysql.activity; | |
| 2 | - | |
| 3 | -import java.util.*; | |
| 4 | - | |
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 8 | -import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO; | |
| 9 | -import org.apache.ibatis.annotations.Mapper; | |
| 10 | -import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 促销活动 Mapper | |
| 14 | - * | |
| 15 | - * @author 芋道源码 | |
| 16 | - */ | |
| 17 | -@Mapper | |
| 18 | -public interface ActivityMapper extends BaseMapperX<ActivityDO> { | |
| 19 | - | |
| 20 | - default PageResult<ActivityDO> selectPage(ActivityPageReqVO reqVO) { | |
| 21 | - return selectPage(reqVO, new LambdaQueryWrapperX<ActivityDO>() | |
| 22 | - .eqIfPresent(ActivityDO::getTitle, reqVO.getTitle()) | |
| 23 | - .eqIfPresent(ActivityDO::getActivityType, reqVO.getActivityType()) | |
| 24 | - .eqIfPresent(ActivityDO::getStatus, reqVO.getStatus()) | |
| 25 | - .betweenIfPresent(ActivityDO::getStartTime, reqVO.getStartTime()) | |
| 26 | - .betweenIfPresent(ActivityDO::getEndTime, reqVO.getEndTime()) | |
| 27 | - .betweenIfPresent(ActivityDO::getInvalidTime, reqVO.getInvalidTime()) | |
| 28 | - .betweenIfPresent(ActivityDO::getDeleteTime, reqVO.getDeleteTime()) | |
| 29 | - .eqIfPresent(ActivityDO::getTimeLimitedDiscount, reqVO.getTimeLimitedDiscount()) | |
| 30 | - .eqIfPresent(ActivityDO::getFullPrivilege, reqVO.getFullPrivilege()) | |
| 31 | - .betweenIfPresent(ActivityDO::getCreateTime, reqVO.getCreateTime()) | |
| 32 | - .orderByDesc(ActivityDO::getId)); | |
| 33 | - } | |
| 34 | - | |
| 35 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/dal/mysql/discount/package-info.java
0 → 100644
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/package-info.java
| 1 | 1 | /** |
| 2 | - * market 模块,我们放营销业务。 | |
| 2 | + * promotion 模块,我们放营销业务。 | |
| 3 | 3 | * 例如说:营销活动、banner、优惠券等等 |
| 4 | 4 | * |
| 5 | - * 1. Controller URL:以 /market/ 开头,避免和其它 Module 冲突 | |
| 6 | - * 2. DataObject 表名:以 market_ 开头,方便在数据库中区分 | |
| 5 | + * 1. Controller URL:以 /promotion/ 开头,避免和其它 Module 冲突 | |
| 6 | + * 2. DataObject 表名:以 promotion_ 开头,方便在数据库中区分 | |
| 7 | 7 | */ |
| 8 | 8 | package cn.iocoder.yudao.module.market; | ... | ... |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/activity/ActivityService.java deleted
| 1 | -package cn.iocoder.yudao.module.market.service.activity; | |
| 2 | - | |
| 3 | -import java.util.*; | |
| 4 | -import javax.validation.*; | |
| 5 | -import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*; | |
| 6 | -import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO; | |
| 7 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 促销活动 Service 接口 | |
| 11 | - * | |
| 12 | - * @author 芋道源码 | |
| 13 | - */ | |
| 14 | -public interface ActivityService { | |
| 15 | - | |
| 16 | - /** | |
| 17 | - * 创建促销活动 | |
| 18 | - * | |
| 19 | - * @param createReqVO 创建信息 | |
| 20 | - * @return 编号 | |
| 21 | - */ | |
| 22 | - Long createActivity(@Valid ActivityCreateReqVO createReqVO); | |
| 23 | - | |
| 24 | - /** | |
| 25 | - * 更新促销活动 | |
| 26 | - * | |
| 27 | - * @param updateReqVO 更新信息 | |
| 28 | - */ | |
| 29 | - void updateActivity(@Valid ActivityUpdateReqVO updateReqVO); | |
| 30 | - | |
| 31 | - /** | |
| 32 | - * 删除促销活动 | |
| 33 | - * | |
| 34 | - * @param id 编号 | |
| 35 | - */ | |
| 36 | - void deleteActivity(Long id); | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * 获得促销活动 | |
| 40 | - * | |
| 41 | - * @param id 编号 | |
| 42 | - * @return 促销活动 | |
| 43 | - */ | |
| 44 | - ActivityDO getActivity(Long id); | |
| 45 | - | |
| 46 | - /** | |
| 47 | - * 获得促销活动列表 | |
| 48 | - * | |
| 49 | - * @param ids 编号 | |
| 50 | - * @return 促销活动列表 | |
| 51 | - */ | |
| 52 | - List<ActivityDO> getActivityList(Collection<Long> ids); | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * 获得促销活动分页 | |
| 56 | - * | |
| 57 | - * @param pageReqVO 分页查询 | |
| 58 | - * @return 促销活动分页 | |
| 59 | - */ | |
| 60 | - PageResult<ActivityDO> getActivityPage(ActivityPageReqVO pageReqVO); | |
| 61 | - | |
| 62 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/activity/ActivityServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.market.service.activity; | |
| 2 | - | |
| 3 | -import org.springframework.stereotype.Service; | |
| 4 | -import javax.annotation.Resource; | |
| 5 | -import org.springframework.validation.annotation.Validated; | |
| 6 | - | |
| 7 | -import java.util.*; | |
| 8 | -import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*; | |
| 9 | -import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO; | |
| 10 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 11 | - | |
| 12 | -import cn.iocoder.yudao.module.market.convert.activity.ActivityConvert; | |
| 13 | -import cn.iocoder.yudao.module.market.dal.mysql.activity.ActivityMapper; | |
| 14 | - | |
| 15 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 16 | -import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.*; | |
| 17 | - | |
| 18 | -/** | |
| 19 | - * 促销活动 Service 实现类 | |
| 20 | - * | |
| 21 | - * @author 芋道源码 | |
| 22 | - */ | |
| 23 | -@Service | |
| 24 | -@Validated | |
| 25 | -public class ActivityServiceImpl implements ActivityService { | |
| 26 | - | |
| 27 | - @Resource | |
| 28 | - private ActivityMapper activityMapper; | |
| 29 | - | |
| 30 | - @Override | |
| 31 | - public Long createActivity(ActivityCreateReqVO createReqVO) { | |
| 32 | - // 插入 | |
| 33 | - ActivityDO activity = ActivityConvert.INSTANCE.convert(createReqVO); | |
| 34 | - activityMapper.insert(activity); | |
| 35 | - // 返回 | |
| 36 | - return activity.getId(); | |
| 37 | - } | |
| 38 | - | |
| 39 | - @Override | |
| 40 | - public void updateActivity(ActivityUpdateReqVO updateReqVO) { | |
| 41 | - // 校验存在 | |
| 42 | - this.validateActivityExists(updateReqVO.getId()); | |
| 43 | - // 更新 | |
| 44 | - ActivityDO updateObj = ActivityConvert.INSTANCE.convert(updateReqVO); | |
| 45 | - activityMapper.updateById(updateObj); | |
| 46 | - } | |
| 47 | - | |
| 48 | - @Override | |
| 49 | - public void deleteActivity(Long id) { | |
| 50 | - // 校验存在 | |
| 51 | - this.validateActivityExists(id); | |
| 52 | - // 删除 | |
| 53 | - activityMapper.deleteById(id); | |
| 54 | - } | |
| 55 | - | |
| 56 | - private void validateActivityExists(Long id) { | |
| 57 | - if (activityMapper.selectById(id) == null) { | |
| 58 | - throw exception(ACTIVITY_NOT_EXISTS); | |
| 59 | - } | |
| 60 | - } | |
| 61 | - | |
| 62 | - @Override | |
| 63 | - public ActivityDO getActivity(Long id) { | |
| 64 | - return activityMapper.selectById(id); | |
| 65 | - } | |
| 66 | - | |
| 67 | - @Override | |
| 68 | - public List<ActivityDO> getActivityList(Collection<Long> ids) { | |
| 69 | - return activityMapper.selectBatchIds(ids); | |
| 70 | - } | |
| 71 | - | |
| 72 | - @Override | |
| 73 | - public PageResult<ActivityDO> getActivityPage(ActivityPageReqVO pageReqVO) { | |
| 74 | - return activityMapper.selectPage(pageReqVO); | |
| 75 | - } | |
| 76 | - | |
| 77 | -} |
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/discount/package-info.java
0 → 100644
yudao-module-mall/yudao-module-market-biz/src/test/java/cn/iocoder/yudao/module/market/service/activity/ActivityServiceImplTest.java deleted
| 1 | -package cn.iocoder.yudao.module.market.service.activity; | |
| 2 | - | |
| 3 | -import org.junit.jupiter.api.Disabled; | |
| 4 | -import org.junit.jupiter.api.Test; | |
| 5 | - | |
| 6 | -import javax.annotation.Resource; | |
| 7 | - | |
| 8 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 9 | - | |
| 10 | -import cn.iocoder.yudao.module.market.controller.admin.activity.vo.*; | |
| 11 | -import cn.iocoder.yudao.module.market.dal.dataobject.activity.ActivityDO; | |
| 12 | -import cn.iocoder.yudao.module.market.dal.mysql.activity.ActivityMapper; | |
| 13 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 14 | - | |
| 15 | -import org.springframework.context.annotation.Import; | |
| 16 | - | |
| 17 | -import static cn.iocoder.yudao.module.market.enums.ErrorCodeConstants.*; | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 20 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 21 | -import static org.junit.jupiter.api.Assertions.*; | |
| 22 | - | |
| 23 | -/** | |
| 24 | -* {@link ActivityServiceImpl} 的单元测试类 | |
| 25 | -* | |
| 26 | -* @author 芋道源码 | |
| 27 | -*/ | |
| 28 | -@Import(ActivityServiceImpl.class) | |
| 29 | -public class ActivityServiceImplTest extends BaseDbUnitTest { | |
| 30 | - | |
| 31 | - @Resource | |
| 32 | - private ActivityServiceImpl activityService; | |
| 33 | - | |
| 34 | - @Resource | |
| 35 | - private ActivityMapper activityMapper; | |
| 36 | - | |
| 37 | - @Test | |
| 38 | - public void testCreateActivity_success() { | |
| 39 | - // 准备参数 | |
| 40 | - ActivityCreateReqVO reqVO = randomPojo(ActivityCreateReqVO.class); | |
| 41 | - | |
| 42 | - // 调用 | |
| 43 | - Long activityId = activityService.createActivity(reqVO); | |
| 44 | - // 断言 | |
| 45 | - assertNotNull(activityId); | |
| 46 | - // 校验记录的属性是否正确 | |
| 47 | - ActivityDO activity = activityMapper.selectById(activityId); | |
| 48 | - assertPojoEquals(reqVO, activity); | |
| 49 | - } | |
| 50 | - | |
| 51 | - @Test | |
| 52 | - public void testUpdateActivity_success() { | |
| 53 | - // mock 数据 | |
| 54 | - ActivityDO dbActivity = randomPojo(ActivityDO.class); | |
| 55 | - activityMapper.insert(dbActivity);// @Sql: 先插入出一条存在的数据 | |
| 56 | - // 准备参数 | |
| 57 | - ActivityUpdateReqVO reqVO = randomPojo(ActivityUpdateReqVO.class, o -> { | |
| 58 | - o.setId(dbActivity.getId()); // 设置更新的 ID | |
| 59 | - }); | |
| 60 | - | |
| 61 | - // 调用 | |
| 62 | - activityService.updateActivity(reqVO); | |
| 63 | - // 校验是否更新正确 | |
| 64 | - ActivityDO activity = activityMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 65 | - assertPojoEquals(reqVO, activity); | |
| 66 | - } | |
| 67 | - | |
| 68 | - @Test | |
| 69 | - public void testUpdateActivity_notExists() { | |
| 70 | - // 准备参数 | |
| 71 | - ActivityUpdateReqVO reqVO = randomPojo(ActivityUpdateReqVO.class); | |
| 72 | - | |
| 73 | - // 调用, 并断言异常 | |
| 74 | - assertServiceException(() -> activityService.updateActivity(reqVO), ACTIVITY_NOT_EXISTS); | |
| 75 | - } | |
| 76 | - | |
| 77 | - @Test | |
| 78 | - public void testDeleteActivity_success() { | |
| 79 | - // mock 数据 | |
| 80 | - ActivityDO dbActivity = randomPojo(ActivityDO.class); | |
| 81 | - activityMapper.insert(dbActivity);// @Sql: 先插入出一条存在的数据 | |
| 82 | - // 准备参数 | |
| 83 | - Long id = dbActivity.getId(); | |
| 84 | - | |
| 85 | - // 调用 | |
| 86 | - activityService.deleteActivity(id); | |
| 87 | - // 校验数据不存在了 | |
| 88 | - assertNull(activityMapper.selectById(id)); | |
| 89 | - } | |
| 90 | - | |
| 91 | - @Test | |
| 92 | - public void testDeleteActivity_notExists() { | |
| 93 | - // 准备参数 | |
| 94 | - Long id = randomLongId(); | |
| 95 | - | |
| 96 | - // 调用, 并断言异常 | |
| 97 | - assertServiceException(() -> activityService.deleteActivity(id), ACTIVITY_NOT_EXISTS); | |
| 98 | - } | |
| 99 | - | |
| 100 | - @Test | |
| 101 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 102 | - public void testGetActivityPage() { | |
| 103 | - // mock 数据 | |
| 104 | - ActivityDO dbActivity = randomPojo(ActivityDO.class, o -> { // 等会查询到 | |
| 105 | - o.setTitle(null); | |
| 106 | - o.setActivityType(null); | |
| 107 | - o.setStatus(null); | |
| 108 | - o.setStartTime(null); | |
| 109 | - o.setEndTime(null); | |
| 110 | - o.setInvalidTime(null); | |
| 111 | - o.setDeleteTime(null); | |
| 112 | - o.setTimeLimitedDiscount(null); | |
| 113 | - o.setFullPrivilege(null); | |
| 114 | - o.setCreateTime(null); | |
| 115 | - }); | |
| 116 | - activityMapper.insert(dbActivity); | |
| 117 | - // 测试 title 不匹配 | |
| 118 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTitle(null))); | |
| 119 | - // 测试 activityType 不匹配 | |
| 120 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setActivityType(null))); | |
| 121 | - // 测试 status 不匹配 | |
| 122 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStatus(null))); | |
| 123 | - // 测试 startTime 不匹配 | |
| 124 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStartTime(null))); | |
| 125 | - // 测试 endTime 不匹配 | |
| 126 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setEndTime(null))); | |
| 127 | - // 测试 invalidTime 不匹配 | |
| 128 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setInvalidTime(null))); | |
| 129 | - // 测试 deleteTime 不匹配 | |
| 130 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setDeleteTime(null))); | |
| 131 | - // 测试 timeLimitedDiscount 不匹配 | |
| 132 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTimeLimitedDiscount(null))); | |
| 133 | - // 测试 fullPrivilege 不匹配 | |
| 134 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setFullPrivilege(null))); | |
| 135 | - // 测试 createTime 不匹配 | |
| 136 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setCreateTime(null))); | |
| 137 | - // 准备参数 | |
| 138 | - ActivityPageReqVO reqVO = new ActivityPageReqVO(); | |
| 139 | - reqVO.setTitle(null); | |
| 140 | - reqVO.setActivityType(null); | |
| 141 | - reqVO.setStatus(null); | |
| 142 | - reqVO.setStartTime(null); | |
| 143 | - reqVO.setEndTime(null); | |
| 144 | - reqVO.setInvalidTime(null); | |
| 145 | - reqVO.setDeleteTime(null); | |
| 146 | - reqVO.setTimeLimitedDiscount(null); | |
| 147 | - reqVO.setFullPrivilege(null); | |
| 148 | - reqVO.setCreateTime(null); | |
| 149 | - | |
| 150 | - // 调用 | |
| 151 | - PageResult<ActivityDO> pageResult = activityService.getActivityPage(reqVO); | |
| 152 | - // 断言 | |
| 153 | - assertEquals(1, pageResult.getTotal()); | |
| 154 | - assertEquals(1, pageResult.getList().size()); | |
| 155 | - assertPojoEquals(dbActivity, pageResult.getList().get(0)); | |
| 156 | - } | |
| 157 | - | |
| 158 | - @Test | |
| 159 | - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 160 | - public void testGetActivityList() { | |
| 161 | - // mock 数据 | |
| 162 | - ActivityDO dbActivity = randomPojo(ActivityDO.class, o -> { // 等会查询到 | |
| 163 | - o.setTitle(null); | |
| 164 | - o.setActivityType(null); | |
| 165 | - o.setStatus(null); | |
| 166 | - o.setStartTime(null); | |
| 167 | - o.setEndTime(null); | |
| 168 | - o.setInvalidTime(null); | |
| 169 | - o.setDeleteTime(null); | |
| 170 | - o.setTimeLimitedDiscount(null); | |
| 171 | - o.setFullPrivilege(null); | |
| 172 | - o.setCreateTime(null); | |
| 173 | - }); | |
| 174 | - activityMapper.insert(dbActivity); | |
| 175 | - // 测试 title 不匹配 | |
| 176 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTitle(null))); | |
| 177 | - // 测试 activityType 不匹配 | |
| 178 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setActivityType(null))); | |
| 179 | - // 测试 status 不匹配 | |
| 180 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStatus(null))); | |
| 181 | - // 测试 startTime 不匹配 | |
| 182 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setStartTime(null))); | |
| 183 | - // 测试 endTime 不匹配 | |
| 184 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setEndTime(null))); | |
| 185 | - // 测试 invalidTime 不匹配 | |
| 186 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setInvalidTime(null))); | |
| 187 | - // 测试 deleteTime 不匹配 | |
| 188 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setDeleteTime(null))); | |
| 189 | - // 测试 timeLimitedDiscount 不匹配 | |
| 190 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setTimeLimitedDiscount(null))); | |
| 191 | - // 测试 fullPrivilege 不匹配 | |
| 192 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setFullPrivilege(null))); | |
| 193 | - // 测试 createTime 不匹配 | |
| 194 | - activityMapper.insert(cloneIgnoreId(dbActivity, o -> o.setCreateTime(null))); | |
| 195 | - } | |
| 196 | - | |
| 197 | -} |