dev-discount
袁野 3 years ago
commit 68fdf0dd5f
  1. 21
      hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java
  2. 45
      hai-service/src/main/java/com/hai/dao/HighDiscountMapper.java
  3. 14
      hai-service/src/main/java/com/hai/dao/HighDiscountSqlProvider.java
  4. 22
      hai-service/src/main/java/com/hai/entity/HighDiscount.java
  5. 60
      hai-service/src/main/java/com/hai/entity/HighDiscountExample.java
  6. 48
      hai-service/src/main/java/com/hai/enum_type/DiscountUseScope.java

@ -15,6 +15,7 @@ import com.hai.common.utils.IDGenerator;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.TuanYouConfig; import com.hai.config.TuanYouConfig;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.DiscountUseScope;
import com.hai.model.HighMerchantStoreModel; import com.hai.model.HighMerchantStoreModel;
import com.hai.model.HighUserModel; import com.hai.model.HighUserModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
@ -252,6 +253,26 @@ public class HighOrderController {
if (highDiscountUserRel != null) { if (highDiscountUserRel != null) {
highOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName()); highOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName());
// 交易优惠券使用范围
if (highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType())) {
// 暂无限制
} else if (highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type2.getType())) {
// 1:卡卷 2:金币充值 3:团油【加油站】 4: KFC 5:电影票 6:话费充值
if (!highOrder.getHighChildOrderList().get(0).getGoodsType().equals(1)) {
log.error("HighOrderController --> addOrder() error!", "此优惠券只能购买卡券商品使用");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "此优惠券只能购买卡券商品使用");
}
} else if (highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) {
// 1:卡卷 2:金币充值 3:团油【加油站】 4: KFC 5:电影票 6:话费充值
if (!highOrder.getHighChildOrderList().get(0).getGoodsType().equals(6)) {
log.error("HighOrderController --> addOrder() error!", "此优惠券只能充值话费中使用");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "此优惠券只能充值话费中使用");
}
} else {
log.error("HighOrderController --> addOrder() error!", "暂时无法使用此优惠券");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "暂时无法使用此优惠券");
}
// 卡卷类型 1:满减 2:抵扣 3:折扣 // 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) { if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) {
// 如果订单总额 小于 满减价格 // 如果订单总额 小于 满减价格

