xiaoyong931011
2022-12-21 1fc5510367dcf321ac85e50e31c9dcdaaf5cd09e
src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java
@@ -4,6 +4,7 @@
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.AgentLevelEnum;
import cc.mrbird.febs.common.enumerates.FlowTypeEnum;
import cc.mrbird.febs.common.enumerates.MemberAgentLevelEnum;
import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.LoginUserUtil;
@@ -16,6 +17,8 @@
import cc.mrbird.febs.mall.service.IApiMallMemberWalletService;
import cc.mrbird.febs.mall.service.IMallMoneyFlowService;
import cc.mrbird.febs.mall.vo.*;
import cc.mrbird.febs.pay.model.SinglePayDto;
import cc.mrbird.febs.pay.service.UnipayService;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@@ -58,11 +61,14 @@
    private final IApiMallMemberWalletService iApiMallMemberWalletService;
    private final AppVersionMapper appVersionMapper;
    private final MallMemberWithdrawMapper mallMemberWithdrawMapper;
    private final MallNewsInfoMapper mallNewsInfoMapper;
    private final MallShopApplyMapper mallShopApplyMapper;
    private final IMallMoneyFlowService mallMoneyFlowService;
    private final UnipayService unipayService;
    private final MallMemberBankMapper mallMemberBankMapper;
    @Override
    public IPage<MallMember> getMallMemberList(MallMember mallMember, QueryRequest request) {
@@ -143,41 +149,70 @@
    @Override
    @Transactional
    public FebsResponse chargeAgree(Long id) {
        MallMoneyFlow mallMoneyFlow = mallMoneyFlowMapper.selectById(id);
        if(ObjectUtil.isEmpty(mallMoneyFlow)){
        MallMemberWithdraw mallMemberWithdraw = mallMemberWithdrawMapper.selectById(id);
        if(ObjectUtil.isEmpty(mallMemberWithdraw)){
            return new FebsResponse().fail().message("系统繁忙,请刷新后重试");
        }
        if(1 != mallMoneyFlow.getStatus()){
        if(1 != mallMemberWithdraw.getStatus()){
            return new FebsResponse().fail().message("当前状态不是提现中");
        }
        mallMoneyFlow.setStatus(2);
        mallMoneyFlowMapper.updateById(mallMoneyFlow);
        Long wtihdrawTypeId = mallMemberWithdraw.getWtihdrawTypeId();
        MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(wtihdrawTypeId);
        /**
         * 调用汇聚代付
         */
        SinglePayDto singlePayDto = new SinglePayDto();
        singlePayDto.setMerchantOrderNo(mallMemberWithdraw.getWithdrawNo());
        singlePayDto.setReceiverAccountNoEncBankNo(mallMemberBank.getBankNo());
        singlePayDto.setReceiverAccountNoEncName(mallMemberBank.getName());
        singlePayDto.setReceiverAccountType("201");
        BigDecimal paidAmount = mallMemberWithdraw.getAmount().subtract(mallMemberWithdraw.getAmountFee()).setScale(2, BigDecimal.ROUND_DOWN);
        singlePayDto.setPaidAmount(paidAmount);
        singlePayDto.setCurrency("201");
        singlePayDto.setIsChecked("202");
        singlePayDto.setPaidDesc("用户提现");
        singlePayDto.setPaidUse("202");
        String singlePayRep = unipayService.singlePay(singlePayDto);
        if(!mallMemberWithdraw.getWithdrawNo().equals(singlePayRep)){
            return new FebsResponse().fail().message("提现失败,请稍后查看错误信息一览");
        }
        return new FebsResponse().success();
    }
    @Override
    @Transactional
    public FebsResponse chargeDisagree(Long id) {
        MallMoneyFlow mallMoneyFlow = mallMoneyFlowMapper.selectById(id);
        if(ObjectUtil.isEmpty(mallMoneyFlow)){
        MallMemberWithdraw mallMemberWithdraw = mallMemberWithdrawMapper.selectById(id);
        if(ObjectUtil.isEmpty(mallMemberWithdraw)){
            return new FebsResponse().fail().message("系统繁忙,请刷新后重试");
        }
        if(1 != mallMoneyFlow.getStatus()){
        if(1 != mallMemberWithdraw.getStatus()){
            return new FebsResponse().fail().message("当前状态不是提现中");
        }
        mallMemberWithdraw.setStatus(3);
        mallMemberWithdrawMapper.updateById(mallMemberWithdraw);
        QueryWrapper<MallMoneyFlow> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("order_no",mallMemberWithdraw.getWithdrawNo());
        objectQueryWrapper.eq("type",MoneyFlowTypeEnum.WITHDRAWAL.getValue());
        MallMoneyFlow mallMoneyFlow = mallMoneyFlowMapper.selectOne(objectQueryWrapper);
        mallMoneyFlow.setStatus(3);
        mallMoneyFlowMapper.updateById(mallMoneyFlow);
        //用户钱包增加对应的余额
        iApiMallMemberWalletService.addBalance(mallMoneyFlow.getAmount().negate(),mallMoneyFlow.getMemberId());
        //用户佣金增加对应的余额
        iApiMallMemberWalletService.add(mallMemberWithdraw.getAmount(),mallMemberWithdraw.getMemberId(),"commission");
        return new FebsResponse().success();
    }
    @Override
    public AdminMallMemberPaymentVo getMallMemberPaymentInfoByFlowId(long id) {
        AdminMallMemberPaymentVo adminMallMemberPaymentVo = new AdminMallMemberPaymentVo();
        MallMoneyFlow mallMoneyFlow = mallMoneyFlowMapper.selectById(id);
        AdminMallMemberPaymentVo adminMallMemberPaymentVoa = mallMemberPaymentMapper.getMallMemberPaymentInfoByMemberId(mallMoneyFlow.getMemberId());
        MallMemberWithdraw mallMemberWithdraw = mallMemberWithdrawMapper.selectById(id);
        AdminMallMemberPaymentVo adminMallMemberPaymentVoa = mallMemberPaymentMapper.getMallMemberPaymentInfoByMemberId(mallMemberWithdraw.getMemberId());
        if(ObjectUtil.isNotEmpty(adminMallMemberPaymentVoa)){
            adminMallMemberPaymentVo = adminMallMemberPaymentVoa;
        }
@@ -358,7 +393,11 @@
        }
        if (isReduce) {
            iApiMallMemberWalletService.reduce(mallSystemPayDto.getAddBalance().negate(), mallSystemPayDto.getId(), filedType);
            int i = iApiMallMemberWalletService.reduce(mallSystemPayDto.getAddBalance().negate(), mallSystemPayDto.getId(), filedType);
            if (i == 2) {
                throw new FebsException("剩余数量不足");
            }
        } else {
            iApiMallMemberWalletService.add(mallSystemPayDto.getAddBalance(), mallSystemPayDto.getId(), filedType);
        }
@@ -379,7 +418,10 @@
        if(ObjectUtil.isEmpty(mallMember)){
            return new FebsResponse().fail().message("系统繁忙,请刷新页面重试");
        }
        mallMember.setLevel(agentLevelSetUpdateDto.getLevelCode());
        String levelCode = agentLevelSetUpdateDto.getLevelCode();
        String nameByCode = MemberAgentLevelEnum.AGENT.getNameByCode(levelCode);
        mallMember.setLevel(nameByCode);
        mallMember.setLevelStatus(1);
        mallMemberMapper.updateById(mallMember);
        return new FebsResponse().success();
    }
@@ -448,6 +490,10 @@
        if (!MallShopApply.APPLY_ING.equals(apply.getStatus())) {
            throw new FebsException("申请已审核, 请勿重复操作");
        }
        MallMember member = mallMemberMapper.selectById(apply.getMemberId());
        member.setStoreMaster(1);
        mallMemberMapper.updateById(member);
        apply.setStatus(MallShopApply.APPLY_AGREE);
        mallShopApplyMapper.updateById(apply);
@@ -551,6 +597,32 @@
        }
    }
    @Override
    public void updateShopApply(MallShopApply apply) {
        MallShopApply mallShopApply = mallShopApplyMapper.selectById(apply.getId());
        mallShopApply.setName(apply.getName());
        mallShopApply.setPhone(apply.getPhone());
        mallShopApply.setIdcard(apply.getIdcard());
        mallShopApply.setBusinessLicense(apply.getBusinessLicense());
        mallShopApply.setSaleArea(apply.getSaleArea());
        mallShopApply.setShopName(apply.getShopName());
        mallShopApplyMapper.updateById(mallShopApply);
    }
    @Override
    public AdminMallMemberPaymentVo getMallBankInfoById(long id) {
        MallMemberWithdraw mallMemberWithdraw = mallMemberWithdrawMapper.selectById(id);
        Long wtihdrawTypeId = mallMemberWithdraw.getWtihdrawTypeId();
        MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(wtihdrawTypeId);
        AdminMallMemberPaymentVo adminMallMemberPaymentVo = new AdminMallMemberPaymentVo();
        if(ObjectUtil.isNotEmpty(mallMemberBank)){
            adminMallMemberPaymentVo.setBankNo(mallMemberBank.getBankNo());
            adminMallMemberPaymentVo.setBankName(mallMemberBank.getName());
        }
        return adminMallMemberPaymentVo;
    }
    private String refererIds(String parentId) {
        boolean flag = false;
        if (StrUtil.isBlank(parentId)) {