| | |
| | | private final AgentProducer agentProducer; |
| | | private final MallScoreRecordMapper mallScoreRecordMapper; |
| | | private final MallScoreAchieveReleaseMapper mallScoreAchieveReleaseMapper; |
| | | private final MallScoreVoucherMapper mallScoreVoucherMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void scoreRecordReleaseJob() { |
| | | /** |
| | | * 每日按照比例释放记录的百分比到用户的绿色凭证账户 |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void achieveReleaseJob() { |
| | | /** |
| | | * 业绩产生凭证 |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void selaHalfVoucher(String price) { |
| | | /** |
| | | * 获取所有凭证大于0的用户 |
| | | * 当前价格卖出账户的一半凭证 |
| | | */ |
| | | BigDecimal scorePrice = new BigDecimal(price == null ? "0" : price); |
| | | if(scorePrice.compareTo(BigDecimal.ZERO) <= 0){ |
| | | return; |
| | | } |
| | | List<MallMemberWallet> mallMemberWallets = mallMemberWalletMapper.selectList(null); |
| | | if(CollUtil.isNotEmpty(mallMemberWallets)){ |
| | | List<MallMemberWallet> wallets = mallMemberWallets |
| | | .stream() |
| | | .filter(mallMemberWallet -> mallMemberWallet.getVoucherCnt().compareTo(BigDecimal.ZERO) > 0) |
| | | .collect(Collectors.toList()); |
| | | if(CollUtil.isNotEmpty(wallets)){ |
| | | BigDecimal scorePoolCntAdd = BigDecimal.ZERO; |
| | | //绿色积分剩余数量 |
| | | for(MallMemberWallet mallMemberWallet : wallets){ |
| | | //增加账户的凭证金额,减少当前的一半的凭证数量 |
| | | BigDecimal voucherCnt = mallMemberWallet.getVoucherCnt().divide(new BigDecimal(2), 2, BigDecimal.ROUND_DOWN) |
| | | .setScale(2,BigDecimal.ROUND_DOWN); |
| | | BigDecimal voucherAmountAdd = scorePrice.multiply(voucherCnt) |
| | | .setScale(2,BigDecimal.ROUND_DOWN); |
| | | mallMemberWalletMapper.addVorCherAmountAndCntById(voucherAmountAdd,voucherCnt,mallMemberWallet.getId()); |
| | | |
| | | scorePoolCntAdd = scorePoolCntAdd.add(voucherCnt); |
| | | |
| | | DataDictionaryCustom surplusCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | GreenScoreEnum.SURPLUS_CNT.getType(), |
| | | GreenScoreEnum.SURPLUS_CNT.getCode() |
| | | ); |
| | | //增加绿色积分剩余数量 |
| | | BigDecimal surplusCnt = new BigDecimal(surplusCntDic.getValue() == null ? "0" : surplusCntDic.getValue()); |
| | | BigDecimal voucherCntAdd = surplusCnt.add(voucherCnt).setScale(2,BigDecimal.ROUND_DOWN); |
| | | surplusCntDic.setValue(voucherCntAdd.toString()); |
| | | dataDictionaryCustomMapper.updateById(surplusCntDic); |
| | | |
| | | /** |
| | | * 生成一条卖出记录 |
| | | */ |
| | | String voucherNo = MallUtils.getOrderNum("VS"); |
| | | MallScoreVoucher mallScoreVoucher = new MallScoreVoucher(); |
| | | mallScoreVoucher.setVoucherNo(voucherNo); |
| | | mallScoreVoucher.setMemberId(mallMemberWallet.getMemberId()); |
| | | mallScoreVoucher.setVoucherCnt(voucherCnt); |
| | | mallScoreVoucher.setPrice(scorePrice); |
| | | mallScoreVoucher.setVoucherAmount(voucherAmountAdd); |
| | | mallScoreVoucher.setType("S"); |
| | | mallScoreVoucherMapper.insert(mallScoreVoucher); |
| | | |
| | | //产生一条流水记录 |
| | | mallMoneyFlowService.addMoneyFlow( |
| | | mallMemberWallet.getMemberId(), |
| | | voucherAmountAdd, |
| | | MoneyFlowTypeEnum.VOUCHER_SALE.getValue(), |
| | | voucherNo, |
| | | FlowTypeEnum.VOUCHER_AMOUNT.getValue()); |
| | | } |
| | | |
| | | //增加积分凭证池的凭证数量 |
| | | DataDictionaryCustom scorePoolCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | GreenScoreEnum.SCORE_POOL_CNT.getType(), |
| | | GreenScoreEnum.SCORE_POOL_CNT.getCode() |
| | | ); |
| | | //增加绿色积分剩余数量 |
| | | BigDecimal scorePoolCnt = new BigDecimal(scorePoolCntDic.getValue() == null ? "0" : scorePoolCntDic.getValue()); |
| | | scorePoolCnt = scorePoolCnt.add(scorePoolCntAdd); |
| | | scorePoolCntDic.setValue(scorePoolCnt.toString()); |
| | | dataDictionaryCustomMapper.updateById(scorePoolCntDic); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 给用户的增加凭证数据,并且增加流水 |
| | | * @param memberAchieveRelease 释放数量 |