Преглед на файлове

积分倍率

release_toaliyun_real
xhxu преди 5 години
родител
ревизия
c4ba289db9
променени са 21 файла, в които са добавени 217 реда и са изтрити 40 реда
  1. +2
    -2
      mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java
  2. +1
    -1
      mallinkBApi/src/main/java/com/iformall/controller/WxCUserController.java
  3. +2
    -2
      mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java
  4. +1
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java
  5. +1
    -1
      mallinkCApi/src/main/java/com/iformall/controller/WxUserGrantController.java
  6. +2
    -2
      mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java
  7. +9
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java
  8. +34
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumScoreScaleRules.java
  9. +2
    -2
      mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java
  10. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxActivityJoinServiceImpl.java
  11. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java
  12. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserServiceImpl.java
  13. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java
  14. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  15. +14
    -8
      mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java
  16. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java
  17. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  18. +1
    -1
      mallinkService/src/main/java/com/iformall/service/park/impl/util/ParkHelper.java
  19. +95
    -8
      mallinkService/src/main/java/com/iformall/utils/CreditUtil.java
  20. +41
    -0
      mallinkService/src/main/java/com/iformall/utils/DateUtils.java
  21. +1
    -1
      mallinkSysAdmin/src/main/java/com/iformall/controller/datafix/DataInitController.java

+ 2
- 2
mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCreditHistoryController.java Целия файл

@@ -74,7 +74,7 @@ public class WxCreditHistoryController extends BaseController {
}

try {
Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId, getTenantInfo().getFinalTenantId()) ;
Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId) ;
return new ResultData(result);
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(),e.getMessage());
@@ -110,7 +110,7 @@ public class WxCreditHistoryController extends BaseController {
wxCreditHistory.setChangePurpose(desc);
try {
wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),getTenantInfo()) ;
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory,getTenantInfo().getTenantId());
return new ResultData(Result.SUCCESS, "操作成功", credit);
} catch (MallinkException e) {
logger.error(e.getMessage());


+ 1
- 1
mallinkBApi/src/main/java/com/iformall/controller/WxCUserController.java Целия файл

@@ -279,7 +279,7 @@ public class WxCUserController extends BaseController {
wxCreditHistory.setChangePurpose("商户端["+wxMerchant.getName()+"]操作完善个人信息");
wxCreditHistory.setOperatorType(EnumUserType.BUSER.getCode());
wxCreditHistory.setOperatorId(bUser.getId());
wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory,wxMerchant.getTenantId());
}




+ 2
- 2
mallinkBApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java Целия файл

@@ -71,7 +71,7 @@ public class WxCreditHistoryController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ;
}
try {
Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId, getTenantInfo().getFinalTenantId());
Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId);
return new ResultData(result);
} catch (MallinkException e) {
return new ResultData(e.getErrorCode(), e.getMessage());
@@ -132,7 +132,7 @@ public class WxCreditHistoryController extends BaseController {
if (null != getLoginBUser().getBuserId()) {
wxCreditHistory.setBuserId(getLoginBUser().getBuserId());
}
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory,tenantInfo.getTenantId());
//更新标签
if (wxCreditHistory.getTags() != null && !wxCreditHistory.getTags().isEmpty()) {
wxCUserTagsService.updateTagByUserId(wxCreditHistory.getCUserId(),tenantInfo, wxCreditHistory.getTags());


+ 1
- 1
mallinkCApi/src/main/java/com/iformall/controller/WxCreditHistoryController.java Целия файл

@@ -83,7 +83,7 @@ public class WxCreditHistoryController extends BaseController{

try {
wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),getTenantInfo()) ;
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory,getTenantInfo().getTenantId());
removeCacheCUser();
return new ResultData(Result.SUCCESS, "操作成功", credit);
} catch (MallinkException e) {


+ 1
- 1
mallinkCApi/src/main/java/com/iformall/controller/WxUserGrantController.java Целия файл

@@ -927,7 +927,7 @@ public class WxUserGrantController extends BaseController {
wxCreditHistory.setChangePurpose(EnumScoreType.COMPLETE_INFO.getMessage());
wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode());
wxCreditHistory.setOperatorId(memberId);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory,tenantEntity.getTenantId());
wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT, record,tenantEntity);

removeCacheCUser();


+ 2
- 2
mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java Целия файл

