package com.hzs.member.account.provider;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.core.constant.msg.ConfigMsgConstants;
import com.hzs.common.core.domain.R;
import com.hzs.common.core.enums.*;
import com.hzs.common.core.utils.StringUtils;
import com.hzs.common.domain.member.business.SignOnlineInfoVo;
import com.hzs.common.domain.member.detail.CuMemberAchieveLog;
import com.hzs.common.domain.member.detail.CuMemberServiceLog;
import com.hzs.common.domain.member.detail.CuMemberServiceLogExt;
import com.hzs.common.domain.member.empty.CuMemberEmpty;
import com.hzs.common.domain.member.empty.CuMemberEmptyLog;
import com.hzs.common.domain.system.base.BdCountry;
import com.hzs.common.domain.system.config.BdAwards;
import com.hzs.common.core.utils.TransactionUtils;
import com.hzs.member.account.service.ICuMemberRechargeService;
import com.hzs.member.account.service.ICuMemberWithdrawService;
import com.hzs.member.base.service.ICuMemberAchieveLogService;
import com.hzs.member.base.service.ICuMemberService;
import com.hzs.member.detail.service.ICuMemberServiceLogService;
import com.hzs.member.empty.service.ICuMemberEmptyLogService;
import com.hzs.member.empty.service.ICuMemberEmptyService;
import com.hzs.member.empty.service.IMemberEmptyService;
import com.hzs.member.handlebusiness.ICuHandleBusinessServiceApi;
import com.hzs.member.handlebusiness.dto.AnalysisBusinessAppealParam;
import com.hzs.member.handlebusiness.dto.MemberEmptyDTO;
import com.hzs.member.handlebusiness.service.ICuHandleBusinessService;
import com.hzs.member.store.service.ICuStoreService;
import com.hzs.sale.order.ISaOrderServiceApi;
import com.hzs.system.base.ICountryServiceApi;
import com.hzs.system.config.IAwardsServiceApi;
import com.hzs.system.config.IGradeServiceApi;
import com.hzs.system.config.dto.GradeDTO;
import com.hzs.system.sys.dto.ApprovalBusinessResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 会员业务处理
 */
@Slf4j
@DubboService
public class ICuHandleBusinessServiceProvider implements ICuHandleBusinessServiceApi {

    @Autowired
    private ICuMemberServiceLogService memberServiceLogService;
    @Autowired
    private ICuHandleBusinessService handleBusinessService;
    @Autowired
    private ICuMemberService cuMemberService;
    @Autowired
    private ICuMemberServiceLogService iCuMemberServiceLogService;
    @Autowired
    private IMemberEmptyService iMemberEmptyService;
    @Autowired
    private ICuMemberEmptyService iCuMemberEmptyService;
    @Autowired
    private ICuMemberEmptyLogService iCuMemberEmptyLogService;
    @Autowired
    private ICuMemberAchieveLogService iCuMemberAchieveLogService;

    @DubboReference
    IGradeServiceApi gradeServiceApi;
    @DubboReference
    IAwardsServiceApi awardsServiceApi;
    @DubboReference
    ICountryServiceApi countryServiceApi;
    @DubboReference
    ISaOrderServiceApi orderServiceApi;

    @Autowired
    ICuMemberRechargeService cuMemberRechargeService;
    @Autowired
    ICuMemberWithdrawService cuMemberWithdrawService;
    @Autowired
    ICuMemberAchieveLogService cuMemberAchieveLogService;
    @Autowired
    ICuStoreService iCuStoreService;

