Browse Source

Merge branch 'devlocal' into develop

release_toaliyun_real
Burce 6 years ago
parent
commit
804bb3fa52
5 changed files with 27 additions and 5 deletions
  1. +2
    -0
      mallinkAdmin/src/main/resources/db/migration/V201908131725__W_ADD_SCALE.sql
  2. +1
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxLevelConfig.java
  3. +7
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java
  4. +12
    -4
      mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java
  5. +5
    -1
      mallinkService/src/main/resources/mapper/WxScoreRulesMapper.xml

+ 2
- 0
mallinkAdmin/src/main/resources/db/migration/V201908131725__W_ADD_SCALE.sql View File

@@ -0,0 +1,2 @@
ALTER TABLE `wx_level_config` CHANGE COLUMN `scale` `scale` smallint UNSIGNED NOT NULL DEFAULT 10 COMMENT '会员等级积分倍率';
ALTER TABLE `wx_score_rules` ADD COLUMN `scale` smallint UNSIGNED COMMENT '会员生日积分倍率' AFTER `clear_year`;

+ 1
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxLevelConfig.java View File

@@ -14,6 +14,7 @@ import javax.persistence.Id;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class WxLevelConfig extends BaseEntity { public class WxLevelConfig extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Transient
public static final int DEFAULT_SCALE = 10; public static final int DEFAULT_SCALE = 10;


@Id @Id


+ 7
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java View File

@@ -26,6 +26,9 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class WxScoreRules extends BaseEntity { public class WxScoreRules extends BaseEntity {


@Transient
public static final int DEFAULT_SCALE = 10;

@Transient @Transient
private static final String scoreDefaultRules = private static final String scoreDefaultRules =
"[" + "[" +
@@ -70,6 +73,7 @@ public class WxScoreRules extends BaseEntity {
"{\"id\":5,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权个人信息\"}," + "{\"id\":5,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权个人信息\"}," +
"{\"id\":6,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权手机号\"}," + "{\"id\":6,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权手机号\"}," +
"{\"id\":7,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"编辑个人信息\"}" + "{\"id\":7,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"编辑个人信息\"}" +
"{\"id\":8,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"编辑个人信息\"}" +
"]"; "]";


@Transient @Transient
@@ -105,6 +109,9 @@ public class WxScoreRules extends BaseEntity {
@io.swagger.annotations.ApiModelProperty(value="清除前多少年积分",name="clearYear") @io.swagger.annotations.ApiModelProperty(value="清除前多少年积分",name="clearYear")
private Integer clearYear; private Integer clearYear;


@io.swagger.annotations.ApiModelProperty(value="生日积分倍率",name="scale")
private Integer scale;

public static String getScoreDefaultRules() { public static String getScoreDefaultRules() {
return scoreDefaultRules; return scoreDefaultRules;
} }


+ 12
- 4
mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java View File

@@ -213,19 +213,27 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
currentCreditAmount = wxCUserBasicInfo.getCredit(); currentCreditAmount = wxCUserBasicInfo.getCredit();
} }


// 获取当前用户成长值:默认为1.0,
int scale = 10;
// 获取等级积分倍率:默认为1.0,
int levelScale = WxLevelConfig.DEFAULT_SCALE;
Integer score = wxCUser.getScore(); Integer score = wxCUser.getScore();
if (Objects.nonNull(score)) { if (Objects.nonNull(score)) {
Integer scaleFromDb = wxLevelConfigMapper.getScale(wxCUser.getTenantId(), wxCUser.getScore()); Integer scaleFromDb = wxLevelConfigMapper.getScale(wxCUser.getTenantId(), wxCUser.getScore());
if (Objects.nonNull(scaleFromDb)) { if (Objects.nonNull(scaleFromDb)) {
scale = scaleFromDb;
levelScale = scaleFromDb;
}
}
// 获取等级积分倍率:
int scoreScale = WxScoreRules.DEFAULT_SCALE;
if(Objects.nonNull(wxCUserBasicInfo.getBirthdate())) {
WxScoreRules rules = wxScoreRulesService.getScoreRules(wxCUser.getTenantId()) ;
if(Objects.nonNull(rules)&&Objects.nonNull(rules.getScale())) {
scoreScale = rules.getScale() ;
} }
} }


//计算出需要新增或减少的积分 //计算出需要新增或减少的积分
int creditChangeNumOrigin = creditIncrement(record); int creditChangeNumOrigin = creditIncrement(record);
int creditChangeNum = new BigDecimal(creditChangeNumOrigin).multiply(new BigDecimal(scale)).divide(new BigDecimal(WxLevelConfig.DEFAULT_SCALE),BigDecimal.ROUND_HALF_UP).intValue();
int creditChangeNum = new BigDecimal(creditChangeNumOrigin).multiply(new BigDecimal(levelScale)).multiply(new BigDecimal(scoreScale)).divide(new BigDecimal(WxScoreRules.DEFAULT_SCALE)).divide(new BigDecimal(WxLevelConfig.DEFAULT_SCALE),BigDecimal.ROUND_HALF_UP).intValue();


if (creditChangeNum != 0) { if (creditChangeNum != 0) {
Long total = Long.valueOf(currentCreditAmount) + Long.valueOf(creditChangeNum); Long total = Long.valueOf(currentCreditAmount) + Long.valueOf(creditChangeNum);


+ 5
- 1
mallinkService/src/main/resources/mapper/WxScoreRulesMapper.xml View File

@@ -9,10 +9,11 @@
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="type" jdbcType="INTEGER" property="type"/> <result column="type" jdbcType="INTEGER" property="type"/>
<result column="clear_year" jdbcType="INTEGER" property="clearYear"/> <result column="clear_year" jdbcType="INTEGER" property="clearYear"/>
<result column="scale" jdbcType="INTEGER" property="scale"/>
</resultMap> </resultMap>


<sql id="allColumns"> <sql id="allColumns">
`id`,`tenant_id`,`rules`,`create_date`,`update_date`,`type`,`clear_year`
`id`,`tenant_id`,`rules`,`create_date`,`update_date`,`type`,`clear_year`,`scale`
</sql> </sql>


<sql id="dynamicWhereConditions"> <sql id="dynamicWhereConditions">
@@ -38,6 +39,9 @@
and `clear_year` = #{clearYear} and `clear_year` = #{clearYear}
</if> </if>


<if test=" null != scale ">
and `scale` = #{scale}
</if>
<if test=" null != ids "> <if test=" null != ids ">
and id in and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


Loading…
Cancel
Save