diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java index c7efd61b..888d5206 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountController.java @@ -60,6 +60,7 @@ public class HighDiscountController { } if (StringUtils.isBlank(highDiscount.getDiscountName()) || StringUtils.isBlank(highDiscount.getDiscountImg()) + || highDiscount.getPlatform() == null || highDiscount.getDiscountType() == null || highDiscount.getDiscountPrice() == null || highDiscount.getEffectiveDay() == null diff --git a/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapper.java b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapper.java index b030bbbd..9ce4277b 100644 --- a/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelMapper.java @@ -39,22 +39,22 @@ public interface HighDiscountUserRelMapper extends HighDiscountUserRelMapperExt int deleteByPrimaryKey(Long id); @Insert({ - "insert into high_discount_user_rel (discount_company_id, discount_id, ", - "discount_name, discount_img, ", - "discount_using_range, discount_use_scope, ", - "discount_type, discount_condition, ", - "discount_price, agent_id, ", - "discount_agent_code_id, user_id, ", - "`status`, use_time, ", + "insert into high_discount_user_rel (discount_company_id, discount_platform, ", + "discount_id, discount_name, ", + "discount_img, discount_using_range, ", + "discount_use_scope, discount_type, ", + "discount_condition, discount_price, ", + "agent_id, discount_agent_code_id, ", + "user_id, `status`, use_time, ", "create_time, use_end_time, ", "ext_1, ext_2, ext_3)", - "values (#{discountCompanyId,jdbcType=BIGINT}, #{discountId,jdbcType=BIGINT}, ", - "#{discountName,jdbcType=VARCHAR}, #{discountImg,jdbcType=VARCHAR}, ", - "#{discountUsingRange,jdbcType=INTEGER}, #{discountUseScope,jdbcType=INTEGER}, ", - "#{discountType,jdbcType=INTEGER}, #{discountCondition,jdbcType=DECIMAL}, ", - "#{discountPrice,jdbcType=DECIMAL}, #{agentId,jdbcType=BIGINT}, ", - "#{discountAgentCodeId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, ", - "#{status,jdbcType=INTEGER}, #{useTime,jdbcType=TIMESTAMP}, ", + "values (#{discountCompanyId,jdbcType=BIGINT}, #{discountPlatform,jdbcType=INTEGER}, ", + "#{discountId,jdbcType=BIGINT}, #{discountName,jdbcType=VARCHAR}, ", + "#{discountImg,jdbcType=VARCHAR}, #{discountUsingRange,jdbcType=INTEGER}, ", + "#{discountUseScope,jdbcType=INTEGER}, #{discountType,jdbcType=INTEGER}, ", + "#{discountCondition,jdbcType=DECIMAL}, #{discountPrice,jdbcType=DECIMAL}, ", + "#{agentId,jdbcType=BIGINT}, #{discountAgentCodeId,jdbcType=BIGINT}, ", + "#{userId,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, #{useTime,jdbcType=TIMESTAMP}, ", "#{createTime,jdbcType=TIMESTAMP}, #{useEndTime,jdbcType=TIMESTAMP}, ", "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @@ -69,6 +69,7 @@ public interface HighDiscountUserRelMapper extends HighDiscountUserRelMapperExt @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="discount_company_id", property="discountCompanyId", jdbcType=JdbcType.BIGINT), + @Result(column="discount_platform", property="discountPlatform", jdbcType=JdbcType.INTEGER), @Result(column="discount_id", property="discountId", jdbcType=JdbcType.BIGINT), @Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR), @Result(column="discount_img", property="discountImg", jdbcType=JdbcType.VARCHAR), @@ -92,16 +93,17 @@ public interface HighDiscountUserRelMapper extends HighDiscountUserRelMapperExt @Select({ "select", - "id, discount_company_id, discount_id, discount_name, discount_img, discount_using_range, ", - "discount_use_scope, discount_type, discount_condition, discount_price, agent_id, ", - "discount_agent_code_id, user_id, `status`, use_time, create_time, use_end_time, ", - "ext_1, ext_2, ext_3", + "id, discount_company_id, discount_platform, discount_id, discount_name, discount_img, ", + "discount_using_range, discount_use_scope, discount_type, discount_condition, ", + "discount_price, agent_id, discount_agent_code_id, user_id, `status`, use_time, ", + "create_time, use_end_time, ext_1, ext_2, ext_3", "from high_discount_user_rel", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="discount_company_id", property="discountCompanyId", jdbcType=JdbcType.BIGINT), + @Result(column="discount_platform", property="discountPlatform", jdbcType=JdbcType.INTEGER), @Result(column="discount_id", property="discountId", jdbcType=JdbcType.BIGINT), @Result(column="discount_name", property="discountName", jdbcType=JdbcType.VARCHAR), @Result(column="discount_img", property="discountImg", jdbcType=JdbcType.VARCHAR), @@ -135,6 +137,7 @@ public interface HighDiscountUserRelMapper extends HighDiscountUserRelMapperExt @Update({ "update high_discount_user_rel", "set discount_company_id = #{discountCompanyId,jdbcType=BIGINT},", + "discount_platform = #{discountPlatform,jdbcType=INTEGER},", "discount_id = #{discountId,jdbcType=BIGINT},", "discount_name = #{discountName,jdbcType=VARCHAR},", "discount_img = #{discountImg,jdbcType=VARCHAR},", diff --git a/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelSqlProvider.java index 6219ee6b..0c5f94cf 100644 --- a/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighDiscountUserRelSqlProvider.java @@ -32,6 +32,10 @@ public class HighDiscountUserRelSqlProvider { sql.VALUES("discount_company_id", "#{discountCompanyId,jdbcType=BIGINT}"); } + if (record.getDiscountPlatform() != null) { + sql.VALUES("discount_platform", "#{discountPlatform,jdbcType=INTEGER}"); + } + if (record.getDiscountId() != null) { sql.VALUES("discount_id", "#{discountId,jdbcType=BIGINT}"); } @@ -115,6 +119,7 @@ public class HighDiscountUserRelSqlProvider { sql.SELECT("id"); } sql.SELECT("discount_company_id"); + sql.SELECT("discount_platform"); sql.SELECT("discount_id"); sql.SELECT("discount_name"); sql.SELECT("discount_img"); @@ -158,6 +163,10 @@ public class HighDiscountUserRelSqlProvider { sql.SET("discount_company_id = #{record.discountCompanyId,jdbcType=BIGINT}"); } + if (record.getDiscountPlatform() != null) { + sql.SET("discount_platform = #{record.discountPlatform,jdbcType=INTEGER}"); + } + if (record.getDiscountId() != null) { sql.SET("discount_id = #{record.discountId,jdbcType=BIGINT}"); } @@ -240,6 +249,7 @@ public class HighDiscountUserRelSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("discount_company_id = #{record.discountCompanyId,jdbcType=BIGINT}"); + sql.SET("discount_platform = #{record.discountPlatform,jdbcType=INTEGER}"); sql.SET("discount_id = #{record.discountId,jdbcType=BIGINT}"); sql.SET("discount_name = #{record.discountName,jdbcType=VARCHAR}"); sql.SET("discount_img = #{record.discountImg,jdbcType=VARCHAR}"); @@ -272,6 +282,10 @@ public class HighDiscountUserRelSqlProvider { sql.SET("discount_company_id = #{discountCompanyId,jdbcType=BIGINT}"); } + if (record.getDiscountPlatform() != null) { + sql.SET("discount_platform = #{discountPlatform,jdbcType=INTEGER}"); + } + if (record.getDiscountId() != null) { sql.SET("discount_id = #{discountId,jdbcType=BIGINT}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighDiscountUserRel.java b/hai-service/src/main/java/com/hai/entity/HighDiscountUserRel.java index 36c07a4a..5d2b0a27 100644 --- a/hai-service/src/main/java/com/hai/entity/HighDiscountUserRel.java +++ b/hai-service/src/main/java/com/hai/entity/HighDiscountUserRel.java @@ -26,6 +26,11 @@ public class HighDiscountUserRel extends HighDiscountUserRelModel implements Ser */ private Long discountCompanyId; + /** + * 优惠券平台 平台类型 1: 嗨森逛 2:惠支付 + */ + private Integer discountPlatform; + /** * 优惠券id */ @@ -125,6 +130,14 @@ public class HighDiscountUserRel extends HighDiscountUserRelModel implements Ser this.discountCompanyId = discountCompanyId; } + public Integer getDiscountPlatform() { + return discountPlatform; + } + + public void setDiscountPlatform(Integer discountPlatform) { + this.discountPlatform = discountPlatform; + } + public Long getDiscountId() { return discountId; } @@ -283,6 +296,7 @@ public class HighDiscountUserRel extends HighDiscountUserRelModel implements Ser HighDiscountUserRel other = (HighDiscountUserRel) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getDiscountCompanyId() == null ? other.getDiscountCompanyId() == null : this.getDiscountCompanyId().equals(other.getDiscountCompanyId())) + && (this.getDiscountPlatform() == null ? other.getDiscountPlatform() == null : this.getDiscountPlatform().equals(other.getDiscountPlatform())) && (this.getDiscountId() == null ? other.getDiscountId() == null : this.getDiscountId().equals(other.getDiscountId())) && (this.getDiscountName() == null ? other.getDiscountName() == null : this.getDiscountName().equals(other.getDiscountName())) && (this.getDiscountImg() == null ? other.getDiscountImg() == null : this.getDiscountImg().equals(other.getDiscountImg())) @@ -309,6 +323,7 @@ public class HighDiscountUserRel extends HighDiscountUserRelModel implements Ser int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getDiscountCompanyId() == null) ? 0 : getDiscountCompanyId().hashCode()); + result = prime * result + ((getDiscountPlatform() == null) ? 0 : getDiscountPlatform().hashCode()); result = prime * result + ((getDiscountId() == null) ? 0 : getDiscountId().hashCode()); result = prime * result + ((getDiscountName() == null) ? 0 : getDiscountName().hashCode()); result = prime * result + ((getDiscountImg() == null) ? 0 : getDiscountImg().hashCode()); @@ -338,6 +353,7 @@ public class HighDiscountUserRel extends HighDiscountUserRelModel implements Ser sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); sb.append(", discountCompanyId=").append(discountCompanyId); + sb.append(", discountPlatform=").append(discountPlatform); sb.append(", discountId=").append(discountId); sb.append(", discountName=").append(discountName); sb.append(", discountImg=").append(discountImg); diff --git a/hai-service/src/main/java/com/hai/entity/HighDiscountUserRelExample.java b/hai-service/src/main/java/com/hai/entity/HighDiscountUserRelExample.java index 5aa9dfa3..91688078 100644 --- a/hai-service/src/main/java/com/hai/entity/HighDiscountUserRelExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighDiscountUserRelExample.java @@ -246,6 +246,66 @@ public class HighDiscountUserRelExample { return (Criteria) this; } + public Criteria andDiscountPlatformIsNull() { + addCriterion("discount_platform is null"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformIsNotNull() { + addCriterion("discount_platform is not null"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformEqualTo(Integer value) { + addCriterion("discount_platform =", value, "discountPlatform"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformNotEqualTo(Integer value) { + addCriterion("discount_platform <>", value, "discountPlatform"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformGreaterThan(Integer value) { + addCriterion("discount_platform >", value, "discountPlatform"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformGreaterThanOrEqualTo(Integer value) { + addCriterion("discount_platform >=", value, "discountPlatform"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformLessThan(Integer value) { + addCriterion("discount_platform <", value, "discountPlatform"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformLessThanOrEqualTo(Integer value) { + addCriterion("discount_platform <=", value, "discountPlatform"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformIn(List values) { + addCriterion("discount_platform in", values, "discountPlatform"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformNotIn(List values) { + addCriterion("discount_platform not in", values, "discountPlatform"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformBetween(Integer value1, Integer value2) { + addCriterion("discount_platform between", value1, value2, "discountPlatform"); + return (Criteria) this; + } + + public Criteria andDiscountPlatformNotBetween(Integer value1, Integer value2) { + addCriterion("discount_platform not between", value1, value2, "discountPlatform"); + return (Criteria) this; + } + public Criteria andDiscountIdIsNull() { addCriterion("discount_id is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/enum_type/DiscountPlatform.java b/hai-service/src/main/java/com/hai/enum_type/DiscountPlatform.java new file mode 100644 index 00000000..0ec768e4 --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/DiscountPlatform.java @@ -0,0 +1,55 @@ +package com.hai.enum_type; + +import java.util.Objects; + +/** + * 优惠券平台类型 + */ +public enum DiscountPlatform { + HSG(1, "HSG", "嗨森逛"), + GRATIA_PAY(2, "GRATIA_PAY","惠支付"), + ; + + private Integer number; + + private String code; + + private String name; + + DiscountPlatform(int number, String code,String name) { + this.number = number; + this.code = code; + this.name = name; + } + + public static DiscountPlatform getPlatformByCode(String code) { + for (DiscountPlatform ele : values()) { + if(Objects.equals(code,ele.getCode())) return ele; + } + return null; + } + + public Integer getNumber() { + return number; + } + + public void setNumber(Integer number) { + this.number = number; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java index f3cd8466..d997906a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java @@ -5,8 +5,10 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.dao.HighDiscountUserRelMapper; import com.hai.entity.*; +import com.hai.enum_type.DiscountPlatform; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.annotation.Isolation; @@ -94,6 +96,7 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic }*/ HighDiscountUserRel userRel = new HighDiscountUserRel(); + userRel.setDiscountPlatform(DiscountPlatform.getPlatformByCode(discount.getPlatform()).getNumber()); userRel.setDiscountCompanyId(discount.getCompanyId()); userRel.setDiscountId(rel.getDiscountId()); userRel.setDiscountName(discount.getDiscountName()); @@ -158,6 +161,7 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic highDiscountAgentRelService.updateDiscountAgentRel(discountAgentRel); HighDiscountUserRel userRel = new HighDiscountUserRel(); + userRel.setDiscountPlatform(DiscountPlatform.getPlatformByCode(discount.getPlatform()).getNumber()); userRel.setDiscountId(discountAgentRel.getDiscountId()); userRel.setAgentId(discountAgentRel.getAgentId()); userRel.setUserId(userId); @@ -237,6 +241,10 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); } + if (MapUtils.getInteger(map, "discountPlatform") != null) { + criteria.andDiscountPlatformEqualTo(MapUtils.getInteger(map, "discountPlatform")); + } + if (MapUtils.getInteger(map, "status") != null) { criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); } diff --git a/hai-user/src/main/java/com/web/controller/DiscountController.java b/hai-user/src/main/java/com/web/controller/DiscountController.java index 3e1d13a3..e59476a3 100644 --- a/hai-user/src/main/java/com/web/controller/DiscountController.java +++ b/hai-user/src/main/java/com/web/controller/DiscountController.java @@ -164,12 +164,10 @@ public class DiscountController { @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { - HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); if (userInfoModel == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); } - Map param = new HashMap<>(); param.put("userId", userInfoModel.getHighUser().getId()); param.put("platform", platform); @@ -178,7 +176,11 @@ public class DiscountController { param.put("status", status); PageHelper.startPage(pageNum,pageSize); - return ResponseMsgUtil.success(new PageInfo<>(discountUserRelService.getDiscountList(param))); + PageInfo pageInfo = new PageInfo<>(discountUserRelService.getDiscountList(param)); + + + + return ResponseMsgUtil.success(pageInfo); } catch (Exception e) { log.error("HighDiscountController -> getUserDiscountList() error!",e);