Commit d4b7f4aaa0b86f5ea9043d64dcb449da0a8fdee8
1 parent
00f90e75
promotion:增加限时折扣的基础代码
Showing
28 changed files
with
1139 additions
and
113 deletions
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| @@ -3,14 +3,19 @@ package cn.iocoder.yudao.module.promotion.enums; | @@ -3,14 +3,19 @@ package cn.iocoder.yudao.module.promotion.enums; | ||
| 3 | import cn.iocoder.yudao.framework.common.exception.ErrorCode; | 3 | import cn.iocoder.yudao.framework.common.exception.ErrorCode; |
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | - * market 错误码枚举类 | ||
| 7 | - * <p> | 6 | + * promotion 错误码枚举类 |
| 7 | + * | ||
| 8 | * market 系统,使用 1-003-000-000 段 | 8 | * market 系统,使用 1-003-000-000 段 |
| 9 | */ | 9 | */ |
| 10 | public interface ErrorCodeConstants { | 10 | public interface ErrorCodeConstants { |
| 11 | 11 | ||
| 12 | - // ========== 促销活动相关 1003001000 ============ TODO 芋艿:看看是不是要删除掉 | ||
| 13 | - ErrorCode ACTIVITY_NOT_EXISTS = new ErrorCode(1003001000, "促销活动不存在"); | 12 | + // ========== 促销活动相关 1003001000 ============ |
| 13 | + ErrorCode DISCOUNT_ACTIVITY_NOT_EXISTS = new ErrorCode(1003001000, "限时折扣活动不存在"); | ||
| 14 | + ErrorCode DISCOUNT_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1003006001, "存在商品参加了其它限时折扣活动"); | ||
| 15 | + ErrorCode DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1003006002, "限时折扣活动已关闭,不能修改"); | ||
| 16 | + ErrorCode DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1003006003, "限时折扣活动未关闭,不能删除"); | ||
| 17 | + ErrorCode DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1003006004, "限时折扣活动已关闭,不能重复关闭"); | ||
| 18 | + ErrorCode DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1003006004, "限时折扣活动已结束,不能关闭"); | ||
| 14 | 19 | ||
| 15 | // ========== Banner 相关 1003002000 ============ | 20 | // ========== Banner 相关 1003002000 ============ |
| 16 | ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1003002000, "Banner 不存在"); | 21 | ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1003002000, "Banner 不存在"); |
| @@ -29,7 +34,7 @@ public interface ErrorCodeConstants { | @@ -29,7 +34,7 @@ public interface ErrorCodeConstants { | ||
| 29 | 34 | ||
| 30 | // ========== 满减送活动 1003006000 ========== | 35 | // ========== 满减送活动 1003006000 ========== |
| 31 | ErrorCode REWARD_ACTIVITY_NOT_EXISTS = new ErrorCode(1003006000, "满减送活动不存在"); | 36 | ErrorCode REWARD_ACTIVITY_NOT_EXISTS = new ErrorCode(1003006000, "满减送活动不存在"); |
| 32 | - ErrorCode REWARD_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1003006001, "商品({}) 已经参加满减送活动({})"); | 37 | + ErrorCode REWARD_ACTIVITY_SPU_CONFLICTS = new ErrorCode(1003006001, "存在商品参加了其它满减送活动"); |
| 33 | ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1003006002, "满减送活动已关闭,不能修改"); | 38 | ErrorCode REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED = new ErrorCode(1003006002, "满减送活动已关闭,不能修改"); |
| 34 | ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1003006003, "满减送活动未关闭,不能删除"); | 39 | ErrorCode REWARD_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED = new ErrorCode(1003006003, "满减送活动未关闭,不能删除"); |
| 35 | ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1003006004, "满减送活动已关闭,不能重复关闭"); | 40 | ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1003006004, "满减送活动已关闭,不能重复关闭"); |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/DiscountActivityController.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.discount; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; | ||
| 12 | +import io.swagger.annotations.Api; | ||
| 13 | +import io.swagger.annotations.ApiImplicitParam; | ||
| 14 | +import io.swagger.annotations.ApiOperation; | ||
| 15 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 16 | +import org.springframework.validation.annotation.Validated; | ||
| 17 | +import org.springframework.web.bind.annotation.*; | ||
| 18 | + | ||
| 19 | +import javax.annotation.Resource; | ||
| 20 | +import javax.validation.Valid; | ||
| 21 | + | ||
| 22 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 23 | + | ||
| 24 | +@Api(tags = "管理后台 - 限时折扣活动") | ||
| 25 | +@RestController | ||
| 26 | +@RequestMapping("/promotion/discount-activity") | ||
| 27 | +@Validated | ||
| 28 | +public class DiscountActivityController { | ||
| 29 | + | ||
| 30 | + @Resource | ||
| 31 | + private DiscountActivityService discountActivityService; | ||
| 32 | + | ||
| 33 | + @PostMapping("/create") | ||
| 34 | + @ApiOperation("创建限时折扣活动") | ||
| 35 | + @PreAuthorize("@ss.hasPermission('promotion:discount-activity:create')") | ||
| 36 | + public CommonResult<Long> createDiscountActivity(@Valid @RequestBody DiscountActivityCreateReqVO createReqVO) { | ||
| 37 | + return success(discountActivityService.createDiscountActivity(createReqVO)); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @PutMapping("/update") | ||
| 41 | + @ApiOperation("更新限时折扣活动") | ||
| 42 | + @PreAuthorize("@ss.hasPermission('promotion:discount-activity:update')") | ||
| 43 | + public CommonResult<Boolean> updateDiscountActivity(@Valid @RequestBody DiscountActivityUpdateReqVO updateReqVO) { | ||
| 44 | + discountActivityService.updateDiscountActivity(updateReqVO); | ||
| 45 | + return success(true); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @PutMapping("/close") | ||
| 49 | + @ApiOperation("关闭限时折扣活动") | ||
| 50 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | ||
| 51 | + @PreAuthorize("@ss.hasPermission('promotion:discount-activity:close')") | ||
| 52 | + public CommonResult<Boolean> closeRewardActivity(@RequestParam("id") Long id) { | ||
| 53 | + discountActivityService.closeRewardActivity(id); | ||
| 54 | + return success(true); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @DeleteMapping("/delete") | ||
| 58 | + @ApiOperation("删除限时折扣活动") | ||
| 59 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | ||
| 60 | + @PreAuthorize("@ss.hasPermission('promotion:discount-activity:delete')") | ||
| 61 | + public CommonResult<Boolean> deleteDiscountActivity(@RequestParam("id") Long id) { | ||
| 62 | + discountActivityService.deleteDiscountActivity(id); | ||
| 63 | + return success(true); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @GetMapping("/get") | ||
| 67 | + @ApiOperation("获得限时折扣活动") | ||
| 68 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | ||
| 69 | + @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") | ||
| 70 | + public CommonResult<DiscountActivityRespVO> getDiscountActivity(@RequestParam("id") Long id) { | ||
| 71 | + DiscountActivityDO discountActivity = discountActivityService.getDiscountActivity(id); | ||
| 72 | + return success(DiscountActivityConvert.INSTANCE.convert(discountActivity)); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @GetMapping("/page") | ||
| 76 | + @ApiOperation("获得限时折扣活动分页") | ||
| 77 | + @PreAuthorize("@ss.hasPermission('promotion:discount-activity:query')") | ||
| 78 | + public CommonResult<PageResult<DiscountActivityRespVO>> getDiscountActivityPage(@Valid DiscountActivityPageReqVO pageVO) { | ||
| 79 | + PageResult<DiscountActivityDO> pageResult = discountActivityService.getDiscountActivityPage(pageVO); | ||
| 80 | + return success(DiscountActivityConvert.INSTANCE.convertPage(pageResult)); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/package-info.java deleted
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityBaseVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 7 | + | ||
| 8 | +import javax.validation.constraints.Min; | ||
| 9 | +import javax.validation.constraints.NotNull; | ||
| 10 | +import java.util.Date; | ||
| 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 DiscountActivityBaseVO { | ||
| 20 | + | ||
| 21 | + @ApiModelProperty(value = "活动标题", required = true, example = "一个标题") | ||
| 22 | + @NotNull(message = "活动标题不能为空") | ||
| 23 | + private String name; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty(value = "开始时间", required = true) | ||
| 26 | + @NotNull(message = "开始时间不能为空") | ||
| 27 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 28 | + private Date startTime; | ||
| 29 | + | ||
| 30 | + @ApiModelProperty(value = "结束时间", required = true) | ||
| 31 | + @NotNull(message = "结束时间不能为空") | ||
| 32 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 33 | + private Date endTime; | ||
| 34 | + | ||
| 35 | + @ApiModelProperty(value = "备注", example = "我是备注") | ||
| 36 | + private String remark; | ||
| 37 | + | ||
| 38 | + @ApiModel("商品") | ||
| 39 | + @Data | ||
| 40 | + public static class Product { | ||
| 41 | + | ||
| 42 | + @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1") | ||
| 43 | + @NotNull(message = "商品 SPU 编号不能为空") | ||
| 44 | + private Long spuId; | ||
| 45 | + | ||
| 46 | + @ApiModelProperty(value = "商品 SKU 编号", required = true, example = "1") | ||
| 47 | + @NotNull(message = "商品 SKU 编号不能为空") | ||
| 48 | + private Long skuId; | ||
| 49 | + | ||
| 50 | + @ApiModelProperty(value = "折扣价格,单位:分", required = true, example = "1000") | ||
| 51 | + @NotNull(message = "折扣价格不能为空") | ||
| 52 | + @Min(value = 1, message = "折扣价格必须大于 0") | ||
| 53 | + private Integer discountPrice; | ||
| 54 | + | ||
| 55 | + } | ||
| 56 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityCreateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import lombok.EqualsAndHashCode; | ||
| 6 | +import lombok.ToString; | ||
| 7 | + | ||
| 8 | +import javax.validation.constraints.NotNull; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +@ApiModel("管理后台 - 限时折扣活动创建 Request VO") | ||
| 12 | +@Data | ||
| 13 | +@EqualsAndHashCode(callSuper = true) | ||
| 14 | +@ToString(callSuper = true) | ||
| 15 | +public class DiscountActivityCreateReqVO extends DiscountActivityBaseVO { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 商品列表 | ||
| 19 | + */ | ||
| 20 | + @NotNull(message = "商品列表不能为空") | ||
| 21 | + private List<Product> products; | ||
| 22 | + | ||
| 23 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityPageReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import io.swagger.annotations.*; | ||
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 8 | + | ||
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 10 | + | ||
| 11 | +@ApiModel("管理后台 - 限时折扣活动分页 Request VO") | ||
| 12 | +@Data | ||
| 13 | +@EqualsAndHashCode(callSuper = true) | ||
| 14 | +@ToString(callSuper = true) | ||
| 15 | +public class DiscountActivityPageReqVO extends PageParam { | ||
| 16 | + | ||
| 17 | + @ApiModelProperty(value = "活动标题", example = "一个标题") | ||
| 18 | + private String name; | ||
| 19 | + | ||
| 20 | + @ApiModelProperty(value = "活动状态", example = "1") | ||
| 21 | + private Integer status; | ||
| 22 | + | ||
| 23 | + @ApiModelProperty(value = "创建时间") | ||
| 24 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 25 | + private Date[] createTime; | ||
| 26 | + | ||
| 27 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityRespVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | + | ||
| 9 | +import javax.validation.constraints.NotNull; | ||
| 10 | +import java.util.Date; | ||
| 11 | + | ||
| 12 | +@ApiModel("管理后台 - 限时折扣活动 Response VO") | ||
| 13 | +@Data | ||
| 14 | +@EqualsAndHashCode(callSuper = true) | ||
| 15 | +@ToString(callSuper = true) | ||
| 16 | +public class DiscountActivityRespVO extends DiscountActivityBaseVO { | ||
| 17 | + | ||
| 18 | + @ApiModelProperty(value = "活动编号", required = true, example = "1024") | ||
| 19 | + private Long id; | ||
| 20 | + | ||
| 21 | + @ApiModelProperty(value = "活动状态", required = true, example = "1") | ||
| 22 | + @NotNull(message = "活动状态不能为空") | ||
| 23 | + private Integer status; | ||
| 24 | + | ||
| 25 | + @ApiModelProperty(value = "创建时间", required = true) | ||
| 26 | + private Date createTime; | ||
| 27 | + | ||
| 28 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/discount/vo/DiscountActivityUpdateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.discount.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.annotations.ApiModel; | ||
| 4 | +import io.swagger.annotations.ApiModelProperty; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | + | ||
| 9 | +import javax.validation.constraints.NotNull; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +@ApiModel("管理后台 - 限时折扣活动更新 Request VO") | ||
| 13 | +@Data | ||
| 14 | +@EqualsAndHashCode(callSuper = true) | ||
| 15 | +@ToString(callSuper = true) | ||
| 16 | +public class DiscountActivityUpdateReqVO extends DiscountActivityBaseVO { | ||
| 17 | + | ||
| 18 | + @ApiModelProperty(value = "活动编号", required = true, example = "1024") | ||
| 19 | + @NotNull(message = "活动编号不能为空") | ||
| 20 | + private Long id; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 商品列表 | ||
| 24 | + */ | ||
| 25 | + @NotNull(message = "商品列表不能为空") | ||
| 26 | + private List<DiscountActivityCreateReqVO.Product> products; | ||
| 27 | + | ||
| 28 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/DiscountActivityConvert.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.convert.discount; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityRespVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; | ||
| 12 | +import org.mapstruct.Mapper; | ||
| 13 | +import org.mapstruct.factory.Mappers; | ||
| 14 | + | ||
| 15 | +import java.util.List; | ||
| 16 | +import java.util.Map; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 限时折扣活动 Convert | ||
| 20 | + * | ||
| 21 | + * @author 芋道源码 | ||
| 22 | + */ | ||
| 23 | +@Mapper | ||
| 24 | +public interface DiscountActivityConvert { | ||
| 25 | + | ||
| 26 | + DiscountActivityConvert INSTANCE = Mappers.getMapper(DiscountActivityConvert.class); | ||
| 27 | + | ||
| 28 | + DiscountActivityDO convert(DiscountActivityCreateReqVO bean); | ||
| 29 | + | ||
| 30 | + DiscountActivityDO convert(DiscountActivityUpdateReqVO bean); | ||
| 31 | + | ||
| 32 | + DiscountActivityRespVO convert(DiscountActivityDO bean); | ||
| 33 | + | ||
| 34 | + List<DiscountActivityRespVO> convertList(List<DiscountActivityDO> list); | ||
| 35 | + | ||
| 36 | + PageResult<DiscountActivityRespVO> convertPage(PageResult<DiscountActivityDO> page); | ||
| 37 | + | ||
| 38 | + DiscountProductDetailBO convert(DiscountProductDO product); | ||
| 39 | + | ||
| 40 | + default List<DiscountProductDetailBO> convertList(List<DiscountProductDO> products, Map<Long, DiscountActivityDO> activityMap) { | ||
| 41 | + return CollectionUtils.convertList(products, product -> { | ||
| 42 | + DiscountProductDetailBO detail = convert(product); | ||
| 43 | + MapUtils.findAndThen(activityMap, product.getActivityId(), activity -> { | ||
| 44 | + detail.setActivityName(activity.getName()); | ||
| 45 | + }); | ||
| 46 | + return detail; | ||
| 47 | + }); | ||
| 48 | + } | ||
| 49 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/discount/package-info.java deleted
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/discount/DiscountProductDO.java
| @@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.annotation.TableName; | @@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.annotation.TableName; | ||
| 7 | import lombok.Data; | 7 | import lombok.Data; |
| 8 | import lombok.EqualsAndHashCode; | 8 | import lombok.EqualsAndHashCode; |
| 9 | 9 | ||
| 10 | -import java.util.Date; | ||
| 11 | - | ||
| 12 | /** | 10 | /** |
| 13 | * 限时折扣商品 DO | 11 | * 限时折扣商品 DO |
| 14 | * | 12 | * |
| @@ -32,12 +30,6 @@ public class DiscountProductDO extends BaseDO { | @@ -32,12 +30,6 @@ public class DiscountProductDO extends BaseDO { | ||
| 32 | */ | 30 | */ |
| 33 | private Long activityId; | 31 | private Long activityId; |
| 34 | /** | 32 | /** |
| 35 | - * 限时折扣活动的名字 | ||
| 36 | - * | ||
| 37 | - * 冗余 {@link DiscountActivityDO#getName()} | ||
| 38 | - */ | ||
| 39 | - private String activityName; | ||
| 40 | - /** | ||
| 41 | * 商品 SPU 编号 | 33 | * 商品 SPU 编号 |
| 42 | * | 34 | * |
| 43 | * 关联 ProductSpuDO 的 id 编号 | 35 | * 关联 ProductSpuDO 的 id 编号 |
| @@ -50,22 +42,8 @@ public class DiscountProductDO extends BaseDO { | @@ -50,22 +42,8 @@ public class DiscountProductDO extends BaseDO { | ||
| 50 | */ | 42 | */ |
| 51 | private Long skuId; | 43 | private Long skuId; |
| 52 | /** | 44 | /** |
| 53 | - * 开始时间 | ||
| 54 | - */ | ||
| 55 | - private Date startTime; | ||
| 56 | - /** | ||
| 57 | - * 结束时间 | ||
| 58 | - */ | ||
| 59 | - private Date endTime; | ||
| 60 | - /** | ||
| 61 | - * 销售价格,单位:分 | ||
| 62 | - * | ||
| 63 | - * 冗余 ProductSkuDO 的 price 字段 | ||
| 64 | - */ | ||
| 65 | - private Integer originalPrice; | ||
| 66 | - /** | ||
| 67 | * 优惠价格,单位:分 | 45 | * 优惠价格,单位:分 |
| 68 | */ | 46 | */ |
| 69 | - private Integer promotionPrice; | 47 | + private Integer discountPrice; |
| 70 | 48 | ||
| 71 | } | 49 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountActivityMapper.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.dal.mysql.discount; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +import java.util.Collection; | ||
| 11 | +import java.util.List; | ||
| 12 | +import java.util.Set; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 限时折扣活动 Mapper | ||
| 16 | + * | ||
| 17 | + * @author 芋道源码 | ||
| 18 | + */ | ||
| 19 | +@Mapper | ||
| 20 | +public interface DiscountActivityMapper extends BaseMapperX<DiscountActivityDO> { | ||
| 21 | + | ||
| 22 | + default PageResult<DiscountActivityDO> selectPage(DiscountActivityPageReqVO reqVO) { | ||
| 23 | + return selectPage(reqVO, new LambdaQueryWrapperX<DiscountActivityDO>() | ||
| 24 | + .likeIfPresent(DiscountActivityDO::getName, reqVO.getName()) | ||
| 25 | + .eqIfPresent(DiscountActivityDO::getStatus, reqVO.getStatus()) | ||
| 26 | + .betweenIfPresent(DiscountActivityDO::getCreateTime, reqVO.getCreateTime()) | ||
| 27 | + .orderByDesc(DiscountActivityDO::getId)); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/DiscountProductMapper.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.dal.mysql.discount; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; | ||
| 5 | +import org.apache.ibatis.annotations.Mapper; | ||
| 6 | + | ||
| 7 | +import java.util.Collection; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 限时折扣商城 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface DiscountProductMapper extends BaseMapperX<DiscountProductDO> { | ||
| 17 | + | ||
| 18 | + default List<DiscountProductDO> selectListBySkuId(Collection<Long> skuIds) { | ||
| 19 | + return selectList(DiscountProductDO::getSkuId, skuIds); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/discount/package-info.java deleted
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/reward/RewardActivityMapper.java
| @@ -7,6 +7,9 @@ import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivi | @@ -7,6 +7,9 @@ import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivi | ||
| 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | ||
| 10 | +import java.util.Collection; | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 10 | /** | 13 | /** |
| 11 | * 满减送活动 Mapper | 14 | * 满减送活动 Mapper |
| 12 | * | 15 | * |
| @@ -22,4 +25,8 @@ public interface RewardActivityMapper extends BaseMapperX<RewardActivityDO> { | @@ -22,4 +25,8 @@ public interface RewardActivityMapper extends BaseMapperX<RewardActivityDO> { | ||
| 22 | .orderByDesc(RewardActivityDO::getId)); | 25 | .orderByDesc(RewardActivityDO::getId)); |
| 23 | } | 26 | } |
| 24 | 27 | ||
| 28 | + default List<RewardActivityDO> selectListByStatus(Collection<Integer> statuses) { | ||
| 29 | + return selectList(RewardActivityDO::getStatus, statuses); | ||
| 30 | + } | ||
| 31 | + | ||
| 25 | } | 32 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.discount; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; | ||
| 9 | + | ||
| 10 | +import javax.validation.Valid; | ||
| 11 | +import java.util.Collection; | ||
| 12 | +import java.util.Map; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 限时折扣 Service 接口 | ||
| 16 | + * | ||
| 17 | + * @author 芋道源码 | ||
| 18 | + */ | ||
| 19 | +public interface DiscountActivityService { | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 基于指定 SKU 编号数组,获得匹配的限时折扣商品 | ||
| 23 | + * | ||
| 24 | + * 注意,匹配的条件,仅仅是日期符合,并且处于开启状态 | ||
| 25 | + * | ||
| 26 | + * @param skuIds SKU 编号数组 | ||
| 27 | + * @return 匹配的限时折扣商品 | ||
| 28 | + */ | ||
| 29 | + Map<Long, DiscountProductDO> getMatchDiscountProducts(Collection<Long> skuIds); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 创建限时折扣活动 | ||
| 33 | + * | ||
| 34 | + * @param createReqVO 创建信息 | ||
| 35 | + * @return 编号 | ||
| 36 | + */ | ||
| 37 | + Long createDiscountActivity(@Valid DiscountActivityCreateReqVO createReqVO); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 更新限时折扣活动 | ||
| 41 | + * | ||
| 42 | + * @param updateReqVO 更新信息 | ||
| 43 | + */ | ||
| 44 | + void updateDiscountActivity(@Valid DiscountActivityUpdateReqVO updateReqVO); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 关闭限时折扣活动 | ||
| 48 | + * | ||
| 49 | + * @param id 编号 | ||
| 50 | + */ | ||
| 51 | + void closeRewardActivity(Long id); | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * 删除限时折扣活动 | ||
| 55 | + * | ||
| 56 | + * @param id 编号 | ||
| 57 | + */ | ||
| 58 | + void deleteDiscountActivity(Long id); | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 获得限时折扣活动 | ||
| 62 | + * | ||
| 63 | + * @param id 编号 | ||
| 64 | + * @return 限时折扣活动 | ||
| 65 | + */ | ||
| 66 | + DiscountActivityDO getDiscountActivity(Long id); | ||
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * 获得限时折扣活动分页 | ||
| 70 | + * | ||
| 71 | + * @param pageReqVO 分页查询 | ||
| 72 | + * @return 限时折扣活动分页 | ||
| 73 | + */ | ||
| 74 | + PageResult<DiscountActivityDO> getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO); | ||
| 75 | + | ||
| 76 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.discount; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityBaseVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.convert.discount.DiscountActivityConvert; | ||
| 11 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; | ||
| 12 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; | ||
| 13 | +import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountActivityMapper; | ||
| 14 | +import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountProductMapper; | ||
| 15 | +import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; | ||
| 16 | +import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; | ||
| 17 | +import cn.iocoder.yudao.module.promotion.util.PromotionUtils; | ||
| 18 | +import org.springframework.stereotype.Service; | ||
| 19 | +import org.springframework.validation.annotation.Validated; | ||
| 20 | + | ||
| 21 | +import javax.annotation.Resource; | ||
| 22 | +import java.util.*; | ||
| 23 | + | ||
| 24 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 25 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 26 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; | ||
| 27 | +import static java.util.Arrays.asList; | ||
| 28 | + | ||
| 29 | +/** | ||
| 30 | + * 限时折扣 Service 实现类 | ||
| 31 | + * | ||
| 32 | + * @author 芋道源码 | ||
| 33 | + */ | ||
| 34 | +@Service | ||
| 35 | +@Validated | ||
| 36 | +public class DiscountActivityServiceImpl implements DiscountActivityService { | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private DiscountActivityMapper discountActivityMapper; | ||
| 40 | + @Resource | ||
| 41 | + private DiscountProductMapper discountProductMapper; | ||
| 42 | + | ||
| 43 | + // TODO 芋艿:待实现 | ||
| 44 | + @Override | ||
| 45 | + public Map<Long, DiscountProductDO> getMatchDiscountProducts(Collection<Long> skuIds) { | ||
| 46 | + Map<Long, DiscountProductDO> products = new HashMap<>(); | ||
| 47 | + products.put(1L, new DiscountProductDO().setDiscountPrice(100)); | ||
| 48 | + products.put(2L, new DiscountProductDO().setDiscountPrice(50)); | ||
| 49 | + return products; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @Override | ||
| 53 | + public Long createDiscountActivity(DiscountActivityCreateReqVO createReqVO) { | ||
| 54 | + // 校验商品是否冲突 | ||
| 55 | + validateDiscountActivityProductConflicts(null, createReqVO.getProducts()); | ||
| 56 | + | ||
| 57 | + // 插入 | ||
| 58 | + DiscountActivityDO discountActivity = DiscountActivityConvert.INSTANCE.convert(createReqVO) | ||
| 59 | + .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime())); | ||
| 60 | + discountActivityMapper.insert(discountActivity); | ||
| 61 | + // 返回 | ||
| 62 | + return discountActivity.getId(); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Override | ||
| 66 | + public void updateDiscountActivity(DiscountActivityUpdateReqVO updateReqVO) { | ||
| 67 | + // 校验存在 | ||
| 68 | + DiscountActivityDO discountActivity = validateDiscountActivityExists(updateReqVO.getId()); | ||
| 69 | + if (discountActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能修改噢 | ||
| 70 | + throw exception(DISCOUNT_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); | ||
| 71 | + } | ||
| 72 | + // 校验商品是否冲突 | ||
| 73 | + validateDiscountActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts()); | ||
| 74 | + | ||
| 75 | + // 更新 | ||
| 76 | + DiscountActivityDO updateObj = DiscountActivityConvert.INSTANCE.convert(updateReqVO) | ||
| 77 | + .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getStartTime(), updateReqVO.getEndTime())); | ||
| 78 | + discountActivityMapper.updateById(updateObj); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 校验商品是否冲突 | ||
| 84 | + * | ||
| 85 | + * @param id 编号 | ||
| 86 | + * @param products 商品列表 | ||
| 87 | + */ | ||
| 88 | + private void validateDiscountActivityProductConflicts(Long id, List<DiscountActivityBaseVO.Product> products) { | ||
| 89 | + if (CollUtil.isEmpty(products)) { | ||
| 90 | + return; | ||
| 91 | + } | ||
| 92 | + // 查询商品参加的活动 | ||
| 93 | + List<DiscountProductDetailBO> discountActivityProductList = getRewardActivityListBySkuIds( | ||
| 94 | + convertSet(products, DiscountActivityBaseVO.Product::getSkuId), | ||
| 95 | + asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus())); | ||
| 96 | + if (id != null) { // 排除自己这个活动 | ||
| 97 | + discountActivityProductList.removeIf(product -> id.equals(product.getActivityId())); | ||
| 98 | + } | ||
| 99 | + // 如果非空,则说明冲突 | ||
| 100 | + if (CollUtil.isNotEmpty(discountActivityProductList)) { | ||
| 101 | + throw exception(DISCOUNT_ACTIVITY_SPU_CONFLICTS); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + private List<DiscountProductDetailBO> getRewardActivityListBySkuIds(Collection<Long> skuIds, | ||
| 106 | + Collection<Integer> statuses) { | ||
| 107 | + // 查询商品 | ||
| 108 | + List<DiscountProductDO> products = discountProductMapper.selectListBySkuId(skuIds); | ||
| 109 | + if (CollUtil.isEmpty(products)) { | ||
| 110 | + return new ArrayList<>(0); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + // 查询活动 | ||
| 114 | + List<DiscountActivityDO> activities = discountActivityMapper.selectBatchIds(skuIds); | ||
| 115 | + activities.removeIf(activity -> !statuses.contains(activity.getStatus())); // 移除不满足 statuses 状态的 | ||
| 116 | + Map<Long, DiscountActivityDO> activityMap = CollectionUtils.convertMap(activities, DiscountActivityDO::getId); | ||
| 117 | + | ||
| 118 | + // 移除不满足活动的商品 | ||
| 119 | + products.removeIf(product -> !activityMap.containsKey(product.getActivityId())); | ||
| 120 | + return DiscountActivityConvert.INSTANCE.convertList(products, activityMap); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + @Override | ||
| 124 | + public void closeRewardActivity(Long id) { | ||
| 125 | + // 校验存在 | ||
| 126 | + DiscountActivityDO dbDiscountActivity = validateDiscountActivityExists(id); | ||
| 127 | + if (dbDiscountActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能关闭噢 | ||
| 128 | + throw exception(DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED); | ||
| 129 | + } | ||
| 130 | + if (dbDiscountActivity.getStatus().equals(PromotionActivityStatusEnum.END.getStatus())) { // 已关闭的活动,不能关闭噢 | ||
| 131 | + throw exception(DISCOUNT_ACTIVITY_CLOSE_FAIL_STATUS_END); | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + // 更新 | ||
| 135 | + DiscountActivityDO updateObj = new DiscountActivityDO().setId(id).setStatus(PromotionActivityStatusEnum.CLOSE.getStatus()); | ||
| 136 | + discountActivityMapper.updateById(updateObj); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + @Override | ||
| 140 | + public void deleteDiscountActivity(Long id) { | ||
| 141 | + // 校验存在 | ||
| 142 | + DiscountActivityDO discountActivity = validateDiscountActivityExists(id); | ||
| 143 | + if (!discountActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 未关闭的活动,不能删除噢 | ||
| 144 | + throw exception(DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED); | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + // 删除 | ||
| 148 | + discountActivityMapper.deleteById(id); | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + private DiscountActivityDO validateDiscountActivityExists(Long id) { | ||
| 152 | + DiscountActivityDO discountActivity = discountActivityMapper.selectById(id); | ||
| 153 | + if (discountActivity == null) { | ||
| 154 | + throw exception(DISCOUNT_ACTIVITY_NOT_EXISTS); | ||
| 155 | + } | ||
| 156 | + return discountActivity; | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + @Override | ||
| 160 | + public DiscountActivityDO getDiscountActivity(Long id) { | ||
| 161 | + return discountActivityMapper.selectById(id); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + @Override | ||
| 165 | + public PageResult<DiscountActivityDO> getDiscountActivityPage(DiscountActivityPageReqVO pageReqVO) { | ||
| 166 | + return discountActivityMapper.selectPage(pageReqVO); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountService.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.service.discount; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; | ||
| 4 | - | ||
| 5 | -import java.util.Collection; | ||
| 6 | -import java.util.Map; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 限时折扣 Service 接口 | ||
| 10 | - * | ||
| 11 | - * @author 芋道源码 | ||
| 12 | - */ | ||
| 13 | -public interface DiscountService { | ||
| 14 | - | ||
| 15 | - /** | ||
| 16 | - * 基于指定 SKU 编号数组,获得匹配的限时折扣商品 | ||
| 17 | - * | ||
| 18 | - * 注意,匹配的条件,仅仅是日期符合,并且处于开启状态 | ||
| 19 | - * | ||
| 20 | - * @param skuIds SKU 编号数组 | ||
| 21 | - * @return 匹配的限时折扣商品 | ||
| 22 | - */ | ||
| 23 | - Map<Long, DiscountProductDO> getMatchDiscountProducts(Collection<Long> skuIds); | ||
| 24 | - | ||
| 25 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.promotion.service.discount; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; | ||
| 4 | -import org.springframework.stereotype.Service; | ||
| 5 | -import org.springframework.validation.annotation.Validated; | ||
| 6 | - | ||
| 7 | -import java.util.Collection; | ||
| 8 | -import java.util.HashMap; | ||
| 9 | -import java.util.Map; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * 限时折扣 Service 实现类 | ||
| 13 | - * | ||
| 14 | - * @author 芋道源码 | ||
| 15 | - */ | ||
| 16 | -@Service | ||
| 17 | -@Validated | ||
| 18 | -public class DiscountServiceImpl implements DiscountService { | ||
| 19 | - | ||
| 20 | - // TODO 芋艿:待实现 | ||
| 21 | - @Override | ||
| 22 | - public Map<Long, DiscountProductDO> getMatchDiscountProducts(Collection<Long> skuIds) { | ||
| 23 | - Map<Long, DiscountProductDO> products = new HashMap<>(); | ||
| 24 | - products.put(1L, new DiscountProductDO().setPromotionPrice(100)); | ||
| 25 | - products.put(2L, new DiscountProductDO().setPromotionPrice(50)); | ||
| 26 | - return products; | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | -} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/bo/DiscountProductDetailBO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.service.discount.bo; | ||
| 2 | + | ||
| 3 | +import lombok.Data; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 限时折扣活动商品 BO | ||
| 7 | + * | ||
| 8 | + * @author 芋道源码 | ||
| 9 | + */ | ||
| 10 | +@Data | ||
| 11 | +public class DiscountProductDetailBO { | ||
| 12 | + | ||
| 13 | + // ========== DiscountProductDO 字段 ========== | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 编号,主键自增 | ||
| 17 | + */ | ||
| 18 | + private Long id; | ||
| 19 | + /** | ||
| 20 | + * 限时折扣活动的编号 | ||
| 21 | + */ | ||
| 22 | + private Long activityId; | ||
| 23 | + /** | ||
| 24 | + * 商品 SPU 编号 | ||
| 25 | + */ | ||
| 26 | + private Long spuId; | ||
| 27 | + /** | ||
| 28 | + * 商品 SKU 编号 | ||
| 29 | + */ | ||
| 30 | + private Long skuId; | ||
| 31 | + /** | ||
| 32 | + * 优惠价格,单位:分 | ||
| 33 | + */ | ||
| 34 | + private Integer discountPrice; | ||
| 35 | + | ||
| 36 | + // ========== DiscountActivityDO 字段 ========== | ||
| 37 | + /** | ||
| 38 | + * 活动标题 | ||
| 39 | + */ | ||
| 40 | + private String activityName; | ||
| 41 | + | ||
| 42 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceImpl.java
| @@ -12,7 +12,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProduct | @@ -12,7 +12,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProduct | ||
| 12 | import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; | 12 | import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; |
| 13 | import cn.iocoder.yudao.module.promotion.enums.common.*; | 13 | import cn.iocoder.yudao.module.promotion.enums.common.*; |
| 14 | import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; | 14 | import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; |
| 15 | -import cn.iocoder.yudao.module.promotion.service.discount.DiscountService; | 15 | +import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; |
| 16 | import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; | 16 | import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; |
| 17 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | 17 | import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 18 | import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; | 18 | import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; |
| @@ -54,7 +54,7 @@ import static java.util.Collections.singletonList; | @@ -54,7 +54,7 @@ import static java.util.Collections.singletonList; | ||
| 54 | public class PriceServiceImpl implements PriceService { | 54 | public class PriceServiceImpl implements PriceService { |
| 55 | 55 | ||
| 56 | @Resource | 56 | @Resource |
| 57 | - private DiscountService discountService; | 57 | + private DiscountActivityService discountService; |
| 58 | @Resource | 58 | @Resource |
| 59 | private RewardActivityService rewardActivityService; | 59 | private RewardActivityService rewardActivityService; |
| 60 | @Resource | 60 | @Resource |
| @@ -121,7 +121,7 @@ public class PriceServiceImpl implements PriceService { | @@ -121,7 +121,7 @@ public class PriceServiceImpl implements PriceService { | ||
| 121 | Double memberDiscountPercent = memberDiscountPercentSupplier.get(); | 121 | Double memberDiscountPercent = memberDiscountPercentSupplier.get(); |
| 122 | DiscountProductDO discountProduct = discountProducts.get(orderItem.getSkuId()); | 122 | DiscountProductDO discountProduct = discountProducts.get(orderItem.getSkuId()); |
| 123 | if (discountProduct != null // 假设优惠价格更贵,则认为没优惠 | 123 | if (discountProduct != null // 假设优惠价格更贵,则认为没优惠 |
| 124 | - && discountProduct.getPromotionPrice() >= orderItem.getOriginalUnitPrice()) { | 124 | + && discountProduct.getDiscountPrice() >= orderItem.getOriginalUnitPrice()) { |
| 125 | discountProduct = null; | 125 | discountProduct = null; |
| 126 | } | 126 | } |
| 127 | if (memberDiscountPercent == null && discountProduct == null) { | 127 | if (memberDiscountPercent == null && discountProduct == null) { |
| @@ -129,7 +129,7 @@ public class PriceServiceImpl implements PriceService { | @@ -129,7 +129,7 @@ public class PriceServiceImpl implements PriceService { | ||
| 129 | } | 129 | } |
| 130 | // 计算价格,判断选择哪个折扣 | 130 | // 计算价格,判断选择哪个折扣 |
| 131 | Integer memberPrice = memberDiscountPercent != null ? (int) (orderItem.getPayPrice() * memberDiscountPercent / 100) : null; | 131 | Integer memberPrice = memberDiscountPercent != null ? (int) (orderItem.getPayPrice() * memberDiscountPercent / 100) : null; |
| 132 | - Integer promotionPrice = discountProduct != null ? discountProduct.getPromotionPrice() * orderItem.getCount() : null; | 132 | + Integer promotionPrice = discountProduct != null ? discountProduct.getDiscountPrice() * orderItem.getCount() : null; |
| 133 | if (memberPrice == null) { | 133 | if (memberPrice == null) { |
| 134 | calculatePriceByDiscountActivity(priceCalculate, orderItem, discountProduct, promotionPrice); | 134 | calculatePriceByDiscountActivity(priceCalculate, orderItem, discountProduct, promotionPrice); |
| 135 | } else if (promotionPrice == null) { | 135 | } else if (promotionPrice == null) { |
| @@ -155,7 +155,8 @@ public class PriceServiceImpl implements PriceService { | @@ -155,7 +155,8 @@ public class PriceServiceImpl implements PriceService { | ||
| 155 | private void calculatePriceByDiscountActivity(PriceCalculateRespDTO priceCalculate, PriceCalculateRespDTO.OrderItem orderItem, | 155 | private void calculatePriceByDiscountActivity(PriceCalculateRespDTO priceCalculate, PriceCalculateRespDTO.OrderItem orderItem, |
| 156 | DiscountProductDO discountProduct, Integer promotionPrice) { | 156 | DiscountProductDO discountProduct, Integer promotionPrice) { |
| 157 | // 记录优惠明细 | 157 | // 记录优惠明细 |
| 158 | - addPromotion(priceCalculate, orderItem, discountProduct.getActivityId(), discountProduct.getActivityName(), | 158 | + addPromotion(priceCalculate, orderItem, discountProduct.getActivityId(), null |
| 159 | + /* TODO 芋艿:修复下 discountProduct.getActivityName()*/, | ||
| 159 | PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(), PromotionLevelEnum.SKU.getLevel(), promotionPrice, | 160 | PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(), PromotionLevelEnum.SKU.getLevel(), promotionPrice, |
| 160 | true, StrUtil.format("限时折扣:省 {} 元", formatPrice(orderItem.getPayPrice() - promotionPrice))); | 161 | true, StrUtil.format("限时折扣:省 {} 元", formatPrice(orderItem.getPayPrice() - promotionPrice))); |
| 161 | // 修改 SKU 的优惠 | 162 | // 修改 SKU 的优惠 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/reward/RewardActivityServiceImpl.java
| @@ -14,13 +14,11 @@ import org.springframework.stereotype.Service; | @@ -14,13 +14,11 @@ import org.springframework.stereotype.Service; | ||
| 14 | import org.springframework.validation.annotation.Validated; | 14 | import org.springframework.validation.annotation.Validated; |
| 15 | 15 | ||
| 16 | import javax.annotation.Resource; | 16 | import javax.annotation.Resource; |
| 17 | -import java.util.Collection; | ||
| 18 | -import java.util.List; | ||
| 19 | -import java.util.Map; | ||
| 20 | -import java.util.Set; | 17 | +import java.util.*; |
| 21 | 18 | ||
| 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 23 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; | 20 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| 21 | +import static java.util.Arrays.asList; | ||
| 24 | 22 | ||
| 25 | /** | 23 | /** |
| 26 | * 满减送活动 Service 实现类 | 24 | * 满减送活动 Service 实现类 |
| @@ -54,6 +52,7 @@ public class RewardActivityServiceImpl implements RewardActivityService { | @@ -54,6 +52,7 @@ public class RewardActivityServiceImpl implements RewardActivityService { | ||
| 54 | if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能修改噢 | 52 | if (dbRewardActivity.getStatus().equals(PromotionActivityStatusEnum.CLOSE.getStatus())) { // 已关闭的活动,不能修改噢 |
| 55 | throw exception(REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); | 53 | throw exception(REWARD_ACTIVITY_UPDATE_FAIL_STATUS_CLOSED); |
| 56 | } | 54 | } |
| 55 | + // 校验商品是否冲突 | ||
| 57 | validateRewardActivitySpuConflicts(updateReqVO.getId(), updateReqVO.getProductSpuIds()); | 56 | validateRewardActivitySpuConflicts(updateReqVO.getId(), updateReqVO.getProductSpuIds()); |
| 58 | 57 | ||
| 59 | // 更新 | 58 | // 更新 |
| @@ -109,8 +108,9 @@ public class RewardActivityServiceImpl implements RewardActivityService { | @@ -109,8 +108,9 @@ public class RewardActivityServiceImpl implements RewardActivityService { | ||
| 109 | return; | 108 | return; |
| 110 | } | 109 | } |
| 111 | // 查询商品参加的活动 | 110 | // 查询商品参加的活动 |
| 112 | - List<RewardActivityDO> rewardActivityList = getRewardActivityListBySpuIds(spuIds); | ||
| 113 | - if (id != null) { // 排除活动 | 111 | + List<RewardActivityDO> rewardActivityList = getRewardActivityListBySpuIds(spuIds, |
| 112 | + asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus())); | ||
| 113 | + if (id != null) { // 排除自己这个活动 | ||
| 114 | rewardActivityList.removeIf(activity -> id.equals(activity.getId())); | 114 | rewardActivityList.removeIf(activity -> id.equals(activity.getId())); |
| 115 | } | 115 | } |
| 116 | // 如果非空,则说明冲突 | 116 | // 如果非空,则说明冲突 |
| @@ -123,10 +123,12 @@ public class RewardActivityServiceImpl implements RewardActivityService { | @@ -123,10 +123,12 @@ public class RewardActivityServiceImpl implements RewardActivityService { | ||
| 123 | * 获得商品参加的满减送活动的数组 | 123 | * 获得商品参加的满减送活动的数组 |
| 124 | * | 124 | * |
| 125 | * @param spuIds 商品 SPU 编号数组 | 125 | * @param spuIds 商品 SPU 编号数组 |
| 126 | + * @param statuses 活动状态数组 | ||
| 126 | * @return 商品参加的满减送活动的数组 | 127 | * @return 商品参加的满减送活动的数组 |
| 127 | */ | 128 | */ |
| 128 | - private List<RewardActivityDO> getRewardActivityListBySpuIds(Collection<Long> spuIds) { | ||
| 129 | - List<RewardActivityDO> list = rewardActivityMapper.selectList(); | 129 | + private List<RewardActivityDO> getRewardActivityListBySpuIds(Collection<Long> spuIds, |
| 130 | + Collection<Integer> statuses) { | ||
| 131 | + List<RewardActivityDO> list = rewardActivityMapper.selectListByStatus(statuses); | ||
| 130 | return CollUtil.filter(list, activity -> CollUtil.containsAny(activity.getProductSpuIds(), spuIds)); | 132 | return CollUtil.filter(list, activity -> CollUtil.containsAny(activity.getProductSpuIds(), spuIds)); |
| 131 | } | 133 | } |
| 132 | 134 |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImplTest.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.promotion.service.discount; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 5 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityCreateReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; | ||
| 9 | +import cn.iocoder.yudao.module.promotion.dal.mysql.discount.DiscountActivityMapper; | ||
| 10 | +import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; | ||
| 11 | +import org.junit.jupiter.api.Test; | ||
| 12 | +import org.springframework.context.annotation.Import; | ||
| 13 | + | ||
| 14 | +import javax.annotation.Resource; | ||
| 15 | +import java.time.Duration; | ||
| 16 | +import java.util.Date; | ||
| 17 | + | ||
| 18 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.addTime; | ||
| 19 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime; | ||
| 20 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | ||
| 21 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | ||
| 22 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | ||
| 23 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | ||
| 24 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | ||
| 25 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.DISCOUNT_ACTIVITY_NOT_EXISTS; | ||
| 26 | +import static org.junit.jupiter.api.Assertions.*; | ||
| 27 | + | ||
| 28 | +/** | ||
| 29 | +* {@link DiscountActivityServiceImpl} 的单元测试类 | ||
| 30 | +* | ||
| 31 | +* @author 芋道源码 | ||
| 32 | +*/ | ||
| 33 | +@Import(DiscountActivityServiceImpl.class) | ||
| 34 | +public class DiscountActivityServiceImplTest extends BaseDbUnitTest { | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 37 | + private DiscountActivityServiceImpl discountActivityService; | ||
| 38 | + | ||
| 39 | + @Resource | ||
| 40 | + private DiscountActivityMapper discountActivityMapper; | ||
| 41 | + | ||
| 42 | + @Test | ||
| 43 | + public void testCreateDiscountActivity_success() { | ||
| 44 | + // 准备参数 | ||
| 45 | + DiscountActivityCreateReqVO reqVO = randomPojo(DiscountActivityCreateReqVO.class, o -> { | ||
| 46 | + // 用于触发进行中的状态 | ||
| 47 | + o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2))); | ||
| 48 | + }); | ||
| 49 | + | ||
| 50 | + // 调用 | ||
| 51 | + Long discountActivityId = discountActivityService.createDiscountActivity(reqVO); | ||
| 52 | + // 断言 | ||
| 53 | + assertNotNull(discountActivityId); | ||
| 54 | + // 校验记录的属性是否正确 | ||
| 55 | + DiscountActivityDO discountActivity = discountActivityMapper.selectById(discountActivityId); | ||
| 56 | + assertPojoEquals(reqVO, discountActivity); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Test | ||
| 60 | + public void testUpdateDiscountActivity_success() { | ||
| 61 | + // mock 数据 | ||
| 62 | + DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class); | ||
| 63 | + discountActivityMapper.insert(dbDiscountActivity);// @Sql: 先插入出一条存在的数据 | ||
| 64 | + // 准备参数 | ||
| 65 | + DiscountActivityUpdateReqVO reqVO = randomPojo(DiscountActivityUpdateReqVO.class, o -> { | ||
| 66 | + o.setId(dbDiscountActivity.getId()); // 设置更新的 ID | ||
| 67 | + }); | ||
| 68 | + | ||
| 69 | + // 调用 | ||
| 70 | + discountActivityService.updateDiscountActivity(reqVO); | ||
| 71 | + // 校验是否更新正确 | ||
| 72 | + DiscountActivityDO discountActivity = discountActivityMapper.selectById(reqVO.getId()); // 获取最新的 | ||
| 73 | + assertPojoEquals(reqVO, discountActivity); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Test | ||
| 77 | + public void testUpdateDiscountActivity_notExists() { | ||
| 78 | + // 准备参数 | ||
| 79 | + DiscountActivityUpdateReqVO reqVO = randomPojo(DiscountActivityUpdateReqVO.class); | ||
| 80 | + | ||
| 81 | + // 调用, 并断言异常 | ||
| 82 | + assertServiceException(() -> discountActivityService.updateDiscountActivity(reqVO), DISCOUNT_ACTIVITY_NOT_EXISTS); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Test | ||
| 86 | + public void testDeleteDiscountActivity_success() { | ||
| 87 | + // mock 数据 | ||
| 88 | + DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class); | ||
| 89 | + discountActivityMapper.insert(dbDiscountActivity);// @Sql: 先插入出一条存在的数据 | ||
| 90 | + // 准备参数 | ||
| 91 | + Long id = dbDiscountActivity.getId(); | ||
| 92 | + | ||
| 93 | + // 调用 | ||
| 94 | + discountActivityService.deleteDiscountActivity(id); | ||
| 95 | + // 校验数据不存在了 | ||
| 96 | + assertNull(discountActivityMapper.selectById(id)); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + @Test | ||
| 100 | + public void testDeleteDiscountActivity_notExists() { | ||
| 101 | + // 准备参数 | ||
| 102 | + Long id = randomLongId(); | ||
| 103 | + | ||
| 104 | + // 调用, 并断言异常 | ||
| 105 | + assertServiceException(() -> discountActivityService.deleteDiscountActivity(id), DISCOUNT_ACTIVITY_NOT_EXISTS); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @Test | ||
| 109 | + public void testGetDiscountActivityPage() { | ||
| 110 | + // mock 数据 | ||
| 111 | + DiscountActivityDO dbDiscountActivity = randomPojo(DiscountActivityDO.class, o -> { // 等会查询到 | ||
| 112 | + o.setName("芋艿"); | ||
| 113 | + o.setStatus(PromotionActivityStatusEnum.WAIT.getStatus()); | ||
| 114 | + o.setCreateTime(buildTime(2021, 1, 15)); | ||
| 115 | + }); | ||
| 116 | + discountActivityMapper.insert(dbDiscountActivity); | ||
| 117 | + // 测试 name 不匹配 | ||
| 118 | + discountActivityMapper.insert(cloneIgnoreId(dbDiscountActivity, o -> o.setName("土豆"))); | ||
| 119 | + // 测试 status 不匹配 | ||
| 120 | + discountActivityMapper.insert(cloneIgnoreId(dbDiscountActivity, o -> o.setStatus(PromotionActivityStatusEnum.END.getStatus()))); | ||
| 121 | + // 测试 createTime 不匹配 | ||
| 122 | + discountActivityMapper.insert(cloneIgnoreId(dbDiscountActivity, o -> o.setCreateTime(buildTime(2021, 2, 10)))); | ||
| 123 | + // 准备参数 | ||
| 124 | + DiscountActivityPageReqVO reqVO = new DiscountActivityPageReqVO(); | ||
| 125 | + reqVO.setName("芋艿"); | ||
| 126 | + reqVO.setStatus(PromotionActivityStatusEnum.WAIT.getStatus()); | ||
| 127 | + reqVO.setCreateTime((new Date[]{buildTime(2021, 1, 1), buildTime(2021, 1, 31)})); | ||
| 128 | + | ||
| 129 | + // 调用 | ||
| 130 | + PageResult<DiscountActivityDO> pageResult = discountActivityService.getDiscountActivityPage(reqVO); | ||
| 131 | + // 断言 | ||
| 132 | + assertEquals(1, pageResult.getTotal()); | ||
| 133 | + assertEquals(1, pageResult.getList().size()); | ||
| 134 | + assertPojoEquals(dbDiscountActivity, pageResult.getList().get(0)); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | +} |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java
| @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProduct | @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProduct | ||
| 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; | 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; |
| 12 | import cn.iocoder.yudao.module.promotion.enums.common.*; | 12 | import cn.iocoder.yudao.module.promotion.enums.common.*; |
| 13 | import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; | 13 | import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; |
| 14 | -import cn.iocoder.yudao.module.promotion.service.discount.DiscountService; | 14 | +import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; |
| 15 | import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; | 15 | import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; |
| 16 | import org.junit.jupiter.api.Test; | 16 | import org.junit.jupiter.api.Test; |
| 17 | import org.mockito.InjectMocks; | 17 | import org.mockito.InjectMocks; |
| @@ -41,7 +41,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest { | @@ -41,7 +41,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest { | ||
| 41 | private PriceServiceImpl priceService; | 41 | private PriceServiceImpl priceService; |
| 42 | 42 | ||
| 43 | @Mock | 43 | @Mock |
| 44 | - private DiscountService discountService; | 44 | + private DiscountActivityService discountService; |
| 45 | @Mock | 45 | @Mock |
| 46 | private RewardActivityService rewardActivityService; | 46 | private RewardActivityService rewardActivityService; |
| 47 | @Mock | 47 | @Mock |
| @@ -109,10 +109,10 @@ public class PriceServiceTest extends BaseMockitoUnitTest { | @@ -109,10 +109,10 @@ public class PriceServiceTest extends BaseMockitoUnitTest { | ||
| 109 | ProductSkuRespDTO productSku02 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(20L).setPrice(50)); | 109 | ProductSkuRespDTO productSku02 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(20L).setPrice(50)); |
| 110 | when(productSkuApi.getSkuList(eq(asSet(10L, 20L)))).thenReturn(asList(productSku01, productSku02)); | 110 | when(productSkuApi.getSkuList(eq(asSet(10L, 20L)))).thenReturn(asList(productSku01, productSku02)); |
| 111 | // mock 方法(限时折扣 DiscountActivity 信息) | 111 | // mock 方法(限时折扣 DiscountActivity 信息) |
| 112 | - DiscountProductDO discountProduct01 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(1000L).setActivityName("活动 1000 号") | ||
| 113 | - .setSkuId(10L).setPromotionPrice(80)); | ||
| 114 | - DiscountProductDO discountProduct02 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(2000L).setActivityName("活动 2000 号") | ||
| 115 | - .setSkuId(20L).setPromotionPrice(40)); | 112 | + DiscountProductDO discountProduct01 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(1000L)/*.setActsivityName("活动 1000 号") TODO 芋艿:待完善 */ |
| 113 | + .setSkuId(10L).setDiscountPrice(80)); | ||
| 114 | + DiscountProductDO discountProduct02 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(2000L)/*.setActivityName("活动 2000 号") TODO 芋艿:待完善 */ | ||
| 115 | + .setSkuId(20L).setDiscountPrice(80)); | ||
| 116 | when(discountService.getMatchDiscountProducts(eq(asSet(10L, 20L)))).thenReturn( | 116 | when(discountService.getMatchDiscountProducts(eq(asSet(10L, 20L)))).thenReturn( |
| 117 | MapUtil.builder(10L, discountProduct01).put(20L, discountProduct02).map()); | 117 | MapUtil.builder(10L, discountProduct01).put(20L, discountProduct02).map()); |
| 118 | 118 |
yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/clean.sql
| @@ -2,3 +2,5 @@ DELETE FROM "market_activity"; | @@ -2,3 +2,5 @@ DELETE FROM "market_activity"; | ||
| 2 | DELETE FROM "promotion_coupon_template"; | 2 | DELETE FROM "promotion_coupon_template"; |
| 3 | DELETE FROM "promotion_coupon"; | 3 | DELETE FROM "promotion_coupon"; |
| 4 | DELETE FROM "promotion_reward_activity"; | 4 | DELETE FROM "promotion_reward_activity"; |
| 5 | +DELETE FROM "promotion_discount_activity"; | ||
| 6 | +DELETE FROM "promotion_discount_product"; |
yudao-module-mall/yudao-module-promotion-biz/src/test/resources/sql/create_tables.sql
| @@ -91,3 +91,32 @@ CREATE TABLE IF NOT EXISTS "promotion_reward_activity" ( | @@ -91,3 +91,32 @@ CREATE TABLE IF NOT EXISTS "promotion_reward_activity" ( | ||
| 91 | "deleted" bit NOT NULL DEFAULT FALSE, | 91 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 92 | PRIMARY KEY ("id") | 92 | PRIMARY KEY ("id") |
| 93 | ) COMMENT '满减送活动'; | 93 | ) COMMENT '满减送活动'; |
| 94 | + | ||
| 95 | +CREATE TABLE IF NOT EXISTS "promotion_discount_activity" ( | ||
| 96 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
| 97 | + "name" varchar NOT NULL, | ||
| 98 | + "status" int NOT NULL, | ||
| 99 | + "start_time" datetime NOT NULL, | ||
| 100 | + "end_time" datetime NOT NULL, | ||
| 101 | + "remark" varchar, | ||
| 102 | + "creator" varchar DEFAULT '', | ||
| 103 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 104 | + "updater" varchar DEFAULT '', | ||
| 105 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
| 106 | + "deleted" bit NOT NULL DEFAULT FALSE, | ||
| 107 | + PRIMARY KEY ("id") | ||
| 108 | +) COMMENT '限时折扣活动'; | ||
| 109 | + | ||
| 110 | +CREATE TABLE IF NOT EXISTS "promotion_discount_product" ( | ||
| 111 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | ||
| 112 | + "activity_id" bigint NOT NULL, | ||
| 113 | + "spu_id" bigint NOT NULL, | ||
| 114 | + "sku_id" bigint NOT NULL, | ||
| 115 | + "discount_price" int NOT NULL, | ||
| 116 | + "creator" varchar DEFAULT '', | ||
| 117 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| 118 | + "updater" varchar DEFAULT '', | ||
| 119 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
| 120 | + "deleted" bit NOT NULL DEFAULT FALSE, | ||
| 121 | + PRIMARY KEY ("id") | ||
| 122 | +) COMMENT '限时折扣活动'; |
yudao-ui-admin/src/api/mall/promotion/discountActivity.js
0 → 100755
| 1 | +import request from '@/utils/request' | ||
| 2 | + | ||
| 3 | +// 创建限时折扣活动 | ||
| 4 | +export function createDiscountActivity(data) { | ||
| 5 | + return request({ | ||
| 6 | + url: '/promotion/discount-activity/create', | ||
| 7 | + method: 'post', | ||
| 8 | + data: data | ||
| 9 | + }) | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +// 更新限时折扣活动 | ||
| 13 | +export function updateDiscountActivity(data) { | ||
| 14 | + return request({ | ||
| 15 | + url: '/promotion/discount-activity/update', | ||
| 16 | + method: 'put', | ||
| 17 | + data: data | ||
| 18 | + }) | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +// 关闭限时折扣活动 | ||
| 22 | +export function closeDiscountActivity(id) { | ||
| 23 | + return request({ | ||
| 24 | + url: '/promotion/discount-activity/close?id=' + id, | ||
| 25 | + method: 'put' | ||
| 26 | + }) | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +// 删除限时折扣活动 | ||
| 30 | +export function deleteDiscountActivity(id) { | ||
| 31 | + return request({ | ||
| 32 | + url: '/promotion/discount-activity/delete?id=' + id, | ||
| 33 | + method: 'delete' | ||
| 34 | + }) | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +// 获得限时折扣活动 | ||
| 38 | +export function getDiscountActivity(id) { | ||
| 39 | + return request({ | ||
| 40 | + url: '/promotion/discount-activity/get?id=' + id, | ||
| 41 | + method: 'get' | ||
| 42 | + }) | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +// 获得限时折扣活动分页 | ||
| 46 | +export function getDiscountActivityPage(query) { | ||
| 47 | + return request({ | ||
| 48 | + url: '/promotion/discount-activity/page', | ||
| 49 | + method: 'get', | ||
| 50 | + params: query | ||
| 51 | + }) | ||
| 52 | +} |
yudao-ui-admin/src/views/mall/promotion/discountActivity/index.vue
0 → 100755
| 1 | +<template> | ||
| 2 | + <div class="app-container"> | ||
| 3 | + | ||
| 4 | + <!-- 搜索工作栏 --> | ||
| 5 | + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> | ||
| 6 | + <el-form-item label="活动名称" prop="name"> | ||
| 7 | + <el-input v-model="queryParams.name" placeholder="请输入活动名称" clearable @keyup.enter.native="handleQuery"/> | ||
| 8 | + </el-form-item> | ||
| 9 | + <el-form-item label="活动状态" prop="status"> | ||
| 10 | + <el-select v-model="queryParams.status" placeholder="请选择活动状态" clearable size="small"> | ||
| 11 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.PROMOTION_ACTIVITY_STATUS)" | ||
| 12 | + :key="dict.value" :label="dict.label" :value="dict.value"/> | ||
| 13 | + </el-select> | ||
| 14 | + </el-form-item> | ||
| 15 | + <el-form-item label="创建时间" prop="createTime"> | ||
| 16 | + <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" | ||
| 17 | + range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" /> | ||
| 18 | + </el-form-item> | ||
| 19 | + <el-form-item> | ||
| 20 | + <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> | ||
| 21 | + <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> | ||
| 22 | + </el-form-item> | ||
| 23 | + </el-form> | ||
| 24 | + | ||
| 25 | + <!-- 操作工具栏 --> | ||
| 26 | + <el-row :gutter="10" class="mb8"> | ||
| 27 | + <el-col :span="1.5"> | ||
| 28 | + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" | ||
| 29 | + v-hasPermi="['promotion:discount-activity:create']">新增</el-button> | ||
| 30 | + </el-col> | ||
| 31 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||
| 32 | + </el-row> | ||
| 33 | + | ||
| 34 | + <!-- 列表 --> | ||
| 35 | + <el-table v-loading="loading" :data="list"> | ||
| 36 | + <el-table-column label="活动名称" align="center" prop="name" /> | ||
| 37 | + <el-table-column label="活动时间" align="center" prop="startTime" width="240"> | ||
| 38 | + <template slot-scope="scope"> | ||
| 39 | + <div>开始:{{ parseTime(scope.row.startTime) }}</div> | ||
| 40 | + <div>结束:{{ parseTime(scope.row.endTime) }}</div> | ||
| 41 | + </template> | ||
| 42 | + </el-table-column> | ||
| 43 | + <el-table-column label="状态" align="center" prop="status"> | ||
| 44 | + <template slot-scope="scope"> | ||
| 45 | + <dict-tag :type="DICT_TYPE.PROMOTION_ACTIVITY_STATUS" :value="scope.row.status" /> | ||
| 46 | + </template> | ||
| 47 | + </el-table-column> | ||
| 48 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||
| 49 | + <template slot-scope="scope"> | ||
| 50 | + <span>{{ parseTime(scope.row.createTime) }}</span> | ||
| 51 | + </template> | ||
| 52 | + </el-table-column> | ||
| 53 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||
| 54 | + <template slot-scope="scope"> | ||
| 55 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" | ||
| 56 | + v-if="scope.row.status !== PromotionActivityStatusEnum.CLOSE.type" | ||
| 57 | + v-hasPermi="['promotion:discount-activity:update']">修改</el-button> | ||
| 58 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleClose(scope.row)" | ||
| 59 | + v-if="scope.row.status !== PromotionActivityStatusEnum.CLOSE.type && | ||
| 60 | + scope.row.status !== PromotionActivityStatusEnum.END.type" | ||
| 61 | + v-hasPermi="['promotion:discount-activity:close']">关闭</el-button> | ||
| 62 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" | ||
| 63 | + v-if="scope.row.status === PromotionActivityStatusEnum.CLOSE.type" | ||
| 64 | + v-hasPermi="['promotion:discount-activity:delete']">删除</el-button> | ||
| 65 | + </template> | ||
| 66 | + </el-table-column> | ||
| 67 | + </el-table> | ||
| 68 | + <!-- 分页组件 --> | ||
| 69 | + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" | ||
| 70 | + @pagination="getList"/> | ||
| 71 | + | ||
| 72 | + <!-- 对话框(添加 / 修改) --> | ||
| 73 | + <el-dialog :title="title" :visible.sync="open" width="600px" v-dialogDrag append-to-body> | ||
| 74 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | ||
| 75 | + <el-form-item label="活动名称" prop="name"> | ||
| 76 | + <el-input v-model="form.name" placeholder="请输入活动名称" /> | ||
| 77 | + </el-form-item> | ||
| 78 | + <el-form-item label="备注" prop="remark"> | ||
| 79 | + <el-input type="textarea" v-model="form.remark" placeholder="请输入备注" /> | ||
| 80 | + </el-form-item> | ||
| 81 | + <el-form-item label="活动时间" prop="startAndEndTime"> | ||
| 82 | + <el-date-picker clearable v-model="form.startAndEndTime" type="datetimerange" :default-time="['00:00:00', '23:59:59']" | ||
| 83 | + value-format="timestamp" placeholder="选择开始时间" style="width: 480px" /> | ||
| 84 | + </el-form-item> | ||
| 85 | + </el-form> | ||
| 86 | + <div slot="footer" class="dialog-footer"> | ||
| 87 | + <el-button type="primary" @click="submitForm">确 定</el-button> | ||
| 88 | + <el-button @click="cancel">取 消</el-button> | ||
| 89 | + </div> | ||
| 90 | + </el-dialog> | ||
| 91 | + </div> | ||
| 92 | +</template> | ||
| 93 | + | ||
| 94 | +<script> | ||
| 95 | +import { createDiscountActivity, updateDiscountActivity, deleteDiscountActivity, getDiscountActivity, getDiscountActivityPage } from "@/api/mall/promotion/discountActivity"; | ||
| 96 | +import {PromotionActivityStatusEnum, PromotionProductScopeEnum} from "@/utils/constants"; | ||
| 97 | +import {closeRewardActivity} from "@/api/mall/promotion/rewardActivity"; | ||
| 98 | + | ||
| 99 | +export default { | ||
| 100 | + name: "DiscountActivity", | ||
| 101 | + components: { | ||
| 102 | + }, | ||
| 103 | + data() { | ||
| 104 | + return { | ||
| 105 | + // 遮罩层 | ||
| 106 | + loading: true, | ||
| 107 | + // 导出遮罩层 | ||
| 108 | + exportLoading: false, | ||
| 109 | + // 显示搜索条件 | ||
| 110 | + showSearch: true, | ||
| 111 | + // 总条数 | ||
| 112 | + total: 0, | ||
| 113 | + // 限时折扣活动列表 | ||
| 114 | + list: [], | ||
| 115 | + // 弹出层名称 | ||
| 116 | + title: "", | ||
| 117 | + // 是否显示弹出层 | ||
| 118 | + open: false, | ||
| 119 | + // 查询参数 | ||
| 120 | + queryParams: { | ||
| 121 | + pageNo: 1, | ||
| 122 | + pageSize: 10, | ||
| 123 | + name: null, | ||
| 124 | + status: null, | ||
| 125 | + createTime: [], | ||
| 126 | + }, | ||
| 127 | + // 表单参数 | ||
| 128 | + form: {}, | ||
| 129 | + // 表单校验 | ||
| 130 | + rules: { | ||
| 131 | + name: [{ required: true, message: "活动名称不能为空", trigger: "blur" }], | ||
| 132 | + startAndEndTime: [{ required: true, message: "活动时间不能为空", trigger: "blur" }], | ||
| 133 | + }, | ||
| 134 | + // 商品列表 | ||
| 135 | + productSpus: [], // TODO 芋艿:需要重新写下 | ||
| 136 | + // 如下的变量,主要为了 v-if 判断可以使用到 | ||
| 137 | + PromotionProductScopeEnum: PromotionProductScopeEnum, | ||
| 138 | + PromotionActivityStatusEnum: PromotionActivityStatusEnum, | ||
| 139 | + }; | ||
| 140 | + }, | ||
| 141 | + created() { | ||
| 142 | + this.getList(); | ||
| 143 | + }, | ||
| 144 | + methods: { | ||
| 145 | + /** 查询列表 */ | ||
| 146 | + getList() { | ||
| 147 | + this.loading = true; | ||
| 148 | + // 执行查询 | ||
| 149 | + getDiscountActivityPage(this.queryParams).then(response => { | ||
| 150 | + this.list = response.data.list; | ||
| 151 | + this.total = response.data.total; | ||
| 152 | + this.loading = false; | ||
| 153 | + }); | ||
| 154 | + }, | ||
| 155 | + /** 取消按钮 */ | ||
| 156 | + cancel() { | ||
| 157 | + this.open = false; | ||
| 158 | + this.reset(); | ||
| 159 | + }, | ||
| 160 | + /** 表单重置 */ | ||
| 161 | + reset() { | ||
| 162 | + this.form = { | ||
| 163 | + id: undefined, | ||
| 164 | + name: undefined, | ||
| 165 | + startAndEndTime: undefined, | ||
| 166 | + startTime: undefined, | ||
| 167 | + endTime: undefined, | ||
| 168 | + remark: undefined, | ||
| 169 | + }; | ||
| 170 | + this.resetForm("form"); | ||
| 171 | + }, | ||
| 172 | + /** 搜索按钮操作 */ | ||
| 173 | + handleQuery() { | ||
| 174 | + this.queryParams.pageNo = 1; | ||
| 175 | + this.getList(); | ||
| 176 | + }, | ||
| 177 | + /** 重置按钮操作 */ | ||
| 178 | + resetQuery() { | ||
| 179 | + this.resetForm("queryForm"); | ||
| 180 | + this.handleQuery(); | ||
| 181 | + }, | ||
| 182 | + /** 新增按钮操作 */ | ||
| 183 | + handleAdd() { | ||
| 184 | + this.reset(); | ||
| 185 | + this.open = true; | ||
| 186 | + this.title = "添加限时折扣活动"; | ||
| 187 | + }, | ||
| 188 | + /** 修改按钮操作 */ | ||
| 189 | + handleUpdate(row) { | ||
| 190 | + this.reset(); | ||
| 191 | + const id = row.id; | ||
| 192 | + getDiscountActivity(id).then(response => { | ||
| 193 | + this.form = response.data; | ||
| 194 | + this.form.startAndEndTime = [response.data.startTime, response.data.endTime]; | ||
| 195 | + this.open = true; | ||
| 196 | + this.title = "修改限时折扣活动"; | ||
| 197 | + }); | ||
| 198 | + }, | ||
| 199 | + /** 提交按钮 */ | ||
| 200 | + submitForm() { | ||
| 201 | + this.$refs["form"].validate(valid => { | ||
| 202 | + if (!valid) { | ||
| 203 | + return; | ||
| 204 | + } | ||
| 205 | + this.form.startTime = this.form.startAndEndTime[0]; | ||
| 206 | + this.form.endTime = this.form.startAndEndTime[1]; | ||
| 207 | + // 修改的提交 | ||
| 208 | + if (this.form.id != null) { | ||
| 209 | + updateDiscountActivity(this.form).then(response => { | ||
| 210 | + this.$modal.msgSuccess("修改成功"); | ||
| 211 | + this.open = false; | ||
| 212 | + this.getList(); | ||
| 213 | + }); | ||
| 214 | + return; | ||
| 215 | + } | ||
| 216 | + // 添加的提交 | ||
| 217 | + createDiscountActivity(this.form).then(response => { | ||
| 218 | + this.$modal.msgSuccess("新增成功"); | ||
| 219 | + this.open = false; | ||
| 220 | + this.getList(); | ||
| 221 | + }); | ||
| 222 | + }); | ||
| 223 | + }, | ||
| 224 | + /** 删除按钮操作 */ | ||
| 225 | + handleDelete(row) { | ||
| 226 | + const id = row.id; | ||
| 227 | + this.$modal.confirm('是否确认删除限时折扣活动编号为"' + id + '"的数据项?').then(function() { | ||
| 228 | + return deleteDiscountActivity(id); | ||
| 229 | + }).then(() => { | ||
| 230 | + this.getList(); | ||
| 231 | + this.$modal.msgSuccess("删除成功"); | ||
| 232 | + }).catch(() => {}); | ||
| 233 | + }, | ||
| 234 | + /** 关闭按钮操作 */ | ||
| 235 | + handleClose(row) { | ||
| 236 | + const id = row.id; | ||
| 237 | + this.$modal.confirm('是否确认关闭限时折扣活动编号为"' + id + '"的数据项?').then(function() { | ||
| 238 | + return closeRewardActivity(id); | ||
| 239 | + }).then(() => { | ||
| 240 | + this.getList(); | ||
| 241 | + this.$modal.msgSuccess("关闭成功"); | ||
| 242 | + }).catch(() => {}); | ||
| 243 | + } | ||
| 244 | + } | ||
| 245 | +}; | ||
| 246 | +</script> |