xiaoyong931011
2022-12-22 2abd05a4ab94edfacb73edc59866a9057be6fca8
src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java
@@ -2,9 +2,7 @@
import cc.mrbird.febs.common.entity.FebsResponse;
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.MoneyFlowTypeEnum;
import cc.mrbird.febs.common.enumerates.*;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.LoginUserUtil;
import cc.mrbird.febs.common.utils.MallUtils;
@@ -16,6 +14,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 +58,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) {
@@ -96,6 +99,24 @@
    }
    @Override
    public void changeIdentity(Integer type, Long id, Integer value) {
        MallMember mallMember = mallMemberMapper.selectById(id);
        if(mallMember == null) {
            throw new FebsException("参数错误");
        }
        if (type == 1) {
            mallMember.setDirector(value);
        } else if (type == 2){
            mallMember.setStoreMaster(value);
        } else {
            throw new FebsException("参数错误");
        }
        this.baseMapper.updateById(mallMember);
    }
    @Override
    public MallMemberVo getMallMemberInfoById(long id) {
        MallMemberVo mallMemberVo = mallMemberMapper.getMallMemberInfoById(id);
        return mallMemberVo;
@@ -125,41 +146,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);
        if(ObjectUtil.isEmpty(mallMemberBank)){
            return new FebsResponse().fail().message("提现地址不存在");
        }
        //更新提现记录状态为成功
        mallMemberWithdrawMapper.updateStatusById(2,mallMemberWithdraw.getId());
        //更新提现流水记录为成功
        String withdrawNo = mallMemberWithdraw.getWithdrawNo();
        MallMoneyFlow withdrawMoneyFlow = mallMoneyFlowMapper.selectOneByMemberIdAndOrderNoAndTypeAndStatusAndIsReturn(
                mallMemberWithdraw.getMemberId(),
                withdrawNo,
                MallMoneyFlowTypeEnum.WITHDRAW.getCode(),
                MallMoneyFlow.STATUS_ING,
                MallMoneyFlow.IS_RETURN_Y
        );
        withdrawMoneyFlow.setStatus(MallMoneyFlow.STATUS_SUCCESS);
        mallMoneyFlowMapper.updateById(withdrawMoneyFlow);
        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("当前状态不是提现中");
        }
        mallMoneyFlow.setStatus(3);
        mallMoneyFlowMapper.updateById(mallMoneyFlow);
        //更新提现记录状态为失败
        mallMemberWithdrawMapper.updateStatusById(3,mallMemberWithdraw.getId());
        //更新提现流水记录为成功
        String withdrawNo = mallMemberWithdraw.getWithdrawNo();
        MallMoneyFlow withdrawMoneyFlow = mallMoneyFlowMapper.selectOneByMemberIdAndOrderNoAndTypeAndStatusAndIsReturn(
                mallMemberWithdraw.getMemberId(),
                withdrawNo,
                MallMoneyFlowTypeEnum.WITHDRAW.getCode(),
                MallMoneyFlow.STATUS_ING,
                MallMoneyFlow.IS_RETURN_Y
        );
        withdrawMoneyFlow.setStatus(MallMoneyFlow.STATUS_FAIL);
        mallMoneyFlowMapper.updateById(withdrawMoneyFlow);
        //用户钱包增加对应的余额
        iApiMallMemberWalletService.addBalance(mallMoneyFlow.getAmount().negate(),mallMoneyFlow.getMemberId());
        //用户余额增加对应的余额
        iApiMallMemberWalletService.addBalance(mallMemberWithdraw.getAmount(),mallMemberWithdraw.getMemberId());
        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;
        }
@@ -322,8 +372,9 @@
        }
        BigDecimal bigDecimal = mallSystemPayDto.getAddBalance();
        boolean isReduce = false;
        if(bigDecimal.compareTo(BigDecimal.ZERO) <= 0){
            return new FebsResponse().fail().message("拨付数目需要大于0");
            isReduce = true;
        }
        Integer type = mallSystemPayDto.getType();
@@ -338,14 +389,41 @@
            throw new FebsException("参数错误");
        }
        iApiMallMemberWalletService.add(mallSystemPayDto.getAddBalance(), mallSystemPayDto.getId(), filedType);
        mallMoneyFlowService.addMoneyFlow(memberId, bigDecimal, MoneyFlowTypeEnum.SYSTEM.getValue(), null, type);
        if (isReduce) {
            int i = iApiMallMemberWalletService.reduce(mallSystemPayDto.getAddBalance().negate(), mallSystemPayDto.getId(), filedType);
            if (i == 2) {
                throw new FebsException("剩余数量不足");
            }
        } else {
            iApiMallMemberWalletService.add(mallSystemPayDto.getAddBalance(), mallSystemPayDto.getId(), filedType);
        }
        mallMoneyFlowService.addMoneyFlow(
                memberId,
                null,
                bigDecimal,
                MallMoneyFlowTypeEnum.SYSTEM_CHARGE.getCode(),
                MallMoneyFlow.STATUS_SUCCESS,
                MallMoneyFlow.IS_RETURN_Y,
                memberId,
                FlowTypeEnum.BALANCE.getValue(),
                MallMoneyFlowTypeEnum.SYSTEM_CHARGE.getName()
        );
        return new FebsResponse().success();
    }
    @Override
    public AdminAgentLevelSetInfoVo getAgentLevelSetInfoByMemberId(long id) {
        AdminAgentLevelSetInfoVo adminAgentLevelSetInfoVo = mallMemberMapper.getAgentLevelSetInfoByMemberId(id);
        AdminAgentLevelSetInfoVo adminAgentLevelSetInfoVo = new AdminAgentLevelSetInfoVo();
        AdminAgentLevelSetInfoVo adminAgentLevelSetInfo = mallMemberMapper.getAgentLevelSetInfoByMemberId(id);
        if(ObjectUtil.isEmpty(adminAgentLevelSetInfo)){
            adminAgentLevelSetInfoVo.setId(id);
            adminAgentLevelSetInfoVo.setLevelCode(MemberAgentLevelEnum.AGENT.getCodeByName(MemberAgentLevelEnum.AGENT.getName()));
        }else{
            adminAgentLevelSetInfoVo.setId(id);
            adminAgentLevelSetInfoVo.setLevelCode(MemberAgentLevelEnum.AGENT.getCodeByName(adminAgentLevelSetInfo.getLevelCode()));
        }
        return adminAgentLevelSetInfoVo;
    }
@@ -356,8 +434,10 @@
        if(ObjectUtil.isEmpty(mallMember)){
            return new FebsResponse().fail().message("系统繁忙,请刷新页面重试");
        }
        mallMember.setLevel(agentLevelSetUpdateDto.getLevelCode());
        mallMemberMapper.updateById(mallMember);
        String levelCode = agentLevelSetUpdateDto.getLevelCode();
        String nameByCode = MemberAgentLevelEnum.AGENT.getNameByCode(levelCode);
        mallMemberMapper.updateLevelStatusById(1,memberId);
        mallMemberMapper.updateLevelById(nameByCode,memberId);
        return new FebsResponse().success();
    }
@@ -425,6 +505,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);
@@ -528,6 +612,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)) {