Merge remote-tracking branch 'origin/master'

pull/1/head
sin 2019-04-03 18:19:29 +08:00
commit 8c84841362
17 changed files with 496 additions and 37 deletions

View File

@ -0,0 +1,102 @@
package cn.iocoder.mall.promotion.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.promotion.api.bo.CouponCardBO;
import cn.iocoder.mall.promotion.api.bo.CouponCardTemplatePageBO;
import cn.iocoder.mall.promotion.api.bo.CouponCodeTemplateBO;
import cn.iocoder.mall.promotion.api.bo.CouponCodeTemplatePageBO;
import cn.iocoder.mall.promotion.api.dto.*;
public interface CouponService {
// ========== 优惠劵(码)模板 ==========
CommonResult<CouponCodeTemplatePageBO> getCouponCodeTemplatePage(CouponCodeTemplatePageDTO couponCodeTemplatePageDTO);
CommonResult<CouponCardTemplatePageBO> getCouponCardTemplatePage(CouponCardTemplatePageDTO couponCardTemplatePageDTO);
/**
*
*
* @param couponCodeTemplateAddDTO DTO
* @return
*/
CommonResult<CouponCodeTemplateBO> addCouponCodeTemplate(CouponCodeTemplateAddDTO couponCodeTemplateAddDTO);
/**
*
*
* @param couponCardTemplateAddDTO DTO
* @return
*/
CommonResult<CouponCodeTemplateBO> addCouponCardTemplate(CouponCardTemplateAddDTO couponCardTemplateAddDTO);
/**
*
*
* @param couponCodeTemplateUpdateDTO DTO
* @return
*/
CommonResult<Boolean> updateCouponCodeTemplate(CouponCodeTemplateUpdateDTO couponCodeTemplateUpdateDTO);
/**
*
*
* @param couponCardTemplateUpdateDTO DTO
* @return
*/
CommonResult<Boolean> updateCouponCardTemplate(CouponCardTemplateUpdateDTO couponCardTemplateUpdateDTO);
/**
*
*
* @param adminId
* @param couponTemplateId
* @param status
* @return
*/
CommonResult<Boolean> updateCouponTemplateStatus(Integer adminId, Integer couponTemplateId, Integer status);
// ========== 优惠劵 ==========
/**
*
*
* @param userId
* @param couponTemplateId
* @return
*/
CommonResult<CouponCardBO> addCouponCard(Integer userId, Integer couponTemplateId);
/**
* 使
*
* @param userId
* @param couponCardId
* @param usedOrderId
* @param usedPrice
* @return
*/
CommonResult<Boolean> useCouponCard(Integer userId, Integer couponCardId, Integer usedOrderId, Integer usedPrice);
/**
* 使
*
* @param userId
* @param couponCardId
* @return
*/
CommonResult<Boolean> cancelUseCouponCard(Integer userId, Integer couponCardId);
// ========== 优惠码 ==========
/**
* 使
*
* @param userId
* @param code
* @return
*/
CommonResult<CouponCardBO> useCouponCode(Integer userId, String code);
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.promotion.api.bo;
public class CouponCardBO {
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.promotion.api.bo;
public class CouponCardTemplateBO {
}

View File

@ -0,0 +1,5 @@
package cn.iocoder.mall.promotion.api.bo;
public class CouponCardTemplatePageBO {
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.promotion.api.bo;
public class CouponCodeTemplateBO {
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.promotion.api.bo;
public class CouponCodeTemplatePageBO {
}

View File

@ -0,0 +1,119 @@
package cn.iocoder.mall.promotion.api.dto;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
public class CouponCardTemplateAddDTO {
// ========== 基本信息 BEGIN ==========
/**
*
*/
@NotEmpty(message = "标题不能为空")
@Length(min = 6, max = 16, message = "标题长度为 {min}-{max} 位")
private String title;
/**
* 使
*/
@Length(max = 255, message = "使用说明最大长度为 {max} 位")
private String description;
// ========== 基本信息 END ==========
// ========== 领取规则 BEGIN ==========
/**
*
*
* null -
*/
private Integer quota;
/**
*
*
* null -
*/
private Integer stock;
// ========== 领取规则 END ==========
// ========== 使用规则 BEGIN ==========
/**
*
*
* 0-
* 0-
*/
@NotNull(message = "使用金额门槛不能为空")
private Integer priceAvailable;
/**
*
*
* 10-ALL
* 20-PART
* 21-PART
* 30-PART
* 31-PART
*/
@NotNull(message = "可用范围的类型不能为空")
private Integer rangeType;
/**
* / 使
*/
private String rangeValues;
/**
*
*
* 1-
* 2- {@link #fixedTerm} N
*/
@NotNull(message = "生效日期类型不能为空")
private Integer dateType;
/**
* -
*/
private Date validStartTime;
/**
* -
*/
private Date validEndTime;
// /**
// * 领取日期-开始天数
// *
// * 例如0-当天1-次天
// */
// private Integer fixedBeginTerm;
/**
* -
*/
private Integer fixedTerm;
// ========== 使用规则 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 ==========
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.mall.promotion.api.dto;
/**
* DTO
*/
public class CouponCardTemplatePageDTO {
/**
*
*/
private String title;
/**
*
*/
private Integer status;
/**
*
*/
private Integer preferentialType;
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.promotion.api.dto;
public class CouponCardTemplateUpdateDTO {
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.promotion.api.dto;
public class CouponCodeTemplateAddDTO {
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.mall.promotion.api.dto;
/**
* DTO
*/
public class CouponCodeTemplatePageDTO {
/**
*
*/
private String title;
/**
*
*/
private Integer status;
/**
*
*/
private Integer preferentialType;
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.promotion.api.dto;
public class CouponCodeTemplateUpdateDTO {
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.mall.promotion.biz.dao;
import cn.iocoder.mall.promotion.biz.dataobject.CouponTemplateDO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface CouponTemplateMapper {
CouponTemplateDO selectById(@Param("id") Integer id);
List<CouponTemplateDO> selectListByPage(@Param("title") String title,
@Param("status") Integer status,
@Param("preferentialType") Integer preferentialType,
@Param("offset") Integer offset,
@Param("limit") Integer limit);
Integer selectCountByPage(@Param("title") String title,
@Param("status") Integer status,
@Param("preferentialType") Integer preferentialType);
void insert(CouponTemplateDO couponTemplate);
int update(CouponTemplateDO couponTemplate);
}

View File

@ -7,7 +7,7 @@ import java.util.Date;
/**
* DO
*/
public class CouponDO extends BaseDO {
public class CouponCardDO extends BaseDO {
// ========== 基本信息 BEGIN ==========
/**
@ -25,13 +25,9 @@ public class CouponDO extends BaseDO {
/**
*
*
* 1-
* 2-
* 3-
* 4-
* 5-使
*
* TODO
* 1-使
* 2-使
* 3-
*/
private Integer status;
@ -103,6 +99,9 @@ public class CouponDO extends BaseDO {
* 使
*/
private Date usedTime;
// TODO 芋艿,后续要加优惠劵的使用日志,因为下单后,可能会取消。
// ========== 使用情况 END ==========
}
}

View File

@ -7,7 +7,7 @@ import java.util.Date;
/**
* DO
*
* {@link CouponDO}
* {@link CouponCardDO}
*/
public class CouponTemplateDO extends BaseDO {
@ -43,36 +43,25 @@ public class CouponTemplateDO extends BaseDO {
/**
*
*
* 1-
* 2-
* 1-
* 2-
* 3-
* 4-
*
*
*
* TODO
*
*/
private Integer status;
// /**
// * 是否可分享领取链接
// */
// private Boolean isShare;
/**
*
*/
private Date invalidTime;
/**
*
*/
private Date deleteTime;
/**
*
*/
private Date beginTime;
/**
*
*/
private Date endTime;
// /**
// * 设置为失效时间
// */
// private Date invalidTime;
// /**
// * 删除时间
// */
// private Date deleteTime;
// ========== 基本信息 END ==========
@ -211,14 +200,14 @@ public class CouponTemplateDO extends BaseDO {
// * 领取优惠券的人数
// */
// private Integer statFetchUserNum;
// /**
// * 领取优惠券的次数
// */
// private Integer statFetchNum;
/**
*
*/
private Integer statFetchNum;
// /**
// * 使用优惠券的次数
// */
// private Integer statUseNum;
// // ========== 统计信息 END ==========
}
}

View File

@ -0,0 +1,4 @@
package cn.iocoder.mall.promotion.biz.service;
public class CouponServiceImpl {
}

View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.iocoder.mall.promotion.biz.dao.CouponTemplateMapper">
<sql id="FIELDS">
id, title, description, type, code_type,
status, quota, stock, price_available, range_type,
range_values, date_type, valid_start_time, valid_end_time, fixed_term,
preferential_type, percent_off, price_off, discount_price_limit, stat_fetch_num,
create_time
</sql>
<!-- <select id="selectListByPidAndStatusOrderBySort" resultType="CouponTemplateDO">-->
<!-- SELECT-->
<!-- <include refid="FIELDS" />-->
<!-- FROM coupon_template-->
<!-- WHERE pid = #{pid}-->
<!-- AND status = #{status}-->
<!-- AND deleted = 0-->
<!-- ORDER BY sort ASC-->
<!-- </select>-->
<!-- <select id="selectList" resultType="CouponTemplateDO">-->
<!-- SELECT-->
<!-- <include refid="FIELDS" />-->
<!-- FROM coupon_template-->
<!-- WHERE deleted = 0-->
<!-- </select>-->
<select id="selectById" parameterType="Integer" resultType="CouponTemplateDO">
SELECT
<include refid="FIELDS" />
FROM coupon_template
WHERE id = #{id}
</select>
<select id="selectListByPage" resultType="CouponTemplateDO">
SELECT
<include refid="FIELDS" />
FROM coupon_template
<where>
<if test="title != null">
title LIKE "%"#{title}"%"
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="preferentialType != null">
AND preferential_type = #{preferentialType}
</if>
</where>
LIMIT #{offset}, #{limit}
</select>
<select id="selectCountByPage" resultType="Integer">
SELECT
COUNT(1)
FROM coupon_template
<where>
<if test="title != null">
title LIKE "%"#{title}"%"
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="preferentialType != null">
AND preferential_type = #{preferentialType}
</if>
</where>
</select>
<insert id="insert" parameterType="CouponTemplateDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO coupon_template (
title, description, type, code_type,
status, quota, stock, price_available, range_type,
range_values, date_type, valid_start_time, valid_end_time, fixed_term,
preferential_type, percent_off, price_off, discount_price_limit, stat_fetch_num,
create_time
) VALUES (
#{title}, #{description, #{type, #{code_type},
#{status}, #{quota, #{stock}, #{priceAvailable}, #{rangeType},
#{rangeValues}, #{dateType}, #{validStartTime}, #{validEndTime, #{fixedTerm},
#{preferentialType, #{percentOff}, #{priceOff}, #{discountPriceLimit}, #{statFetchNum},
#{createTime}
)
</insert>
<update id="update" parameterType="CouponTemplateDO">
UPDATE coupon_template
<set>
<if test="title != null">
title = #{title},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="quota != null">
quota = #{quota},
</if>
<if test="stock != null">
stock = #{stock},
</if>
<if test="priceAvailable != null">
price_available = #{priceAvailable}
</if>
<if test="rangeType != null">
range_type = #{rangeType}
</if>
<if test="rangeValues != null">
range_values = #{rangeValues}
</if>
<if test="dateType != null">
date_type = #{dateType}
</if>
<if test="validStartTime != null">
valid_start_time = #{validStartTime}
</if>
<if test="validEndTime != null">
valid_end_time = #{validEndTime}
</if>
<if test="fixedTerm != null">
fixed_term = #{fixedTerm}
</if>
<if test="preferentialType != null">
preferential_type = #{preferentialType}
</if>
<if test="percentOff != null">
percent_off = #{percentOff}
</if>
<if test="priceOff != null">
price_off = #{priceOff}
</if>
<if test="discountPriceLimit != null">
discount_price_limit = #{discountPriceLimit}
</if>
</set>
WHERE id = #{id}
</update>
</mapper>