| @@ -256,10 +256,6 @@ public class CouponSendSchedule { | |||||
| logger.info("生日发券: 会员生日券投放列表为空 couponSendList = {}, 任务跳过不执行", couponSendList); | logger.info("生日发券: 会员生日券投放列表为空 couponSendList = {}, 任务跳过不执行", couponSendList); | ||||
| return; | return; | ||||
| } | } | ||||
| // WxCouponSend config = wxCouponSendService.getConfig(EnumCouponSendSendType.BIRTHDAY.getCode(), cu.getTenantId()); | |||||
| // | |||||
| boolean sent = false; | boolean sent = false; | ||||
| for (WxCouponSendVo cs : couponSendList) { | for (WxCouponSendVo cs : couponSendList) { | ||||
| String conditions = cs.getConditions(); | String conditions = cs.getConditions(); | ||||
| @@ -293,8 +289,8 @@ public class CouponSendSchedule { | |||||
| logger.info("生日发券: 会员{}已经发送过生日券, 本次不再发送", cu.getNickName()); | logger.info("生日发券: 会员{}已经发送过生日券, 本次不再发送", cu.getNickName()); | ||||
| continue; | continue; | ||||
| } | } | ||||
| //提前n天发送生日券,不满足跳过不执行 | |||||
| if (DateUtils.birthdaysBetween(cu.getBirthdate()) != beforeDays) { | |||||
| //提前n天发送生日券,不满足跳过不执行,没有发送的进行补发 | |||||
| if (DateUtils.birthdaysBetween(cu.getBirthdate()) <= beforeDays) { | |||||
| logger.info("生日发券: [会员={},生日={}不满足提前{}天发券]", cu.getNickName(), cu.getBirthdate(),beforeDays); | logger.info("生日发券: [会员={},生日={}不满足提前{}天发券]", cu.getNickName(), cu.getBirthdate(),beforeDays); | ||||
| continue; | continue; | ||||
| } | } | ||||
| @@ -217,7 +217,8 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| int creditChangeNumOrigin = creditIncrement(record); | int creditChangeNumOrigin = creditIncrement(record); | ||||
| int creditChangeNum = creditChangeNumOrigin ; | int creditChangeNum = creditChangeNumOrigin ; | ||||
| if (record.getCreditType().equals(EnumScoreType.CONSUMPTION.getCode()) || record.getCreditType().equals(EnumScoreType.SPEND_CREDIT.getCode())) { | if (record.getCreditType().equals(EnumScoreType.CONSUMPTION.getCode()) || record.getCreditType().equals(EnumScoreType.SPEND_CREDIT.getCode())) { | ||||
| creditChangeNum = CreditUtil.calUserCredit(creditChangeNumOrigin, wxCUser, wxLevelConfigMapper, wxCUserBasicInfo, wxScoreRulesService); | |||||
| int birthdayScale = wxLevelConfigMapper.getScale(wxCUser.getTenantId(), wxCUser.getScore()) ; | |||||
| creditChangeNum = CreditUtil.calUserCredit(creditChangeNumOrigin, wxCUser, birthdayScale, wxCUserBasicInfo, wxScoreRulesService); | |||||
| } | } | ||||
| if (creditChangeNum != 0) { | if (creditChangeNum != 0) { | ||||
| @@ -320,7 +321,8 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| if (Objects.nonNull(userId)) { | if (Objects.nonNull(userId)) { | ||||
| WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(userId); | WxCUser wxCUser = wxCUserMapper.selectByPrimaryKey(userId); | ||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectByPrimaryKey(userId); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectByPrimaryKey(userId); | ||||
| creditNew = CreditUtil.calUserCredit(credit, wxCUser, wxLevelConfigMapper, wxCUserBasicInfo, wxScoreRulesService); | |||||
| int birthdayScale = wxLevelConfigMapper.getScale(wxCUser.getTenantId(), wxCUser.getScore()) ; | |||||
| creditNew = CreditUtil.calUserCredit(credit, wxCUser, birthdayScale, wxCUserBasicInfo, wxScoreRulesService); | |||||
| } else { | } else { | ||||
| creditNew = credit; | creditNew = credit; | ||||
| } | } | ||||
| @@ -1,10 +1,9 @@ | |||||
| package com.iformall.utils; | package com.iformall.utils; | ||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||||
| import com.iformall.domain.po.WxLevelConfig; | |||||
| import com.iformall.domain.po.WxScoreRules; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.mapper.WxLevelConfigMapper; | import com.iformall.mapper.WxLevelConfigMapper; | ||||
| import com.iformall.service.WxCouponActionLogService; | |||||
| import com.iformall.service.WxCouponOrderService; | |||||
| import com.iformall.service.WxScoreRulesService; | import com.iformall.service.WxScoreRulesService; | ||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| @@ -20,7 +19,7 @@ public class CreditUtil { | |||||
| * | * | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| public static int calUserCredit(int creditOrigin, WxCUser wxCUser, WxLevelConfigMapper wxLevelConfigMapper, WxCUserBasicInfo wxCUserBasicInfo, WxScoreRulesService wxScoreRulesService) { | |||||
| public static int calUserCredit(int creditOrigin, WxCUser wxCUser, Integer scaleFromDb, WxCUserBasicInfo wxCUserBasicInfo, WxScoreRulesService wxScoreRulesService) { | |||||
| if (Objects.isNull(wxCUser) || Objects.isNull(wxCUserBasicInfo)) { | if (Objects.isNull(wxCUser) || Objects.isNull(wxCUserBasicInfo)) { | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -28,13 +27,14 @@ public class CreditUtil { | |||||
| int levelScale = WxLevelConfig.DEFAULT_SCALE; | 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()); | |||||
| if (Objects.nonNull(scaleFromDb)) { | if (Objects.nonNull(scaleFromDb)) { | ||||
| levelScale = scaleFromDb; | levelScale = scaleFromDb; | ||||
| } | } | ||||
| } | } | ||||
| // 获取生日积分倍率: | // 获取生日积分倍率: | ||||
| int birthdayScale = WxScoreRules.DEFAULT_SCALE; | int birthdayScale = WxScoreRules.DEFAULT_SCALE; | ||||
| // TODO,如有修改生日,生日积分倍率也只在一天有效 | |||||
| //判断是否生日当天 | //判断是否生日当天 | ||||
| if (Objects.nonNull(wxCUserBasicInfo.getBirthdate()) && DateUtils.birthdaysBetween(wxCUserBasicInfo.getBirthdate()) == 0) { | if (Objects.nonNull(wxCUserBasicInfo.getBirthdate()) && DateUtils.birthdaysBetween(wxCUserBasicInfo.getBirthdate()) == 0) { | ||||
| WxScoreRules rules = wxScoreRulesService.getCreditRules(wxCUser.getTenantId()); | WxScoreRules rules = wxScoreRulesService.getCreditRules(wxCUser.getTenantId()); | ||||
| @@ -1079,7 +1079,6 @@ public class DateUtils { | |||||
| /** | /** | ||||
| * 日期距离今天还有几天 | * 日期距离今天还有几天 | ||||
| * | |||||
| * @param date | * @param date | ||||
| * @return <0 今后n天? | * @return <0 今后n天? | ||||
| */ | */ | ||||
| @@ -1089,7 +1088,7 @@ public class DateUtils { | |||||
| Calendar todayCal = Calendar.getInstance(); | Calendar todayCal = Calendar.getInstance(); | ||||
| Calendar birthdayCal = Calendar.getInstance(); | Calendar birthdayCal = Calendar.getInstance(); | ||||
| birthdayCal.setTime(date); | birthdayCal.setTime(date); | ||||
| return todayCal.get(Calendar.DAY_OF_YEAR) - birthdayCal.get(Calendar.DAY_OF_YEAR) ; | |||||
| return birthdayCal.get(Calendar.DAY_OF_YEAR) - todayCal.get(Calendar.DAY_OF_YEAR) ; | |||||
| } | } | ||||
| /** | /** | ||||