From dc51a9353394e411006548468ff36aac0ae1cba8 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 1 Nov 2022 22:31:07 +0800 Subject: [PATCH] =?UTF-8?q?promotion=EF=BC=9A=E5=AE=9E=E7=8E=B0=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BC=98=E6=83=A0=E5=8A=B5=E6=A8=A1=E6=9D=BF=E7=9A=84?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/PromotionDiscountTypeEnum.java | 4 +- .../admin/coupon/vo/CouponTemplateRespVO.java | 2 +- .../dataobject/coupon/CouponTemplateDO.java | 6 ++ .../coupon/CouponTemplateServiceImplTest.java | 71 ++++----------- yudao-ui-admin/src/utils/constants.js | 28 ++++++ yudao-ui-admin/src/utils/dict.js | 3 + .../views/promotion/couponTemplate/index.vue | 91 ++++++++++--------- 7 files changed, 103 insertions(+), 102 deletions(-) diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java index 7cfa7ec47..7da6b4b08 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/common/PromotionDiscountTypeEnum.java @@ -15,8 +15,8 @@ import java.util.Arrays; @AllArgsConstructor public enum PromotionDiscountTypeEnum implements IntArrayValuable { - PRICE(1, "减价"), // 具体金额 - PERCENT(2, "打折"), // 百分比 + PRICE(1, "满减"), // 具体金额 + PERCENT(2, "折扣"), // 百分比 ; public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionDiscountTypeEnum::getType).toArray(); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplateRespVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplateRespVO.java index 294055590..835149027 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplateRespVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/CouponTemplateRespVO.java @@ -24,7 +24,7 @@ public class CouponTemplateRespVO extends CouponTemplateBaseVO { private Integer status; @ApiModelProperty(value = "领取优惠券的数量", required = true, example = "1024") - private Integer takeNum; + private Integer takeCount; @ApiModelProperty(value = "使用优惠券的次数", required = true, example = "2048") private Integer useCount; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java index 78a207e98..543289c63 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java @@ -105,6 +105,12 @@ public class CouponTemplateDO extends BaseDO { * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#DATE} */ private Date validEndTime; + /** + * 领取日期 - 开始天数 + * + * 当 {@link #validityType} 为 {@link CouponTemplateValidityTypeEnum#TERM} + */ + private Integer fixedStartTerm; /** * 领取日期 - 结束天数 * diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java index 27152005b..8a87fb584 100755 --- a/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/coupon/CouponTemplateServiceImplTest.java @@ -1,30 +1,26 @@ package cn.iocoder.yudao.module.promotion.service.coupon; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; - -import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.*; +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateCreateReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplatePageReqVO; +import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateUpdateReqVO; import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponTemplateDO; import cn.iocoder.yudao.module.promotion.dal.mysql.coupon.CouponTemplateMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; +import java.util.Date; -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; /** * {@link CouponTemplateServiceImpl} 的单元测试类 @@ -110,7 +106,7 @@ public class CouponTemplateServiceImplTest extends BaseDbUnitTest { CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class, o -> { // 等会查询到 o.setName(null); o.setStatus(null); - o.setType(null); + o.setDiscountType(null); o.setCreateTime(null); }); couponTemplateMapper.insert(dbCouponTemplate); @@ -119,14 +115,14 @@ public class CouponTemplateServiceImplTest extends BaseDbUnitTest { // 测试 status 不匹配 couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setStatus(null))); // 测试 type 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setType(null))); + couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setDiscountType(null))); // 测试 createTime 不匹配 couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setCreateTime(null))); // 准备参数 CouponTemplatePageReqVO reqVO = new CouponTemplatePageReqVO(); reqVO.setName(null); reqVO.setStatus(null); - reqVO.setType(null); + reqVO.setDiscountType(null); reqVO.setCreateTime((new Date[]{})); // 调用 @@ -137,37 +133,4 @@ public class CouponTemplateServiceImplTest extends BaseDbUnitTest { assertPojoEquals(dbCouponTemplate, pageResult.getList().get(0)); } - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCouponTemplateList() { - // mock 数据 - CouponTemplateDO dbCouponTemplate = randomPojo(CouponTemplateDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatus(null); - o.setType(null); - o.setCreateTime(null); - }); - couponTemplateMapper.insert(dbCouponTemplate); - // 测试 name 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setName(null))); - // 测试 status 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setStatus(null))); - // 测试 type 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setType(null))); - // 测试 createTime 不匹配 - couponTemplateMapper.insert(cloneIgnoreId(dbCouponTemplate, o -> o.setCreateTime(null))); - // 准备参数 - CouponTemplateExportReqVO reqVO = new CouponTemplateExportReqVO(); - reqVO.setName(null); - reqVO.setStatus(null); - reqVO.setType(null); - reqVO.setCreateTime((new Date[]{})); - - // 调用 - List list = couponTemplateService.getCouponTemplateList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbCouponTemplate, list.get(0)); - } - } diff --git a/yudao-ui-admin/src/utils/constants.js b/yudao-ui-admin/src/utils/constants.js index 9f5d796ed..ef2805ea9 100644 --- a/yudao-ui-admin/src/utils/constants.js +++ b/yudao-ui-admin/src/utils/constants.js @@ -236,3 +236,31 @@ export const ProductSpuStatusEnum = { name: '上架' }, } + +/** + * 优惠类型枚举 + */ +export const PromotionDiscountTypeEnum = { + PRICE: { + type: 1, + name: '满减' + }, + PERCENT: { + type: 2, + name: '折扣' + } +} + +/** + * 优惠劵模板的有限期类型的枚举 + */ +export const CouponTemplateValidityTypeEnum = { + DATE: { + type: 1, + name: '固定日期可用' + }, + TERM: { + type: 2, + name: '领取之后可用' + } +} diff --git a/yudao-ui-admin/src/utils/dict.js b/yudao-ui-admin/src/utils/dict.js index 8c5b4bbca..d5e0158d8 100644 --- a/yudao-ui-admin/src/utils/dict.js +++ b/yudao-ui-admin/src/utils/dict.js @@ -59,6 +59,9 @@ export const DICT_TYPE = { // ========== MALL - PRODUCT 模块 ========== PRODUCT_SPU_STATUS: 'product_spu_status', // 商品 SPU 状态 + + // ========== MALL - PROMOTION 模块 ========== + PROMOTION_DISCOUNT_TYPE: 'promotion_discount_type', // 优惠类型 } /** diff --git a/yudao-ui-admin/src/views/promotion/couponTemplate/index.vue b/yudao-ui-admin/src/views/promotion/couponTemplate/index.vue index ad0dc137c..4cf1d7ec8 100755 --- a/yudao-ui-admin/src/views/promotion/couponTemplate/index.vue +++ b/yudao-ui-admin/src/views/promotion/couponTemplate/index.vue @@ -2,25 +2,19 @@
- - + + - - - + + + - - - + + @@ -48,45 +42,24 @@ - - - - - - - - + + + + + + - - - - - - - - - - - - -