@ -40,23 +40,25 @@ public interface HighDiscountMapper extends HighDiscountMapperExt {
@Insert({ @Insert({
"insert into high_discount (company_id, discount_key, ", "insert into high_discount (company_id, discount_key, ",
"using_range, discount_name, ", "using_range, use_scope, ",
"discount_img, discount_carousel_img, ", "discount_name, discount_img, ",
"discount_type, discount_condition, ", "discount_carousel_img, discount_type, ",
"discount_price, effective_day, ", "discount_condition, discount_price, ",
"sales_end_time, create_time, ", "effective_day, sales_end_time, ",
"update_time, operator_id, ", "create_time, update_time, ",
"operator_name, `status`, ", "operator_id, operator_name, ",
"ext_1, ext_2, ext_3)", "`status`, ext_1, ext_2, ",
"ext_3)",
"values (#{companyId,jdbcType=BIGINT}, #{discountKey,jdbcType=VARCHAR}, ", "values (#{companyId,jdbcType=BIGINT}, #{discountKey,jdbcType=VARCHAR}, ",
"#{usingRange,jdbcType=INTEGER}, #{discountName,jdbcType=VARCHAR}, ", "#{usingRange,jdbcType=INTEGER}, #{useScope,jdbcType=INTEGER}, ",
"#{discountImg,jdbcType=VARCHAR}, #{discountCarouselImg,jdbcType=VARCHAR}, ", "#{discountName,jdbcType=VARCHAR}, #{discountImg,jdbcType=VARCHAR}, ",
"#{discountType,jdbcType=INTEGER}, #{discountCondition,jdbcType=DECIMAL}, ", "#{discountCarouselImg,jdbcType=VARCHAR}, #{discountType,jdbcType=INTEGER}, ",
"#{discountPrice,jdbcType=DECIMAL}, #{effectiveDay,jdbcType=INTEGER}, ", "#{discountCondition,jdbcType=DECIMAL}, #{discountPrice,jdbcType=DECIMAL}, ",
"#{salesEndTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, ", "#{effectiveDay,jdbcType=INTEGER}, #{salesEndTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{operatorId,jdbcType=BIGINT}, ", "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
"#{operatorName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" "#{status,jdbcType=INTEGER}, #{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, ",
"#{ext3,jdbcType=VARCHAR})"
}) })
@Options(useGeneratedKeys=true,keyProperty="id") @Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighDiscount record); int insert(HighDiscount record);
@ -71,6 +73,7 @@ public interface HighDiscountMapper extends HighDiscountMapperExt {
@Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT),
@Result(column="discount_key", property="discountKey", jdbcType=JdbcType.VARCHAR), @Result(column="discount_key", property="discountKey", jdbcType=JdbcType.VARCHAR),
@Result(column="using_range", property="usingRange", jdbcType=JdbcType.INTEGER), @Result(column="using_range", property="usingRange", jdbcType=JdbcType.INTEGER),
@Result(column="use_scope", property="useScope", jdbcType=JdbcType.INTEGER),
@Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR), @Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_img", property="discountImg", jdbcType=JdbcType.VARCHAR), @Result(column="discount_img", property="discountImg", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_carousel_img", property="discountCarouselImg", jdbcType=JdbcType.VARCHAR), @Result(column="discount_carousel_img", property="discountCarouselImg", jdbcType=JdbcType.VARCHAR),
@ -92,10 +95,10 @@ public interface HighDiscountMapper extends HighDiscountMapperExt {
@Select({ @Select({
"select", "select",
"id, company_id, discount_key, using_range, discount_name, discount_img, discount_carousel_img, ", "id, company_id, discount_key, using_range, use_scope, discount_name, discount_img, ",
"discount_type, discount_condition, discount_price, effective_day, sales_end_time, ", "discount_carousel_img, discount_type, discount_condition, discount_price, effective_day, ",
"create_time, update_time, operator_id, operator_name, `status`, ext_1, ext_2, ", "sales_end_time, create_time, update_time, operator_id, operator_name, `status`, ",
"ext_3", "ext_1, ext_2, ext_3",
"from high_discount", "from high_discount",
"where id = #{id,jdbcType=BIGINT}" "where id = #{id,jdbcType=BIGINT}"
}) })
@ -104,6 +107,7 @@ public interface HighDiscountMapper extends HighDiscountMapperExt {
@Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT), @Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT),
@Result(column="discount_key", property="discountKey", jdbcType=JdbcType.VARCHAR), @Result(column="discount_key", property="discountKey", jdbcType=JdbcType.VARCHAR),
@Result(column="using_range", property="usingRange", jdbcType=JdbcType.INTEGER), @Result(column="using_range", property="usingRange", jdbcType=JdbcType.INTEGER),
@Result(column="use_scope", property="useScope", jdbcType=JdbcType.INTEGER),
@Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR), @Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_img", property="discountImg", jdbcType=JdbcType.VARCHAR), @Result(column="discount_img", property="discountImg", jdbcType=JdbcType.VARCHAR),
@Result(column="discount_carousel_img", property="discountCarouselImg", jdbcType=JdbcType.VARCHAR), @Result(column="discount_carousel_img", property="discountCarouselImg", jdbcType=JdbcType.VARCHAR),
@ -137,6 +141,7 @@ public interface HighDiscountMapper extends HighDiscountMapperExt {
"set company_id = #{companyId,jdbcType=BIGINT},", "set company_id = #{companyId,jdbcType=BIGINT},",
"discount_key = #{discountKey,jdbcType=VARCHAR},", "discount_key = #{discountKey,jdbcType=VARCHAR},",
"using_range = #{usingRange,jdbcType=INTEGER},", "using_range = #{usingRange,jdbcType=INTEGER},",
"use_scope = #{useScope,jdbcType=INTEGER},",
"discount_name = #{discountName,jdbcType=VARCHAR},", "discount_name = #{discountName,jdbcType=VARCHAR},",
"discount_img = #{discountImg,jdbcType=VARCHAR},", "discount_img = #{discountImg,jdbcType=VARCHAR},",
"discount_carousel_img = #{discountCarouselImg,jdbcType=VARCHAR},", "discount_carousel_img = #{discountCarouselImg,jdbcType=VARCHAR},",

@ -40,6 +40,10 @@ public class HighDiscountSqlProvider {
sql.VALUES("using_range", "#{usingRange,jdbcType=INTEGER}"); sql.VALUES("using_range", "#{usingRange,jdbcType=INTEGER}");
} }
if (record.getUseScope() != null) {
sql.VALUES("use_scope", "#{useScope,jdbcType=INTEGER}");
}
if (record.getDiscountName() != null) { if (record.getDiscountName() != null) {
sql.VALUES("discount_name", "#{discountName,jdbcType=VARCHAR}"); sql.VALUES("discount_name", "#{discountName,jdbcType=VARCHAR}");
} }
@ -117,6 +121,7 @@ public class HighDiscountSqlProvider {
sql.SELECT("company_id"); sql.SELECT("company_id");
sql.SELECT("discount_key"); sql.SELECT("discount_key");
sql.SELECT("using_range"); sql.SELECT("using_range");
sql.SELECT("use_scope");
sql.SELECT("discount_name"); sql.SELECT("discount_name");
sql.SELECT("discount_img"); sql.SELECT("discount_img");
sql.SELECT("discount_carousel_img"); sql.SELECT("discount_carousel_img");
@ -166,6 +171,10 @@ public class HighDiscountSqlProvider {
sql.SET("using_range = #{record.usingRange,jdbcType=INTEGER}"); sql.SET("using_range = #{record.usingRange,jdbcType=INTEGER}");
} }
if (record.getUseScope() != null) {
sql.SET("use_scope = #{record.useScope,jdbcType=INTEGER}");
}
if (record.getDiscountName() != null) { if (record.getDiscountName() != null) {
sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}"); sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}");
} }
@ -242,6 +251,7 @@ public class HighDiscountSqlProvider {
sql.SET("company_id = #{record.companyId,jdbcType=BIGINT}"); sql.SET("company_id = #{record.companyId,jdbcType=BIGINT}");
sql.SET("discount_key = #{record.discountKey,jdbcType=VARCHAR}"); sql.SET("discount_key = #{record.discountKey,jdbcType=VARCHAR}");
sql.SET("using_range = #{record.usingRange,jdbcType=INTEGER}"); sql.SET("using_range = #{record.usingRange,jdbcType=INTEGER}");
sql.SET("use_scope = #{record.useScope,jdbcType=INTEGER}");
sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}"); sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}");
sql.SET("discount_img = #{record.discountImg,jdbcType=VARCHAR}"); sql.SET("discount_img = #{record.discountImg,jdbcType=VARCHAR}");
sql.SET("discount_carousel_img = #{record.discountCarouselImg,jdbcType=VARCHAR}"); sql.SET("discount_carousel_img = #{record.discountCarouselImg,jdbcType=VARCHAR}");
@ -280,6 +290,10 @@ public class HighDiscountSqlProvider {
sql.SET("using_range = #{usingRange,jdbcType=INTEGER}"); sql.SET("using_range = #{usingRange,jdbcType=INTEGER}");
} }
if (record.getUseScope() != null) {
sql.SET("use_scope = #{useScope,jdbcType=INTEGER}");
}
if (record.getDiscountName() != null) { if (record.getDiscountName() != null) {
sql.SET("discount_name = #{discountName,jdbcType=VARCHAR}"); sql.SET("discount_name = #{discountName,jdbcType=VARCHAR}");
} }

