diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/PreferentialTypeEnum.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/PreferentialTypeEnum.java deleted file mode 100644 index 9af2827cf..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/PreferentialTypeEnum.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.mall.promotion.api.enums; - -import cn.iocoder.common.framework.core.IntArrayValuable; - -import java.util.Arrays; - -/** - * 优惠类型枚举 - */ -public enum PreferentialTypeEnum implements IntArrayValuable { - - PRICE(1, "减价"), - DISCOUNT(2, "打折"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PreferentialTypeEnum::getValue).toArray(); - - /** - * 值 - */ - private final Integer value; - /** - * 名字 - */ - private final String name; - - PreferentialTypeEnum(Integer value, String name) { - this.value = value; - this.name = name; - } - - public Integer getValue() { - return value; - } - - public String getName() { - return name; - } - - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateDateTypeEnum.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateDateTypeEnum.java deleted file mode 100644 index a23a0e956..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateDateTypeEnum.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.iocoder.mall.promotion.api.enums.coupon.template; - -import cn.iocoder.common.framework.core.IntArrayValuable; - -import java.util.Arrays; - -/** - * 优惠劵(码)模板的时间类型的枚举 - */ -public enum CouponTemplateDateTypeEnum implements IntArrayValuable { - - FIXED_DATE(1, "固定日期"), - FIXED_TERM(2, "领取日期"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateDateTypeEnum::getValue).toArray(); - - /** - * 值 - */ - private final Integer value; - /** - * 名字 - */ - private final String name; - - CouponTemplateDateTypeEnum(Integer value, String name) { - this.value = value; - this.name = name; - } - - public Integer getValue() { - return value; - } - - public String getName() { - return name; - } - - - @Override - public int[] array() { - return ARRAYS; - } - -} diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateStatusEnum.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateStatusEnum.java deleted file mode 100644 index 0dbfa3125..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateStatusEnum.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.mall.promotion.api.enums.coupon.template; - -import cn.iocoder.common.framework.core.IntArrayValuable; - -import java.util.Arrays; - -/** - * 优惠劵(码)模板的状态的枚举 - */ -public enum CouponTemplateStatusEnum implements IntArrayValuable { - - ENABLE(1, "生效中"), - DISABLE(2, "已失效"), -// EXPIRE(3, "已过期"), TODO 芋艿,暂时不考虑过期的 - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateStatusEnum::getValue).toArray(); - - /** - * 值 - */ - private final Integer value; - /** - * 名字 - */ - private final String name; - - CouponTemplateStatusEnum(Integer value, String name) { - this.value = value; - this.name = name; - } - - public Integer getValue() { - return value; - } - - public String getName() { - return name; - } - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateTypeEnum.java b/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateTypeEnum.java deleted file mode 100644 index 7d86a6ed0..000000000 --- a/归档/promotion-service-project/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/enums/coupon/template/CouponTemplateTypeEnum.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.mall.promotion.api.enums.coupon.template; - -import java.util.Arrays; - -/** - * 优惠劵(码)模板的类型的枚举 - */ -public enum CouponTemplateTypeEnum { - - CARD(1, "优惠劵"), - CODE(2, "折扣卷"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateTypeEnum::getValue).toArray(); - - /** - * 值 - */ - private final Integer value; - /** - * 名字 - */ - private final String name; - - CouponTemplateTypeEnum(Integer value, String name) { - this.value = value; - this.name = name; - } - - public Integer getValue() { - return value; - } - - public String getName() { - return name; - } - -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponTemplateController.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponTemplateController.java deleted file mode 100644 index 01e46b769..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/CouponTemplateController.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.mall.promotionservice.controller; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.*; -import cn.iocoder.mall.promotionservice.manager.coupon.CouponTemplateManager; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -/** - * Title: - * Description: - * - * @author zhuyang - * @version 1.0 2021/10/9 - */ -@RestController -@RequestMapping("/coupon/template") -public class CouponTemplateController { - - @Autowired - private CouponTemplateManager couponTemplateManager; - - // ========== 通用逻辑 ========= - - @GetMapping("getCouponTemplate") - public CommonResult getCouponTemplate(@RequestParam("couponTemplateId") Integer couponTemplateId) { - return success(couponTemplateManager.getCouponTemplate(couponTemplateId)); - } - - @PostMapping("pageCouponTemplate") - public CommonResult> pageCouponTemplate(@RequestBody CouponTemplatePageReqDTO pageDTO) { - return success(couponTemplateManager.pageCouponTemplate(pageDTO)); - } - - @PostMapping("updateCouponTemplateStatus") - public CommonResult updateCouponTemplateStatus(@RequestBody CouponCardTemplateUpdateStatusReqDTO updateStatusReqDTO) { - couponTemplateManager.updateCouponTemplateStatus(updateStatusReqDTO); - return success(true); - } - - // ========== 优惠劵模板 ========== - - @PostMapping("createCouponCardTemplate") - public CommonResult createCouponCardTemplate(@RequestBody CouponCardTemplateCreateReqDTO createDTO) { - return success(couponTemplateManager.createCouponCardTemplate(createDTO)); - } - - @PostMapping("updateCouponCardTemplate") - public CommonResult updateCouponCardTemplate(@RequestBody CouponCardTemplateUpdateReqDTO updateDTO) { - couponTemplateManager.updateCouponCardTemplate(updateDTO); - return success(true); - } -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PriceController.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PriceController.java deleted file mode 100644 index bfa596676..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/controller/PriceController.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.mall.promotionservice.controller; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcReqDTO; -import cn.iocoder.mall.promotion.api.rpc.price.dto.PriceProductCalcRespDTO; -import cn.iocoder.mall.promotionservice.manager.price.PriceManager; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -/** - * Title: - * Description: - * - * @author zhuyang - * @version 1.0 2021/10/9 - */ -@RestController -@RequestMapping("/promotion/price") -public class PriceController { - - @Autowired - private PriceManager priceManager; - - @PostMapping("calcProductPrice") - public CommonResult calcProductPrice(@RequestBody PriceProductCalcReqDTO calcReqDTO) { - return success(priceManager.calcProductPrice(calcReqDTO)); - } -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/convert/coupon/CouponCardConvert.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/convert/coupon/CouponCardConvert.java deleted file mode 100644 index be9870bb3..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/convert/coupon/CouponCardConvert.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.mall.promotionservice.convert.coupon; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardAvailableRespDTO; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.card.CouponCardRespDTO; -import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.coupon.CouponCardDO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface CouponCardConvert { - - CouponCardConvert INSTANCE = Mappers.getMapper(CouponCardConvert.class); - - CouponCardRespDTO convert(CouponCardDO bean); - - @Mapping(source = "records", target = "list") - PageResult convertPage(IPage page); - - @Named("convertCouponCardDOToCouponCardAvailableRespDTO") // 避免生成的方法名的冲突 - CouponCardAvailableRespDTO convert01(CouponCardDO bean); - -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/convert/coupon/CouponTemplateConvert.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/convert/coupon/CouponTemplateConvert.java deleted file mode 100644 index 21a557d19..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/convert/coupon/CouponTemplateConvert.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.mall.promotionservice.convert.coupon; - -import cn.iocoder.common.framework.util.StringUtils; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateCreateReqDTO; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateReqDTO; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO; -import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.coupon.CouponTemplateDO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface CouponTemplateConvert { - - CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class); - - @Mapping(source = "rangeValues", target = "rangeValues", qualifiedByName = "translateStringToIntList") - CouponTemplateRespDTO convert(CouponTemplateDO bean); - - CouponTemplateDO convert(CouponCardTemplateCreateReqDTO bean); - - CouponTemplateDO convert(CouponCardTemplateUpdateReqDTO bean); - - @Mapping(source = "records", target = "list") - PageResult convertPage(IPage couponTemplatePage); - - @Named("translateStringToIntList") - default List translateStringToIntList(String str) { - return StringUtils.splitToInt(str, ","); - } - -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/dataobject/coupon/CouponCodeDO.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/dataobject/coupon/CouponCodeDO.java deleted file mode 100644 index b8651fe1b..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/dataobject/coupon/CouponCodeDO.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.iocoder.mall.promotionservice.dal.mysql.dataobject.coupon; - -import cn.iocoder.mall.mybatis.core.dataobject.BaseDO; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * 优惠码 - */ -@Data -@Accessors(chain = true) -public class CouponCodeDO extends BaseDO { - - /** - * 编号 - */ - private Integer id; - /** - * 模板编号 {@link CouponTemplateDO} 的 id - */ - private Integer templateId; - /** - * 优惠码 - */ - private Integer code; - /** - * 领取时间 - */ - private Date takeTime; - /** - * 领取用户编号 - */ - private Integer userId; - /** - * 领取的优惠劵编号 - */ - private Integer couponId; - - // TODO 芋艿,后续要考虑状态的追踪 - -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/dataobject/coupon/CouponTemplateDO.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/dataobject/coupon/CouponTemplateDO.java deleted file mode 100644 index 666ed99a2..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/dataobject/coupon/CouponTemplateDO.java +++ /dev/null @@ -1,237 +0,0 @@ -package cn.iocoder.mall.promotionservice.dal.mysql.dataobject.coupon; - -import cn.iocoder.mall.mybatis.core.dataobject.BaseDO; -import cn.iocoder.mall.promotion.api.enums.PreferentialTypeEnum; -import cn.iocoder.mall.promotion.api.enums.RangeTypeEnum; -import cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateDateTypeEnum; -import cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateStatusEnum; -import cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateTypeEnum; -import com.baomidou.mybatisplus.annotation.TableName; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * 优惠劵(码)模板 DO - * - * 当用户领取时,会生成 {@link CouponCardDO} 优惠劵(码)。 - */ -@TableName("coupon_template") -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class CouponTemplateDO extends BaseDO { - - // ========== 基本信息 BEGIN ========== - /** - * 模板编号,自增唯一。 - */ - private Integer id; - /** - * 标题 - */ - private String title; - /** - * 使用说明 - */ - private String description; - /** - * 类型 - * - * 枚举 {@link CouponTemplateTypeEnum} - * - * 1-优惠劵 - * 2-优惠码 - */ - private Integer type; - /** - * 优惠码状态 - * - * 枚举 {@link CouponTemplateStatusEnum} - * - * 当优惠劵(码)开启中,可以手动操作,设置禁用中。 - */ - private Integer status; -// /** -// * 是否可分享领取链接 -// */ -// private Boolean isShare; -// /** -// * 设置为失效时间 -// */ -// private Date invalidTime; -// /** -// * 删除时间 -// */ -// private Date deleteTime; - - // ========== 基本信息 END ========== - - // ========== 领取规则 BEGIN ========== -// /** -// * 是否限制领用者的等级 -// * -// * 0-不限制 -// * 大于0-领用者必须是这个等级编号 -// * -// * 【优惠劵独有】 -// */ -// private Integer needUserLevel; - /** - * 每人限领个数 - * - * null - 则表示不限制 - */ - private Integer quota; - /** - * 发行总量 - */ - private Integer total; - // ========== 领取规则 END ========== - - // ========== 使用规则 BEGIN ========== -// /** -// * 是否仅原价购买商品时可用 -// * -// * true-是 -// * false-否 -// */ -// private Boolean isForbidPreference; - /** - * 是否设置满多少金额可用,单位:分 - * - * 0-不限制 - * 大于0-多少金额可用 - */ - private Integer priceAvailable; - /** - * 可用范围的类型 - * - * 枚举 {@link RangeTypeEnum} - * - * 10-全部(ALL):所有可用 - * 20-部分(PART):部分商品可用,或指定商品可用 - * 21-部分(PART):部分商品不可用,或指定商品可用 - * 30-部分(PART):部分分类可用,或指定商品可用 - * 31-部分(PART):部分分类不可用,或指定商品可用 - */ - private Integer rangeType; - /** - * 指定商品 / 分类列表,使用逗号分隔商品编号 - */ - private String rangeValues; - /** - * 生效日期类型 - * - * 枚举 {@link CouponTemplateDateTypeEnum} - * - * 1-固定日期 - * 2-领取日期:领到券 {@link #fixedStartTerm} 日开始 N 天内有效 - */ - private Integer dateType; - /** - * 固定日期-生效开始时间 - */ - private Date validStartTime; - /** - * 固定日期-生效结束时间 - */ - private Date validEndTime; - /** - * 领取日期-开始天数 - * - * 例如,0-当天;1-次天 - */ - private Integer fixedStartTerm; - /** - * 领取日期-结束天数 - */ - private Integer fixedEndTerm; -// /** -// * 是否到期前4天发送提醒 -// * -// * true-发送 -// * false-不发送 -// */ -// private Boolean expireNotice; - // ========== 使用规则 END ========== - - // ========== 使用效果 BEGIN ========== - /** - * 优惠类型 - * - * 枚举 {@link PreferentialTypeEnum} - * - * 1-代金卷 - * 2-折扣卷 - */ - private Integer preferentialType; - /** - * 折扣百分比。 - * - * 例如,80% 为 80。 - * 当 100% 为 100 ,则代表免费。 - */ - private Integer percentOff; -// /** -// * 是否是随机优惠券 -// * -// * true-随机 -// * false-不随机 -// * -// * 【优惠劵独有】 -// */ -// private Boolean isRandom; - /** - * 优惠金额,单位:分 - */ -// * 当 {@link #isRandom} 为 true 时,代表随机优惠金额的下限 - private Integer priceOff; -// /** -// * 优惠金额上限 -// * -// * 【优惠劵独有】 -// */ -// private Integer valueRandomTo; - /** - * 折扣上限,仅在 {@link #preferentialType} 等于 2 时生效。 - * - * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。 - */ - private Integer discountPriceLimit; - // ========== 使用效果 END ========== - - // ========== 统计信息 BEGIN ========== -// /** -// * 领取优惠券的人数 -// */ -// private Integer statFetchUserNum; - /** - * 领取优惠券的次数 - */ - private Integer statFetchNum; -// /** -// * 使用优惠券的次数 -// */ -// private Integer statUseNum; - // ========== 统计信息 END ========== - - // ========== 优惠码 BEGIN ========== - /** - * 码类型 - * - * 1-一卡一码(UNIQUE) - * 2-通用码(GENERAL) - * - * 【优惠码独有】 @see CouponCodeDO - */ - private Integer codeType; - /** - * 通用码 - */ - private String commonCode; - // ========== 优惠码 BEGIN ========== - -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/coupon/CouponTemplateMapper.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/coupon/CouponTemplateMapper.java index 913121c8e..32a0e6f7e 100644 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/coupon/CouponTemplateMapper.java +++ b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/coupon/CouponTemplateMapper.java @@ -12,14 +12,6 @@ import org.springframework.stereotype.Repository; @Repository public interface CouponTemplateMapper extends BaseMapper { - default IPage selectPage(CouponTemplatePageReqDTO pageReqDTO) { - return selectPage(new Page<>(pageReqDTO.getPageNo(), pageReqDTO.getPageSize()), - new QueryWrapperX().eqIfPresent("type", pageReqDTO.getType()) - .likeIfPresent("title", pageReqDTO.getTitle()) - .eqIfPresent("status", pageReqDTO.getStatus()) - .eqIfPresent("preferential_type", pageReqDTO.getPreferentialType())); - } - /** * 更新优惠劵模板已领取的数量 * diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/recommend/ProductRecommendMapper.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/recommend/ProductRecommendMapper.java index 46850b680..231442ce3 100644 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/recommend/ProductRecommendMapper.java +++ b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/dal/mysql/mapper/recommend/ProductRecommendMapper.java @@ -20,11 +20,6 @@ public interface ProductRecommendMapper extends BaseMapper { .eq("type", type)); } - default List selectList(ProductRecommendListReqDTO listReqDTO) { - return selectList(new QueryWrapperX().eqIfPresent("type", listReqDTO.getType()) - .eqIfPresent("status", listReqDTO.getStatus())); - } - default IPage selectPage(ProductRecommendPageReqDTO pageReqDTO) { return selectPage(new Page<>(pageReqDTO.getPageNo(), pageReqDTO.getPageSize()), new QueryWrapperX().eqIfPresent("type", pageReqDTO.getType())); diff --git a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/coupon/CouponTemplateService.java b/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/coupon/CouponTemplateService.java deleted file mode 100644 index e087459b5..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/service/coupon/CouponTemplateService.java +++ /dev/null @@ -1,173 +0,0 @@ -package cn.iocoder.mall.promotionservice.service.coupon; - -import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil; -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.promotion.api.enums.PreferentialTypeEnum; -import cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants; -import cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateDateTypeEnum; -import cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateStatusEnum; -import cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateTypeEnum; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateCreateReqDTO; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateReqDTO; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplatePageReqDTO; -import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO; -import cn.iocoder.mall.promotionservice.convert.coupon.CouponTemplateConvert; -import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.coupon.CouponTemplateDO; -import cn.iocoder.mall.promotionservice.dal.mysql.mapper.coupon.CouponTemplateMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.validation.annotation.Validated; - -import java.util.Date; - -import static cn.iocoder.common.framework.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST; - -/** - * 优惠劵模板 Service - */ -@Service -@Validated -public class CouponTemplateService { - - @Autowired - private CouponTemplateMapper couponTemplateMapper; - - // ========== 通用逻辑 ========= - - /** - * 获得优惠劵(码)模板 - * - * @param couponCardId 优惠劵模板编号 - * @return 优惠劵(码)模板 - */ - public CouponTemplateRespDTO getCouponTemplate(Integer couponCardId) { - return CouponTemplateConvert.INSTANCE.convert(couponTemplateMapper.selectById(couponCardId)); - } - - /** - * 获得优惠劵(码)分页 - * - * @param pageDTO 分页条件 - * @return 优惠劵(码)分页 - */ - public PageResult pageCouponTemplate(CouponTemplatePageReqDTO pageDTO) { - IPage couponTemplatePage = couponTemplateMapper.selectPage(pageDTO); - return CouponTemplateConvert.INSTANCE.convertPage(couponTemplatePage); - } - - /** - * 更新优惠劵(码)模板的状态 - * - * @param couponTemplateId 优惠劵模板编号 - * @param status 状态 - */ - public void updateCouponTemplateStatus(Integer couponTemplateId, Integer status) { - // 校验 CouponCardTemplate 存在 - CouponTemplateDO template = couponTemplateMapper.selectById(couponTemplateId); - if (template == null) { - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS.getCode()); - } - // 更新到数据库 - CouponTemplateDO updateTemplateDO = new CouponTemplateDO().setId(couponTemplateId).setStatus(status); - couponTemplateMapper.updateById(updateTemplateDO); - } - - private Boolean checkCouponTemplateDateType(Integer dateType, Date validStartTime, Date validEndTime, Integer fixedStartTerm, Integer fixedEndTerm) { - // TODO 芋艿:后续这种类型的校验,看看怎么优化到对象里 - if (CouponTemplateDateTypeEnum.FIXED_DATE.getValue().equals(dateType)) { // 固定日期 - if (validStartTime == null) { - throw ServiceExceptionUtil.exception(BAD_REQUEST, "生效开始时间不能为空"); - } - if (validEndTime == null) { - throw ServiceExceptionUtil.exception(BAD_REQUEST, "生效结束时间不能为空"); - } - if (validStartTime.after(validEndTime)) { - throw ServiceExceptionUtil.exception(BAD_REQUEST, "生效开始时间不能大于生效结束时间"); - } - } else if (CouponTemplateDateTypeEnum.FIXED_TERM.getValue().equals(dateType)) { // 领取日期 - if (fixedStartTerm == null) { - throw ServiceExceptionUtil.exception(BAD_REQUEST, "领取日期开始时间不能为空"); - } - if (fixedEndTerm == null) { - throw ServiceExceptionUtil.exception(BAD_REQUEST, "领取日期结束时间不能为空"); - } - } else { - throw new IllegalArgumentException("未知的生效日期类型:" + dateType); - } - return true; - } - - private Boolean checkCouponTemplatePreferentialType(Integer preferentialType, Integer percentOff, - Integer priceOff, Integer priceAvailable) { - if (PreferentialTypeEnum.PRICE.getValue().equals(preferentialType)) { - if (priceOff == null) { - throw ServiceExceptionUtil.exception(BAD_REQUEST, "优惠金额不能为空"); - } - if (priceOff >= priceAvailable) { - throw ServiceExceptionUtil.exception(BAD_REQUEST, "优惠金额不能d大于等于使用金额门槛"); - } - } else if (PreferentialTypeEnum.DISCOUNT.getValue().equals(preferentialType)) { - if (percentOff == null) { - throw ServiceExceptionUtil.exception(BAD_REQUEST, "折扣百分比不能为空"); - } - } else { - throw new IllegalArgumentException("未知的优惠类型:" + preferentialType); - } - return true; - } - - // ========== 优惠劵模板 ========== - - /** - * 添加优惠劵模板 - * - * @param createReqDTO 优惠劵模板添加信息 - * @return 优惠劵模板编号 - */ - public Integer createCouponCardTemplate(CouponCardTemplateCreateReqDTO createReqDTO) { - // 校验生效日期相关 - checkCouponTemplateDateType(createReqDTO.getDateType(), - createReqDTO.getValidStartTime(), createReqDTO.getValidEndTime(), - createReqDTO.getFixedStartTerm(), createReqDTO.getFixedEndTerm()); - // 校验优惠类型 - checkCouponTemplatePreferentialType(createReqDTO.getPreferentialType(), createReqDTO.getPercentOff(), - createReqDTO.getPriceOff(), createReqDTO.getPriceAvailable()); - // 保存优惠劵模板到数据库 - CouponTemplateDO template = CouponTemplateConvert.INSTANCE.convert(createReqDTO) - .setType(CouponTemplateTypeEnum.CARD.getValue()) - .setStatus(CouponTemplateStatusEnum.ENABLE.getValue()) - .setStatFetchNum(0); - couponTemplateMapper.insert(template); - // 返回成功 - return template.getId(); - } - - /** - * 更新优惠劵模板 - * - * @param updateReqDTO 优惠劵模板修改信息 - */ - public void updateCouponCardTemplate(CouponCardTemplateUpdateReqDTO updateReqDTO) { - // 校验 CouponCardTemplate 存在 - CouponTemplateDO template = couponTemplateMapper.selectById(updateReqDTO.getId()); - if (template == null) { - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_TEMPLATE_NOT_EXISTS.getCode()); - } - // 校验 CouponCardTemplate 是 CARD - if (!CouponTemplateTypeEnum.CARD.getValue().equals(template.getType())) { - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_TEMPLATE_NOT_CARD.getCode()); - } - // 校验发放数量不能减少 - if (updateReqDTO.getTotal() < template.getTotal()) { - throw ServiceExceptionUtil.exception(PromotionErrorCodeConstants.COUPON_TEMPLATE_TOTAL_CAN_NOT_REDUCE.getCode()); - } - // 更新优惠劵模板到数据库 - CouponTemplateDO updateTemplateDO = CouponTemplateConvert.INSTANCE.convert(updateReqDTO); - couponTemplateMapper.updateById(updateTemplateDO); - } - - // ========== 优惠码模板 TODO 芋艿:以后开发 ========== - - -} diff --git a/归档/promotion-service-project/promotion-service-app/src/main/resources/application-dev.yaml b/归档/promotion-service-project/promotion-service-app/src/main/resources/application-dev.yaml deleted file mode 100644 index 946ea52b2..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,21 +0,0 @@ -spring: - # 数据源配置项 - datasource: - url: jdbc:mysql://localhost:3306/mall_promotion?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: zhuyang - # Spring Cloud 配置项 - cloud: - nacos: - # Spring Cloud Nacos Discovery 配置项 - discovery: - server-addr: localhost:8848 # Nacos 服务器地址 - namespace: dev # Nacos 命名空间 - -# Dubbo 配置项 -dubbo: - # Dubbo 注册中心 - registry: - # address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址 - address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址 diff --git a/归档/promotion-service-project/promotion-service-app/src/main/resources/application-local.yaml b/归档/promotion-service-project/promotion-service-app/src/main/resources/application-local.yaml deleted file mode 100644 index 43bff1671..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/resources/application-local.yaml +++ /dev/null @@ -1,24 +0,0 @@ -spring: - # 数据源配置项 - datasource: - url: jdbc:mysql://localhost:3306/mall_promotion?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT - driver-class-name: com.mysql.jdbc.Driver - username: root - password: zhuyang - # Spring Cloud 配置项 - cloud: - nacos: - # Spring Cloud Nacos Discovery 配置项 - discovery: - server-addr: localhost:8848 # Nacos 服务器地址 - namespace: dev # Nacos 命名空间 - -# Dubbo 配置项 -dubbo: - # Dubbo 注册中心 - registry: -# address: spring-cloud://localhost:8848 # 指定 Dubbo 服务注册中心的地址 - address: nacos://localhost:8848?namespace=dev # 指定 Dubbo 服务注册中心的地址 - # Dubbo 服务提供者的配置 - provider: - tag: ${DUBBO_TAG} # Dubbo 路由分组 diff --git a/归档/promotion-service-project/promotion-service-app/src/main/resources/application.yaml b/归档/promotion-service-project/promotion-service-app/src/main/resources/application.yaml deleted file mode 100644 index 10d90e898..000000000 --- a/归档/promotion-service-project/promotion-service-app/src/main/resources/application.yaml +++ /dev/null @@ -1,64 +0,0 @@ -spring: - # Application 的配置项 - application: - name: promotion-service - # Profile 的配置项 - profiles: - active: local - -# MyBatis Plus 配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: auto - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - mapper-locations: classpath*:mapper/*.xml - type-aliases-package: cn.iocoder.mall.promotionservice.dal.mysql.dataobject - -# Dubbo 配置项 -dubbo: - # Spring Cloud Alibaba Dubbo 专属配置 - cloud: - subscribed-services: '' # 设置订阅的应用列表,默认为 * 订阅所有应用 - # Dubbo 提供者的协议 - protocol: - name: dubbo - port: -1 - # Dubbo 提供服务的扫描基础包 - scan: - base-packages: cn.iocoder.mall.promotionservice.rpc - # Dubbo 服务提供者的配置 - provider: - filter: -exception - validation: true # 开启 Provider 参数校验 - version: 1.0.0 # 服务的版本号 - # Dubbo 服务消费者的配置 - consumer: - ErrorCodeRpc: - version: 1.0.0 - ProductSkuRpc: - version: 1.0.0 - ProductSpuRpc: - version: 1.0.0 - -# RocketMQ 配置项 -rocketmq: - name-server: localhost:9876 - producer: - group: ${spring.application.name}-producer-group - -# Actuator 监控配置项 -management: - server.port: 38085 # 独立端口,避免被暴露出去 - endpoints.web.exposure.include: '*' # 暴露所有监控端点 -server.port: ${management.server.port} # 设置使用 Actuator 的服务器端口,因为 RPC 服务不需要 Web 端口 - -# Mall 配置项 -mall: - # 错误码配置项对应 ErrorCodeProperties 配置类 - error-code: - group: ${spring.application.name} - constants-class: cn.iocoder.mall.promotionservice.enums.PromotionErrorCodeConstants