1 files added
11 files modified
New file |
| | |
| | | package cc.mrbird.febs.common.enumerates; |
| | | |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @date 2022-04-28 |
| | | **/ |
| | | @Getter |
| | | public enum FlowTypeEnum { |
| | | |
| | | |
| | | /** |
| | | * 余额 |
| | | */ |
| | | BALANCE(1), |
| | | /** |
| | | * 积分 |
| | | */ |
| | | SCORE(2), |
| | | /** |
| | | * 竞猜积分 |
| | | */ |
| | | PRIZE_SCORE(3), |
| | | /** |
| | | * 佣金 |
| | | */ |
| | | COMMISSION(4); |
| | | |
| | | private final int value; |
| | | |
| | | FlowTypeEnum(int value) { |
| | | this.value = value; |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | private Integer isHot; |
| | | |
| | | private BigDecimal staticMultiple; |
| | | |
| | | private Integer isNormal; |
| | | |
| | | @TableField(exist = false) |
| | | private List<MallGoodsStyle> styles; |
| | | |
| | |
| | | * 抽奖积分 |
| | | */ |
| | | private BigDecimal prizeScore; |
| | | |
| | | /** |
| | | * 佣金 |
| | | */ |
| | | private BigDecimal commission; |
| | | } |
| | |
| | | public static final Integer IS_RETURN_Y = 1; |
| | | |
| | | /** |
| | | * 流水类型 1-余额 2-赠送积分 3-竞猜积分 |
| | | * 流水类型 1-余额 2-赠送积分 3-竞猜积分 4-佣金 |
| | | */ |
| | | private Integer flowType; |
| | | } |
| | |
| | | |
| | | int updateBalanceWithVersion(@Param("record") MallMemberWallet wallet); |
| | | |
| | | int updateCommissionWithVersion(@Param("record") MallMemberWallet wallet); |
| | | |
| | | void updateBalanceWithId(@Param("record")MallMemberWallet mallMemberWallet); |
| | | } |
| | |
| | | |
| | | FebsResponse moneyFlows(MoneyFlowDto moneyFlowDto); |
| | | |
| | | void addMoneyFlow(Long memberId, BigDecimal amount, Integer type, String orderNo, String description, String remark, Long rtMemberId, Integer status); |
| | | void addMoneyFlow(Long memberId, BigDecimal amount, Integer type, String orderNo, String description, String remark, Long rtMemberId, Integer status, Integer flowType); |
| | | |
| | | void transfer(TransferDto transferDto); |
| | | |
| | |
| | | void addBalance(BigDecimal amount, Long member); |
| | | |
| | | void reduceBalance(BigDecimal amount, Long memberId); |
| | | |
| | | void addCommission(BigDecimal amount, Long member); |
| | | |
| | | void reduceCommission(BigDecimal amount, Long member); |
| | | } |
| | |
| | | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.*; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void addMoneyFlow(Long memberId, BigDecimal amount, Integer type, String orderNo, String description, String remark, Long rtMemberId, Integer status) { |
| | | public void addMoneyFlow(Long memberId, BigDecimal amount, Integer type, String orderNo, String description, String remark, Long rtMemberId, Integer status, Integer flowType) { |
| | | MallMoneyFlow flow = new MallMoneyFlow(); |
| | | flow.setMemberId(memberId); |
| | | flow.setAmount(amount); |
| | |
| | | flow.setRemark(remark); |
| | | flow.setRtMemberId(rtMemberId); |
| | | flow.setStatus(status); |
| | | flow.setFlowType(flowType); |
| | | mallMoneyFlowMapper.insert(flow); |
| | | } |
| | | |
| | |
| | | |
| | | walletService.reduceBalance(transferDto.getAmount(), memberId); |
| | | String orderNo = MallUtils.getOrderNum("T"); |
| | | this.addMoneyFlow(memberId, transferDto.getAmount().negate(), MoneyFlowTypeEnum.TRANSFER.getValue(), orderNo, null, null, mallMember.getId(), null); |
| | | this.addMoneyFlow(memberId, transferDto.getAmount().negate(), MoneyFlowTypeEnum.TRANSFER.getValue(), orderNo, null, null, mallMember.getId(), null, FlowTypeEnum.BALANCE.getValue()); |
| | | |
| | | walletService.addBalance(transferDto.getAmount(), mallMember.getId()); |
| | | this.addMoneyFlow(mallMember.getId(), transferDto.getAmount(), MoneyFlowTypeEnum.TRANSFER.getValue(), orderNo, null, null, memberId, null); |
| | | this.addMoneyFlow(mallMember.getId(), transferDto.getAmount(), MoneyFlowTypeEnum.TRANSFER.getValue(), orderNo, null, null, memberId, null, FlowTypeEnum.BALANCE.getValue()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | if (profit != null) { |
| | | // 可提现 |
| | | BigDecimal canMoney = wallet.getBalance().subtract(profit); |
| | | BigDecimal canMoney = wallet.getCommission().subtract(profit); |
| | | |
| | | if(withdrawalDto.getAmount().compareTo(canMoney) > 0) { |
| | | throw new FebsException("提现金额不足"); |
| | | } |
| | | } |
| | | |
| | | walletService.reduceBalance(withdrawalDto.getAmount(), memberId); |
| | | walletService.reduceCommission(withdrawalDto.getAmount(), memberId); |
| | | String orderNo = MallUtils.getOrderNum("W"); |
| | | this.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1); |
| | | this.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.COMMISSION.getValue()); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void addCommission(BigDecimal amount, Long memberId) { |
| | | int i = 0; |
| | | boolean flag = true; |
| | | |
| | | while (flag) { |
| | | i++; |
| | | MallMemberWallet wallet = this.baseMapper.selectWalletByMemberId(memberId); |
| | | wallet.setCommission(wallet.getCommission().add(amount)); |
| | | |
| | | int result = this.baseMapper.updateCommissionWithVersion(wallet); |
| | | if (result > 0) { |
| | | flag = false; |
| | | } else { |
| | | if (i > 2) { |
| | | throw new FebsException("余额增加失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void reduceCommission(BigDecimal amount, Long memberId) { |
| | | int i = 0; |
| | | boolean flag = true; |
| | | |
| | | while (flag) { |
| | | i++; |
| | | MallMemberWallet wallet = this.baseMapper.selectWalletByMemberId(memberId); |
| | | if (amount.compareTo(wallet.getCommission()) > 0) { |
| | | throw new FebsException("佣金不足"); |
| | | } |
| | | |
| | | wallet.setCommission(wallet.getCommission().subtract(amount)); |
| | | |
| | | int result = this.baseMapper.updateCommissionWithVersion(wallet); |
| | | if (result > 0) { |
| | | flag = false; |
| | | } else { |
| | | if (i > 2) { |
| | | throw new FebsException("佣金支付失败"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.OrderRefundStatusEnum; |
| | | import cc.mrbird.febs.common.enumerates.OrderStatusEnum; |
| | | import cc.mrbird.febs.common.enumerates.*; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.AppContants; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | |
| | | payResultStr = balancePay(orderInfo, payOrderDto.getTradePwd()); |
| | | |
| | | orderInfo.setPayOrderNo(orderInfo.getOrderNo()); |
| | | orderInfo.setPayMethod("积分支付"); |
| | | orderInfo.setPayMethod("余额支付"); |
| | | orderInfo.setStatus(OrderStatusEnum.WAIT_SHIPPING.getValue()); |
| | | orderInfo.setPayTime(new Date()); |
| | | orderInfo.setPayResult("1"); |
| | | |
| | | MallMember mallMember = memberMapper.selectById(member.getId()); |
| | | if (AgentLevelEnum.ZERO_LEVEL.name().equals(mallMember.getLevel())) { |
| | | mallMember.setLevel(AgentLevelEnum.FIRST_LEVEL.name()); |
| | | memberMapper.updateById(mallMember); |
| | | // MallMember mallMember = memberMapper.selectById(member.getId()); |
| | | // if (AgentLevelEnum.ZERO_LEVEL.name().equals(mallMember.getLevel())) { |
| | | // mallMember.setLevel(AgentLevelEnum.FIRST_LEVEL.name()); |
| | | // memberMapper.updateById(mallMember); |
| | | // } |
| | | |
| | | // 静态倍数 |
| | | List<MallOrderItem> orderItems = this.baseMapper.getMallOrderItemByOrderId(orderInfo.getId()); |
| | | if (CollUtil.isNotEmpty(orderItems)) { |
| | | for (MallOrderItem orderItem : orderItems) { |
| | | MallGoods mallGoods = mallGoodsMapper.selectById(orderItem.getGoodsId()); |
| | | |
| | | MallGoodsSku sku = mallGoodsSkuMapper.selectById(orderItem.getSkuId()); |
| | | BigDecimal score = sku.getOriginalPrice().multiply(mallGoods.getStaticMultiple()); |
| | | memberService.addMoneyFlow(member.getId(), score, MoneyFlowTypeEnum.STATIC_BONUS.getValue(), orderInfo.getOrderNo(), null, null, null, null, FlowTypeEnum.SCORE.getValue()); |
| | | } |
| | | } |
| | | |
| | | memberService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), null, null, null, null); |
| | | memberService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), null, null, null, null, FlowTypeEnum.BALANCE.getValue()); |
| | | // agentProducer.sendAutoLevelUpMsg(member.getId()); |
| | | // agentProducer.sendReturnMoneyMsg(orderInfo.getId()); |
| | | |
| | | agentProducer.sendAutoLevelUpMsg(member.getId()); |
| | | agentProducer.sendReturnMoneyMsg(orderInfo.getId()); |
| | | default: |
| | | |
| | | } |
| | |
| | | package cc.mrbird.febs.pay.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.enumerates.AgentLevelEnum; |
| | | import cc.mrbird.febs.common.enumerates.FlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum; |
| | | import cc.mrbird.febs.common.enumerates.OrderStatusEnum; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | |
| | | agentProducer.sendReturnMoneyMsg(orderInfo.getId()); |
| | | agentProducer.sendAutoLevelUpMsg(orderInfo.getMemberId()); |
| | | |
| | | memberService.addMoneyFlow(orderInfo.getMemberId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), null, null, null, null); |
| | | memberService.addMoneyFlow(orderInfo.getMemberId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), null, null, null, null, FlowTypeEnum.BALANCE.getValue()); |
| | | } |
| | | } |
| | |
| | | where id=#{record.id} and revision=#{record.revision} |
| | | </update> |
| | | |
| | | <update id="updateCommissionWithVersion"> |
| | | update mall_member_wallet |
| | | set revision = revision + 1, |
| | | commission = #{record.commission} |
| | | where id=#{record.id} and revision=#{record.revision} |
| | | </update> |
| | | |
| | | <update id="updateBalanceWithId"> |
| | | update mall_member_wallet |
| | | set revision = revision + 1, |