mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
promotion:完善优惠劵模板的功能
This commit is contained in:
@ -53,6 +53,7 @@ public class ProductSpuController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO 芋艿:修改接口
|
||||
@GetMapping("/get/detail")
|
||||
@ApiOperation("获得商品 SPU")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@ -79,6 +80,14 @@ public class ProductSpuController {
|
||||
return success(ProductSpuConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/get-simple-list")
|
||||
@ApiOperation("获得商品 SPU 精简列表")
|
||||
@PreAuthorize("@ss.hasPermission('product:spu:query')")
|
||||
public CommonResult<List<ProductSpuSimpleRespVO>> getSpuSimpleList() {
|
||||
List<ProductSpuDO> list = spuService.getSpuList();
|
||||
return success(ProductSpuConvert.INSTANCE.convertList02(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得商品 SPU 分页")
|
||||
@PreAuthorize("@ss.hasPermission('product:spu:query')")
|
||||
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ApiModel("管理后台 - 商品 SPU 精简 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ProductSpuSimpleRespVO extends ProductSpuBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "主键", required = true, example = "1")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商品名称", required = true, example = "芋道")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer minPrice;
|
||||
|
||||
@ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024")
|
||||
private Integer maxPrice;
|
||||
|
||||
}
|
@ -36,5 +36,7 @@ public interface ProductSpuConvert {
|
||||
AppSpuPageRespVO convertAppResp(ProductSpuDO list);
|
||||
|
||||
List<SpuInfoRespDTO> convertList2(List<ProductSpuDO> list);
|
||||
|
||||
|
||||
List<ProductSpuSimpleRespVO> convertList02(List<ProductSpuDO> list);
|
||||
|
||||
}
|
||||
|
@ -63,6 +63,13 @@ public interface ProductSpuService {
|
||||
*/
|
||||
List<ProductSpuDO> getSpuList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得所有商品 SPU 列表
|
||||
*
|
||||
* @return 商品 SPU 列表
|
||||
*/
|
||||
List<ProductSpuDO> getSpuList();
|
||||
|
||||
/**
|
||||
* 获得商品 SPU 分页
|
||||
*
|
||||
|
@ -176,6 +176,11 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
return productSpuMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductSpuDO> getSpuList() {
|
||||
return productSpuMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ProductSpuRespVO> getSpuPage(ProductSpuPageReqVO pageReqVO) {
|
||||
// 库存告警的 SPU 编号的集合
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionDiscountTypeEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.coupon.CouponTemplateValidityTypeEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -19,6 +20,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
|
||||
|
||||
/**
|
||||
* 优惠劵模板 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
@ -62,10 +64,12 @@ public class CouponTemplateBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "固定日期 - 生效开始时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||
private Date validStartTime;
|
||||
|
||||
@ApiModelProperty(value = "固定日期 - 生效结束时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||
private Date validEndTime;
|
||||
|
||||
@ApiModelProperty(value = "领取日期 - 开始天数")
|
||||
@ -82,15 +86,14 @@ public class CouponTemplateBaseVO {
|
||||
private Integer discountType;
|
||||
|
||||
@ApiModelProperty(value = "折扣百分比", example = "80", notes = "例如说,80% 为 80")
|
||||
@Min(value = 1)
|
||||
private Integer discountPercent;
|
||||
|
||||
@ApiModelProperty(value = "优惠金额", example = "10", notes = "单位:分")
|
||||
@Min(value = 1)
|
||||
@Min(value = 0, message = "优惠金额需要大于等于 0")
|
||||
private Integer discountPrice;
|
||||
|
||||
@ApiModelProperty(value = "折扣上限", example = "100", notes = "单位:分,仅在 discountType 为 PERCENT 使用")
|
||||
private Integer discountPriceLimit;
|
||||
private Integer discountLimitPrice;
|
||||
|
||||
@AssertTrue(message = "商品 SPU 编号的数组不能为空")
|
||||
@JsonIgnore
|
||||
@ -127,11 +130,11 @@ public class CouponTemplateBaseVO {
|
||||
|| fixedEndTerm != null;
|
||||
}
|
||||
|
||||
@AssertTrue(message = "折扣百分比不能为空")
|
||||
@AssertTrue(message = "折扣百分比需要大于等于 1")
|
||||
@JsonIgnore
|
||||
public boolean isDiscountPercentValid() {
|
||||
return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType())
|
||||
|| discountPercent != null;
|
||||
|| (discountPercent != null && discountPercent >= 1);
|
||||
}
|
||||
|
||||
@AssertTrue(message = "优惠金额不能为空")
|
||||
@ -143,9 +146,9 @@ public class CouponTemplateBaseVO {
|
||||
|
||||
@AssertTrue(message = "折扣上限不能为空")
|
||||
@JsonIgnore
|
||||
public boolean isDiscountPriceLimit() {
|
||||
public boolean isDiscountLimitPriceValid() {
|
||||
return ObjectUtil.notEqual(discountType, PromotionDiscountTypeEnum.PERCENT.getType())
|
||||
|| discountPriceLimit != null;
|
||||
|| discountLimitPrice != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.coupon;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplateCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.coupon.vo.CouponTemplatePageReqVO;
|
||||
@ -30,7 +31,8 @@ public class CouponTemplateServiceImpl implements CouponTemplateService {
|
||||
@Override
|
||||
public Long createCouponTemplate(CouponTemplateCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
CouponTemplateDO couponTemplate = CouponTemplateConvert.INSTANCE.convert(createReqVO);
|
||||
CouponTemplateDO couponTemplate = CouponTemplateConvert.INSTANCE.convert(createReqVO)
|
||||
.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
couponTemplateMapper.insert(couponTemplate);
|
||||
// 返回
|
||||
return couponTemplate.getId();
|
||||
|
Reference in New Issue
Block a user