后端:促销活动增加表

pull/1/head
YunaiV 2019-04-15 23:33:56 +08:00
parent daf3f4c8c7
commit 974b9650de
17 changed files with 445 additions and 29 deletions

View File

@ -6,8 +6,22 @@
<img :src="thumb">
</van-swipe-item>
</van-swipe>
<!-- TODO 这里需要优化下芋艿 -->
<div class="limit-dising-banner">
<div class="row no-wrap flex-center limit-price">
<span class="font-13 pusht">¥</span><span class="price">2.8</span>
<div class="pushl">
<div><del>¥14</del></div>
<div><span class="tag">限时抢购</span></div>
</div>
</div>
<div class="counting">
<p>距离结束仅剩</p>
<div class="row no-wrap flex-center counting-clock" style="display: block;"><span class="num">71</span><i class="wxIcon wxIcon-colon"></i><span class="num">42</span><i class="wxIcon wxIcon-colon"></i><span class="num">02</span></div>
</div>
</div>
<van-cell-group>
<van-cell-group>
<van-cell>
<span class="goods-price">{{ formatPrice(initialSku.price) }}</span>
<!--<span class="goods-market-price">{{ formatPrice(goods.market_price) }}</span>-->

View File

@ -22,6 +22,11 @@
<artifactId>product-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>promotion-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>

View File

@ -1,10 +1,7 @@
package cn.iocoder.mall.order.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.bo.CalcOrderPriceBO;
import cn.iocoder.mall.order.api.bo.CartBO;
import cn.iocoder.mall.order.api.bo.CartItemBO;
import cn.iocoder.mall.order.api.bo.OrderCreateBO;
import cn.iocoder.mall.order.api.bo.*;
import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO;
import org.springframework.lang.Nullable;
@ -90,6 +87,8 @@ public interface CartService {
*/
CommonResult<CalcOrderPriceBO> calcOrderPrice(CalcOrderPriceDTO calcOrderPriceDTO);
CommonResult<CalcSkuPriceBO> calcSkuPrice(Integer skuId);
/**
*
*

View File

@ -1,6 +1,7 @@
package cn.iocoder.mall.order.api.bo;
import cn.iocoder.mall.product.api.bo.ProductSkuDetailBO;
import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO;
import lombok.Data;
import lombok.experimental.Accessors;
@ -35,8 +36,11 @@ public class CalcOrderPriceBO {
@Accessors(chain = true)
public static class ItemGroup {
// TODO 优惠活动
private Object activity;
/**
*
*/
// TODO 芋艿,目前只会有【满减送】的情况,未来有新的促销方式,可能需要改成数组
private PromotionActivityBO activity;
/**
*
*/
@ -56,6 +60,16 @@ public class CalcOrderPriceBO {
*
*/
private Integer buyQuantity;
/**
*
*/
private PromotionActivityBO activity;
/**
*
*
* TODO postageTotal
*/
private Fee fee;
}

View File

@ -0,0 +1,31 @@
package cn.iocoder.mall.order.api.bo;
import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* SKU BO
*/
@Data
@Accessors(chain = true)
public class CalcSkuPriceBO {
/**
*
*/
private PromotionActivityBO fullPrivilege;
/**
*
*/
private PromotionActivityBO timeLimitedDiscount;
/**
*
*/
private Integer originalPrice;
/**
*
*/
private Integer presentPrice;
}

View File

@ -4,10 +4,7 @@ import cn.iocoder.common.framework.constant.CommonStatusEnum;
import cn.iocoder.common.framework.util.ServiceExceptionUtil;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.CartService;
import cn.iocoder.mall.order.api.bo.CalcOrderPriceBO;
import cn.iocoder.mall.order.api.bo.CartBO;
import cn.iocoder.mall.order.api.bo.CartItemBO;
import cn.iocoder.mall.order.api.bo.OrderCreateBO;
import cn.iocoder.mall.order.api.bo.*;
import cn.iocoder.mall.order.api.constant.CartItemStatusEnum;
import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO;
@ -190,6 +187,11 @@ public class CartServiceImpl implements CartService {
return CommonResult.success(calcOrderPriceBO);
}
@Override
public CommonResult<CalcSkuPriceBO> calcSkuPrice(Integer skuId) {
return null;
}
@Override
public CommonResult<CartBO> details(Integer userId) {
return null;

View File

@ -0,0 +1,17 @@
package cn.iocoder.mall.promotion.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO;
import java.util.Collection;
import java.util.List;
public interface PromotionActivityService {
CommonResult<List<PromotionActivityBO>> getPromotionActivityListBySpuId(Integer spuId,
Collection<Integer> activityStatuses);
CommonResult<List<PromotionActivityBO>> getPromotionActivityListBySpuIds(Collection<Integer> spuIds,
Collection<Integer> activityStatuses);
}

View File

@ -0,0 +1,134 @@
package cn.iocoder.mall.promotion.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
import java.util.Set;
@Data
@Accessors(chain = true)
public class PromotionActivityBO {
/**
*
*/
private Integer id;
/**
*
*/
private String title;
/**
*
*
* {@link cn.iocoder.mall.promotion.api.constant.PromotionActivityTypeEnum}
*/
private Integer type;
/**
*
*
* {@link cn.iocoder.mall.promotion.api.constant.PromotionActivityStatusEnum}
*/
private Integer status;
/**
* SPU
*/
private Set<Integer> spuIds;
/**
*
*/
@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;
}
/**
*
*
* {@link cn.iocoder.mall.promotion.api.constant.RangeTypeEnum}
* + PRODUCT_INCLUDE_PRT
*/
private Integer rangeType;
/**
*
*/
private List<Integer> rangeValues;
/**
*
*/
private List<Privilege> privileges;
}
}

