|
|
@@ -4,8 +4,11 @@ import com.alibaba.fastjson.JSONObject; |
|
|
import com.aliyun.oss.common.utils.DateUtil; |
|
|
import com.aliyun.oss.common.utils.DateUtil; |
|
|
import com.iformall.domain.po.*; |
|
|
import com.iformall.domain.po.*; |
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
|
|
import com.iformall.enums.EnumScoreRules; |
|
|
import com.iformall.enums.EnumScoreScaleRules; |
|
|
import com.iformall.enums.EnumScoreScaleRules; |
|
|
|
|
|
import com.iformall.enums.EnumYesOrNo; |
|
|
import com.iformall.mapper.WxLevelConfigMapper; |
|
|
import com.iformall.mapper.WxLevelConfigMapper; |
|
|
|
|
|
import com.iformall.mapper.WxMerchantScoreRulesMapper; |
|
|
import com.iformall.service.WxScoreRulesService; |
|
|
import com.iformall.service.WxScoreRulesService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@@ -29,7 +32,8 @@ public class CreditUtil { |
|
|
* @param wxLevelConfigMapper |
|
|
* @param wxLevelConfigMapper |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public static int calUserCredit(int creditOrigin, WxCUserBasicInfo wxCUserBasicInfo, TenantEntity tenantEntity, WxScoreRulesService wxScoreRulesService, WxLevelConfigMapper wxLevelConfigMapper) { |
|
|
|
|
|
|
|
|
public static int calUserCredit(int creditOrigin, WxCUserBasicInfo wxCUserBasicInfo, TenantEntity tenantEntity, Long merchantId, |
|
|
|
|
|
WxScoreRulesService wxScoreRulesService, WxLevelConfigMapper wxLevelConfigMapper, WxMerchantScoreRulesMapper wxMerchantScoreRulesMapper) { |
|
|
Long userId = wxCUserBasicInfo.getId(); |
|
|
Long userId = wxCUserBasicInfo.getId(); |
|
|
Integer score = wxCUserBasicInfo.getPoins(); |
|
|
Integer score = wxCUserBasicInfo.getPoins(); |
|
|
String finalTenantId = wxCUserBasicInfo.getFinalTenantId(); |
|
|
String finalTenantId = wxCUserBasicInfo.getFinalTenantId(); |
|
|
@@ -44,13 +48,18 @@ public class CreditUtil { |
|
|
// 获取会员日倍率: |
|
|
// 获取会员日倍率: |
|
|
int memberDayScale = getMemberDayScale(tenantEntity, wxScoreRulesService); |
|
|
int memberDayScale = getMemberDayScale(tenantEntity, wxScoreRulesService); |
|
|
|
|
|
|
|
|
|
|
|
//获取商户积分倍率: |
|
|
|
|
|
int merchantScale = getMerchantScale(merchantId,wxMerchantScoreRulesMapper); |
|
|
|
|
|
|
|
|
int creditNew = new BigDecimal(creditOrigin) |
|
|
int creditNew = new BigDecimal(creditOrigin) |
|
|
.multiply(new BigDecimal(levelScale)) |
|
|
.multiply(new BigDecimal(levelScale)) |
|
|
.multiply(new BigDecimal(birthdayScale)) |
|
|
.multiply(new BigDecimal(birthdayScale)) |
|
|
.multiply(new BigDecimal(memberDayScale)) |
|
|
.multiply(new BigDecimal(memberDayScale)) |
|
|
|
|
|
.multiply(new BigDecimal(merchantScale)) |
|
|
.divide(new BigDecimal(WxScoreRules.DEFAULT_SCALE)) |
|
|
.divide(new BigDecimal(WxScoreRules.DEFAULT_SCALE)) |
|
|
.divide(new BigDecimal(WxScoreRules.DEFAULT_SCALE)) |
|
|
.divide(new BigDecimal(WxScoreRules.DEFAULT_SCALE)) |
|
|
.divide(new BigDecimal(WxLevelConfig.DEFAULT_SCALE) |
|
|
|
|
|
|
|
|
.divide(new BigDecimal(WxLevelConfig.DEFAULT_SCALE)) |
|
|
|
|
|
.divide(new BigDecimal(WxMerchantScoreRules.DEFAULT_SCALE) |
|
|
, BigDecimal.ROUND_HALF_UP).intValue(); |
|
|
, BigDecimal.ROUND_HALF_UP).intValue(); |
|
|
|
|
|
|
|
|
log.info("积分倍率计算, 用户:{},成长值:{},等级积分倍率:{},生日积分倍率:{},原积分:{},新积分:{}", userId, score, levelScale, birthdayScale, creditOrigin, creditNew); |
|
|
log.info("积分倍率计算, 用户:{},成长值:{},等级积分倍率:{},生日积分倍率:{},原积分:{},新积分:{}", userId, score, levelScale, birthdayScale, creditOrigin, creditNew); |
|
|
@@ -228,6 +237,28 @@ public class CreditUtil { |
|
|
return memberDayScale; |
|
|
return memberDayScale; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取商户积分倍率 |
|
|
|
|
|
* |
|
|
|
|
|
* @param |
|
|
|
|
|
* @param wxMerchantScoreRulesMapper |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
private static int getMerchantScale(Long merchantId, WxMerchantScoreRulesMapper wxMerchantScoreRulesMapper) { |
|
|
|
|
|
int merchantScale = WxMerchantScoreRules.DEFAULT_SCALE; |
|
|
|
|
|
|
|
|
|
|
|
WxMerchantScoreRules rules = wxMerchantScoreRulesMapper.findMerchantScoreRules(merchantId, EnumScoreRules.CREDIT.getCode()); |
|
|
|
|
|
if (Objects.nonNull(rules) && EnumYesOrNo.YES.getCode().equals(rules.getOpen())) { |
|
|
|
|
|
merchantScale = rules.getScale(); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
//没有配置积分规则 |
|
|
|
|
|
//log.info("积分倍率计算:商户积分倍率配置=null"); |
|
|
|
|
|
} |
|
|
|
|
|
log.info("商户积分倍率配置:{}", merchantScale); |
|
|
|
|
|
return merchantScale; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static Long getIsBirthDayScale() { |
|
|
public static Long getIsBirthDayScale() { |
|
|
return isBirthDayScale.get(); |
|
|
return isBirthDayScale.get(); |
|
|
} |
|
|
} |
|
|
|