移除商品推荐的逻辑

pull/12/head
YunaiV 2022-11-05 01:19:25 +08:00
parent fcea893ec9
commit 479a05b5d7
52 changed files with 0 additions and 2783 deletions

View File

@ -1,36 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.activity;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.activity.vo.PromotionActivityPageReqVO;
import cn.iocoder.mall.managementweb.manager.promotion.activity.PromotionActivityManager;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import cn.iocoder.security.annotations.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("/promotion/activity")
@Api(tags = "促销活动 API")
@Validated
public class PromotionActivityController {
@Autowired
private PromotionActivityManager promotionActivityManager;
// TODO 芋艿DTO => VO
@GetMapping("/page")
@ApiOperation("获得促销活动分页")
@RequiresPermissions("promotion:activity:page")
public CommonResult<PageResult<PromotionActivityRespDTO>> pagePromotionActivity(PromotionActivityPageReqVO pageReqVO) {
return success(promotionActivityManager.pagePromotionActivity(pageReqVO));
}
}

View File

@ -1,26 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.activity.vo;
import cn.iocoder.common.framework.vo.PageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Collection;
/**
* Request DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PromotionActivityPageReqVO extends PageParam {
@ApiModelProperty(value = "标题", example = "优惠劵牛逼")
private String title;
@ApiModelProperty(value = "活动类型", example = "1", notes = "参见 PromotionActivityTypeEnum 枚举")
private Integer activityType;
@ApiModelProperty(value = "状态数组", example = "1,2", notes = "参考 PromotionActivityStatusEnum 枚举")
private Collection<Integer> statuses;
}

View File

@ -1,65 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.brand;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerCreateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerPageReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerRespVO;
import cn.iocoder.mall.managementweb.controller.promotion.brand.vo.BannerUpdateReqVO;
import cn.iocoder.mall.managementweb.manager.promotion.brand.BannerManager;
import cn.iocoder.security.annotations.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* Banner Controller
*/
@RestController
@RequestMapping("/promotion/banner")
@Api(tags = "Banner API")
@Validated
public class BannerController {
@Autowired
private BannerManager bannerManager;
@PostMapping("/create")
@ApiOperation("创建 Banner")
@RequiresPermissions("promotion:banner:create")
public CommonResult<Integer> createBanner(@Valid BannerCreateReqVO createVO) {
return success(bannerManager.createBanner(createVO));
}
@PostMapping("/update")
@ApiOperation("更新 Banner")
@RequiresPermissions("promotion:banner:update")
public CommonResult<Boolean> updateBanner(@Valid BannerUpdateReqVO updateVO) {
bannerManager.updateBanner(updateVO);
return success(true);
}
@PostMapping("/delete")
@ApiOperation("删除 Banner")
@ApiImplicitParam(name = "bannerId", value = " Banner 编号", required = true)
@RequiresPermissions("promotion:banner:delete")
public CommonResult<Boolean> deleteBanner(@RequestParam("bannerId") Integer bannerId) {
bannerManager.deleteBanner(bannerId);
return success(true);
}
@GetMapping("/page")
@ApiOperation("获得 Banner 分页")
@RequiresPermissions("promotion:banner:page")
public CommonResult<PageResult<BannerRespVO>> pageBanner(BannerPageReqVO pageVO) {
return success(bannerManager.pageBanner(pageVO));
}
}

View File

@ -1,43 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.brand.vo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.URL;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ApiModel("Banner 创建 Request VO")
@Data
public class BannerCreateReqVO {
@ApiModelProperty(value = "标题", required = true, example = "活动 A")
@NotEmpty(message = "标题不能为空")
@Length(min = 2, max = 32, message = "标题长度为 2-32 位")
private String title;
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.baidu.com")
@NotEmpty(message = "跳转链接不能为空")
@URL(message = "跳转链接格式不正确")
@Length(max = 255, message = "跳转链接最大长度为 255 位")
private String url;
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.iocoder.cn/01.jpg")
@NotEmpty(message = "跳转链接不能为空")
@URL(message = "图片链接格式不正确")
@Length(max = 255, message = "图片链接最大长度为 255 位")
private String picUrl;
@ApiModelProperty(value = "排序", required = true, example = "10")
@NotNull(message = "排序不能为空")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, example = "1")
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
@ApiModelProperty(value = "备注", example = "这个活动很牛逼")
@Length(max = 255, message = "备注最大长度为 255 位")
private String memo;
}

View File

@ -1,17 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.brand.vo;
import cn.iocoder.common.framework.vo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ApiModel("Banner 分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
public class BannerPageReqVO extends PageParam {
@ApiModelProperty(value = "标题", required = true, example = "活动 A")
private String title;
}

View File

@ -1,32 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.brand.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
@ApiModel("Banner VO")
@Data
@Accessors(chain = true)
public class BannerRespVO {
@ApiModelProperty(value = "Banner 编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "标题", required = true, example = "活动 A")
private String title;
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.baidu.com")
private String url;
@ApiModelProperty(value = "图片链接", required = true, example = "http://www.iocoder.cn/01.jpg")
private String picUrl;
@ApiModelProperty(value = "排序", required = true, example = "10")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, example = "1")
private Integer status;
@ApiModelProperty(value = "备注", example = "这个活动很牛逼")
private String memo;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
private Date createTime;
}

View File

@ -1,43 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.brand.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.URL;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ApiModel("Banner 更新 Request VO")
@Data
public class BannerUpdateReqVO {
@ApiModelProperty(value = "Banner 编号", required = true, example = "1")
@NotNull(message = "编号不能为空")
private Integer id;
@ApiModelProperty(value = "标题", required = true, example = "活动 A")
@NotEmpty(message = "标题不能为空")
@Length(min = 2, max = 32, message = "标题长度为 2-32 位")
private String title;
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.baidu.com")
@NotEmpty(message = "跳转链接不能为空")
@URL(message = "跳转链接格式不正确")
@Length(max = 255, message = "跳转链接最大长度为 255 位")
private String url;
@ApiModelProperty(value = "跳转链接", required = true, example = "http://www.iocoder.cn/01.jpg")
@NotEmpty(message = "跳转链接不能为空")
@URL(message = "图片链接格式不正确")
@Length(max = 255, message = "图片链接最大长度为 255 位")
private String picUrl;
@ApiModelProperty(value = "排序", required = true, example = "10")
@NotNull(message = "排序不能为空")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, example = "1")
@NotNull(message = "状态不能为空")
private Integer status;
@ApiModelProperty(value = "备注", example = "这个活动很牛逼")
@Length(max = 255, message = "备注最大长度为 255 位")
private String memo;
}

View File

@ -1,71 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.coupon;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardCreateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardUpdateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplatePageReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateRespVO;
import cn.iocoder.mall.managementweb.manager.promotion.coupon.CouponTemplateManager;
import cn.iocoder.security.annotations.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("/promotion/coupon-template")
@Api(tags = "优惠劵(码)模板 API")
@Validated
public class CouponTemplateController {
@Autowired
private CouponTemplateManager couponTemplateManager;
// ========== 通用逻辑 =========
@GetMapping("/page")
@ApiOperation("获得优惠劵模板分页")
@RequiresPermissions("promotion:coupon-template:page")
public CommonResult<PageResult<CouponTemplateRespVO>> pageCouponTemplate(CouponTemplatePageReqVO pageVO) {
return success(couponTemplateManager.pageCouponTemplate(pageVO));
}
@PostMapping("/update-status")
@ApiOperation("更新优惠劵(码)模板的状态")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "优惠劵(码)模板编号", required = true, example = "1"),
@ApiImplicitParam(name = "status", value = "状态。1 - 开启2 - 禁用", required = true, example = "1"),
})
@RequiresPermissions("promotion:coupon-template:update-status")
public CommonResult<Boolean> updateCouponTemplateStatus(@RequestParam("id") Integer id,
@RequestParam("status") Integer status) {
couponTemplateManager.updateCouponTemplateStatus(id, status);
return success(true);
}
// ========== 优惠劵模板 ==========
@PostMapping("/create-card")
@ApiOperation("创建优惠劵模板")
@RequiresPermissions("promotion:coupon-template:create-card")
public CommonResult<Integer> createCouponCardTemplate(@Valid CouponTemplateCardCreateReqVO createVO) {
return success(couponTemplateManager.createCouponCardTemplate(createVO));
}
@PostMapping("/update-card")
@ApiOperation("更新优惠劵模板")
@RequiresPermissions("promotion:coupon-template:update-card")
public CommonResult<Boolean> updateCouponCardTemplate(@Valid CouponTemplateCardUpdateReqVO updateVO) {
couponTemplateManager.updateCouponCardTemplate(updateVO);
return success(true);
}
}

