| | |
| | | return false; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | BigDecimal q = new BigDecimal("100"); |
| | | BigDecimal q1 = new BigDecimal("99"); |
| | | BigDecimal q2 = new BigDecimal("100"); |
| | | BigDecimal q3= new BigDecimal("88"); |
| | | |
| | | List<BigDecimal> list = new ArrayList<>(); |
| | | list.add(q); |
| | | list.add(q1); |
| | | list.add(q2); |
| | | list.add(q3); |
| | | |
| | | BigDecimal bigMax = list.stream().max(BigDecimal::compareTo).get(); |
| | | System.out.println(bigMax); |
| | | } |
| | | // public static void main(String[] args) { |
| | | // BigDecimal q = new BigDecimal("100"); |
| | | // BigDecimal q1 = new BigDecimal("99"); |
| | | // BigDecimal q2 = new BigDecimal("100"); |
| | | // BigDecimal q3= new BigDecimal("88"); |
| | | // |
| | | // List<BigDecimal> list = new ArrayList<>(); |
| | | // list.add(q); |
| | | // list.add(q1); |
| | | // list.add(q2); |
| | | // list.add(q3); |
| | | // |
| | | // BigDecimal bigMax = list.stream().max(BigDecimal::compareTo).get(); |
| | | // System.out.println(bigMax); |
| | | // } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | return; |
| | | } |
| | | //获取订单中套餐总数金额 |
| | | BigDecimal amountTC = mallOrderItemIsTCs.stream().map(MallOrderItem::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if(BigDecimal.ZERO.compareTo(amountTC) >= 0){ |
| | | BigDecimal amountTCAll = mallOrderItemIsTCs.stream().map(MallOrderItem::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if(BigDecimal.ZERO.compareTo(amountTCAll) >= 0){ |
| | | return; |
| | | } |
| | | MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectById(orderId); |
| | | String orderNo = mallOrderInfo.getOrderNo(); |
| | | //购买人 |
| | | Long memberId = mallOrderInfo.getMemberId(); |
| | | BigDecimal amountTC = new BigDecimal(1000); |
| | | //购买套餐按照1000的基数去补贴,如5000,则补贴5次1000 |
| | | int times = Integer.parseInt(amountTCAll.divideToIntegralValue(amountTC).toString()); |
| | | if(times < 1){ |
| | | return; |
| | | } |
| | | |
| | | /** |
| | | * 1、购买人获得固定比例的H金劵 |
| | | * = amountTC * 固定比例 |
| | | */ |
| | | perkMember(memberId, |
| | | PerkEnum.BUY_SET_MEAL_PERK_PERCENT, |
| | | amountTC, |
| | | "score", |
| | | MoneyFlowTypeEnum.BUY_SET_MEAL_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.SCORE.getValue(), |
| | | orderNo); |
| | | for(int i = 0; i < times; i++){ |
| | | MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectById(orderId); |
| | | String orderNo = mallOrderInfo.getOrderNo(); |
| | | //购买人 |
| | | Long memberId = mallOrderInfo.getMemberId(); |
| | | |
| | | /** |
| | | * 2、直推获取8%的现金->余额,4%的H金劵->H金劵 |
| | | */ |
| | | MallMember mallMember = mallMemberMapper.selectById(memberId); |
| | | if(ObjectUtil.isNotEmpty(mallMember.getReferrerId())){ |
| | | String referrerId = mallMember.getReferrerId(); |
| | | MallMember mallMemberDirect = mallMemberMapper.selectInfoByInviteId(referrerId); |
| | | Long directMemberId = mallMemberDirect.getId(); |
| | | |
| | | perkMember(directMemberId, |
| | | PerkEnum.DIRECT_CASH_PERK_PERCENT, |
| | | amountTC, |
| | | "balance", |
| | | MoneyFlowTypeEnum.DIRECT_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | |
| | | perkMember(directMemberId, |
| | | PerkEnum.DIRECT_SCORE_PERK_PERCENT, |
| | | /** |
| | | * 1、购买人获得固定比例的H金劵 |
| | | * = amountTC * 固定比例 |
| | | */ |
| | | perkMember(memberId, |
| | | PerkEnum.BUY_SET_MEAL_PERK_PERCENT, |
| | | amountTC, |
| | | "score", |
| | | MoneyFlowTypeEnum.DIRECT_SCORE_PERK.getValue(), |
| | | MoneyFlowTypeEnum.BUY_SET_MEAL_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.SCORE.getValue(), |
| | | orderNo); |
| | | } |
| | | |
| | | /** |
| | | * 4、董事享受全公司入单分红2%加权(现金) |
| | | */ |
| | | List<MallMember> mallMembersDirectors = mallMemberMapper.selectDirectorsOrStoreMaster(1); |
| | | if(CollUtil.isNotEmpty(mallMembersDirectors)){ |
| | | perkMembersLevel(mallMembersDirectors, |
| | | PerkEnum.DIRECTOR_CASH_PERK_PERCENT, |
| | | amountTC, |
| | | "balance", |
| | | MoneyFlowTypeEnum.DIRECTOR_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | } |
| | | /** |
| | | * 2、直推获取8%的现金->余额,4%的H金劵->H金劵 |
| | | */ |
| | | MallMember mallMember = mallMemberMapper.selectById(memberId); |
| | | if(ObjectUtil.isNotEmpty(mallMember.getReferrerId())){ |
| | | String referrerId = mallMember.getReferrerId(); |
| | | MallMember mallMemberDirect = mallMemberMapper.selectInfoByInviteId(referrerId); |
| | | Long directMemberId = mallMemberDirect.getId(); |
| | | |
| | | /** |
| | | * 5、合伙人享全公司入单分红5%加权(现金) |
| | | */ |
| | | List<MallMember> mallMemberPartners = mallMemberMapper.selectDirectorsOrStoreMaster(3); |
| | | if(CollUtil.isNotEmpty(mallMemberPartners)){ |
| | | perkMembersLevel(mallMemberPartners, |
| | | PerkEnum.PARTNER_CASH_PERK_PERCENT, |
| | | amountTC, |
| | | "balance", |
| | | MoneyFlowTypeEnum.PARTNER_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | } |
| | | perkMember(directMemberId, |
| | | PerkEnum.DIRECT_CASH_PERK_PERCENT, |
| | | amountTC, |
| | | "balance", |
| | | MoneyFlowTypeEnum.DIRECT_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | |
| | | /** |
| | | * 3、团队下不同代理级别获取不用的比例的现金和H金劵 |
| | | */ |
| | | if(StrUtil.isNotEmpty(mallMember.getReferrerIds())){ |
| | | //团队补贴对象 |
| | | perkMember(directMemberId, |
| | | PerkEnum.DIRECT_SCORE_PERK_PERCENT, |
| | | amountTC, |
| | | "score", |
| | | MoneyFlowTypeEnum.DIRECT_SCORE_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.SCORE.getValue(), |
| | | orderNo); |
| | | } |
| | | |
| | | /** |
| | | * 4、董事享受全公司入单分红2%加权(现金) |
| | | */ |
| | | List<MallMember> mallMembersDirectors = mallMemberMapper.selectDirectorsOrStoreMaster(1); |
| | | if(CollUtil.isNotEmpty(mallMembersDirectors)){ |
| | | perkMembersLevel(mallMembersDirectors, |
| | | PerkEnum.DIRECTOR_CASH_PERK_PERCENT, |
| | | amountTC, |
| | | "balance", |
| | | MoneyFlowTypeEnum.DIRECTOR_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | } |
| | | |
| | | /** |
| | | * 5、合伙人享全公司入单分红5%加权(现金) |
| | | */ |
| | | List<MallMember> mallMemberPartners = mallMemberMapper.selectDirectorsOrStoreMaster(3); |
| | | if(CollUtil.isNotEmpty(mallMemberPartners)){ |
| | | perkMembersLevel(mallMemberPartners, |
| | | PerkEnum.PARTNER_CASH_PERK_PERCENT, |
| | | amountTC, |
| | | "balance", |
| | | MoneyFlowTypeEnum.PARTNER_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | } |
| | | |
| | | /** |
| | | * 3、团队下不同代理级别获取不用的比例的现金和H金劵 |
| | | */ |
| | | if(StrUtil.isNotEmpty(mallMember.getReferrerIds())){ |
| | | //团队补贴对象 |
| | | // List<MallMember> mallMemberTeamPerk = new ArrayList<>(); |
| | | |
| | | String referrerIds = mallMember.getReferrerIds(); |
| | | List<String> referrerIdList = StrUtil.splitTrim(referrerIds, ","); |
| | | if(CollUtil.isNotEmpty(referrerIdList)){ |
| | | List<MallMember> mallMemberTeamPerk = mallMemberMapper.selectByInviteIds(referrerIdList); |
| | | String referrerIds = mallMember.getReferrerIds(); |
| | | List<String> referrerIdList = StrUtil.splitTrim(referrerIds, ","); |
| | | if(CollUtil.isNotEmpty(referrerIdList)){ |
| | | List<MallMember> mallMemberTeamPerk = mallMemberMapper.selectByInviteIds(referrerIdList); |
| | | |
| | | if(CollUtil.isNotEmpty(mallMemberTeamPerk)){ |
| | | String levelNormal = MemberLevelEnum.V1.getType(); |
| | | BigDecimal cashPercentNormal = BigDecimal.ZERO; |
| | | BigDecimal scorePercentNormal = BigDecimal.ZERO; |
| | | if(CollUtil.isNotEmpty(mallMemberTeamPerk)){ |
| | | String levelNormal = MemberLevelEnum.V1.getType(); |
| | | BigDecimal cashPercentNormal = BigDecimal.ZERO; |
| | | BigDecimal scorePercentNormal = BigDecimal.ZERO; |
| | | |
| | | DataDictionaryCustom poolScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PRICE.getType(), |
| | | PerkEnum.POOL_SCORE_PRICE.getCode()); |
| | | BigDecimal poolScorePrice = new BigDecimal(poolScorePriceDic.getValue() == null ? "1" : poolScorePriceDic.getValue()); |
| | | for(MallMember teamPerkMember : mallMemberTeamPerk){ |
| | | String level = teamPerkMember.getLevel(); |
| | | //比较两个级别的大小,level大于levelNormal返回1 |
| | | int compareMin = MemberLevelEnum.V1.compareLevel(level, levelNormal); |
| | | int compareMax = MemberLevelEnum.V1.compareLevel(MemberLevelEnum.V6.getType(), level); |
| | | if(compareMin >= 1 && compareMax >= 1){ |
| | | Long teamPerkMemberId = teamPerkMember.getId(); |
| | | DataDictionaryCustom teamPerkMemberDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | "AGENT_PERK_SET", level); |
| | | DataDictionaryCustom poolScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PRICE.getType(), |
| | | PerkEnum.POOL_SCORE_PRICE.getCode()); |
| | | BigDecimal poolScorePrice = new BigDecimal(poolScorePriceDic.getValue() == null ? "1" : poolScorePriceDic.getValue()); |
| | | for(MallMember teamPerkMember : mallMemberTeamPerk){ |
| | | String level = teamPerkMember.getLevel(); |
| | | //比较两个级别的大小,level大于levelNormal返回1 |
| | | int compareMin = MemberLevelEnum.V1.compareLevel(level, levelNormal); |
| | | int compareMax = MemberLevelEnum.V1.compareLevel(MemberLevelEnum.V6.getType(), level); |
| | | if(compareMin >= 1 && compareMax >= 1){ |
| | | Long teamPerkMemberId = teamPerkMember.getId(); |
| | | DataDictionaryCustom teamPerkMemberDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | "AGENT_PERK_SET", level); |
| | | |
| | | AdminAgentInfo adminAgentInfo = JSONObject.parseObject(teamPerkMemberDic.getValue(), AdminAgentInfo.class); |
| | | BigDecimal cashPercent = adminAgentInfo.getCashPercent().multiply(AppContants.PERCENTAGE); |
| | | BigDecimal scorePercent = adminAgentInfo.getScorePercent().multiply(AppContants.PERCENTAGE); |
| | | //极差 |
| | | cashPercent = cashPercent.subtract(cashPercentNormal); |
| | | scorePercent = scorePercent.subtract(scorePercentNormal); |
| | | AdminAgentInfo adminAgentInfo = JSONObject.parseObject(teamPerkMemberDic.getValue(), AdminAgentInfo.class); |
| | | BigDecimal cashPercent = adminAgentInfo.getCashPercent().multiply(AppContants.PERCENTAGE); |
| | | BigDecimal scorePercent = adminAgentInfo.getScorePercent().multiply(AppContants.PERCENTAGE); |
| | | //极差 |
| | | cashPercent = cashPercent.subtract(cashPercentNormal); |
| | | scorePercent = scorePercent.subtract(scorePercentNormal); |
| | | |
| | | BigDecimal cashAmount = amountTC.multiply(cashPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal cashAmount = amountTC.multiply(cashPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | //如果是H金劵,除以当前价格,得到数量。 |
| | | BigDecimal scoreCnt = amountTC.multiply(scorePercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | scoreCnt = scoreCnt.divide(poolScorePrice, 2 ,BigDecimal.ROUND_DOWN); |
| | | if(cashAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | addWalletInfoAndMoneyFlow(cashAmount, |
| | | teamPerkMemberId, |
| | | "balance", |
| | | MoneyFlowTypeEnum.AGENT_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | //如果是H金劵,除以当前价格,得到数量。 |
| | | BigDecimal scoreCnt = amountTC.multiply(scorePercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | scoreCnt = scoreCnt.divide(poolScorePrice, 2 ,BigDecimal.ROUND_DOWN); |
| | | if(cashAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | addWalletInfoAndMoneyFlow(cashAmount, |
| | | teamPerkMemberId, |
| | | "balance", |
| | | MoneyFlowTypeEnum.AGENT_CASH_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.BALANCE.getValue(), |
| | | orderNo); |
| | | } |
| | | if(scoreCnt.compareTo(BigDecimal.ZERO) > 0){ |
| | | addWalletInfoAndMoneyFlow(scoreCnt, |
| | | teamPerkMemberId, |
| | | "score", |
| | | MoneyFlowTypeEnum.AGENT_SCORE_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.SCORE.getValue(), |
| | | orderNo); |
| | | } |
| | | levelNormal = level; |
| | | cashPercentNormal = adminAgentInfo.getCashPercent().multiply(AppContants.PERCENTAGE); |
| | | scorePercentNormal = adminAgentInfo.getScorePercent().multiply(AppContants.PERCENTAGE); |
| | | } |
| | | if(scoreCnt.compareTo(BigDecimal.ZERO) > 0){ |
| | | addWalletInfoAndMoneyFlow(scoreCnt, |
| | | teamPerkMemberId, |
| | | "score", |
| | | MoneyFlowTypeEnum.AGENT_SCORE_PERK.getValue(), |
| | | memberId, |
| | | FlowTypeEnum.SCORE.getValue(), |
| | | orderNo); |
| | | } |
| | | levelNormal = level; |
| | | cashPercentNormal = adminAgentInfo.getCashPercent().multiply(AppContants.PERCENTAGE); |
| | | scorePercentNormal = adminAgentInfo.getScorePercent().multiply(AppContants.PERCENTAGE); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // for(MallMember levelMember : mallMembers){ |
| | | // String level = levelMember.getLevel(); |
| | | // } |
| | | // /** |
| | | // * 根据等级分组,获取对应的<级别,会员数组>map todo 目前获取到的levelMember是无序的 |
| | | // */ |
| | | // Map<String, List<MallMember>> collect = mallMembers.stream().collect(Collectors.groupingBy(MallMember::getLevel)); |
| | | // Set<String> set = collect.keySet(); // 得到所有key的集合 |
| | | // for (String key : set) { |
| | | // /** |
| | | // * 团队补贴从v1到v6 |
| | | // */ |
| | | // int compareMin = MemberLevelEnum.V1.compareLevel(key, MemberLevelEnum.V1.getType()); |
| | | // int compareMax = MemberLevelEnum.V1.compareLevel(MemberLevelEnum.V6.getType(), key); |
| | | // if(compareMin >= 1 && compareMax >= 1){ |
| | | // List<MallMember> value = collect.get(key); |
| | | // mallMemberTeamPerk.add(value.get(0)); |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 6、入单后,50%入现金池 35%的H金劵入H金劵池,更新价格 |
| | | */ |
| | | DataDictionaryCustom poolCashPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_CASH_PERCENT.getType(), |
| | | PerkEnum.POOL_CASH_PERCENT.getCode()); |
| | | DataDictionaryCustom poolScorePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PERCENT.getType(), |
| | | PerkEnum.POOL_SCORE_PERCENT.getCode()); |
| | | if(ObjectUtil.isNotEmpty(poolCashPercentDic)){ |
| | | BigDecimal poolCashPercent = new BigDecimal(poolCashPercentDic.getValue()).multiply(AppContants.PERCENTAGE); |
| | | //新增现金数量 |
| | | BigDecimal poolCashAdd = amountTC.multiply(poolCashPercent); |
| | | DataDictionaryCustom poolCashDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_CASH.getType(), |
| | | PerkEnum.POOL_CASH.getCode()); |
| | | //当前现金池数量 |
| | | BigDecimal poolCash = new BigDecimal(poolCashDic.getValue()); |
| | | poolCash = poolCash.add(poolCashAdd).setScale(2,BigDecimal.ROUND_DOWN); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode( |
| | | PerkEnum.POOL_CASH.getType(), |
| | | PerkEnum.POOL_CASH.getCode(), |
| | | poolCash.toString() |
| | | ); |
| | | |
| | | DataDictionaryCustom poolScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PRICE.getType(), |
| | | PerkEnum.POOL_SCORE_PRICE.getCode()); |
| | | BigDecimal poolScorePrice = new BigDecimal(poolScorePriceDic.getValue() == null ? "1" : poolScorePriceDic.getValue()); |
| | | BigDecimal poolScorePercent = new BigDecimal(poolScorePercentDic.getValue()).multiply(AppContants.PERCENTAGE); |
| | | //新增H金劵数量 |
| | | BigDecimal poolScoreAdd = amountTC.multiply(poolScorePercent); |
| | | poolScoreAdd = poolScoreAdd.divide(poolScorePrice,2,BigDecimal.ROUND_DOWN); |
| | | DataDictionaryCustom poolScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE.getType(), |
| | | PerkEnum.POOL_SCORE.getCode()); |
| | | //当前H金劵池数量 |
| | | BigDecimal poolScore = new BigDecimal(poolScoreDic.getValue()); |
| | | poolScore = poolScore.add(poolScoreAdd).setScale(2,BigDecimal.ROUND_DOWN); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode( |
| | | PerkEnum.POOL_SCORE.getType(), |
| | | PerkEnum.POOL_SCORE.getCode(), |
| | | poolScore.toString() |
| | | ); |
| | | |
| | | if(poolScore.compareTo(BigDecimal.ZERO) > 0 && poolCash.compareTo(BigDecimal.ZERO) > 0){ |
| | | BigDecimal divide = poolCash.divide(poolScore, 6, BigDecimal.ROUND_DOWN); |
| | | /** |
| | | * 6、入单后,50%入现金池 35%的H金劵入H金劵池,更新价格 |
| | | */ |
| | | DataDictionaryCustom poolCashPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_CASH_PERCENT.getType(), |
| | | PerkEnum.POOL_CASH_PERCENT.getCode()); |
| | | DataDictionaryCustom poolScorePercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PERCENT.getType(), |
| | | PerkEnum.POOL_SCORE_PERCENT.getCode()); |
| | | if(ObjectUtil.isNotEmpty(poolCashPercentDic)){ |
| | | BigDecimal poolCashPercent = new BigDecimal(poolCashPercentDic.getValue()).multiply(AppContants.PERCENTAGE); |
| | | //新增现金数量 |
| | | BigDecimal poolCashAdd = amountTC.multiply(poolCashPercent); |
| | | DataDictionaryCustom poolCashDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_CASH.getType(), |
| | | PerkEnum.POOL_CASH.getCode()); |
| | | //当前现金池数量 |
| | | BigDecimal poolCash = new BigDecimal(poolCashDic.getValue()); |
| | | poolCash = poolCash.add(poolCashAdd).setScale(2,BigDecimal.ROUND_DOWN); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PRICE.getType(), |
| | | PerkEnum.POOL_SCORE_PRICE.getCode(), |
| | | divide.toString() |
| | | PerkEnum.POOL_CASH.getType(), |
| | | PerkEnum.POOL_CASH.getCode(), |
| | | poolCash.toString() |
| | | ); |
| | | |
| | | DataDictionaryCustom poolScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PRICE.getType(), |
| | | PerkEnum.POOL_SCORE_PRICE.getCode()); |
| | | BigDecimal poolScorePrice = new BigDecimal(poolScorePriceDic.getValue() == null ? "1" : poolScorePriceDic.getValue()); |
| | | BigDecimal poolScorePercent = new BigDecimal(poolScorePercentDic.getValue()).multiply(AppContants.PERCENTAGE); |
| | | //新增H金劵数量 |
| | | BigDecimal poolScoreAdd = amountTC.multiply(poolScorePercent); |
| | | poolScoreAdd = poolScoreAdd.divide(poolScorePrice,2,BigDecimal.ROUND_DOWN); |
| | | DataDictionaryCustom poolScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PerkEnum.POOL_SCORE.getType(), |
| | | PerkEnum.POOL_SCORE.getCode()); |
| | | //当前H金劵池数量 |
| | | BigDecimal poolScore = new BigDecimal(poolScoreDic.getValue()); |
| | | poolScore = poolScore.add(poolScoreAdd).setScale(2,BigDecimal.ROUND_DOWN); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode( |
| | | PerkEnum.POOL_SCORE.getType(), |
| | | PerkEnum.POOL_SCORE.getCode(), |
| | | poolScore.toString() |
| | | ); |
| | | |
| | | if(poolScore.compareTo(BigDecimal.ZERO) > 0 && poolCash.compareTo(BigDecimal.ZERO) > 0){ |
| | | BigDecimal divide = poolCash.divide(poolScore, 6, BigDecimal.ROUND_DOWN); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PRICE.getType(), |
| | | PerkEnum.POOL_SCORE_PRICE.getCode(), |
| | | divide.toString() |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public void rankReturnMoney(Long orderId) { |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | BigDecimal amountTCAll = new BigDecimal(900); |
| | | BigDecimal amountTCBasicAmount = new BigDecimal(1000); |
| | | //购买套餐按照1000的基数去补贴,如5000,则补贴5次1000 |
| | | BigDecimal bigDecimal = amountTCAll.divideToIntegralValue(amountTCBasicAmount); |
| | | System.out.println(bigDecimal); |
| | | } |
| | | } |