| | |
| | | import cc.mrbird.febs.mall.service.IMallMemberWithdrawService; |
| | | import cc.mrbird.febs.mall.service.MallMemberService; |
| | | import cc.mrbird.febs.mall.vo.CashOutSettingVo; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | cashOutSettingVo = JSONObject.parseObject(dic.getValue(), CashOutSettingVo.class); |
| | | } |
| | | |
| | | //每日提现额度上限 |
| | | BigDecimal allCashOut = cashOutSettingVo.getAllCashOut(); |
| | | if(withdrawalDto.getAmount().compareTo(allCashOut) > 0){ |
| | | throw new FebsException("限额:"+cashOutSettingVo.getAllCashOut().setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | List<MallMemberWithdraw> mallMemberWithdrawListDone = this.baseMapper.selectListByMemberIdAndDate(memberId,new Date()); |
| | | if(CollUtil.isNotEmpty(mallMemberWithdrawListDone)){ |
| | | BigDecimal amountTCAll = mallMemberWithdrawListDone.stream().map(MallMemberWithdraw::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | amountTCAll = amountTCAll.add(withdrawalDto.getAmount()); |
| | | if (amountTCAll.compareTo(allCashOut) > 0) { |
| | | throw new FebsException("限额:"+cashOutSettingVo.getAllCashOut().setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | } |
| | | |
| | | if (withdrawalDto.getAmount().compareTo(cashOutSettingVo.getMinCashOut()) < 0) { |
| | | throw new FebsException("最小提现金额为"+cashOutSettingVo.getMinCashOut().setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | |
| | | if(withdrawalDto.getAmount().compareTo(wallet.getBalance()) > 0) { |
| | | throw new FebsException("金额不足"); |
| | | } |
| | | BigDecimal commission = wallet.getCommission(); |
| | | if(withdrawalDto.getAmount().compareTo(commission) > 0){ |
| | | throw new FebsException("金额不足"); |
| | | } |
| | | // BigDecimal commission = wallet.getCommission(); |
| | | // if(withdrawalDto.getAmount().compareTo(commission) > 0){ |
| | | // throw new FebsException("金额不足"); |
| | | // } |
| | | |
| | | BigDecimal serviceFee = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01)); |
| | | walletService.reduce(withdrawalDto.getAmount(), memberId, "balance"); |
| | | walletService.reduce(withdrawalDto.getAmount(), memberId, "commission"); |
| | | // walletService.reduce(withdrawalDto.getAmount(), memberId, "commission"); |
| | | String orderNo = MallUtils.getOrderNum("W"); |
| | | |
| | | MallMemberWithdraw withdraw = new MallMemberWithdraw(); |
| | |
| | | FlowTypeEnum.SCORE.getValue()); |
| | | |
| | | mallMemberService.addMoneyFlow(memberId, |
| | | scoreAmount, |
| | | scoreAmount.subtract(amountFee), |
| | | MoneyFlowTypeEnum.SCORE_TO_CASH.getValue(), |
| | | orderNo, |
| | | null, |
| | |
| | | PerkEnum.POOL_CASH.getCode() |
| | | ); |
| | | BigDecimal poolCash = new BigDecimal(poolCashDic.getValue()); |
| | | poolCash = poolCash.add(amountFee); |
| | | //先减去百分之百的提现金额在加上30%的回流金额 |
| | | poolCash = poolCash.subtract(scoreAmount).add(amountFee); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode( |
| | | PerkEnum.POOL_CASH.getType(), |
| | | PerkEnum.POOL_CASH.getCode(), |
| | |
| | | ); |
| | | |
| | | if(poolScore.compareTo(BigDecimal.ZERO) > 0 && poolCash.compareTo(BigDecimal.ZERO) > 0){ |
| | | BigDecimal divide = poolCash.divide(poolScore, 4, BigDecimal.ROUND_DOWN); |
| | | BigDecimal divide = poolCash.divide(poolScore, 8, BigDecimal.ROUND_DOWN); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode( |
| | | PerkEnum.POOL_SCORE_PRICE.getType(), |
| | | PerkEnum.POOL_SCORE_PRICE.getCode(), |