View File

@ -1,84 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template;
import cn.iocoder.common.framework.validator.InEnum;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
@ApiModel("优惠劵模板创建 Request VO")
@Data
@Accessors(chain = true)
public class CouponTemplateCardCreateReqVO {
// ========== 基本信息 BEGIN ==========
@ApiModelProperty(value = "标题", required = true, example = "优惠劵牛逼")
@NotEmpty(message = "标题不能为空")
@Length(min = 2, max = 16, message = "标题长度为 {min}-{max} 位")
private String title;
@ApiModelProperty(value = "使用说明", required = true, example = "我只是描述")
@Length(max = 255, message = "使用说明最大长度为 {max} 位")
private String description;
@ApiModelProperty(value = "每人限领个数", example = "1", notes = "null - 则表示不限制")
@Min(value = 1, message = "每人限领个数最小为 {value}")
private Integer quota;
@ApiModelProperty(value = "发放总量", example = "100")
@Min(value = 1, message = "每人限领个数最小为 {value}")
private Integer total;
// ========== 领取规则 END ==========
// ========== 使用规则 BEGIN ==========
@ApiModelProperty(value = "是否设置满多少金额可用,单位:分", required = true, example = "0", notes = "0-不限制大于0-多少金额可用")
@Min(value = 0L, message = "使用金额门槛最低为 {value}")
private Integer priceAvailable;
@ApiModelProperty(value = "可用范围的类型", required = true, example = "10", notes = "参见 RangeTypeEnum 枚举")
@NotNull(message = "可用范围的类型不能为空")
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
private Integer rangeType;
@ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "1,3,5")
private String rangeValues;
@ApiModelProperty(value = "生效日期类型", example = "1", notes = "参见 CouponTemplateDateTypeEnum 枚举")
@NotNull(message = "生效日期类型不能为空")
@InEnum(value = CouponTemplateDateTypeEnum.class, message = "生效日期类型必须在 {value}")
private Integer dateType;
@ApiModelProperty(value = "固定日期-生效开始时间", notes = "当 dateType 为固定日期时,非空")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date validStartTime;
@ApiModelProperty(value = "固定日期-生效结束时间", notes = "当 dateType 为固定日期时,非空")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date validEndTime;
@ApiModelProperty(value = "领取日期-开始天数", example = "0", notes = "例如0-当天1-次天")
@Min(value = 0L, message = "领取日期开始时间最小为 {value}")
private Integer fixedStartTerm;
@ApiModelProperty(value = "领取日期-结束天数", example = "1", notes = "当 dateType 为领取日期时,非空")
@Min(value = 1L, message = "领取日期结束时间最小为 {value}")
private Integer fixedEndTerm;
// ========== 使用效果 BEGIN ==========
@ApiModelProperty(value = "优惠类型", required = true, example = "1", notes = "参见 PreferentialTypeEnum 枚举")
@NotNull(message = "优惠类型不能为空")
@InEnum(value = PreferentialTypeEnum.class, message = "优惠类型必须在 {value}")
private Integer preferentialType;
@ApiModelProperty(value = "折扣百分比", example = "80", notes = "当 preferentialType 为现金券时,非空")
@Max(value = 100, message = "折扣比最大值为 {value}")
private Integer percentOff;
@ApiModelProperty(value = "优惠金额,单位:分", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
@Min(value = 1, message = "优惠金额最小值为 {value}")
private Integer priceOff;
@ApiModelProperty(value = "折扣上限", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
@Min(value = 1, message = "折扣上限最小值为 {value}")
private Integer discountPriceLimit;
// ========== 使用效果 END ==========
}

View File

@ -1,47 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.enums.RangeTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@ApiModel("优惠劵模板更新 Request VO")
@Data
@Accessors(chain = true)
public class CouponTemplateCardUpdateReqVO {
// ========== 基本信息 BEGIN ==========
@ApiModelProperty(value = "模板编号,自增唯一", required = true, example = "1")
@NotNull(message = "编号不能为空")
private Integer id;
@ApiModelProperty(value = "标题", required = true, example = "优惠劵牛逼")
@NotEmpty(message = "标题不能为空")
@Length(min = 2, max = 16, message = "标题长度为 {min}-{max} 位")
private String title;
@ApiModelProperty(value = "使用说明", required = true, example = "我只是描述")
@Length(max = 255, message = "使用说明最大长度为 {max} 位")
private String description;
@ApiModelProperty(value = "每人限领个数", example = "1", notes = "null - 则表示不限制")
@Min(value = 1, message = "每人限领个数最小为 {value}")
private Integer quota;
@ApiModelProperty(value = "发放总量", example = "100")
@Min(value = 1, message = "每人限领个数最小为 {value}")
private Integer total;
// ========== 领取规则 END ==========
// ========== 使用规则 BEGIN ==========
@NotNull(message = "可用范围的类型不能为空")
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
private Integer rangeType;
@ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "1,3,5")
private String rangeValues;
// ========== 使用规则 END ==========
}

View File