@@ -1376,7 +1376,7 @@ public class PosServiceImpl implements PosService {
//如果券与商户一对一 则直接将消费商户更新为此商户 若一对多 则消费商户显示多商户
creditHistory.setMerchantId(wxMerchant.getId());
creditHistory.setChangePurpose("pos消费:消费商户["+wxMerchant.getName()+"] 卷名称["+coupon.getTitle()+"("+creditHistory.getSpendStr()+"元)] ");
creditHistory = creditHistoryService.saveOrUpdate(creditHistory);
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,couponOrderCVo.getTenantId());
if (creditHistory.getCreditNum() != null) {
return creditHistory.getCreditNum();
} else {
@@ -1405,7 +1405,7 @@ public class PosServiceImpl implements PosService {
//如果券与商户一对一 则直接将消费商户更新为此商户 若一对多 则消费商户显示多商户
creditHistory.setMerchantId(merchant.getId());
creditHistory.setChangePurpose("pos消费:消费商户["+merchant.getName()+"] 消费金额["+creditHistory.getSpendStr()+"元]");
creditHistory = creditHistoryService.saveOrUpdate(creditHistory);
creditHistory = creditHistoryService.saveOrUpdate(creditHistory,merchant.getTenantId());
if (creditHistory.getCreditNum() != null) {
return creditHistory.getCreditNum();
} else {


+ 9
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java Целия файл

@@ -86,6 +86,15 @@ public class WxScoreRules extends BaseTenantEntity {
@TableField(exist = false)
public static final String SCORE = "score";

@TableField(exist = false)
public static final String CYCLE = "cycle";//EnumScoreScaleRules会员日周期(1:周;2:月;3:年)
@TableField(exist = false)
public static final String CYCLE_START = "cycleStart";//周期开始
@TableField(exist = false)
public static final String CYCLE_END = "cycleEnd";//周期结束
@TableField(exist = false)
public static final String CYCLE_SCALE = "cycleScale";//倍率


protected Long id;



+ 34
- 0
mallinkService/src/main/java/com/iformall/enums/EnumScoreScaleRules.java Целия файл

@@ -0,0 +1,34 @@
package com.iformall.enums;

public enum EnumScoreScaleRules {

WEEK(1, "周"),
MONTH(2, "月"),
YEAR(3, "年")
;

public static EnumScoreScaleRules getEnum(Integer code) {
for (EnumScoreScaleRules value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumScoreScaleRules(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

+ 2
- 2
mallinkService/src/main/java/com/iformall/service/WxCreditHistoryService.java Целия файл

@@ -54,7 +54,7 @@ public interface WxCreditHistoryService {
*
* @param record
*/
WxCreditHistory saveOrUpdate(WxCreditHistory record);
WxCreditHistory saveOrUpdate(WxCreditHistory record,String tenantId);

/**
* 积分历史回退
@@ -70,7 +70,7 @@ public interface WxCreditHistoryService {
*/
//void deleteById(Long id);

Map<String, Integer> findByMerchantIdAndSpend(Long merchantId, String spendStr, Long userId, String tenantId);
Map<String, Integer> findByMerchantIdAndSpend(Long merchantId, String spendStr, Long userId);
void clearCreditByYear();



+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxActivityJoinServiceImpl.java Целия файл

@@ -190,7 +190,7 @@ public class WxActivityJoinServiceImpl implements WxActivityJoinService {
wxCreditHistory.setChangePurpose(EnumScoreType.ACTIVITY_JOIN.getMessage()+"["+wxActivity.getTitle()+"]");
wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode());
wxCreditHistory.setOperatorId(wxActivityJoin.getUserId());
wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory,wxActivity.getTenantId());
}
//保存到报名表中
final IdWorker idWorker = IdWorker.get();


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java Целия файл

@@ -1132,7 +1132,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc
}
wxCreditHistory.setCreditAmount(credit);
wxCreditHistory.setCreditNum(credit);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory,mallUserInfo.getTenantId());
}
} catch (Exception e) {
logger.error(e.getMessage());


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxCUserServiceImpl.java Целия файл

@@ -331,7 +331,7 @@ public class WxCUserServiceImpl implements WxCUserService {
wxCreditHistory.setChangePurpose(enumScoreType.getMessage());
wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode());
wxCreditHistory.setOperatorId(user.getUserId());
WxCreditHistory record = wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
WxCreditHistory record = wxCreditHistoryService.saveOrUpdate(wxCreditHistory,user.getTenantId());
return record.getCreditAmount();
}



+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java Целия файл

@@ -312,7 +312,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
creditHistory.setMerchantId(record.getMerchantId());
WxMerchant wxMerchant = wxMerchantMapper.selectById(record.getMerchantId());
creditHistory.setChangePurpose("卡消费:消费商户["+wxMerchant.getName()+"] 金额["+creditHistory.getSpendStr()+"元]");
wxCreditHistoryService.saveOrUpdate(creditHistory);
wxCreditHistoryService.saveOrUpdate(creditHistory,record.getTenantId());
} catch (Exception e) {
logger.error("积分值:" + e.getMessage());
}
@@ -935,7 +935,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService {
creditHistory.setMerchantId(record.getMerchantId());
// WxMerchant wxMerchant = wxMerchantMapper.selectById(record.getMerchantId());
creditHistory.setChangePurpose("pos卡消费:消费商户["+merchant.getName()+"] 金额["+creditHistory.getSpendStr()+"元]");
creditHistory = wxCreditHistoryService.saveOrUpdate(creditHistory);
creditHistory = wxCreditHistoryService.saveOrUpdate(creditHistory,record.getTenantId());
if (creditHistory != null) {
scoreCreditCalc.setCredit(scoreCreditCalc.getCredit() + creditHistory.getCreditNum());
}


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java Целия файл

@@ -467,7 +467,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
creditHistory.setBuserId(bUser.getBuserId());
WxMerchant wxMerchant = wxMerchantMapper.selectById(bUser.getMerchantId());
creditHistory.setChangePurpose("商户核销增加积分:商户名称["+wxMerchant.getName()+"] 券名称["+wxCoupon.getTitle()+"("+creditHistory.getSpendStr()+"元)] ");
wxCreditHistoryService.saveOrUpdate(creditHistory);
wxCreditHistoryService.saveOrUpdate(creditHistory,couponOrder.getTenantId());
} catch (Exception e) {
logger.error("积分值:" + e.getMessage());
}
@@ -498,7 +498,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
creditHistory.setBusinessId(wxCoupon.getBusiness());
creditHistory.setSpend(couponOrder.getCouponPrice());
creditHistory.setChangePurpose("核销停车劵["+wxCoupon.getTitle()+"("+creditHistory.getSpendStr()+"元)] ");
wxCreditHistoryService.saveOrUpdate(creditHistory);
wxCreditHistoryService.saveOrUpdate(creditHistory,couponOrder.getTenantId());
} catch (Exception e) {
logger.error("积分值:" + e.getMessage());
}


+ 14
- 8
mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java Целия файл

@@ -240,7 +240,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public WxCreditHistory saveOrUpdate(WxCreditHistory record) {
public WxCreditHistory saveOrUpdate(WxCreditHistory record,String tenantId) {
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(record.getCUserId(),record.getTenantId());
if (wxCUserBasicInfo == null) {
//验证此用户是否存在
@@ -267,7 +267,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
if (record.getCreditType().equals(EnumScoreType.CONSUMPTION.getCode()) || record.getCreditType().equals(EnumScoreType.SPEND_CREDIT.getCode())) {
//等级积分配置
try {
creditChangeNum = CreditUtil.calUserCredit(creditChangeNumOrigin, wxCUserBasicInfo, wxScoreRulesService,wxLevelConfigMapper);
creditChangeNum = CreditUtil.calUserCredit(creditChangeNumOrigin, wxCUserBasicInfo, tenantId, wxScoreRulesService,wxLevelConfigMapper);
if (Objects.nonNull(CreditUtil.getIsBirthDayScale())) {
hasBirthDateCredit = true;
}
@@ -354,23 +354,29 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
// }

@Override
public Map<String, Integer> findByMerchantIdAndSpend(Long merchantId, String spendStr, Long userId, String tenantId) {
public Map<String, Integer> findByMerchantIdAndSpend(Long merchantId, String spendStr, Long userId) {
WxMerchant wxMerchant = wxMerchantMapper.selectById(merchantId);
Map<String, Integer> creditMap = Maps.newHashMap();
if (wxMerchant != null && wxMerchant.getBusinessId() != null) {
WxCreditHistory wxCreditHistory = new WxCreditHistory();
wxCreditHistory.setBusinessId(wxMerchant.getBusinessId());
//wxCreditHistory.updateTenantInfo(tenantEntity);
wxCreditHistory.setTenantId(tenantId);
wxCreditHistory.setFinalTenantId(tenantId);
wxCreditHistory.setTenantId(wxMerchant.getFinalTenantId());
wxCreditHistory.setFinalTenantId(wxMerchant.getFinalTenantId());
int credit;
int creditNew = 0 ;
if (StringUtils.isNotBlank(spendStr)) {
wxCreditHistory.setSpend(new BigDecimal(spendStr).multiply(new BigDecimal(100)).intValue());
credit = payAddCredit(wxCreditHistory);
if (Objects.nonNull(userId)) {
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(userId,tenantId);
creditNew = CreditUtil.calUserCredit(credit, wxCUserBasicInfo, wxScoreRulesService,wxLevelConfigMapper);
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(userId,wxMerchant.getFinalTenantId());
try {
creditNew = CreditUtil.calUserCredit(credit, wxCUserBasicInfo, wxMerchant.getTenantId(), wxScoreRulesService,wxLevelConfigMapper);
} catch (Exception e) {
logger.error("积分倍率计算异常",e);
} finally {
CreditUtil.clear();
}
} else {
creditNew = credit;
}
@@ -495,7 +501,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService {
throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND);
}
//根据商户id和花费金额计算需要新增的积分
Map<String, Integer> map = findByMerchantIdAndSpend(record.getMerchantId(), record.getSpendStr(), null,record.getTenantId());
Map<String, Integer> map = findByMerchantIdAndSpend(record.getMerchantId(), record.getSpendStr(), null);
return map.get("credit");
}



+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxGameServiceImpl.java Целия файл

@@ -474,7 +474,7 @@ public class WxGameServiceImpl implements WxGameService {
wxCreditHistory.setCreditType(EnumScoreType.GAME_ADD_CREDIT.getCode());
wxCreditHistory.setChangePurpose(EnumScoreType.GAME_ADD_CREDIT.getMessage());
wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),wxGame) ;
wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory,wxGame.getTenantId());
addCredit = credit;
orderId = Constant.creditPlayOrderIdTab;
}else{
@@ -521,7 +521,7 @@ public class WxGameServiceImpl implements WxGameService {
wxCreditHistory.setCreditType(EnumScoreType.GAME_LES_CREDIT.getCode());
wxCreditHistory.setChangePurpose(EnumScoreType.GAME_LES_CREDIT.getMessage());
wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),wxGame) ;
wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory,wxGame.getTenantId());

return this.luckDraw(gameId,userId,wxGame.getPlayCredit());
}else{


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java Целия файл

@@ -1542,7 +1542,7 @@ public class WxOrderServiceImpl implements WxOrderService {
creditHistory.setChangePurpose("付款码消费:消费商户["+wxMerchant.getName()+"] 金额["+creditHistory.getSpendStr()+"元]");


wxCreditHistoryService.saveOrUpdate(creditHistory);
wxCreditHistoryService.saveOrUpdate(creditHistory,wxMerchant.getTenantId());
} catch (Exception e) {
logger.error("积分值:" + e.getMessage());
}
@@ -2181,7 +2181,7 @@ public class WxOrderServiceImpl implements WxOrderService {
creditHistory.setChangePurpose("积分兑换"+"["+coupon.getTitle()+"]");
}

wxCreditHistoryService.saveOrUpdate(creditHistory);
wxCreditHistoryService.saveOrUpdate(creditHistory,coupon.getTenantId());
}

@Override


+ 1
- 1
mallinkService/src/main/java/com/iformall/service/park/impl/util/ParkHelper.java Целия файл

@@ -88,7 +88,7 @@ public class ParkHelper {
wxCreditHistory.setChangePurpose(EnumScoreType.BIND_CAR.getMessage());
wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode());
wxCreditHistory.setOperatorId(cuUserId);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory);
wxCreditHistoryService.saveOrUpdate(wxCreditHistory,park.getTenantId());
}
public ResultData unbindCar(Map<String, String> paramMap, WxPark park, Long cuUserId) {


+ 95
- 8
mallinkService/src/main/java/com/iformall/utils/CreditUtil.java Целия файл

@@ -1,13 +1,18 @@
package com.iformall.utils;

import com.alibaba.fastjson.JSONObject;
import com.aliyun.oss.common.utils.DateUtil;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumScoreScaleRules;
import com.iformall.mapper.WxLevelConfigMapper;
import com.iformall.service.WxScoreRulesService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@Slf4j
@@ -24,21 +29,26 @@ public class CreditUtil {
* @param wxLevelConfigMapper
* @return
*/
public static int calUserCredit(int creditOrigin, WxCUserBasicInfo wxCUserBasicInfo, WxScoreRulesService wxScoreRulesService, WxLevelConfigMapper wxLevelConfigMapper) {
public static int calUserCredit(int creditOrigin, WxCUserBasicInfo wxCUserBasicInfo, String tenantId, WxScoreRulesService wxScoreRulesService, WxLevelConfigMapper wxLevelConfigMapper) {
Long userId = wxCUserBasicInfo.getId();
Integer score = wxCUserBasicInfo.getPoins();
String tenantId = wxCUserBasicInfo.getFinalTenantId();
String finalTenantId = wxCUserBasicInfo.getFinalTenantId();
Integer levelScaleConfig = WxLevelConfig.DEFAULT_SCALE ;
levelScaleConfig = wxLevelConfigMapper.getScale(tenantId, score) ;
levelScaleConfig = wxLevelConfigMapper.getScale(finalTenantId, score) ;
// 获取等级积分倍率,
int levelScale = getLevelScale(score, levelScaleConfig);

// 获取生日积分倍率:
int birthdayScale = getBirthdayScale(wxCUserBasicInfo, wxScoreRulesService);
int birthdayScale = getBirthdayScale(wxCUserBasicInfo, tenantId, wxScoreRulesService);

// 获取会员日倍率:
int memberDayScale = getMemberDayScale(tenantId, wxScoreRulesService);

int creditNew = new BigDecimal(creditOrigin)
.multiply(new BigDecimal(levelScale))
.multiply(new BigDecimal(birthdayScale))
.multiply(new BigDecimal(memberDayScale))
.divide(new BigDecimal(WxScoreRules.DEFAULT_SCALE))
.divide(new BigDecimal(WxScoreRules.DEFAULT_SCALE))
.divide(new BigDecimal(WxLevelConfig.DEFAULT_SCALE)
, BigDecimal.ROUND_HALF_UP).intValue();
@@ -76,7 +86,7 @@ public class CreditUtil {
* @param wxScoreRulesService
* @return
*/
private static int getBirthdayScale(WxCUserBasicInfo wxCUserBasicInfo, WxScoreRulesService wxScoreRulesService) {
private static int getBirthdayScale(WxCUserBasicInfo wxCUserBasicInfo,String tenantId, WxScoreRulesService wxScoreRulesService) {
int birthdayScale = WxScoreRules.DEFAULT_SCALE;
if (Objects.isNull(wxCUserBasicInfo) || StringUtils.isBlank(wxCUserBasicInfo.getPhone())) {
return 0;
@@ -86,14 +96,14 @@ public class CreditUtil {
if(Objects.isNull(wxCUserBasicInfo.getScoreDate())) {
//设置过生日的用户
if (Objects.nonNull(wxCUserBasicInfo.getBirthdate()) && DateUtils.birthdaysBetween(wxCUserBasicInfo.getBirthdate()) == 0) {
birthdayScale = getBirthdayScoreScale(wxCUserBasicInfo.getFinalTenantId(),wxScoreRulesService);
birthdayScale = getBirthdayScoreScale(tenantId,wxScoreRulesService);
} else {
log.info("积分倍率计算:未设置生日或生日条件未匹配={}", wxCUserBasicInfo.getScoreDate());
}
} else {
//发过生日券的用户或者享受过生日积分倍率的用户
if (Objects.nonNull(wxCUserBasicInfo.getScoreDate()) && DateUtils.birthdaysBetween(wxCUserBasicInfo.getScoreDate()) == 0) {
birthdayScale = getBirthdayScoreScale(wxCUserBasicInfo.getFinalTenantId(), wxScoreRulesService);
birthdayScale = getBirthdayScoreScale(tenantId, wxScoreRulesService);
}
}

@@ -113,7 +123,7 @@ public class CreditUtil {
*/
public static int getBirthdayScoreScale(String tenantId, WxScoreRulesService wxScoreRulesService) {
int birthdayScale = WxScoreRules.DEFAULT_SCALE;
WxScoreRules rules = wxScoreRulesService.getCreditRules(tenantId);
WxScoreRules rules = wxScoreRulesService.getCreditDoubleRules(tenantId);
if (Objects.nonNull(rules) && Objects.nonNull(rules.getScale())) {
//规则存使用积分倍率
birthdayScale = rules.getScale();
@@ -125,6 +135,83 @@ public class CreditUtil {
return birthdayScale;
}

/**
* 获取会员日倍率
*
* @param
* @param wxScoreRulesService
* @return
*/
private static int getMemberDayScale(String tenantId, WxScoreRulesService wxScoreRulesService) {
int memberDayScale = WxScoreRules.DEFAULT_SCALE;

WxScoreRules rules = wxScoreRulesService.getCreditDoubleRules(tenantId);
if (Objects.nonNull(rules) && Objects.nonNull(rules.getRules())) {
//会员日积分规则
List<JSONObject> ruleList = JSONObject.parseArray(rules.getRules(), JSONObject.class);
for (JSONObject rule:ruleList) {
Integer cycle = rule.getInteger(WxScoreRules.CYCLE);
String cycleStart = rule.getString(WxScoreRules.CYCLE_START);
String cycleEnd = rule.getString(WxScoreRules.CYCLE_END);
Integer cycleScale = rule.getInteger(WxScoreRules.CYCLE_SCALE);
if(cycle == null || StringUtils.isBlank(cycleStart) || StringUtils.isBlank(cycleEnd) || cycleScale == null){
break;
}
if(cycleScale > memberDayScale){
if(cycle.equals(EnumScoreScaleRules.WEEK.getCode())){
try {
int start = Integer.parseInt(cycleStart);
int end = Integer.parseInt(cycleEnd);
int weekDay = DateUtils.getWeekOfDate(new Date());
if(weekDay >= start && weekDay <=end){
memberDayScale = cycleScale;
}
} catch (NumberFormatException e) {
break;
}
}else if(cycle.equals(EnumScoreScaleRules.MONTH.getCode())){
try {
int start = Integer.parseInt(cycleStart);
int end = Integer.parseInt(cycleEnd);
int monthDay = DateUtils.getMonthOfDate(new Date());
if(monthDay >= start && monthDay <=end){
memberDayScale = cycleScale;
}
} catch (NumberFormatException e) {
break;
}
}else if(cycle.equals(EnumScoreScaleRules.YEAR.getCode())){
try {
if(cycleStart.contains("-") && cycleEnd.contains("-")){
String[] cycleStarts = cycleStart.split("-");
String[] cycleEnds = cycleEnd.split("-");
int month = DateUtils.getMonth(new Date());
int monthStart = Integer.parseInt(cycleStarts[0]);
int monthEnd = Integer.parseInt(cycleEnds[0]);
if(month >= monthStart && month <= monthEnd){
int monthDay = DateUtils.getMonthOfDate(new Date());
int dayStart = Integer.parseInt(cycleStarts[1]);
int dayEnd = Integer.parseInt(cycleEnds[1]);
if(monthDay >= dayStart && monthDay <= dayEnd){
memberDayScale = cycleScale;
}
}
}
} catch (NumberFormatException e) {
break;
}
}
}
}

} else {
//没有配置积分规则
//log.info("积分倍率计算:会员生日积分倍率配置=null");
}
log.info("会员日积分倍率配置:{}", memberDayScale);
return memberDayScale;
}

public static Long getIsBirthDayScale() {
return isBirthDayScale.get();
}


+ 41
- 0
mallinkService/src/main/java/com/iformall/utils/DateUtils.java Целия файл

@@ -1288,4 +1288,45 @@ public class DateUtils {
}
} return age;
}

/**
* 获取当前日期是星期几<br>
*
* @param date
* @return 当前日期是星期几
*/
public static int getWeekOfDate(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int w = cal.get(Calendar.DAY_OF_WEEK) ;
if (w == 1)
w = 7;
return w - 1;
}

/**
* 获取当前日期是当前月的第几天<br>
*
* @param date
* @return 获取当前日期是当前月的第几天
*/
public static int getMonthOfDate(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int m = cal.get(Calendar.DAY_OF_MONTH);
return m;
}

/**
* 获取当前日期是几月<br>
*
* @param date
* @return 获取当前日期是几月
*/
public static int getMonth(Date date) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int month = cal.get(Calendar.MONTH) + 1;
return month;
}
}

+ 1
- 1
mallinkSysAdmin/src/main/java/com/iformall/controller/datafix/DataInitController.java Целия файл

@@ -216,7 +216,7 @@ public class DataInitController extends BaseController {
creditHistory.setMerchantId(buUser.getMerchantId());
WxMerchant wxMerchant = merchantService.getById(buUser.getMerchantId());
creditHistory.setChangePurpose("核销积分数据修复:消费商户["+wxMerchant.getName()+"] 卷名称["+coupon.getTitle()+"("+creditHistory.getSpendStr()+"元)] ");
creditHistoryService.saveOrUpdate(creditHistory);
creditHistoryService.saveOrUpdate(creditHistory,co.getTenantId());
});
}



Зареждане…
Отказ
Запис