| | |
| | | |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.ScoreFlowTypeEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | | import cc.mrbird.febs.mall.dto.CommissionChangeDto; |
| | | import cc.mrbird.febs.mall.entity.MallMember; |
| | | import cc.mrbird.febs.mall.entity.MallMemberWallet; |
| | |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.math.BigDecimal; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author wzy |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void reduce(BigDecimal amount, Long memberId, String field) { |
| | | public void add(BigDecimal amount, Long memberId, String... field) { |
| | | String[] fields = field.clone(); |
| | | for (String s : fields) { |
| | | add(amount, memberId, s); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int reduce(BigDecimal amount, Long memberId, String field, Map<String, BigDecimal> map) { |
| | | int i = 0; |
| | | boolean flag = true; |
| | | |
| | |
| | | BigDecimal balance = (BigDecimal) declaredField.get(wallet); |
| | | |
| | | if (amount.compareTo(balance) > 0) { |
| | | throw new FebsException("余额不足"); |
| | | if (map == null) { |
| | | return 2; |
| | | } |
| | | |
| | | // 判断 赠送积分,如果剩下赠送积分不等于0且小于amount, 则扣除所有赠送积分 |
| | | if ("score".equals(field)) { |
| | | if (balance.compareTo(BigDecimal.ZERO) == 0) { |
| | | return 2; |
| | | } |
| | | |
| | | amount = balance; |
| | | map.put("amount", amount); |
| | | } else { |
| | | return 2; |
| | | } |
| | | } |
| | | declaredField.set(update, balance.subtract(amount)); |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @Override |
| | | public int reduce(BigDecimal amount, Long memberId, String field) { |
| | | return reduce(amount, memberId, field, null); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | // 佣金转余额 |
| | | if (commissionChange.getType() == 1) { |
| | | type = MoneyFlowTypeEnum.COMMISSION_TO_BALANCE.getValue(); |
| | | type = ScoreFlowTypeEnum.COMMISSION_TO_BALANCE.getValue(); |
| | | flowType = FlowTypeEnum.BALANCE.getValue(); |
| | | this.add(commissionChange.getAmount(), member.getId(), "balance"); |
| | | |
| | | // 佣金转竞猜积分 |
| | | } else if (commissionChange.getType() == 2){ |
| | | type = MoneyFlowTypeEnum.COMMISSION_TO_PRIZESCORE.getValue(); |
| | | type = ScoreFlowTypeEnum.COMMISSION_TO_PRIZE_SCORE.getValue(); |
| | | flowType = FlowTypeEnum.PRIZE_SCORE.getValue(); |
| | | this.add(commissionChange.getAmount(), member.getId(), "prizeScore"); |
| | | } else { |
| | | throw new FebsException("参数错误"); |
| | | } |
| | | |
| | | moneyFlowService.addMoneyFlow(member.getId(), commissionChange.getAmount().negate(), type, null, FlowTypeEnum.COMMISSION.getValue()); |
| | | moneyFlowService.addMoneyFlow(member.getId(), commissionChange.getAmount(), type, null, flowType); |
| | | moneyFlowService.addMoneyFlow( |
| | | member.getId(), |
| | | commissionChange.getAmount().negate(), |
| | | type, |
| | | MallUtils.getOrderNum(), |
| | | FlowTypeEnum.COMMISSION.getValue(), |
| | | String.format(ScoreFlowTypeEnum.getDescByValue(type), commissionChange.getAmount()), |
| | | 2 |
| | | ); |
| | | |
| | | moneyFlowService.addMoneyFlow( |
| | | member.getId(), |
| | | commissionChange.getAmount(), |
| | | type, |
| | | MallUtils.getOrderNum(), |
| | | flowType, |
| | | String.format(ScoreFlowTypeEnum.getDescByValue(type), commissionChange.getAmount()), |
| | | 2 |
| | | ); |
| | | } |
| | | } |