@ -1,23 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template;
import cn.iocoder.common.framework.vo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ApiModel("优惠劵(码)模板分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
public class CouponTemplatePageReqVO extends PageParam {
@ApiModelProperty(value = "类型", example = "1", notes = "参考 CouponTemplateTypeEnum 枚举")
private Integer type;
@ApiModelProperty(value = "标题", example = "优惠劵牛逼")
private String title;
@ApiModelProperty(value = "状态", example = "1", notes = "参考 CouponTemplateStatusEnum 枚举")
private Integer status;
@ApiModelProperty(value = "优惠类型", example = "1", notes = "参见 PreferentialTypeEnum 枚举")
private Integer preferentialType;
}

View File

@ -1,80 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
@ApiModel("优惠劵(码)模板 VO")
@Data
@Accessors(chain = true)
public class CouponTemplateRespVO {
// ========== 基本信息 BEGIN ==========
@ApiModelProperty(value = "模板编号,自增唯一", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "标题", required = true, example = "优惠劵牛逼")
private String title;
@ApiModelProperty(value = "使用说明", required = true, example = "我只是描述")
private String description;
@ApiModelProperty(value = "优惠劵类型", required = true, example = "1", notes = "参见 CouponTemplateTypeEnum 枚举")
private Integer type;
/**
*
*
* 1-UNIQUE
* 2-GENERAL
*
* @see CouponCodeDO
*/
private Integer codeType;
@ApiModelProperty(value = "优惠码状态", required = true, example = "1", notes = "参见 CouponTemplateStatusEnum 枚举")
private Integer status;
@ApiModelProperty(value = "每人限领个数", example = "1", notes = "null - 则表示不限制")
private Integer quota;
@ApiModelProperty(value = "发放总量", example = "100")
private Integer total;
// ========== 领取规则 END ==========
// ========== 使用规则 BEGIN ==========
@ApiModelProperty(value = "是否设置满多少金额可用,单位:分", required = true, example = "0", notes = "0-不限制大于0-多少金额可用")
private Integer priceAvailable;
@ApiModelProperty(value = "可用范围的类型", required = true, example = "10", notes = "参见 RangeTypeEnum 枚举")
private Integer rangeType;
@ApiModelProperty(value = "指定商品 / 分类列表,使用逗号分隔商品编号", example = "1,3,5")
private List<Integer> rangeValues;
@ApiModelProperty(value = "生效日期类型", example = "1", notes = "参见 CouponTemplateDateTypeEnum 枚举")
private Integer dateType;
@ApiModelProperty(value = "固定日期-生效开始时间", notes = "当 dateType 为固定日期时,非空")
private Date validStartTime;
@ApiModelProperty(value = "固定日期-生效结束时间", notes = "当 dateType 为固定日期时,非空")
private Date validEndTime;
@ApiModelProperty(value = "领取日期-开始天数", example = "0", notes = "例如0-当天1-次天")
private Integer fixedStartTerm;
@ApiModelProperty(value = "领取日期-结束天数", example = "1", notes = "当 dateType 为领取日期时,非空")
private Integer fixedEndTerm;
// ========== 使用规则 END ==========
// ========== 使用效果 BEGIN ==========
@ApiModelProperty(value = "优惠类型", required = true, example = "1", notes = "参见 PreferentialTypeEnum 枚举")
private Integer preferentialType;
@ApiModelProperty(value = "折扣百分比", example = "80", notes = "当 preferentialType 为现金券时,非空")
private Integer percentOff;
@ApiModelProperty(value = "优惠金额,单位:分", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
private Integer priceOff;
@ApiModelProperty(value = "折扣上限", example = "100", notes = "当 preferentialType 为折扣卷时,非空")
private Integer discountPriceLimit;
// ========== 使用效果 END ==========
// ========== 统计信息 BEGIN ==========
@ApiModelProperty(value = "领取优惠券的次数", required = true)
private Integer statFetchNum;
// ========== 统计信息 END ==========
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
}

View File

@ -1,60 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.recommend;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendCreateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendDetailVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendPageReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendUpdateReqVO;
import cn.iocoder.mall.managementweb.manager.promotion.recommend.ProductRecommendManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* Controller
*/
@RestController
@RequestMapping("/promotion/product-recommend")
@Api(tags = "商品推荐")
@Validated
public class ProductRecommendController {
@Autowired
private ProductRecommendManager productRecommendManager;
@PostMapping("/create")
@ApiOperation("创建商品推荐")
public CommonResult<Integer> createProductRecommend(@Valid ProductRecommendCreateReqVO createVO) {
return success(productRecommendManager.createProductRecommend(createVO));
}
@PostMapping("/update")
@ApiOperation("更新商品推荐")
public CommonResult<Boolean> updateProductRecommend(@Valid ProductRecommendUpdateReqVO updateVO) {
productRecommendManager.updateProductRecommend(updateVO);
return success(true);
}
@PostMapping("/delete")
@ApiOperation("删除商品推荐")
@ApiImplicitParam(name = "productRecommendId", value = "商品推荐编号", required = true)
public CommonResult<Boolean> deleteProductRecommend(@RequestParam("productRecommendId") Integer productRecommendId) {
productRecommendManager.deleteProductRecommend(productRecommendId);
return success(true);
}
@GetMapping("/page")
@ApiOperation("获得商品推荐分页")
public CommonResult<PageResult<ProductRecommendDetailVO>> pageProductRecommend(ProductRecommendPageReqVO pageVO) {
return success(productRecommendManager.pageProductRecommend(pageVO));
}
}

View File

@ -1,33 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.recommend.vo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@ApiModel("商品推荐创建 Request VO")
@Data
public class ProductRecommendCreateReqVO {
@ApiModelProperty(value = "类型", example = "1", required = true, notes = "参见 ProductRecommendTypeEnum 枚举")
@NotNull(message = "类型不能为空")
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
private Integer type;
@ApiModelProperty(value = "商品 Spu 编号", required = true, example = "1")
@NotNull(message = "商品 Spu 编号不能为空")
private Integer productSpuId;
@ApiModelProperty(value = "排序", required = true, example = "1")
@NotNull(message = "排序不能为空")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
@ApiModelProperty(value = "备注", example = "我是备注")
private String memo;
}

View File

@ -1,43 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.recommend.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
@ApiModel("商品推荐明细 VO")
@Data
@Accessors(chain = true)
public class ProductRecommendDetailVO {
@ApiModelProperty(value = "编号", required = true, example = "1")
private Integer id;
@ApiModelProperty(value = "推荐类型", required = true, example = "1", notes = "参见 ProductRecommendTypeEnum 枚举")
private Integer type;
@ApiModelProperty(value = "商品编号", required = true, example = "1")
private Integer productSpuId;
@ApiModelProperty(value = "排序", required = true, example = "10")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
private Integer status;
@ApiModelProperty(value = "备注", required = true, example = "这个活动很牛逼")
private String memo;
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
private Date createTime;
/**
*
*/
private Spu spu;
@ApiModel("商品信息")
@Data
public static class Spu {
@ApiModelProperty(value = "SPU 名字", required = true, example = "厮大牛逼")
private String name;
}
}

View File

@ -1,20 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.recommend.vo;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.common.framework.vo.PageParam;
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ApiModel("商品推荐分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
public class ProductRecommendPageReqVO extends PageParam {
@ApiModelProperty(value = "类型", example = "1", notes = "参见 ProductRecommendTypeEnum 枚举")
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
private Integer type;
}

View File

@ -1,36 +0,0 @@
package cn.iocoder.mall.managementweb.controller.promotion.recommend.vo;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@ApiModel("商品推荐更新 Request VO")
@Data
public class ProductRecommendUpdateReqVO {
@ApiModelProperty(value = "编号", required = true, example = "1")
@NotNull(message = "编号不能为空")
private Integer id;
@ApiModelProperty(value = "类型", example = "1", required = true, notes = "参见 ProductRecommendTypeEnum 枚举")
@NotNull(message = "类型不能为空")
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
private Integer type;
@ApiModelProperty(value = "商品 Spu 编号", required = true, example = "1")
@NotNull(message = "商品 Spu 编号不能为空")
private Integer productSpuId;
@ApiModelProperty(value = "排序", required = true, example = "1")
@NotNull(message = "排序不能为空")
private Integer sort;
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
@ApiModelProperty(value = "备注", example = "我是备注")
private String memo;
}

View File

@ -1,28 +0,0 @@
package cn.iocoder.mall.managementweb.convert.promotion;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardCreateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardUpdateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplatePageReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateRespVO;
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 org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface CouponTemplateConvert {
CouponTemplateConvert INSTANCE = Mappers.getMapper(CouponTemplateConvert.class);
CouponCardTemplateUpdateReqDTO convert(CouponTemplateCardUpdateReqVO bean);
CouponTemplatePageReqDTO convert(CouponTemplatePageReqVO bean);
PageResult<CouponTemplateRespVO> convertPage(PageResult<CouponTemplateRespDTO> page);
CouponCardTemplateCreateReqDTO convert(CouponTemplateCardCreateReqVO bean);
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.mall.managementweb.convert.promotion;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendCreateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendDetailVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendPageReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendUpdateReqVO;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendCreateReqDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendPageReqDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendUpdateReqDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface ProductRecommendConvert {
ProductRecommendConvert INSTANCE = Mappers.getMapper(ProductRecommendConvert.class);
ProductRecommendCreateReqDTO convert(ProductRecommendCreateReqVO bean);
ProductRecommendUpdateReqDTO convert(ProductRecommendUpdateReqVO bean);
ProductRecommendPageReqDTO convert(ProductRecommendPageReqVO bean);
PageResult<ProductRecommendDetailVO> convertPage(PageResult<ProductRecommendRespDTO> page);
ProductRecommendDetailVO.Spu convert(ProductSpuRespDTO bean);
}

View File

@ -1,15 +0,0 @@
package cn.iocoder.mall.managementweb.convert.promotion;
import cn.iocoder.mall.managementweb.controller.promotion.activity.vo.PromotionActivityPageReqVO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface PromotionActivityConvert {
PromotionActivityConvert INSTANCE = Mappers.getMapper(PromotionActivityConvert.class);
PromotionActivityPageReqDTO convert(PromotionActivityPageReqVO bean);
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.mall.managementweb.manager.promotion.activity;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.activity.vo.PromotionActivityPageReqVO;
import cn.iocoder.mall.managementweb.convert.promotion.PromotionActivityConvert;
import cn.iocoder.mall.promotion.api.rpc.activity.PromotionActivityFeign;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
/**
* Manager
*/
@Service
@Validated
public class PromotionActivityManager {
@Autowired
private PromotionActivityFeign promotionActivityFeign;
public PageResult<PromotionActivityRespDTO> pagePromotionActivity(PromotionActivityPageReqVO pageReqVO) {
CommonResult<PageResult<PromotionActivityRespDTO>> pagePromotionActivityResult = promotionActivityFeign.pagePromotionActivity(
PromotionActivityConvert.INSTANCE.convert(pageReqVO));
pagePromotionActivityResult.checkError();
return pagePromotionActivityResult.getData();
}
}

View File

@ -1,54 +0,0 @@
package cn.iocoder.mall.managementweb.manager.promotion.coupon;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardCreateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateCardUpdateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplatePageReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.coupon.vo.template.CouponTemplateRespVO;
import cn.iocoder.mall.managementweb.convert.promotion.CouponTemplateConvert;
import cn.iocoder.mall.promotion.api.rpc.coupon.CouponTemplateFeign;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponCardTemplateUpdateStatusReqDTO;
import cn.iocoder.mall.promotion.api.rpc.coupon.dto.template.CouponTemplateRespDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@Service
@Validated
public class CouponTemplateManager {
@Autowired
private CouponTemplateFeign couponTemplateFeign;
// ========== 通用逻辑 =========
public PageResult<CouponTemplateRespVO> pageCouponTemplate(CouponTemplatePageReqVO pageVO) {
CommonResult<PageResult<CouponTemplateRespDTO>> pageCouponTemplateResult =
couponTemplateFeign.pageCouponTemplate(CouponTemplateConvert.INSTANCE.convert(pageVO));
pageCouponTemplateResult.checkError();
return CouponTemplateConvert.INSTANCE.convertPage(pageCouponTemplateResult.getData());
}
public void updateCouponTemplateStatus(Integer id, Integer status) {
CommonResult<Boolean> updateCouponTemplateStatusResult = couponTemplateFeign.updateCouponTemplateStatus(
new CouponCardTemplateUpdateStatusReqDTO().setId(id).setStatus(status));
updateCouponTemplateStatusResult.checkError();
}
// ========== 优惠劵模板 ==========
public Integer createCouponCardTemplate(CouponTemplateCardCreateReqVO createVO) {
CommonResult<Integer> createCouponCardTemplateResult = couponTemplateFeign.createCouponCardTemplate(
CouponTemplateConvert.INSTANCE.convert(createVO));
createCouponCardTemplateResult.checkError();
return createCouponCardTemplateResult.getData();
}
public void updateCouponCardTemplate(CouponTemplateCardUpdateReqVO updateVO) {
CommonResult<Boolean> updateCouponCardTemplateResult = couponTemplateFeign.updateCouponCardTemplate(
CouponTemplateConvert.INSTANCE.convert(updateVO));
updateCouponCardTemplateResult.checkError();
}
}

View File

@ -1,90 +0,0 @@
package cn.iocoder.mall.managementweb.manager.promotion.recommend;
import cn.iocoder.common.framework.util.CollectionUtils;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendCreateReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendDetailVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendPageReqVO;
import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendUpdateReqVO;
import cn.iocoder.mall.managementweb.convert.promotion.ProductRecommendConvert;
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendFeign;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import java.util.Map;
/**
* Manager
*/
@Service
@Validated
public class ProductRecommendManager {
@Autowired
private ProductRecommendFeign productRecommendFeign;
@Autowired
private ProductSpuFeign productSpuFeign;
/**
*
*
* @param createVO VO
* @return
*/
public Integer createProductRecommend(ProductRecommendCreateReqVO createVO) {
CommonResult<Integer> createProductRecommendResult = productRecommendFeign.createProductRecommend(
ProductRecommendConvert.INSTANCE.convert(createVO));
createProductRecommendResult.checkError();
return createProductRecommendResult.getData();
}
/**
*
*
* @param updateVO VO
*/
public void updateProductRecommend(ProductRecommendUpdateReqVO updateVO) {
CommonResult<Boolean> updateProductRecommendResult = productRecommendFeign.updateProductRecommend(
ProductRecommendConvert.INSTANCE.convert(updateVO));
updateProductRecommendResult.checkError();
}
/**
*
*
* @param productRecommendId
*/
public void deleteProductRecommend(Integer productRecommendId) {
CommonResult<Boolean> deleteProductRecommendResult = productRecommendFeign.deleteProductRecommend(productRecommendId);
deleteProductRecommendResult.checkError();
}
/**
*
*
* @param pageVO
* @return
*/
public PageResult<ProductRecommendDetailVO> pageProductRecommend(ProductRecommendPageReqVO pageVO) {
CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommendResult = productRecommendFeign.pageProductRecommend(ProductRecommendConvert.INSTANCE.convert(pageVO));
pageProductRecommendResult.checkError();
// 拼接结果
PageResult<ProductRecommendDetailVO> pageResult = ProductRecommendConvert.INSTANCE.convertPage(pageProductRecommendResult.getData());
if (!CollectionUtils.isEmpty(pageResult.getList())) {
// 获取商品信息,并进行拼接
CommonResult<List<ProductSpuRespDTO>> listProductSpusResult = productSpuFeign.listProductSpus(
CollectionUtils.convertSet(pageResult.getList(), ProductRecommendDetailVO::getProductSpuId));
listProductSpusResult.checkError();
Map<Integer, ProductSpuRespDTO> productSpuMap = CollectionUtils.convertMap(listProductSpusResult.getData(), ProductSpuRespDTO::getId);
pageResult.getList().forEach(detailVO ->
detailVO.setSpu(ProductRecommendConvert.INSTANCE.convert(productSpuMap.get(detailVO.getProductSpuId()))));
}
return pageResult;
}
}

View File

@ -1,33 +0,0 @@
package cn.iocoder.mall.promotion.api.enums;
/**
*
*/
public enum MeetTypeEnum {
PRICE(1, "金额"),
QUANTITY(2, "数量"),;
/**
*
*/
private final Integer value;
/**
*
*/
private final String name;
MeetTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

@ -9,15 +9,6 @@ import cn.iocoder.common.framework.exception.ErrorCode;
*/
public interface PromotionErrorCodeConstants {
// ========== Banner 模块 ==========
ErrorCode BANNER_NOT_EXISTS = new ErrorCode(1006000000, "账号不存在");
// ========== PRODUCT RECOMMEND 模块 ==========
ErrorCode PRODUCT_RECOMMEND_NOT_EXISTS = new ErrorCode(1006001000, "商品推荐不存在");
ErrorCode PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS = new ErrorCode(1006001001, "商品不存在");
ErrorCode PRODUCT_RECOMMEND_EXISTS = new ErrorCode(1006001002, "该商品推荐已经存在");
// ========== COUPON TEMPLATE 模块 ==========
ErrorCode COUPON_TEMPLATE_NOT_EXISTS = new ErrorCode(1006002000, "优惠劵模板(码)不存在");
ErrorCode COUPON_TEMPLATE_NOT_CARD = new ErrorCode(1006002001, "不是优惠劵模板");
@ -34,7 +25,4 @@ public interface PromotionErrorCodeConstants {
ErrorCode COUPON_CARD_STATUS_NOT_UNUSED = new ErrorCode(1006003003, "优惠劵不处于待使用状态");
ErrorCode COUPON_CARD_STATUS_NOT_USED = new ErrorCode( 1006003004, "优惠劵不处于已使用状态");
// ========== PRICE 模块 ==========
ErrorCode PRICE_PRODUCT_SKU_NOT_EXISTS = new ErrorCode(1006004000, "有不存在的商品!");
}

View File

@ -1,49 +0,0 @@
package cn.iocoder.mall.promotion.api.enums;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
*
*/
public enum RangeTypeEnum implements IntArrayValuable {
ALL(10, "所有可用"),
PRODUCT_INCLUDE_PART(20, "部分商品可用,或指定商品可用"),
PRODUCT_EXCLUDE_PART(21, "部分商品不可用,或指定商品不可用"),
CATEGORY_INCLUDE_PART(30, "部分分类可用,或指定分类可用"),
CATEGORY_EXCLUDE_PART(31, "部分分类不可用,或指定分类不可用"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(RangeTypeEnum::getValue).toArray();
/**
*
*/
private final Integer value;
/**
*
*/
private final String name;
RangeTypeEnum(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;
}
}

View File

@ -1,45 +0,0 @@
package cn.iocoder.mall.promotion.api.enums.coupon.card;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
*
*/
public enum CouponCardStatusEnum implements IntArrayValuable {
UNUSED(1, "未使用"),
USED(2, "已使用"),
EXPIRE(3, "已过期"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponCardStatusEnum::getValue).toArray();
/**
*
*/
private final Integer value;
/**
*
*/
private final String name;
CouponCardStatusEnum(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;
}
}

View File

@ -1,53 +0,0 @@
package cn.iocoder.mall.promotion.api.enums.recommend;
import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
/**
*
*/
public enum ProductRecommendTypeEnum implements IntArrayValuable {
HOT(1, "热卖推荐"),
NEW(2, "新品推荐"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductRecommendTypeEnum::getValue).toArray();
/**
*
*/
private final Integer value;
/**
*
*/
private final String name;
ProductRecommendTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
public static boolean isValid(Integer status) {
if (status == null) {
return false;
}
return HOT.value.equals(status)
|| NEW.value.equals(status);
}
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -1,33 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.activity.dto;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Collection;
/**
* Request DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PromotionActivityPageReqDTO extends PageParam {
/**
*
*
*
*/
private String title;
/**
*
*/
private Integer activityType;
/**
*
*/
private Collection<Integer> statuses;
}

View File

@ -1,160 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.activity.dto;
import cn.iocoder.mall.promotion.api.enums.activity.PromotionActivityStatusEnum;
import cn.iocoder.mall.promotion.api.enums.activity.PromotionActivityTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* Response DTO
*/
@Data
@Accessors(chain = true)
public class PromotionActivityRespDTO implements Serializable {
/**
*
*/
private Integer id;
/**
*
*/
private String title;
/**
*
*
* {@link PromotionActivityTypeEnum}
*/
private Integer activityType;
/**
*
*
* {@link PromotionActivityStatusEnum}
*/
private Integer status;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
/**
*
*/
private TimeLimitedDiscount timeLimitedDiscount;
/**
*
*/
private FullPrivilege fullPrivilege;
/**
*
*/
private Date createTime;
/**
*
*/
@Data
@Accessors(chain = true)
public static class TimeLimitedDiscount implements Serializable {
/**
*
*/
@Data
@Accessors(chain = true)
public static class Item implements Serializable {
/**
* SPU
*/
private Integer spuId;
/**
*
*/
private Integer preferentialType;
/**
*
*/
private Integer preferentialValue;
}
/**
*
*
* quota = 0
*/
private Integer quota;
/**
*
*/
private List<Item> items;
}
/**
*
*/
@Data
@Accessors(chain = true)
public static class FullPrivilege implements Serializable {
/**
*
*/
@Data
@Accessors(chain = true)
public static class Privilege implements Serializable {
/**
*
*
* 1 -
* 2 -
*/
private Integer meetType;
/**
*
*/
private Integer meetValue;
/**
*
*/
private Integer preferentialType;
/**
*
*/
private Integer preferentialValue;
}
/**
*
*
* {@link cn.iocoder.mall.promotion.api.enums.RangeTypeEnum}
* + PRODUCT_INCLUDE_PRT
*/
private Integer rangeType;
/**
*
*/
private List<Integer> rangeValues;
/**
*
*/
private Boolean cycled;
/**
*
*/
private List<Privilege> privileges;
}
}

View File

@ -1,143 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.coupon.dto.template;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateDateTypeEnum;
import cn.iocoder.mall.promotion.api.enums.PreferentialTypeEnum;
import cn.iocoder.mall.promotion.api.enums.RangeTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* Request DTO
*/
@Data
@Accessors(chain = true)
public class CouponCardTemplateCreateReqDTO implements Serializable {
// ========== 基本信息 BEGIN ==========
/**
*
*/
@NotEmpty(message = "标题不能为空")
@Length(min = 2, max = 16, message = "标题长度为 {min}-{max} 位")
private String title;
/**
* 使
*/
@Length(max = 255, message = "使用说明最大长度为 {max} 位")
private String description;
// ========== 基本信息 END ==========
// ========== 领取规则 BEGIN ==========
/**
*
*/
@NotNull(message = "每人限领个数不能为空")
@Min(value = 1, message = "每人限领个数最小为 {value}")
private Integer quota;
/**
*
*/
@NotNull(message = "发放总量不能为空")
@Min(value = 1, message = "每人限领个数最小为 {value}")
private Integer total;
// ========== 领取规则 END ==========
// ========== 使用规则 BEGIN ==========
/**
*
*
* 0-
* 0-
*/
@NotNull(message = "使用金额门槛不能为空")
@Min(value = 0L, message = "使用金额门槛最低为 {value}")
private Integer priceAvailable;
/**
*
*
* 10-ALL
* 20-PART
* 21-PART
* 30-PART
* 31-PART
*/
@NotNull(message = "可用范围的类型不能为空")
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
private Integer rangeType;
/**
* / 使
*/
private String rangeValues;
/**
*
*
* 1-
* 2- {@link #fixedEndTerm} N
*/
@NotNull(message = "生效日期类型不能为空")
@InEnum(value = CouponTemplateDateTypeEnum.class, message = "生效日期类型必须在 {value}")
private Integer dateType;
/**
* -
*/
private Date validStartTime;
/**
* -
*/
private Date validEndTime;
/**
* -
*
* 0-1-
*/
@Min(value = 0L, message = "领取日期开始时间最小为 {value}")
private Integer fixedStartTerm;
/**
* -
*/
@Min(value = 1L, message = "领取日期结束时间最小为 {value}")
private Integer fixedEndTerm;
// ========== 使用规则 END ==========
// ========== 使用效果 BEGIN ==========
/**
*
*
* 1-
* 2-
*/
@NotNull(message = "优惠类型不能为空")
@InEnum(value = PreferentialTypeEnum.class, message = "优惠类型必须在 {value}")
private Integer preferentialType;
/**
*
*/
@Min(value = 1, message = "优惠金额最小值为 {value}")
private Integer priceOff;
/**
*
*
* 80% 80
* 100% 100
*/
@Max(value = 100, message = "折扣比最大值为 {value}")
private Integer percentOff;
/**
* {@link #preferentialType} 2
*
* 20 使 8 1000 20 80
*/
@Min(value = 1, message = "折扣上限最小值为 {value}")
private Integer discountPriceLimit;
// ========== 使用效果 END ==========
}

View File

@ -1,142 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.coupon.dto.template;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.enums.RangeTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* Request DTO
*/
@Data
@Accessors(chain = true)
public class CouponCardTemplateUpdateReqDTO implements Serializable {
@NotNull(message = "编号不能为空")
private Integer id;
// ========== 基本信息 BEGIN ==========
/**
*
*/
@NotEmpty(message = "标题不能为空")
@Length(min = 2, max = 16, message = "标题长度为 {min}-{max} 位")
private String title;
/**
* 使
*/
@Length(max = 255, message = "使用说明最大长度为 {max} 位")
private String description;
// ========== 基本信息 END ==========
// ========== 领取规则 BEGIN ==========
/**
*
*/
@NotNull(message = "每人限领个数不能为空")
@Min(value = 1, message = "每人限领个数最小为 {value}")
private Integer quota;
/**
*
*/
@NotNull(message = "发放总量不能为空")
@Min(value = 1, message = "每人限领个数最小为 {value}")
private Integer total;
// ========== 领取规则 END ==========
// ========== 使用规则 BEGIN ==========
// /**
// * 是否设置满多少金额可用,单位:分
// *
// * 0-不限制
// * 大于0-多少金额可用
// */
// @NotNull(message = "使用金额门槛不能为空")
// @Min(value = 0L, message = "使用金额门槛最低为 {value}")
// private Integer priceAvailable;
/**
*
*
* 10-ALL
* 20-PART
* 21-PART
* 30-PART
* 31-PART
*/
@NotNull(message = "可用范围的类型不能为空")
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
private Integer rangeType;
/**
* / 使
*/
private String rangeValues;
// /**
// * 生效日期类型
// *
// * 1-固定日期
// * 2-领取日期:领到券 {@link #fixedEndTerm} 日开始 N 天内有效
// */
// @NotNull(message = "生效日期类型不能为空")
// @InEnum(value = CouponTemplateDateTypeEnum.class, message = "生效日期类型必须在 {value}")
// private Integer dateType;
// /**
// * 固定日期-生效开始时间
// */
// private Date validStartTime;
// /**
// * 固定日期-生效结束时间
// */
// private Date validEndTime;
// /**
// * 领取日期-开始天数
// *
// * 例如0-当天1-次天
// */
// @Min(value = 0L, message = "领取日期开始时间最小为 {value}")
// private Integer fixedStartTerm;
// /**
// * 领取日期-结束天数
// */
// @Min(value = 1L, message = "领取日期结束时间最小为 {value}")
// private Integer fixedEndTerm;
// ========== 使用规则 END ==========
// ========== 使用效果 BEGIN ==========
// /**
// * 优惠类型
// *
// * 1-代金卷
// * 2-折扣卷
// */
// @NotNull(message = "优惠类型不能为空")
// @InEnum(value = CouponTemplatePreferentialTypeEnum.class, message = "优惠类型必须在 {value}")
// private Integer preferentialType;
// /**
// * 优惠金额,单位:分
// */
// @Min(value = 1, message = "优惠金额最小值为 {value}")
// private Integer priceOff;
// /**
// * 折扣百分比。
// *
// * 例如80% 为 80。
// * 当 100% 为 100 ,则代表免费。
// */
// @Max(value = 100, message = "折扣比最大值为 {value}")
// private Integer percentOff;
// /**
// * 折扣上限,仅在 {@link #preferentialType} 等于 2 时生效。
// *
// * 例如,折扣上限为 20 元,当使用 8 折优惠券,订单金额为 1000 元时,最高只可折扣 20 元,而非 80 元。
// */
// @Min(value = 1, message = "折扣上限最小值为 {value}")
// private Integer discountPriceLimit;
// ========== 使用效果 END ==========
}

View File

@ -1,30 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.coupon.dto.template;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.enums.coupon.template.CouponTemplateStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* Request DTO
*/
@Data
@Accessors(chain = true)
public class CouponCardTemplateUpdateStatusReqDTO implements Serializable {
/**
*
*/
@NotNull(message = "编号不能为空")
private Integer id;
/**
*
*/
@NotNull(message = "状态不能为空")
@InEnum(value = CouponTemplateStatusEnum.class, message = "状态必须是 {value}")
private Integer status;
}

View File

@ -1,33 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.coupon.dto.template;
import cn.iocoder.common.framework.vo.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* Request DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class CouponTemplatePageReqDTO extends PageParam {
/**
*
*/
private Integer type;
/**
*
*/
private String title;
/**
*
*/
private Integer status;
/**
*
*/
private Integer preferentialType;
}

View File

@ -1,156 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.coupon.dto.template;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* BO
*/
@Data
@Accessors(chain = true)
public class CouponTemplateRespDTO implements Serializable {
// ========== 基本信息 BEGIN ==========
/**
*
*/
private Integer id;
/**
*
*/
private String title;
/**
* 使
*/
private String description;
/**
*
*
* 1-
* 2-
*/
private Integer type;
/**
*
*
* 1-UNIQUE
* 2-GENERAL
*
* @see CouponCodeDO
*/
private Integer codeType;
/**
*
*
* 1-
* 2-
* 3-
*
*
*/
private Integer status;
/**
*
*
* null -
*/
private Integer quota;
/**
*
*/
private Integer total;
// ========== 领取规则 END ==========
// ========== 使用规则 BEGIN ==========
/**
*
*
* 0-
* 0-
*/
private Integer priceAvailable;
/**
*
*
* 10-ALL
* 20-PART
* 21-PART
* 30-PART
* 31-PART
*/
private Integer rangeType;
/**
* / 使
*/
private List<Integer> rangeValues;
/**
*
*
* 1-
* 2- {@link #fixedStartTerm} N
*/
private Integer dateType;
/**
* -
*/
private Date validStartTime;
/**
* -
*/
private Date validEndTime;
/**
* -
*
* 0-1-
*/
private Integer fixedStartTerm;
/**
* -
*/
private Integer fixedEndTerm;
// ========== 使用规则 END ==========
// ========== 使用效果 BEGIN ==========
/**
*
*
* 1-
* 2-
*/
private Integer preferentialType;
/**
*
*
* 80% 80
* 100% 100
*/
private Integer percentOff;
/**
*
*/
private Integer priceOff;
/**
* {@link #preferentialType} 2
*
* 20 使 8 1000 20 80
*/
private Integer discountPriceLimit;
// ========== 使用效果 END ==========
// ========== 统计信息 BEGIN ==========
/**
*
*/
private Integer statFetchNum;
// ========== 统计信息 END ==========
/**
*
*/
private Date createTime;
}

View File

@ -1,38 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.recommend;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@FeignClient("promotion-service")
public interface ProductRecommendFeign {
@PostMapping("/promotion/prod/recommend/createProductRecommend")
public CommonResult<Integer> createProductRecommend(@RequestBody ProductRecommendCreateReqDTO createDTO) ;
@PostMapping("/promotion/prod/recommend/updateProductRecommend")
public CommonResult<Boolean> updateProductRecommend(@RequestBody ProductRecommendUpdateReqDTO updateDTO);
@GetMapping("/promotion/prod/recommend/deleteProductRecommend")
public CommonResult<Boolean> deleteProductRecommend(@RequestParam("productRecommendId") Integer productRecommendId) ;
@PostMapping("/promotion/prod/recommend/listProductRecommends")
public CommonResult<List<ProductRecommendRespDTO>> listProductRecommends(@RequestBody ProductRecommendListReqDTO listReqDTO) ;
@PostMapping("/promotion/prod/recommend/pageProductRecommend")
public CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommend(@RequestBody ProductRecommendPageReqDTO pageDTO) ;
}

View File

@ -1,48 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* Request DTO
*/
@Data
@Accessors(chain = true)
public class ProductRecommendCreateReqDTO implements Serializable {
/**
*
*/
@InEnum(value = ProductRecommendTypeEnum.class, message = "修改推荐类型必须是 {value}")
@NotNull(message = "推荐类型不能为空")
private Integer type;
/**
*
*/
@NotNull(message = "商品编号不能为空")
private Integer productSpuId;
/**
*
*/
@NotNull(message = "排序不能为空")
private Integer sort;
/**
*
*/
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
/**
*
*/
@Length(max = 255, message = "备注最大长度为 255 位")
private String memo;
}

View File

@ -1,29 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* Req DTO
*/
@Data
@Accessors(chain = true)
public class ProductRecommendListReqDTO implements Serializable {
/**
*
*/
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
private Integer type;
/**
*
*/
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
}

View File

@ -1,24 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.common.framework.vo.PageParam;
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* Request DTO
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class ProductRecommendPageReqDTO extends PageParam {
/**
*
*/
@InEnum(value = ProductRecommendTypeEnum.class, message = "推荐类型必须是 {value}")
private Integer type;
}

View File

@ -1,50 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* BO
*/
@Data
@Accessors(chain = true)
public class ProductRecommendRespDTO implements Serializable {
/**
*
*/
private Integer id;
/**
*
*
* {@link ProductRecommendTypeEnum}
*/
private Integer type;
/**
* Spu
*/
private Integer productSpuId;
/**
*
*/
private Integer sort;
/**
*
*
* {@link cn.iocoder.common.framework.enums.CommonStatusEnum}
*/
private Integer status;
/**
*
*/
private String memo;
/**
*
*/
private Date createTime;
}

View File

@ -1,53 +0,0 @@
package cn.iocoder.mall.promotion.api.rpc.recommend.dto;
import cn.iocoder.common.framework.enums.CommonStatusEnum;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* Request DTO
*/
@Data
@Accessors(chain = true)
public class ProductRecommendUpdateReqDTO implements Serializable {
/**
*
*/
@NotNull(message = "编号不能为空")
private Integer id;
/**
*
*/
@InEnum(value = ProductRecommendTypeEnum.class, message = "修改推荐类型必须是 {value}")
@NotNull(message = "推荐类型不能为空")
private Integer type;
/**
*
*/
@NotNull(message = "商品编号不能为空")
private Integer productSpuId;
/**
*
*/
@NotNull(message = "排序不能为空")
private Integer sort;
/**
*
*/
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
private Integer status;
/**
*
*/
@Length(max = 255, message = "备注最大长度为 255 位")
private String memo;
}

View File

@ -1,55 +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.recommend.dto.*;
import cn.iocoder.mall.promotionservice.manager.recommend.ProductRecommendManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping("/promotion/prod/recommend")
public class ProductRecommendController {
@Autowired
private ProductRecommendManager productRecommendManager;
@PostMapping("createProductRecommend")
public CommonResult<Integer> createProductRecommend(@RequestBody ProductRecommendCreateReqDTO createDTO) {
return success(productRecommendManager.createProductRecommend(createDTO));
}
@PostMapping("updateProductRecommend")
public CommonResult<Boolean> updateProductRecommend(@RequestBody ProductRecommendUpdateReqDTO updateDTO) {
productRecommendManager.updateProductRecommend(updateDTO);
return success(true);
}
@GetMapping("deleteProductRecommend")
public CommonResult<Boolean> deleteProductRecommend(@RequestParam("productRecommendId") Integer productRecommendId) {
productRecommendManager.deleteProductRecommend(productRecommendId);
return success(true);
}
@PostMapping("listProductRecommends")
public CommonResult<List<ProductRecommendRespDTO>> listProductRecommends(@RequestBody ProductRecommendListReqDTO listReqDTO) {
return success(productRecommendManager.listProductRecommends(listReqDTO));
}
@PostMapping("pageProductRecommend")
public CommonResult<PageResult<ProductRecommendRespDTO>> pageProductRecommend(@RequestBody ProductRecommendPageReqDTO pageDTO) {
return success(productRecommendManager.pageProductRecommend(pageDTO));
}
}

View File

@ -1,40 +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.activity.dto.PromotionActivityListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import cn.iocoder.mall.promotionservice.manager.activity.PromotionActivityManager;
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 java.util.List;
import static cn.iocoder.common.framework.vo.CommonResult.success;
/**
* Title:
* Description:
*
* @author zhuyang
* @version 1.0 2021/10/9
*/
@RestController
@RequestMapping("/promotion/activity")
public class PromotionActivityController {
@Autowired
private PromotionActivityManager promotionActivityManager;
@PostMapping("pagePromotionActivity")
public CommonResult<PageResult<PromotionActivityRespDTO>> pagePromotionActivity(@RequestBody PromotionActivityPageReqDTO pageReqDTO) {
return success(promotionActivityManager.pagePromotionActivity(pageReqDTO));
}
@PostMapping("listPromotionActivities")
public CommonResult<List<PromotionActivityRespDTO>> listPromotionActivities(@RequestBody PromotionActivityListReqDTO listReqDTO) {
return success(promotionActivityManager.listPromotionActivities(listReqDTO));
}
}

View File

@ -1,23 +0,0 @@
package cn.iocoder.mall.promotionservice.convert.activity;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.activity.PromotionActivityDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface PromotionActivityConvert {
PromotionActivityConvert INSTANCE = Mappers.getMapper(PromotionActivityConvert.class);
List<PromotionActivityRespDTO> convertList(List<PromotionActivityDO> list);
@Mapping(source = "records", target = "list")
PageResult<PromotionActivityRespDTO> convertPage(IPage<PromotionActivityDO> page);
}

View File

@ -1,29 +0,0 @@
package cn.iocoder.mall.promotionservice.convert.recommend;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendCreateReqDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendUpdateReqDTO;
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.recommend.ProductRecommendDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface ProductRecommendConvert {
ProductRecommendConvert INSTANCE = Mappers.getMapper(ProductRecommendConvert.class);
List<ProductRecommendRespDTO> convertList(List<ProductRecommendDO> list);
@Mapping(source = "records", target = "list")
PageResult<ProductRecommendRespDTO> convertPage(IPage<ProductRecommendDO> page);
ProductRecommendDO convert(ProductRecommendCreateReqDTO bean);
ProductRecommendDO convert(ProductRecommendUpdateReqDTO bean);
}

View File

@ -1,197 +0,0 @@
package cn.iocoder.mall.promotionservice.dal.mysql.dataobject.activity;
import cn.iocoder.mall.mybatis.core.dataobject.BaseDO;
import cn.iocoder.mall.promotion.api.enums.activity.PromotionActivityStatusEnum;
import cn.iocoder.mall.promotion.api.enums.activity.PromotionActivityTypeEnum;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
* DO
*/
@TableName(value = "promotion_activity", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class PromotionActivityDO extends BaseDO {
/**
*
*/
private Integer id;
/**
*
*/
private String title;
/**
*
*
* {@link PromotionActivityTypeEnum}
*/
private Integer activityType;
// /**
// * 促销类型
// * // TODO 芋艿 https://jos.jd.com/api/complexTemplate.htm?webPamer=promotion_v_o&groupName=%E4%BF%83%E9%94%80API&id=54&restName=jingdong.seller.promotion.list&isMulti=false 促销类型可选值单品促销1赠品促销4套装促销6总价促销10
// */
// private Integer promotionType;
/**
*
*
* {@link PromotionActivityStatusEnum}
*/
private Integer status;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
/**
*
*/
private Date invalidTime;
/**
*
*/
private Date deleteTime;
/**
* 使 JSON
*/
@TableField(typeHandler = FastjsonTypeHandler.class)
private TimeLimitedDiscount timeLimitedDiscount;
/**
* 使 JSON
*/
@TableField(typeHandler = FastjsonTypeHandler.class)
private FullPrivilege fullPrivilege;
/**
*
*/
@Data
@Accessors(chain = true)
public static class TimeLimitedDiscount {
/**
*
*/
@Data
@Accessors(chain = true)
public static class Item {
/**
* SPU
*/
private Integer spuId;
/**
*
*/
private Integer preferentialType;
/**
*
*/
private Integer preferentialValue;
}
/**
*
*
* quota = 0
*/
private Integer quota;
/**
*
*/
private List<Item> items;
}
/**
*
*/
@Data
@Accessors(chain = true)
public static class FullPrivilege {
/**
*
*/
@Data
@Accessors(chain = true)
public static class Privilege {
/**
*
*
* 1 -
* 2 -
*/
private Integer meetType;
/**
*
*/
private Integer meetValue;
/**
*
*/
private Integer preferentialType;
/**
*
*/
private Integer preferentialValue;
// /**
// * 是否包邮
// */
// private Boolean isPostage;
// /**
// * 积分
// */
// private Integer score;
// /**
// * 优惠劵(码)分组编号
// */
// private Integer couponTemplateId;
// /**
// * 优惠劵(码)数量
// */
// private Integer couponNum;
// /**
// * 赠品编号
// */
// private Integer presentId;
}
/**
*
*
* {@link cn.iocoder.mall.promotion.api.enums.RangeTypeEnum}
* + PRODUCT_INCLUDE_PRT
*/
private Integer rangeType;
/**
*
*/
private List<Integer> rangeValues;
/**
*
*/
private Boolean cycled;
/**
*
*/
private List<Privilege> privileges;
}
}

View File

@ -1,48 +0,0 @@
package cn.iocoder.mall.promotionservice.dal.mysql.dataobject.recommend;
import cn.iocoder.mall.mybatis.core.dataobject.DeletableDO;
import cn.iocoder.mall.promotion.api.enums.recommend.ProductRecommendTypeEnum;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* DO
*/
@TableName("product_recommend")
@Data
@Accessors(chain = true)
public class ProductRecommendDO extends DeletableDO {
/**
*
*/
private Integer id;
/**
*
*
* {@link ProductRecommendTypeEnum}
*/
private Integer type;
/**
* Spu
*/
private Integer productSpuId;
// TODO 芋艿,商品 spu 名
/**
*
*/
private Integer sort;
/**
*
*
* {@link cn.iocoder.common.framework.enums.CommonStatusEnum}
*/
private Integer status;
/**
*
*/
private String memo;
}

View File

@ -1,28 +0,0 @@
package cn.iocoder.mall.promotionservice.dal.mysql.mapper.recommend;
import cn.iocoder.mall.mybatis.core.query.QueryWrapperX;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendPageReqDTO;
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.recommend.ProductRecommendDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ProductRecommendMapper extends BaseMapper<ProductRecommendDO> {
default ProductRecommendDO selectByProductSpuIdAndType(Integer productSpuId, Integer type) {
return selectOne(new QueryWrapper<ProductRecommendDO>().eq("product_spu_id", productSpuId)
.eq("type", type));
}
default IPage<ProductRecommendDO> selectPage(ProductRecommendPageReqDTO pageReqDTO) {
return selectPage(new Page<>(pageReqDTO.getPageNo(), pageReqDTO.getPageSize()),
new QueryWrapperX<ProductRecommendDO>().eqIfPresent("type", pageReqDTO.getType()));
}
}

View File

@ -1,32 +0,0 @@
package cn.iocoder.mall.promotionservice.manager.activity;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityListReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityPageReqDTO;
import cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO;
import cn.iocoder.mall.promotionservice.service.activity.PromotionActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
/**
* Manager
*/
@Service
@Validated
public class PromotionActivityManager {
@Autowired
private PromotionActivityService promotionActivityService;
public List<PromotionActivityRespDTO> listPromotionActivities(PromotionActivityListReqDTO listReqDTO) {
return promotionActivityService.listPromotionActivities(listReqDTO);
}
public PageResult<PromotionActivityRespDTO> pagePromotionActivity(PromotionActivityPageReqDTO pageReqDTO) {
return promotionActivityService.pagePromotionActivity(pageReqDTO);
}
}

View File

@ -1,65 +0,0 @@
package cn.iocoder.mall.promotionservice.manager.recommend;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign;
import cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
import cn.iocoder.mall.promotionservice.service.recommend.ProductRecommendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS;
/**
* Manager
*/
@Service
@Validated
public class ProductRecommendManager {
@Autowired
private ProductSpuFeign productSpuFeign;
@Autowired
private ProductRecommendService productRecommendService;
public List<ProductRecommendRespDTO> listProductRecommends(ProductRecommendListReqDTO listReqDTO) {
return productRecommendService.listProductRecommends(listReqDTO);
}
public PageResult<ProductRecommendRespDTO> pageProductRecommend(ProductRecommendPageReqDTO pageReqDTO) {
return productRecommendService.pageProductRecommend(pageReqDTO);
}
public Integer createProductRecommend(ProductRecommendCreateReqDTO createReqDTO) {
// 校验商品不存在
checkProductSpu(createReqDTO.getProductSpuId());
// 创建商品推荐
return productRecommendService.createProductRecommend(createReqDTO);
}
public void updateProductRecommend(ProductRecommendUpdateReqDTO updateReqDTO) {
// 校验商品不存在
checkProductSpu(updateReqDTO.getProductSpuId());
// 更新商品推荐
productRecommendService.updateProductRecommend(updateReqDTO);
}
public void deleteProductRecommend(Integer productRecommendId) {
productRecommendService.deleteProductRecommend(productRecommendId);
}
private void checkProductSpu(Integer productSpuId) {
CommonResult<ProductSpuRespDTO> getProductSpuResult = productSpuFeign.getProductSpu(productSpuId);
getProductSpuResult.checkError();
if (getProductSpuResult.getData() == null) {
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS);
}
}
}

View File

@ -1,93 +0,0 @@
package cn.iocoder.mall.promotionservice.service.recommend;
import cn.iocoder.common.framework.exception.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.PageResult;
import cn.iocoder.mall.promotion.api.rpc.recommend.dto.*;
import cn.iocoder.mall.promotionservice.convert.recommend.ProductRecommendConvert;
import cn.iocoder.mall.promotionservice.dal.mysql.dataobject.recommend.ProductRecommendDO;
import cn.iocoder.mall.promotionservice.dal.mysql.mapper.recommend.ProductRecommendMapper;
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.List;
import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.PRODUCT_RECOMMEND_EXISTS;
import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.PRODUCT_RECOMMEND_NOT_EXISTS;
/**
* Service
*/
@Service
@Validated
public class ProductRecommendService {
@Autowired
private ProductRecommendMapper productRecommendMapper;
/**
*
*
* @param listReqDTO DTO
* @return
*/
public List<ProductRecommendRespDTO> listProductRecommends(ProductRecommendListReqDTO listReqDTO) {
List<ProductRecommendDO> productRecommends = productRecommendMapper.selectList(listReqDTO);
return ProductRecommendConvert.INSTANCE.convertList(productRecommends);
}
/**
*
*
* @param pageReqDTO DTO
* @return
*/
public PageResult<ProductRecommendRespDTO> pageProductRecommend(ProductRecommendPageReqDTO pageReqDTO) {
IPage<ProductRecommendDO> productRecommendPage = productRecommendMapper.selectPage(pageReqDTO);
return ProductRecommendConvert.INSTANCE.convertPage(productRecommendPage);
}
/**
*
*
* @param createReqDTO
* @return
*/
public Integer createProductRecommend(ProductRecommendCreateReqDTO createReqDTO) {
// 校验商品是否已经推荐
if (productRecommendMapper.selectByProductSpuIdAndType(createReqDTO.getProductSpuId(), createReqDTO.getType()) != null) {
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_EXISTS);
}
// 保存到数据库
ProductRecommendDO productRecommend = ProductRecommendConvert.INSTANCE.convert(createReqDTO);
productRecommendMapper.insert(productRecommend);
// 返回成功
return productRecommend.getId();
}
public void updateProductRecommend(ProductRecommendUpdateReqDTO updateReqDTO) {
// 校验更新的商品推荐存在
if (productRecommendMapper.selectById(updateReqDTO.getId()) == null) {
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_NOT_EXISTS);
}
// 校验商品是否已经推荐
ProductRecommendDO existProductRecommend = productRecommendMapper.selectByProductSpuIdAndType(updateReqDTO.getProductSpuId(), updateReqDTO.getType());
if (existProductRecommend != null && !existProductRecommend.getId().equals(updateReqDTO.getId())) {
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_EXISTS.getCode());
}
// 更新到数据库
ProductRecommendDO updateProductRecommend = ProductRecommendConvert.INSTANCE.convert(updateReqDTO);
productRecommendMapper.updateById(updateProductRecommend);
}
public void deleteProductRecommend(Integer productRecommendId) {
// 校验更新的商品推荐存在
if (productRecommendMapper.selectById(productRecommendId) == null) {
throw ServiceExceptionUtil.exception(PRODUCT_RECOMMEND_NOT_EXISTS);
}
// 更新到数据库
productRecommendMapper.deleteById(productRecommendId);
}
}

View File

@ -1,34 +0,0 @@
package cn.iocoder.mall.shopweb.controller.promotion;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuRespVO;
import cn.iocoder.mall.shopweb.service.promotion.ProductRecommendManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
import java.util.Map;
import static cn.iocoder.common.framework.vo.CommonResult.success;
@RestController
@RequestMapping("/promotion/product-recommend")
@Api(tags = "商品推荐 API")
@Validated
public class ProductRecommendController {
@Autowired
private ProductRecommendManager productRecommendManager;
@GetMapping("/list")
@ApiOperation("获得所有商品推荐列表")
public CommonResult<Map<Integer, Collection<ProductSpuRespVO>>> list() {
return success(productRecommendManager.listProductRecommends());
}
}