fix
wzy
2022-05-08 534922c09af529424847b8d284412abcc9dea353
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
@@ -13,10 +13,7 @@
import cc.mrbird.febs.mall.service.IApiMallMemberService;
import cc.mrbird.febs.mall.service.IApiMallMemberWalletService;
import cc.mrbird.febs.mall.service.ICommonService;
import cc.mrbird.febs.mall.vo.MallMemberVo;
import cc.mrbird.febs.mall.vo.MoneyFlowVo;
import cc.mrbird.febs.mall.vo.RankListVo;
import cc.mrbird.febs.mall.vo.TeamListVo;
import cc.mrbird.febs.mall.vo.*;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -58,6 +55,7 @@
    private final IApiMallMemberWalletService walletService;
    private final MallMemberPaymentMapper mallMemberPaymentMapper;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    @Value("${spring.profiles.active}")
    private String active;
@@ -315,8 +313,19 @@
        own.setCnt(this.baseMapper.selectOwnCntByInviteId(mallMember.getInviteId()));
        own.setOrderCnt(this.baseMapper.selectOwnOrderCntByInviteId(mallMember.getInviteId()));
        own.setId(mallMember.getId());
        list.add(0, own);
        return new FebsResponse().success().data(list);
//        list.add(0, own);
        MyTeamVo myTeamVo = new MyTeamVo();
        myTeamVo.setTeam(list);
        myTeamVo.setMyAchieve(BigDecimal.valueOf(100));
        myTeamVo.setMyTeamAchieve(BigDecimal.valueOf(100));
        myTeamVo.setMyTeamCnt(100);
        return new FebsResponse().success().data(myTeamVo);
    }
    @Override
    public MyTeamVo teamListForMine(TeamListDto teamListDto) {
        return null;
    }
    @Override
@@ -372,43 +381,6 @@
        walletService.addBalance(transferDto.getAmount(), mallMember.getId());
        this.addMoneyFlow(mallMember.getId(), transferDto.getAmount(), MoneyFlowTypeEnum.TRANSFER.getValue(), orderNo, null, null, memberId, null, FlowTypeEnum.BALANCE.getValue());
    }
    @Override
    public void withdrawal(WithdrawalDto withdrawalDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = this.baseMapper.selectById(memberId);
        if (StrUtil.isBlank(mallMember.getTradePassword())) {
            throw new FebsException("未设置支付密码");
        }
        if (!mallMember.getTradePassword().equals(SecureUtil.md5(withdrawalDto.getTradePwd()))) {
            throw new FebsException("支付密码错误");
        }
        if (withdrawalDto.getAmount().compareTo(BigDecimal.valueOf(100)) < 0) {
            throw new FebsException("最小提现金额为100");
        }
//        MallMemberPayment payment = mallMemberPaymentMapper.selectByMemberId(memberId);
//        if (payment == null) {
//            throw new FebsException("未设置收款方式");
//        }
        BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId);
        MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
        if (profit != null) {
            // 可提现
            BigDecimal canMoney = wallet.getCommission().subtract(profit);
            if(withdrawalDto.getAmount().compareTo(canMoney) > 0) {
                throw new FebsException("提现金额不足");
            }
        }
        walletService.reduceCommission(withdrawalDto.getAmount(), memberId);
        String orderNo = MallUtils.getOrderNum("W");
        this.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.COMMISSION.getValue());
    }
    @Override
@@ -476,4 +448,31 @@
    public MallMember findMemberInfoByAccount(String phone) {
        return this.baseMapper.selectInfoByAccount(phone);
    }
    @Override
    public MyCommissionVo myCommission() {
        Long id = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = this.baseMapper.selectById(id);
        MyCommissionVo commissionVo = MallMemberConversion.INSTANCE.entityToCommissionVo(mallMember);
        MallMember referMember = this.baseMapper.selectInfoByInviteId(mallMember.getReferrerId());
        if (referMember != null) {
            commissionVo.setReferrerName(referMember.getName());
            commissionVo.setAvatar(referMember.getAvatar());
        }
        DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.AGENT_LEVEL, mallMember.getLevel());
        if (dic != null) {
            commissionVo.setLevelName(dic.getDescription());
        }
        MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(id);
        commissionVo.setCommission(wallet.getCommission());
        commissionVo.setToday(mallMoneyFlowMapper.selectCommissionIncome(1, new Date(), id));
        commissionVo.setMonth(mallMoneyFlowMapper.selectCommissionIncome(2, new Date(), id));
        commissionVo.setTotal(mallMoneyFlowMapper.selectCommissionIncome(null, null, id));
        commissionVo.setWaitCommission(BigDecimal.ZERO);
        return commissionVo;
    }
}