    @Override
    public R analysisBusinessAppeal(AnalysisBusinessAppealParam analysisBusinessAppealParam) {
        // 国家
        Integer pkCountry = analysisBusinessAppealParam.getPkCountry();

        if (analysisBusinessAppealParam.getEditType().equals(EApprovalBusiness.EMPTY_ORDER.getValue())) {
            // 空单注册处理
            return R.ok(this.handMemberEmpty(analysisBusinessAppealParam, pkCountry));
        }

        List<SignOnlineInfoVo> resultList = new ArrayList<>();

        CuMemberServiceLog cuMemberServiceLog = new CuMemberServiceLog();
        if (StringUtils.isNotBlank(analysisBusinessAppealParam.getOrderNumber())) {
            cuMemberServiceLog.setOrderNumber(analysisBusinessAppealParam.getOrderNumber());
        }
        if (StringUtils.isNotBlank(analysisBusinessAppealParam.getBusinessNo())) {
            cuMemberServiceLog.setBusinessNo(analysisBusinessAppealParam.getBusinessNo());
        }
        cuMemberServiceLog.setEditType(analysisBusinessAppealParam.getEditType());
        List<CuMemberServiceLogExt> list = memberServiceLogService.selectByServiceLogList(cuMemberServiceLog);

        for (CuMemberServiceLogExt memberServiceLog : list) {
            // 变更前
            String oldValue = memberServiceLog.getOldValue();
            // 变更后
            String newValue = memberServiceLog.getNewValue();
            if (memberServiceLog.getEditType() == EApprovalBusiness.CU_MEMBER_PLACE_PARENT.getValue()) {
                boolean isJson = JSONUtil.isJson(oldValue);
                String oldJson = "";
                String newJson = "";
                if (isJson) {
                    cn.hutool.json.JSONObject oldJsonObj = JSONUtil.parseObj(oldValue);
                    String placeMemberCode = oldJsonObj.getStr("placeMemberCode");
                    oldJson = placeMemberCode;
                }
                boolean isNewJson = JSONUtil.isJson(newValue);
                Integer placeDeptStr = null;
                if (isNewJson) {
                    cn.hutool.json.JSONObject newJsonObj = JSONUtil.parseObj(newValue);
                    String placeMemberCode = newJsonObj.getStr("placeMemberCode");
                    Integer placeDept = newJsonObj.getInt("placeDept");
                    placeDeptStr = placeDept;
                    newJson = placeMemberCode;
                }
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), oldJson, newJson, memberServiceLog.getEditType());
                signOnlineInfoVo.setEditNewPlaceDept(placeDeptStr);
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.CHANGE_NAME.getValue() ||
                    memberServiceLog.getEditType() == EApprovalBusiness.CHANGE_PHONE.getValue() ||
                    memberServiceLog.getEditType() == EApprovalBusiness.CU_MEMBER_PARENT.getValue() ||
                    memberServiceLog.getEditType() == EApprovalBusiness.ORDER_CHANGE_ADDRESS.getValue() ||
                    memberServiceLog.getEditType() == EApprovalBusiness.CHANGE_MEMBER_CODE.getValue() ||
                    memberServiceLog.getEditType() == EApprovalBusiness.RESET_EMAIL.getValue()
            ) {
                // 修改姓名 手机  直推 安置  登录密码 支付密码 修改会员编号
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), oldValue, newValue, memberServiceLog.getEditType());
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.CHANGE_REGISTER_GRADE.getValue() ||
                    memberServiceLog.getEditType() == EApprovalBusiness.CHANGE_SETTLEMENT_GRADE.getValue()
            ) {
                // 修改等级
                String oldLabel = null;
                if (StringUtils.isNotBlank(oldValue)) {
                    R<GradeDTO> gradeDTOR = gradeServiceApi.queryGradeConfigByCondition(pkCountry, Integer.parseInt(oldValue));
                    oldLabel = gradeDTOR.getData().getGradeName();
                }
                String newLabel = null;
                if (StringUtils.isNotBlank(newValue)) {
                    R<GradeDTO> gradeDTOR = gradeServiceApi.queryGradeConfigByCondition(pkCountry, Integer.parseInt(newValue));
                    newLabel = gradeDTOR.getData().getGradeName();
                }
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), oldLabel, newLabel, memberServiceLog.getEditType());
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.RESET_BANK.getValue()) {
                // 重置银行卡
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), null, "-", memberServiceLog.getEditType());
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.CHANGE_AWARDS.getValue()
            ) {
                // 修改真实奖衔
                String oldLabel = null;
                String newLabel = null;

                // 奖衔配置列表
                R<List<BdAwards>> awardsList = awardsServiceApi.queryAwards(analysisBusinessAppealParam.getPkCountry());
                for (BdAwards data : awardsList.getData()) {
                    if (data.getPkId() == Integer.parseInt(oldValue)) {
                        oldLabel = data.getAwardsName();
                    }
                    if (data.getPkId() == Integer.parseInt(newValue)) {
                        newLabel = data.getAwardsName();
                    }
                }
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), oldLabel, newLabel, memberServiceLog.getEditType());
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.RESET_LOGIN_PASSWORD.getValue()) {
                // 重置会员密码
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), "-", "-", memberServiceLog.getEditType());
                // 重置密码 对应枚举 EResetPassword
                //     signOnlineInfoVo.setExpandType(memberServiceLog.getEditType());
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.CHANGE_NATURAL_COUNTRY.getValue()
                    || memberServiceLog.getEditType() == EApprovalBusiness.UPDATE_SETTLE_COUNTRY.getValue()) {
                // 修改自然国家
                // 查询国家
                R<Map<Integer, BdCountry>> countryAllMap = countryServiceApi.getAllCountryMap();

                BdCountry oldCountry = countryAllMap.getData().get(Integer.parseInt(oldValue));
                BdCountry newCountry = countryAllMap.getData().get(Integer.parseInt(newValue));
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), oldCountry.getName(), newCountry.getName(), memberServiceLog.getEditType());
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.SIGN_IN_STATE.getValue()) {
                // 修改登录状态
                String oldLabel = null;
                if (StringUtils.isNotBlank(oldValue)) {
                    oldLabel = EAccountStatus.getEAccountStatus(Integer.parseInt(oldValue)).getLabel();
                }
                String newLabel = null;
                if (StringUtils.isNotBlank(newValue)) {
                    newLabel = EAccountStatus.getEAccountStatus(Integer.parseInt(newValue)).getLabel();
                }
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), oldLabel, newLabel, memberServiceLog.getEditType());
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.PROFIT_STATE.getValue()) {
                // 修改收益状态
                String oldLabel = null;
                if (StringUtils.isNotBlank(oldValue)) {
                    oldLabel = EProfitState.getEnumByValue(Integer.parseInt(oldValue)).getLabel();
                }
                String newLabel = null;
                if (StringUtils.isNotBlank(newValue)) {
                    newLabel = EProfitState.getEnumByValue(Integer.parseInt(newValue)).getLabel();
                }
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), oldLabel, newLabel, memberServiceLog.getEditType());
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.WALLET_STATE.getValue()) {
                // 修改钱包状态
                List<String> oldLabelList = new ArrayList<>();
                if (StringUtils.isNotBlank(oldValue)) {
                    for (String s : oldValue.split(",")) {
                        oldLabelList.add(EMemberAccount.getEnumByValue(Integer.parseInt(s)).getLabel());
                    }
                }
                List<String> newLabelList = new ArrayList<>();
                if (StringUtils.isNotBlank(newValue)) {
                    for (String s : newValue.split(",")) {
                        newLabelList.add(EMemberAccount.getEnumByValue(Integer.parseInt(s)).getLabel());
                    }
                }
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), StringUtils.join(oldLabelList, ","), StringUtils.join(newLabelList, ","), memberServiceLog.getEditType().intValue());
                resultList.add(signOnlineInfoVo);
            } else if (memberServiceLog.getEditType() == EApprovalBusiness.FREE_ASSESSMENT_STATE.getValue()) {
                // 修改免考状态
                List<String> oldLabelList = new ArrayList<>();
                if (StringUtils.isNotBlank(oldValue)) {
                    for (String s : oldValue.split(",")) {
                        oldLabelList.add(EFreeAssessmentState.getEnumByValue(Integer.parseInt(s)).getLabel());
                    }
                }
                List<String> newLabelList = new ArrayList<>();
                if (StringUtils.isNotBlank(newValue)) {
                    for (String s : newValue.split(",")) {
                        newLabelList.add(EFreeAssessmentState.getEnumByValue(Integer.parseInt(s)).getLabel());
                    }
                }
                SignOnlineInfoVo signOnlineInfoVo = paddingSignOnlineInfoVo(memberServiceLog.getMemberName(), memberServiceLog.getMemberCode(), StringUtils.join(oldLabelList, ","), StringUtils.join(newLabelList, ","), memberServiceLog.getEditType().intValue());
                resultList.add(signOnlineInfoVo);
            }
        }
        return R.ok(resultList);
    }

    /**
     * 设置子项
     *
     * @param memberName
     * @param memberCode
     * @param oldValue
     * @param newValue
     * @param approvalBusinessType
     * @return
     */
    private SignOnlineInfoVo paddingSignOnlineInfoVo(String memberName,
                                                     String memberCode, String oldValue, String newValue, Integer approvalBusinessType) {
        SignOnlineInfoVo signOnlineInfoVo = new SignOnlineInfoVo();
        signOnlineInfoVo.setMemberName(memberName);
        signOnlineInfoVo.setMemberCode(memberCode);
        signOnlineInfoVo.setOldValue(oldValue);
        signOnlineInfoVo.setNewValue(newValue);
        signOnlineInfoVo.setApprovalBusinessType(approvalBusinessType);
        return signOnlineInfoVo;
    }

    /**
     * 在线签呈 （审批状态） 同意/驳回
     */
    @Override
    public R signForApproval(ApprovalBusinessResultDTO approvalBusinessResultDTO) {
        try {
            String str;
            switch (approvalBusinessResultDTO.getEApprovalBusiness()) {
                case CHANGE_MEMBER_CODE:
                case MEMBER_ACHIEVE:
                case POLICY_CURRENCY_YES_NO:
                case UPDATE_SETTLE_COUNTRY:
                case AWARDS_CONTROL_SAVE:
                case AWARDS_CONTROL_MODIFY:
                case AWARDS_CONTROL_DELETE:
                case CU_STORE_SAVE:
                case CU_STORE_MODIFY:
                case CU_STORE_DELETE:
                case CU_MEMBER_PARENT:
                case CU_MEMBER_PLACE_PARENT:
                case NOT_ACTIVE_POINT:
                    str = auditProcess(approvalBusinessResultDTO);
                    break;
                case EMPTY_ORDER:
                    // 空单注册
                    if (EApproveOperation.AGREE.getValue() == approvalBusinessResultDTO.getApproveOperation()) {
                        // 通过
                        str = iMemberEmptyService.approvalAgree(approvalBusinessResultDTO);
                    } else {
                        // 驳回
                        str = iMemberEmptyService.approvalReject(approvalBusinessResultDTO);
                    }
                    break;
                default:
                    return handleBusinessService.signForApprovalExamine(approvalBusinessResultDTO);
            }
            // 处理返回
            if (null == str) {
                return R.ok();
            }
            return R.fail(str);
        } catch (Exception e) {
            log.error("会员业务签呈回调处理异常. dto: {}", approvalBusinessResultDTO, e);
            return R.fail(e.getMessage());
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public String auditProcess(ApprovalBusinessResultDTO approvalBusinessResultDTO) {
        try {
            // 查询订单修改记录
            QueryWrapper<CuMemberServiceLog> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("BUSINESS_NO", approvalBusinessResultDTO.getBusinessCode());
            List<CuMemberServiceLog> cuMemberServiceLogList = iCuMemberServiceLogService.list(queryWrapper);
            //校验注水业绩
            if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.MEMBER_ACHIEVE.getValue()) {
                // TODO  注水业绩在这拦住了 其他的校验
                QueryWrapper<CuMemberAchieveLog> queryWrapper1 = new QueryWrapper();
                queryWrapper1.eq("BUSINESS_NO", approvalBusinessResultDTO.getBusinessCode());
                queryWrapper1.eq("APPROVE_STATUS", EApproveStatus.ALREADY_SUBMIT.getValue());
                List<CuMemberAchieveLog> malList = iCuMemberAchieveLogService.list(queryWrapper1);
                if (CollectionUtils.isEmpty(cuMemberServiceLogList) && CollectionUtils.isEmpty(malList)) {
                    log.info("特殊业务：签呈不存在");
                    return TransactionUtils.getContent(ConfigMsgConstants.PETITION_ABSENT_ERROR);
                }
            }

            if (!CollectionUtils.isEmpty(cuMemberServiceLogList)) {
                CuMemberServiceLog cuMemberServiceLog = cuMemberServiceLogList.get(0);
                if (EApproveStatus.ALREADY_SUBMIT.getValue() != cuMemberServiceLog.getApproveStatus()) {
                    log.info("特殊业务:签呈已审核");
                    return TransactionUtils.getContent(ConfigMsgConstants.PETITION_AUDITED_ERROR);
                }
            }
            //修改会员编号
            if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.CHANGE_MEMBER_CODE.getValue()) {
                //审核通过
                if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.FINISH.getValue()) {
                    cuMemberService.updateCodeByBusinessNo(approvalBusinessResultDTO);
                    return null;
                } else if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.REJECTED.getValue()) {
                    cuMemberService.updateCodeReject(approvalBusinessResultDTO);
                    return null;
                }
                //注水业绩
            } else if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.MEMBER_ACHIEVE.getValue()) {
                cuMemberAchieveLogService.toExamine(approvalBusinessResultDTO);
                return null;
            } else if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.POLICY_CURRENCY_YES_NO.getValue()) {
                //修改政策币
                cuMemberService.upPolicyCurrencyProcess(approvalBusinessResultDTO);
                return null;
            } else if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.NOT_ACTIVE_POINT.getValue()) {
                //未激活点位
                cuMemberService.notActiveByBusinessNo(approvalBusinessResultDTO);
                return null;
            } else if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.UPDATE_SETTLE_COUNTRY.getValue()) {
                //审核通过
                if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.FINISH.getValue()) {
                    cuMemberService.updateSettleCountryAdopt(approvalBusinessResultDTO);
                    return null;
                } else if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.REJECTED.getValue()) {
                    cuMemberService.updateSettleCountryReject(approvalBusinessResultDTO);
                    return null;
                }
            } else if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.EMPTY_ORDER.getValue()) {
                // 审核通过  空单注册
                if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.FINISH.getValue()) {
                    orderServiceApi.regEmptyOrderApproved(approvalBusinessResultDTO);
                    return null;
                } else if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.REJECTED.getValue()) {
                    // 驳回
                    orderServiceApi.regEmptyOrderReject(approvalBusinessResultDTO);
                    return null;
                }
            } else if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.AWARDS_CONTROL_SAVE.getValue() ||
                    approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.AWARDS_CONTROL_MODIFY.getValue() ||
                    approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.AWARDS_CONTROL_DELETE.getValue()
            ) {
                //真实奖衔控制审批
                cuMemberService.awardsControlPetition(approvalBusinessResultDTO);
                return null;
            } else if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.CU_STORE_SAVE.getValue() ||
                    approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.CU_STORE_MODIFY.getValue() ||
                    approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.CU_STORE_DELETE.getValue()
            ) {
                //会员店铺配置审批
                iCuStoreService.cuStoreByBusinessNo(approvalBusinessResultDTO);
                return null;
            } else if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.CU_MEMBER_PARENT.getValue()) {
                // 修改直推
                if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.FINISH.getValue()) {
                    cuMemberService.updateParentByBusinessNo(approvalBusinessResultDTO);
                    return null;
                } else if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.REJECTED.getValue()) {
                    // 驳回
                    cuMemberService.updateParentByBusinessNoReject(approvalBusinessResultDTO);
                    return null;
                }

            } else if (approvalBusinessResultDTO.getEApprovalBusiness().getValue() == EApprovalBusiness.CU_MEMBER_PLACE_PARENT.getValue()) {
                // 修改安置
                if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.FINISH.getValue()) {
                    // 通过
                    cuMemberService.updatePlaceParentByBusinessNo(approvalBusinessResultDTO);
                    return null;
                } else if (approvalBusinessResultDTO.getEApproveStatus().getValue() == EApproveStatus.REJECTED.getValue()) {
                    // 驳回
                    cuMemberService.updatePlaceParentByBusinessNoReject(approvalBusinessResultDTO);
                    return null;
                }
            }
        } catch (Exception e) {
            //异常时，审批流程事务回滚
            log.error("审核状态为： {} 的审核出错", approvalBusinessResultDTO.getEApprovalBusiness().getValue(), e);
            return TransactionUtils.getContent(ConfigMsgConstants.MEMBER_UPDATE_CODE_ERROR);
        }
        return null;
    }

    /**
     * 处理空单注册数据
     *
     * @param param     处理参数
     * @param pkCountry 所属国家
     * @return
     */
    private MemberEmptyDTO handMemberEmpty(AnalysisBusinessAppealParam param, Integer pkCountry) {
        QueryWrapper<CuMemberEmptyLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("BUSINESS_CODE", param.getBusinessNo());
        queryWrapper.eq(SystemFieldConstants.PK_COUNTRY, pkCountry);
        CuMemberEmptyLog cuMemberEmptyLog = iCuMemberEmptyLogService.getOne(queryWrapper);
        // 空单批次数据
        CuMemberEmpty cuMemberEmpty = iCuMemberEmptyService.getById(cuMemberEmptyLog.getPkMemberEmpty());

        return MemberEmptyDTO.builder()
                .pkMemberEmpty(cuMemberEmpty.getPkId())
                .businessCode(cuMemberEmpty.getBusinessCode())
                .remark(cuMemberEmpty.getRemark())
                .creationTime(cuMemberEmpty.getCreationTime())
                .build();
    }

}