View File

@ -4,13 +4,16 @@ import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
public enum CouponTemplatePreferentialTypeEnum implements IntArrayValuable {
/**
*
*/
public enum PreferentialTypeEnum implements IntArrayValuable {
PRICE(1, "代金卷"),
DISCOUNT(2, "折扣卷"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplatePreferentialTypeEnum::getValue).toArray();
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PreferentialTypeEnum::getValue).toArray();
/**
*
@ -21,7 +24,7 @@ public enum CouponTemplatePreferentialTypeEnum implements IntArrayValuable {
*/
private final String name;
CouponTemplatePreferentialTypeEnum(Integer value, String name) {
PreferentialTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.mall.promotion.api.constant;
/**
*
*/
public enum PromotionActivityStatusEnum {
WAIT(10, "未开始"),
RUN(20, "进行中"),
END(30, "已结束"),
/**
* 1. WAITRUNEND INVALID
* 2. INVALID DELETED
*/
INVALID(40, "已撤销"),
DELETED(50, "已删除"),
;
/**
*
*/
private final Integer value;
/**
*
*/
private final String name;
PromotionActivityStatusEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

@ -5,8 +5,8 @@ package cn.iocoder.mall.promotion.api.constant;
*/
public enum PromotionActivityTypeEnum {
LIMIT_DISCOUNT(1, "限时折扣"),
MEET_REDUCE(2, "满减送"),
TIME_LIMITED_DISCOUNT(1, "限时折扣"),
FULL_PRIVILEGE(2, "满减送"),
;
/**

View File

@ -4,7 +4,7 @@ import cn.iocoder.common.framework.core.IntArrayValuable;
import java.util.Arrays;
public enum CouponTemplateRangeTypeEnum implements IntArrayValuable {
public enum RangeTypeEnum implements IntArrayValuable {
ALL(10, "所有可用"),
PRODUCT_INCLUDE_PRT(20, "部分商品可用,或指定商品可用"),
@ -13,7 +13,7 @@ public enum CouponTemplateRangeTypeEnum implements IntArrayValuable {
CATEGORY_EXCLUDE_PRT(31, "部分分类不可用,或指定分类可用"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateRangeTypeEnum::getValue).toArray();
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(RangeTypeEnum::getValue).toArray();
/**
*
@ -24,7 +24,7 @@ public enum CouponTemplateRangeTypeEnum implements IntArrayValuable {
*/
private final String name;
CouponTemplateRangeTypeEnum(Integer value, String name) {
RangeTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}

View File

@ -2,8 +2,8 @@ package cn.iocoder.mall.promotion.api.dto;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.constant.CouponTemplateDateTypeEnum;
import cn.iocoder.mall.promotion.api.constant.CouponTemplatePreferentialTypeEnum;
import cn.iocoder.mall.promotion.api.constant.CouponTemplateRangeTypeEnum;
import cn.iocoder.mall.promotion.api.constant.PreferentialTypeEnum;
import cn.iocoder.mall.promotion.api.constant.RangeTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
@ -70,7 +70,7 @@ public class CouponCardTemplateAddDTO {
* 31-PART
*/
@NotNull(message = "可用范围的类型不能为空")
@InEnum(value = CouponTemplateRangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
private Integer rangeType;
/**
* / 使
@ -115,7 +115,7 @@ public class CouponCardTemplateAddDTO {
* 2-
*/
@NotNull(message = "优惠类型不能为空")
@InEnum(value = CouponTemplatePreferentialTypeEnum.class, message = "优惠类型必须在 {value}")
@InEnum(value = PreferentialTypeEnum.class, message = "优惠类型必须在 {value}")
private Integer preferentialType;
/**
*

View File

@ -1,7 +1,7 @@
package cn.iocoder.mall.promotion.api.dto;
import cn.iocoder.common.framework.validator.InEnum;
import cn.iocoder.mall.promotion.api.constant.CouponTemplateRangeTypeEnum;
import cn.iocoder.mall.promotion.api.constant.RangeTypeEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
@ -69,7 +69,7 @@ public class CouponCardTemplateUpdateDTO {
* 31-PART
*/
@NotNull(message = "可用范围的类型不能为空")
@InEnum(value = CouponTemplateRangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
@InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}")
private Integer rangeType;
/**
* / 使

View File

@ -4,6 +4,9 @@ import cn.iocoder.common.framework.dataobject.BaseDO;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
* DO
*/
@ -21,7 +24,160 @@ public class PromotionActivityDO extends BaseDO {
private String title;
/**
*
*
* {@link cn.iocoder.mall.promotion.api.constant.PromotionActivityTypeEnum}
*/
private Integer type;
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 cn.iocoder.mall.promotion.api.constant.PromotionActivityStatusEnum}
*/
private Integer status;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
/**
*
*/
private Date invalidTime;
/**
*
*/
private Date deleteTime;
/**
* 使 JSON
*/
private String timeLimitedDiscount;
/**
* 使 JSON
*/
private String 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.constant.RangeTypeEnum}
* + PRODUCT_INCLUDE_PRT
*/
private Integer rangeType;
/**
*
*/
private List<Integer> rangeValues;
/**
*
*/
private List<Privilege> privileges;
}
}

View File

@ -158,14 +158,14 @@ public class CouponServiceImpl implements CouponService {
private CommonResult<Boolean> checkCouponTemplatePreferentialType(Integer preferentialType, Integer percentOff,
Integer priceOff, Integer priceAvailable) {
if (CouponTemplatePreferentialTypeEnum.PRICE.getValue().equals(preferentialType)) {
if (PreferentialTypeEnum.PRICE.getValue().equals(preferentialType)) {
if (priceOff == null) {
return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "优惠金额不能为空");
}
if (priceOff >= priceAvailable) {
return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "优惠金额不能d大于等于使用金额门槛");
}
} else if (CouponTemplatePreferentialTypeEnum.DISCOUNT.getValue().equals(preferentialType)) {
} else if (PreferentialTypeEnum.DISCOUNT.getValue().equals(preferentialType)) {
if (percentOff == null) {
return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "折扣百分比不能为空");
}