@ -1,7 +1,5 @@
package com.hai.entity; package com.hai.entity;
import com.hai.model.HighDiscountModel;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
@ -15,7 +13,7 @@ import java.util.Date;
* 代码由工具生成 * 代码由工具生成
* *
**/ **/
public class HighDiscount extends HighDiscountModel implements Serializable { public class HighDiscount implements Serializable {
/** /**
* 主键 * 主键
*/ */
@ -36,6 +34,11 @@ public class HighDiscount extends HighDiscountModel implements Serializable {
*/ */
private Integer usingRange; private Integer usingRange;
/**
* 使用范围 1. 全场 2.卡券 3.话费
*/
private Integer useScope;
/** /**
* 优惠券名称 * 优惠券名称
*/ */
@ -141,6 +144,14 @@ public class HighDiscount extends HighDiscountModel implements Serializable {
this.usingRange = usingRange; this.usingRange = usingRange;
} }
public Integer getUseScope() {
return useScope;
}
public void setUseScope(Integer useScope) {
this.useScope = useScope;
}
public String getDiscountName() { public String getDiscountName() {
return discountName; return discountName;
} }
@ -285,6 +296,7 @@ public class HighDiscount extends HighDiscountModel implements Serializable {
&& (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId())) && (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId()))
&& (this.getDiscountKey() == null ? other.getDiscountKey() == null : this.getDiscountKey().equals(other.getDiscountKey())) && (this.getDiscountKey() == null ? other.getDiscountKey() == null : this.getDiscountKey().equals(other.getDiscountKey()))
&& (this.getUsingRange() == null ? other.getUsingRange() == null : this.getUsingRange().equals(other.getUsingRange())) && (this.getUsingRange() == null ? other.getUsingRange() == null : this.getUsingRange().equals(other.getUsingRange()))
&& (this.getUseScope() == null ? other.getUseScope() == null : this.getUseScope().equals(other.getUseScope()))
&& (this.getDiscountName() == null ? other.getDiscountName() == null : this.getDiscountName().equals(other.getDiscountName())) && (this.getDiscountName() == null ? other.getDiscountName() == null : this.getDiscountName().equals(other.getDiscountName()))
&& (this.getDiscountImg() == null ? other.getDiscountImg() == null : this.getDiscountImg().equals(other.getDiscountImg())) && (this.getDiscountImg() == null ? other.getDiscountImg() == null : this.getDiscountImg().equals(other.getDiscountImg()))
&& (this.getDiscountCarouselImg() == null ? other.getDiscountCarouselImg() == null : this.getDiscountCarouselImg().equals(other.getDiscountCarouselImg())) && (this.getDiscountCarouselImg() == null ? other.getDiscountCarouselImg() == null : this.getDiscountCarouselImg().equals(other.getDiscountCarouselImg()))
@ -311,6 +323,7 @@ public class HighDiscount extends HighDiscountModel implements Serializable {
result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode()); result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode());
result = prime * result + ((getDiscountKey() == null) ? 0 : getDiscountKey().hashCode()); result = prime * result + ((getDiscountKey() == null) ? 0 : getDiscountKey().hashCode());
result = prime * result + ((getUsingRange() == null) ? 0 : getUsingRange().hashCode()); result = prime * result + ((getUsingRange() == null) ? 0 : getUsingRange().hashCode());
result = prime * result + ((getUseScope() == null) ? 0 : getUseScope().hashCode());
result = prime * result + ((getDiscountName() == null) ? 0 : getDiscountName().hashCode()); result = prime * result + ((getDiscountName() == null) ? 0 : getDiscountName().hashCode());
result = prime * result + ((getDiscountImg() == null) ? 0 : getDiscountImg().hashCode()); result = prime * result + ((getDiscountImg() == null) ? 0 : getDiscountImg().hashCode());
result = prime * result + ((getDiscountCarouselImg() == null) ? 0 : getDiscountCarouselImg().hashCode()); result = prime * result + ((getDiscountCarouselImg() == null) ? 0 : getDiscountCarouselImg().hashCode());
@ -340,6 +353,7 @@ public class HighDiscount extends HighDiscountModel implements Serializable {
sb.append(", companyId=").append(companyId); sb.append(", companyId=").append(companyId);
sb.append(", discountKey=").append(discountKey); sb.append(", discountKey=").append(discountKey);
sb.append(", usingRange=").append(usingRange); sb.append(", usingRange=").append(usingRange);
sb.append(", useScope=").append(useScope);
sb.append(", discountName=").append(discountName); sb.append(", discountName=").append(discountName);
sb.append(", discountImg=").append(discountImg); sb.append(", discountImg=").append(discountImg);
sb.append(", discountCarouselImg=").append(discountCarouselImg); sb.append(", discountCarouselImg=").append(discountCarouselImg);
@ -360,4 +374,4 @@ public class HighDiscount extends HighDiscountModel implements Serializable {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }

@ -376,6 +376,66 @@ public class HighDiscountExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andUseScopeIsNull() {
addCriterion("use_scope is null");
return (Criteria) this;
}
public Criteria andUseScopeIsNotNull() {
addCriterion("use_scope is not null");
return (Criteria) this;
}
public Criteria andUseScopeEqualTo(Integer value) {
addCriterion("use_scope =", value, "useScope");
return (Criteria) this;
}
public Criteria andUseScopeNotEqualTo(Integer value) {
addCriterion("use_scope <>", value, "useScope");
return (Criteria) this;
}
public Criteria andUseScopeGreaterThan(Integer value) {
addCriterion("use_scope >", value, "useScope");
return (Criteria) this;
}
public Criteria andUseScopeGreaterThanOrEqualTo(Integer value) {
addCriterion("use_scope >=", value, "useScope");
return (Criteria) this;
}
public Criteria andUseScopeLessThan(Integer value) {
addCriterion("use_scope <", value, "useScope");
return (Criteria) this;
}
public Criteria andUseScopeLessThanOrEqualTo(Integer value) {
addCriterion("use_scope <=", value, "useScope");
return (Criteria) this;
}
public Criteria andUseScopeIn(List<Integer> values) {
addCriterion("use_scope in", values, "useScope");
return (Criteria) this;
}
public Criteria andUseScopeNotIn(List<Integer> values) {
addCriterion("use_scope not in", values, "useScope");
return (Criteria) this;
}
public Criteria andUseScopeBetween(Integer value1, Integer value2) {
addCriterion("use_scope between", value1, value2, "useScope");
return (Criteria) this;
}
public Criteria andUseScopeNotBetween(Integer value1, Integer value2) {
addCriterion("use_scope not between", value1, value2, "useScope");
return (Criteria) this;
}
public Criteria andDiscountNameIsNull() { public Criteria andDiscountNameIsNull() {
addCriterion("discount_name is null"); addCriterion("discount_name is null");
return (Criteria) this; return (Criteria) this;

@ -0,0 +1,48 @@
package com.hai.enum_type;
import java.util.Objects;
/**
* 优惠券使用范围
* @author hurui
*/
public enum DiscountUseScope {
type1(1 , "全场"),
type2(2 , "卡券"),
type3(3 , "话费"),
;
private Integer type;
private String name;
DiscountUseScope(int type , String name) {
this.type = type;
this.name = name;
}
public static String getNameByType(Integer type) {
for (DiscountUseScope ele : values()) {
if (Objects.equals(type,ele.getType())) {
return ele.getName();
}
}
return null;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Loading…
Cancel
Save