package com.hzs.member.handlebusiness.controller.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hzs.common.core.annotation.Log;
import com.hzs.common.core.constant.EnumsPrefixConstants;
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.core.utils.poi.ExcelUtil;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.member.account.CuMemberAccount;
import com.hzs.common.domain.member.business.SignOnlineInfoVo;
import com.hzs.common.domain.member.detail.CuMemberServiceLog;
import com.hzs.common.domain.member.handleBusiness.CuHandleBusiness;
import com.hzs.common.domain.system.base.BdCountry;
import com.hzs.common.domain.system.config.BdAwards;
import com.hzs.common.domain.system.sys.SysUser;
import com.hzs.common.security.service.UserTokenService;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.common.service.ITransactionCommonService;
import com.hzs.common.core.utils.TransactionUtils;
import com.hzs.member.account.IBusinessCommission;
import com.hzs.member.account.dto.BusinessCommissionDTO;
import com.hzs.member.account.dto.MemberAmountDTO;
import com.hzs.member.account.dto.MemberBalanceDTO;
import com.hzs.member.account.service.ICuMemberAccountService;
import com.hzs.member.account.service.ICuMemberBaseService;
import com.hzs.member.account.service.ICuMemberTradeService;
import com.hzs.member.detail.service.ICuMemberServiceLogService;
import com.hzs.member.detail.vo.CuMemberServiceLogVO;
import com.hzs.member.handlebusiness.ICuHandleBusinessServiceApi;
import com.hzs.member.handlebusiness.dto.AnalysisBusinessAppealParam;
import com.hzs.member.handlebusiness.service.ICuHandleBusinessService;
import com.hzs.member.handlebusiness.vo.*;
import com.hzs.system.base.ICountryServiceApi;
import com.hzs.system.config.IAccountServiceApi;
import com.hzs.system.config.IAwardsServiceApi;
import com.hzs.system.config.IGradeServiceApi;
import com.hzs.system.config.IServiceChargeServiceApi;
import com.hzs.system.config.dto.GradeDTO;
import com.hzs.system.config.dto.ServiceChargeDTO;
import com.hzs.system.sys.IApprovalServiceApi;
import com.hzs.system.sys.dto.ApprovalInfoDTO;
import com.hzs.system.sys.dto.ApprovalItemInfoDTO;
import com.hzs.system.sys.dto.LoginUser;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.http.client.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 业务办理表 前端控制器
 *
 * @author zhangjing
 * @since 2023-01-11
 */
@RestController
@RequestMapping("/manage/handle-business")
public class CuHandleBusinessController extends BaseController {
    @Autowired
    private ICuHandleBusinessService cuHandleBusinessService;

    @DubboReference
    private IApprovalServiceApi approvalServiceApi;
    @Autowired
    private UserTokenService userTokenService;
    @Autowired
    private ICuMemberServiceLogService memberServiceLogService;
    @DubboReference
    private IServiceChargeServiceApi serviceChargeServiceApi;
    @DubboReference
    private ICuHandleBusinessServiceApi handleBusinessServiceApi;
    @DubboReference
    private IAccountServiceApi iAccountServiceApi;
    @DubboReference
    private IBusinessCommission businessCommission;
    @Autowired
    private ICuMemberTradeService cuMemberTradeService;
    @Autowired
    private ICuHandleBusinessService handleBusinessService;
    @Autowired
    private ITransactionCommonService iTransactionCommonService;
    @DubboReference
    private IGradeServiceApi gradeService;
    @DubboReference
    private IAwardsServiceApi awardsService;
    @Autowired
    private ICuMemberBaseService cuMemberBaseService;
    @DubboReference
    private ICountryServiceApi countryServiceApi;
    @Autowired
    private ICuMemberAccountService cuMemberAccountService;


    /**
     * @description: 查询办理业务列表
     * @author: zhang jing
     * @date: 2023/1/12 14:58
     * @param: [handleBusinessVO]
     * @return: com.hzs.common.core.web.page.TableDataInfo
     **/
    @Log(module = EOperationModule.HANDLE_BUSINESS, business = EOperationBusiness.BASE_BUSINESS, method = EOperationMethod.SELECT)
    @GetMapping("/businessList")
    public TableDataInfo businessList(HandleBusinessShowVO handleBusinessVO) {
        startPage();
        if (StringUtils.isEmpty(handleBusinessVO.getMemberCode()) &&
                StringUtils.isEmpty(handleBusinessVO.getMemberName()) &&
                StringUtils.isNull(handleBusinessVO.getPkAwards()) &&
                StringUtils.isNull(handleBusinessVO.getVertexId()) &&
                StringUtils.isNull(handleBusinessVO.getTeamId()) &&
                StringUtils.isEmpty(handleBusinessVO.getPhone()) &&
                StringUtils.isEmpty(handleBusinessVO.getCenterMemberCode()) &&
                StringUtils.isEmpty(handleBusinessVO.getCenterMemberName()) &&
                StringUtils.isNull(handleBusinessVO.getStartDate()) &&
                StringUtils.isNull(handleBusinessVO.getEndDate()) &&
                StringUtils.isNull(handleBusinessVO.getStartDatePay()) &&
                StringUtils.isNull(handleBusinessVO.getEndDatePay())
        ) {
            return getDataTable(new ArrayList<>());
        }
        handleBusinessVO.setPkCountry(SecurityUtils.getPkCountry());
        List<HandleBusinessShowVO> list = cuHandleBusinessService.queryHandleBusinessList(handleBusinessVO);
        return getDataTable(list);
    }

    /**
     * 保存业务办理
     *
     * @param handleBusinessVO 业务办理表Vo
     * @return AjaxResult
     */
    @Log(module = EOperationModule.HANDLE_BUSINESS, business = EOperationBusiness.BASE_BUSINESS, method = EOperationMethod.SUBMIT)
    @PostMapping("/save")
    public AjaxResult saveHandleBusiness(@RequestBody HandleBusinessVO handleBusinessVO) {
        Integer pkCountry = SecurityUtils.getPkCountry();
        LoginUser loginUser = userTokenService.getLoginUser();
        handleBusinessVO.setPkCountry(pkCountry);
        Integer processType = handleBusinessVO.getProcessType();
        if (null == processType) {
            return AjaxResult.error("请选择按钮类型！");
        }
        return toAjax(cuHandleBusinessService.businessHandling(handleBusinessVO, loginUser));

    }

    /**
     * @param CuHandleBusinessVO
     * @return
     */
    @Log(module = EOperationModule.HANDLE_BUSINESS, method = EOperationMethod.SELECT)
    @PostMapping("/confirm")
    public AjaxResult confirmHandleBusiness(@RequestBody HandleBusinessVO CuHandleBusinessVO) {
        Integer pkCountry = SecurityUtils.getPkCountry();


        return null;
    }


    /**
     * @description: 业务办理导入数据
     * @author: zhang jing
     * @date: 2023/1/21 9:26
     * @param: [file, updateSupport]
     * @return: com.hzs.common.core.web.domain.AjaxResult
     **/
    @PostMapping("/importData")
    @Log(module = EOperationModule.HANDLE_BUSINESS, business = EOperationBusiness.BASE_BUSINESS, method = EOperationMethod.IMPORT)
    public AjaxResult importData(MultipartFile file) throws Exception {
        ExcelUtil<HandleBusinessShowVO> util = new ExcelUtil<>(HandleBusinessShowVO.class);
        List<HandleBusinessShowVO> list = util.importExcel(file.getInputStream());
        List<HandleBusinessShowVO> newlist = new ArrayList<>();
        List<HandleBusinessShowVO> errorlist = new ArrayList<>();
        Integer pkCountry = SecurityUtils.getPkCountry();
        if (CollectionUtil.isNotEmpty(list)) {
            for (HandleBusinessShowVO hbv : list) {
                hbv.setPkCountry(pkCountry);
                List<HandleBusinessShowVO> listNew = cuHandleBusinessService.queryHandleBusinessList(hbv);
                if (CollectionUtil.isEmpty(listNew)) {
                    errorlist.add(hbv);
                    continue;
                } else {
                    listNew.get(0).setNewMemberName(hbv.getNewMemberName());
                    listNew.get(0).setNewPhone(hbv.getNewPhone());
                }
                newlist.add(listNew.get(0));
            }
        }
        if (CollectionUtil.isNotEmpty(errorlist)) {
            return AjaxResult.error(504, TransactionUtils.getContent(ConfigMsgConstants.MEMBER_NOT_VALID), errorlist);
        }
        return AjaxResult.success(newlist);
    }

    /**
     * 下载模板
     *
     * @return
     */
    @PostMapping("/download-template")
    @Log(module = EOperationModule.RECHARGE, method = EOperationMethod.EXPORT)
    public void downloadTemplate(HttpServletResponse response) {
        ExcelUtil<HandleBusinessShowVO> util = new ExcelUtil<>(HandleBusinessShowVO.class);
        util.exportExcel(response, null, TransactionUtils.getContent(ConfigMsgConstants.BASIC_BUSINESS));
    }

    /**
     * @description: 办理业务-基础业务校验
     * @author: zhang jing
     * @date: 2023/1/21 10:31
     * @param: [businessSingleVO]
     * @return: com.hzs.common.core.web.domain.AjaxResult
     **/
    @Log(module = EOperationModule.HANDLE_BUSINESS, business = EOperationBusiness.BASE_BUSINESS, method = EOperationMethod.SELECT)
    @PostMapping("/businessCheck")
    public AjaxResult businessCheck(@RequestBody HandleBusinessVO businessSingleVO) {
        List<BusinessErrorVO> errorMemberList = new ArrayList<>();
        Integer pkCountry = SecurityUtils.getPkCountry();
        //业务类型选中值后再传参数
        if (CollectionUtil.isEmpty(businessSingleVO.getHandleBusinessList())) {
            return AjaxResult.error(TransactionUtils.getContent(ConfigMsgConstants.WORK_TYPE_NOT_NULL));

        }
        List<Integer> businessValueList = new ArrayList<>();
        businessSingleVO.getHandleBusinessList().forEach(itm ->
                businessValueList.addAll(itm.getBusinessValueList())
        );
        if (CollectionUtil.isEmpty(businessValueList)) {
            return AjaxResult.error(TransactionUtils.getContent(ConfigMsgConstants.WORK_TYPE_NOT_NULL));
        }
        if (CollectionUtil.isEmpty(businessSingleVO.getBusinessMemberList())) {
            return AjaxResult.error(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_DATA_NOT_NULL));
        }
        for (BusinessMemberVO uc : businessSingleVO.getBusinessMemberList()) {
            if (StringUtils.isEmpty(uc.getMemberCode())) {
                BusinessErrorVO bev = new BusinessErrorVO();
                bev.setErrorMsg(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_CODE_NOT_NULL));
                bev.setMemberCode(uc.getMemberCode());
                errorMemberList.add(bev);
            }
            if (StringUtils.isNull(uc.getPkMember())) {
                BusinessErrorVO bev = new BusinessErrorVO();
                bev.setErrorMsg(TransactionUtils.getContent(ConfigMsgConstants.PKID_NOT_NULL));
                bev.setMemberCode(uc.getMemberCode());
                errorMemberList.add(bev);
            }
        }
        if (CollectionUtil.isNotEmpty(errorMemberList)) {
            return AjaxResult.error(504, TransactionUtils.getContent(ConfigMsgConstants.MEMBER_DATA_ERROR), errorMemberList);
        }
        // 获取需要翻译的枚举翻译
        Map<String, String> transactionMap = iTransactionCommonService.exportEnumTransaction(EApprovalBusiness.values(), EModifyName.values(),
                EModifyPhone.values(), EResetPassword.values(), EResetBank.values(), EProfitState.values(), ESignInState.values(),
                EMemberAccount.values(), EFreeAssessmentState.values(), ERegistrationAuthority.values(),
                EYesNoAttestation.values(), EYesNo.values(), ESignInState.values());
        /**
         * 会员编号
         */
        List<Long> pkMemberList = new ArrayList<>();
        /**
         * 审批业务类型 来源于枚举  EApprovalBusiness
         */
        List<Integer> editTypeList = new ArrayList<>();
        for (BusinessMemberVO bmv : businessSingleVO.getBusinessMemberList()) {
            pkMemberList.add(bmv.getPkMember());
            if (StringUtils.isNotEmpty(bmv.getNewMemberName()) &&
                    StringUtils.isNotEmpty(bmv.getMemberName())) {
                bmv.setBusinessType(EApprovalBusiness.CHANGE_NAME.getValue());
                bmv.setOldValue(bmv.getMemberName());
                bmv.setNewValue(bmv.getNewMemberName());
            }
        }
        BusinessTableVO btvo = new BusinessTableVO();
        for (BusinessTypeValueVO btv : businessSingleVO.getHandleBusinessList()) {
            if (CollectionUtil.isNotEmpty(btv.getBusinessValueList())) {
                editTypeList.add(btv.getBusinessType());
            }
            btvo.setTable1(EYesNo.YES.getIntValue());
            btvo.setTable2(EYesNo.YES.getIntValue());
            if (CollectionUtil.isNotEmpty(btv.getBusinessValueList()) &&
                    btv.getBusinessType() == EApprovalBusiness.CHANGE_NAME.getValue()) {
                btvo.setTable3(EYesNo.YES.getIntValue());
                btvo.setTable4(EYesNo.YES.getIntValue());
            }
            if (CollectionUtil.isNotEmpty(btv.getBusinessValueList()) && btv.getBusinessType() == EApprovalBusiness.CHANGE_PHONE.getValue()) {
                btvo.setTable5(EYesNo.YES.getIntValue());
                btvo.setTable6(EYesNo.YES.getIntValue());
                btvo.setTable7(EYesNo.YES.getIntValue());
            }


        }
        businessSingleVO.setBtvo(btvo);
        //校验重复审核
        CuMemberServiceLogVO cuMemberServiceLogVO = new CuMemberServiceLogVO();
        cuMemberServiceLogVO.setPkMemberList(pkMemberList);
        cuMemberServiceLogVO.setEditTypeList(editTypeList);
        List<CuMemberServiceLogVO> memberServiceLog = memberServiceLogService.selectServiceLogList(cuMemberServiceLogVO);
        if (CollectionUtil.isNotEmpty(memberServiceLog)) {
            for (CuMemberServiceLogVO cs : memberServiceLog) {
                BusinessErrorVO bev = new BusinessErrorVO();
                bev.setErrorMsg(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_UPDATE_CODE_REPEAT));
                bev.setMemberCode(cs.getMemberCode());
                errorMemberList.add(bev);
            }
        }

        // 查询国家
        R<Map<Integer, BdCountry>> countryAllMap = countryServiceApi.getAllCountryMap();
        //查询会员原值
        BusinessMemberVO businessMemberVO = new BusinessMemberVO();
        businessMemberVO.setPkMemberList(pkMemberList);
        List<BusinessMemberVO> businessOldMemberList = memberServiceLogService.selectOldValue(businessMemberVO);
        //发起签呈会员信息集合(入库数据)
        List<BusinessMemberVO> businessMemberList = new ArrayList<>();
        //返回页面会员信息集合（发起签呈页面展示）
        List<BusinessMemberVO> signMemberList = new ArrayList<>();

        //返回页面会员信息集合（确认页面展示）
        List<BusinessMemberVO> businessNewMemberList = new ArrayList<>();
        //校验会员金额是否充足临时集合
        List<BusinessCostVO> businessCostVOList = new ArrayList<>();
        //校验办理业务的费用
        List<BusinessTypeValueVO> handleBusinessCostList = new ArrayList<>();
        R<List<GradeDTO>> gradeList = gradeService.queryGradeConfigByCondition(pkCountry);
        R<List<BdAwards>> awList = awardsService.queryAwards(pkCountry);
        //会员信息集合
        int count = 1;//计数器
        for (BusinessMemberVO uc : businessSingleVO.getBusinessMemberList()) {
            //返回页面会员信息（确认页面显示）
            BusinessMemberVO nuc = new BusinessMemberVO();
            BigDecimal singleAmountTotal = new BigDecimal(0);
            if (CollectionUtil.isNotEmpty(businessOldMemberList)) {
                for (BusinessMemberVO cov : businessOldMemberList) {
                    if (cov.getPkMember().intValue() == uc.getPkMember().intValue()) {
                        nuc.setMemberCode(cov.getMemberCode());
                        nuc.setMemberName(cov.getMemberName());
                        nuc.setPhone(cov.getPhone());
                    }
                }
            }
            //循环业务类型集合

            BigDecimal singleAmount100 = new BigDecimal(0);
            for (BusinessTypeValueVO etv : businessSingleVO.getHandleBusinessList()) {
                if (CollectionUtil.isNotEmpty(etv.getBusinessValueList())) {
                    //发起签呈列表集合对象（页面显示）
                    BusinessMemberVO sig = new BusinessMemberVO();
                    BusinessTypeValueVO nbtvo = BeanUtil.copyProperties(etv, BusinessTypeValueVO.class);
                    sig.setPkMember(uc.getPkMember());
                    sig.setMemberName(uc.getMemberName());
                    sig.setMemberCode(uc.getMemberCode());
                    sig.setBusinessType(etv.getBusinessType());
                    nbtvo.setMemberCode(uc.getMemberCode());
                    nbtvo.setMemberName(uc.getMemberName());
                    nbtvo.setPkId(count);
                    sig.setPkId(count);
                    count++;
                    if (etv.getBusinessType() != EApprovalBusiness.CHANGE_NAME.getValue() &&
                            etv.getBusinessType() != EApprovalBusiness.CHANGE_PHONE.getValue() &&
                            etv.getBusinessType() != EApprovalBusiness.RESET_LOGIN_PASSWORD.getValue()) {
                        nbtvo.setAfterTheChange(TransactionUtils.getContent(ConfigMsgConstants.AFTER_THE_CHANGE));
                        nbtvo.setButtonType(EYesNo.YES.getIntValue());
                    }
                    //发起签呈集合对象
                    BusinessMemberVO bum = BeanUtil.copyProperties(sig, BusinessMemberVO.class);
                    //当前最大次数
                    Integer approveNumber = memberServiceLogService.selectByMaxApproveNumber(uc.getPkMember(), etv.getBusinessType(), EApproveStatus.FINISH.getValue());
                    if (StringUtils.isNull(approveNumber)) {
                        //当前最大次数
                        approveNumber = 0;
                    }

                    //查询扣费金额，账户信息 singleAmount
                    R<ServiceChargeDTO> serviceChargeDtoR = serviceChargeServiceApi.getServiceChargeByType(ServiceChargeDTO.builder()
                            .type(etv.getBusinessType())
                            .quantity(approveNumber + 1)
                            .pkCountry(SecurityUtils.getPkCountry())
                            .build());
                    ServiceChargeDTO serviceChargeDTO = serviceChargeDtoR.getData();

                    BusinessCostVO businessCostVO = new BusinessCostVO();
                    if (StringUtils.isNotNull(serviceChargeDTO) &&
                            StringUtils.isNotNull(serviceChargeDTO.getPkAccount()) &&
                            StringUtils.isNotNull(serviceChargeDTO.getCost())) {
                        bum.setSingleAmount(serviceChargeDTO.getCost());
                        bum.setApproveNumber(approveNumber);
                        businessCostVO.setPkAccount(serviceChargeDTO.getPkAccount());
                        nbtvo.setPkAccountKey(cuMemberBaseService.translateAccountValue(serviceChargeDTO.getPkAccount()));
                        nuc.setPkAccountKey(cuMemberBaseService.translateAccountValue(serviceChargeDTO.getPkAccount()));
                        nbtvo.setPkAccount(serviceChargeDTO.getPkAccount());
                        nbtvo.setDeductionCurrency(TransactionUtils.getContent(ConfigMsgConstants.DEDUCTION_CURRENCY));
                        nbtvo.setCost(serviceChargeDTO.getCost());
                        businessCostVO.setPkMember(uc.getPkMember());
                        businessCostVO.setTradeAmount(serviceChargeDTO.getCost());
                        singleAmountTotal = singleAmountTotal.add(serviceChargeDTO.getCost());
                        businessCostVOList.add(businessCostVO);
                    } else {
                        BusinessErrorVO bev = new BusinessErrorVO();
                        bev.setErrorMsg(transactionMap.get(EnumsPrefixConstants.APPROVAL_BUSINESS + etv.getBusinessType()) + " " + TransactionUtils.getContent(ConfigMsgConstants.BUSINESS_ACCOUNT_IS_NULL));
                        bev.setMemberCode(uc.getMemberCode());
                        errorMemberList.add(bev);
                    }

                    //修改会员姓名校验姓名不能为空
                    if (StringUtils.isNotNull(etv.getBusinessType()) && etv.getBusinessType() == EApprovalBusiness.CHANGE_NAME.getValue()) {
                        if (StringUtils.isEmpty(uc.getNewValue())) {
                            BusinessErrorVO bev = new BusinessErrorVO();
                            bev.setErrorMsg(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_NAME_NOT_NULL));
                            bev.setMemberCode(uc.getMemberCode());
                            errorMemberList.add(bev);
                        }
                    }
                    //修改会员手机校验手机不能为空
                    if (StringUtils.isNotNull(etv.getBusinessType()) && etv.getBusinessType() == EApprovalBusiness.CHANGE_PHONE.getValue()) {
                        if (StringUtils.isEmpty(uc.getNewPhone())) {
                            BusinessErrorVO bev = new BusinessErrorVO();
                            bev.setErrorMsg(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_PHONE_NOT_NULL));
                            bev.setMemberCode(uc.getMemberCode());
                            errorMemberList.add(bev);
                        }
                    }
                    //修改会员邮箱校验邮箱不能为空
                    if (StringUtils.isNotNull(etv.getBusinessType()) && etv.getBusinessType() == EApprovalBusiness.RESET_EMAIL.getValue()) {
                        if (StringUtils.isEmpty(uc.getNewEmail())) {
                            BusinessErrorVO bev = new BusinessErrorVO();
                            bev.setErrorMsg(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_EMAIL_NOT_NULL));
                            bev.setMemberCode(uc.getMemberCode());
                            errorMemberList.add(bev);
                        }
                    }
                    //根据业务类型更新会员原值
                    if (CollectionUtil.isNotEmpty(businessOldMemberList)) {
                        for (BusinessMemberVO cov : businessOldMemberList) {
                            if (cov.getPkMember().intValue() == uc.getPkMember().intValue()) {
                                //修改姓名
                                if (etv.getBusinessType() == EApprovalBusiness.CHANGE_NAME.getValue()) {
                                    singleAmount100 = singleAmount100.add(businessCostVO.getTradeAmount());
                                    nuc.setSingleAmount100(singleAmount100);
                                    nuc.setNewMemberName(uc.getNewMemberName());
                                    nbtvo.setNewValue(transactionMap.get(EnumsPrefixConstants.EMODIFY_NAME + etv.getBusinessValueList().get(0)));
                                    sig.setOldValue(uc.getMemberName());
                                    sig.setNewValue(uc.getNewMemberName());
                                    bum.setOldValue(uc.getMemberName());
                                    bum.setNewValue(uc.getNewMemberName());
                                    break;
                                }
                                //修改手机号
                                if (etv.getBusinessType() == EApprovalBusiness.CHANGE_PHONE.getValue()) {
                                    nuc.setSingleAmount100(singleAmount100.add(businessCostVO.getTradeAmount()));
                                    nuc.setNewPhone(uc.getNewPhone());
                                    nbtvo.setNewValue(transactionMap.get(EnumsPrefixConstants.EMODIFY_PHONE + etv.getBusinessValueList().get(0)));
                                    sig.setOldValue(uc.getPhone());
                                    sig.setNewValue(uc.getNewPhone());
                                    bum.setOldValue(uc.getPhone());
                                    bum.setNewValue(uc.getNewPhone());
                                    break;
                                }
                                //修改邮箱
                                if (etv.getBusinessType() == EApprovalBusiness.RESET_EMAIL.getValue()) {
                                    bum.setOldValue(uc.getEmail());
                                    bum.setNewValue(uc.getNewEmail());
                                    nuc.setSingleAmount129(businessCostVO.getTradeAmount());
                                    nuc.setOldEmail(uc.getEmail());
                                    nuc.setNewEmail(uc.getNewEmail());
                                    sig.setOldValue(uc.getEmail());
                                    sig.setNewValue(uc.getNewEmail());
                                    nbtvo.setNewValue(transactionMap.get(EnumsPrefixConstants.ERESET_EMAIL + etv.getBusinessValueList().get(0)));
                                    break;
                                }
                                //重置会员密码
                                if (etv.getBusinessType() == EApprovalBusiness.RESET_LOGIN_PASSWORD.getValue()) {
                                    nuc.setSingleAmount103(businessCostVO.getTradeAmount());
                                    bum.setOldValue("  -  ");
                                    bum.setNewValue("*****");
                                    sig.setOldValue("  -  ");
                                    sig.setNewValue("*****");
                                    if (etv.getBusinessValueList().get(0) == EResetPassword.LOGIN_PASSWORD.getValue()) {
                                        nuc.setNewResetPassword("  -  ");
                                        nuc.setOldResetPassword("*****");
                                    }
                                    if (etv.getBusinessValueList().get(0) == EResetPassword.PAY_PASSWORD.getValue()) {
                                        nuc.setNewPaymentPassword("  -  ");
                                        nuc.setOldPaymentPassword("*****");
                                    }
                                    if (etv.getBusinessValueList().get(0) == EResetPassword.ALL_PASSWORD.getValue()) {
                                        nuc.setNewResetPassword("  -  ");
                                        nuc.setOldResetPassword("*****");
                                        nuc.setNewPaymentPassword("  -  ");
                                        nuc.setOldPaymentPassword("*****");
                                    }
                                    nbtvo.setNewValue(transactionMap.get(EnumsPrefixConstants.ERESET_PASSWORD + etv.getBusinessValueList().get(0)));
                                    break;
                                }

                                //修改注册等级
                                if (etv.getBusinessType() == EApprovalBusiness.CHANGE_REGISTER_GRADE.getValue()) {
                                    bum.setOldValue(cov.getPkRegisterGrade().toString());
                                    bum.setNewValue(newValue(etv.getBusinessValueList()));

                                    //更新会员新值
                                    uc.setNewValue(newValue(etv.getBusinessValueList()));
                                    nuc.setSingleAmount106(businessCostVO.getTradeAmount());
                                    for (GradeDTO gr : gradeList.getData()) {
                                        if (etv.getBusinessValueList().get(0).intValue() == gr.getPkId().intValue()) {
                                            nbtvo.setNewValue(gr.getGradeName());
                                            sig.setNewValue(gr.getGradeName());
                                            nuc.setNewPkRegisterGrade(gr.getGradeName());
                                        }
                                        if (cov.getPkRegisterGrade().intValue() == gr.getPkId().intValue()) {
                                            sig.setOldValue(gr.getGradeName());
                                            nuc.setOldPkRegisterGrade(gr.getGradeName());
                                        }
                                    }
                                    break;
                                }
                                //修改奖衔
                                if (etv.getBusinessType() == EApprovalBusiness.CHANGE_AWARDS.getValue()) {
                                    bum.setOldValue(cov.getPkAwards().toString());
                                    bum.setNewValue(newValue(etv.getBusinessValueList()));
                                    nuc.setSingleAmount107(businessCostVO.getTradeAmount());

                                    for (BdAwards ba : awList.getData()) {
                                        if (etv.getBusinessValueList().get(0).intValue() == ba.getPkId().intValue()) {
                                            nbtvo.setNewValue(ba.getAwardsName());
                                            sig.setNewValue(ba.getAwardsName());
                                            nuc.setNewPkAwards(ba.getAwardsName());
                                        }
                                        if (cov.getPkAwards().intValue() == ba.getPkId().intValue()) {
                                            sig.setOldValue(ba.getAwardsName());
                                            nuc.setOldPkAwards(ba.getAwardsName());
                                        }
                                    }
                                    break;
                                }
                                //修改会员礼包收货地址
                                if (etv.getBusinessType() == EApprovalBusiness.CU_MEMBER_GIFT.getValue()) {
                                    nuc.setSingleAmount108(businessCostVO.getTradeAmount());
                                    nbtvo.setNewValue(etv.getBusinessValueList().get(0).toString());
                                    sig.setNewValue(etv.getBusinessValueList().get(0).toString());
                                    break;
                                }
                                //重置银行
                                if (etv.getBusinessType() == EApprovalBusiness.RESET_BANK.getValue()) {
                                    bum.setOldValue("****");
                                    bum.setNewValue(newValue(etv.getBusinessValueList()));
                                    nuc.setSingleAmount112(businessCostVO.getTradeAmount());
                                    nuc.setOldBank("****");
                                    nuc.setNewBank("  -  ");
                                    nbtvo.setNewValue(transactionMap.get(EnumsPrefixConstants.ERESET_BANK + etv.getBusinessValueList().get(0)));
                                    sig.setNewValue(transactionMap.get(EnumsPrefixConstants.ERESET_BANK + etv.getBusinessValueList().get(0)));
                                    break;
                                }

                                //修改结算等级
                                if (etv.getBusinessType() == EApprovalBusiness.CHANGE_SETTLEMENT_GRADE.getValue()) {
                                    bum.setOldValue(cov.getPkSettleGrade().toString());
                                    bum.setNewValue(newValue(etv.getBusinessValueList()));
                                    nuc.setSingleAmount113(businessCostVO.getTradeAmount());
                                    for (GradeDTO gr : gradeList.getData()) {
                                        if (etv.getBusinessValueList().get(0).intValue() == gr.getPkId().intValue()) {
                                            nbtvo.setNewValue(gr.getGradeName());
                                            sig.setNewValue(gr.getGradeName());
                                            nuc.setNewPkSettleGrade(gr.getGradeName());
                                        }
                                        if (cov.getPkRegisterGrade().intValue() == gr.getPkId().intValue()) {
                                            sig.setOldValue(gr.getGradeName());
                                            nuc.setOldPkSettleGrade(gr.getGradeName());
                                        }
                                    }
                                    break;
                                }
                                //修改自然国
                                if (etv.getBusinessType() == EApprovalBusiness.CHANGE_NATURAL_COUNTRY.getValue()) {
                                    bum.setOldValue(cov.getPkCountry().toString());
                                    bum.setNewValue(newValue(etv.getBusinessValueList()));
                                    nuc.setSingleAmount115(businessCostVO.getTradeAmount());
                                    BdCountry oldCountry = countryAllMap.getData().get(cov.getPkCountry());
                                    BdCountry newCountry = countryAllMap.getData().get(etv.getBusinessValueList().get(0));
                                    nuc.setOldPkCountry(oldCountry.getName());
                                    nuc.setNewPkCountry(newCountry.getName());
                                    nbtvo.setNewValue(newCountry.getName());
                                    sig.setNewValue(newCountry.getName());
                                    sig.setOldValue(oldCountry.getName());
                                    break;
                                }
                                //修改登录状态
                                if (etv.getBusinessType() == EApprovalBusiness.SIGN_IN_STATE.getValue()) {
                                    bum.setOldValue(cov.getAccountStatus().toString());
                                    bum.setNewValue(newValue(etv.getBusinessValueList()));
                                    nuc.setNewAccountStatus(transactionMap.get(EnumsPrefixConstants.ESIGN_IN_STATE + etv.getBusinessValueList().get(0)));
                                    nuc.setOldAccountStatus(transactionMap.get(EnumsPrefixConstants.ESIGN_IN_STATE + cov.getAccountStatus()));
                                    nuc.setSingleAmount116(businessCostVO.getTradeAmount());
                                    nbtvo.setNewValue(transactionMap.get(EnumsPrefixConstants.ESIGN_IN_STATE + etv.getBusinessValueList().get(0)));
                                    sig.setNewValue(transactionMap.get(EnumsPrefixConstants.ESIGN_IN_STATE + etv.getBusinessValueList().get(0)));
                                    sig.setOldValue(transactionMap.get(EnumsPrefixConstants.ESIGN_IN_STATE + cov.getAccountStatus()));
                                    break;
                                }
                                //收益状态
                                if (etv.getBusinessType() == EApprovalBusiness.PROFIT_STATE.getValue()) {
                                    bum.setOldValue(cov.getIncomeStatus().toString());
                                    bum.setNewValue(newValue(etv.getBusinessValueList()));
                                    nuc.setSingleAmount117(businessCostVO.getTradeAmount());
                                    nuc.setNewIncomeStatus(transactionMap.get(EnumsPrefixConstants.EPROFIT_STATE + etv.getBusinessValueList().get(0)));
                                    nuc.setOldIncomeStatus(transactionMap.get(EnumsPrefixConstants.EPROFIT_STATE + cov.getAccountStatus()));
                                    nbtvo.setNewValue(transactionMap.get(EnumsPrefixConstants.EPROFIT_STATE + etv.getBusinessValueList().get(0)));
                                    sig.setNewValue(transactionMap.get(EnumsPrefixConstants.EPROFIT_STATE + etv.getBusinessValueList().get(0)));
                                    sig.setOldValue(transactionMap.get(EnumsPrefixConstants.EPROFIT_STATE + cov.getAccountStatus()));
                                    break;
                                }
                                //钱包状态
                                if (etv.getBusinessType() == EApprovalBusiness.WALLET_STATE.getValue()) {
                                    CuMemberAccount cat = cuMemberAccountService.queryCuMemberAccountByPkMember(uc.getPkMember());
                                    StringBuilder newValueVal = new StringBuilder();
                                    bum.setNewValue(newValue(etv.getBusinessValueList()));
                                    if (etv.getBusinessValueList().size() > 1) {
                                        for (int i = 0; i < etv.getBusinessValueList().size(); i++) {
                                            if (i < etv.getBusinessValueList().size() - 1) {
                                                newValueVal.append(transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + etv.getBusinessValueList().get(i))).append("/");
                                            } else {
                                                newValueVal.append(transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + etv.getBusinessValueList().get(i)));
                                            }
                                        }
                                    } else {
                                        newValueVal = new StringBuilder(transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + etv.getBusinessValueList().get(0)));
                                    }
                                    if (StringUtils.isNotNull(cat)) {
                                        Integer isTransfer = cat.getIsTransfer() == EYesNo.NO.getIntValue() ? EMemberAccount.PROHIBIT_TRANSFER.getValue() : null;
                                        Integer isWithdraw = cat.getIsWithdraw() == EYesNo.NO.getIntValue() ? EMemberAccount.PROHIBIT_WITHDRAW.getValue() : null;
                                        Integer isConsume = cat.getIsConsume() == EYesNo.NO.getIntValue() ? EMemberAccount.PROHIBIT_CONSUME.getValue() : null;
                                        sig.setOldValue(transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + isTransfer) + "/" +
                                                transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + isWithdraw) + "/" +
                                                transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + isConsume));
                                        nuc.setOldWalletStatus(transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + isTransfer) + "/" +
                                                transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + isWithdraw) + "/" +
                                                transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + isConsume));

                                        // 使用 StringBuilder 拼接字符串
                                        StringBuilder sb = new StringBuilder();
                                        if (isTransfer != null) {
                                            sb.append(isTransfer);
                                        }
                                        if (isWithdraw != null) {
                                            if (sb.length() > 0) {
                                                sb.append(",");
                                            }
                                            sb.append(isWithdraw);
                                        }
                                        if (isConsume != null) {
                                            if (sb.length() > 0) {
                                                sb.append(",");
                                            }
                                            sb.append(isConsume);
                                        }
                                        // 判断拼接后的字符串是否为空，为空则表示正常
                                        int normalValue = EMemberAccount.NORMAL.getValue();
                                        bum.setOldValue(sb.length() == 0 ? Integer.toString(normalValue) : sb.toString());
                                        if (sb.length() == 0) {
                                            sig.setOldValue(transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + normalValue));
                                            nuc.setOldWalletStatus(transactionMap.get(EnumsPrefixConstants.MEMBER_ACCOUNT + normalValue));
                                        }

                                    } else {
                                        sig.setOldValue("-");
                                        nuc.setOldWalletStatus("-");
                                    }
                                    nuc.setSingleAmount118(businessCostVO.getTradeAmount());
                                    nbtvo.setNewValue(newValueVal.toString());
                                    sig.setNewValue(newValueVal.toString());
                                    nuc.setNewWalletStatus(newValueVal.toString());
                                    break;
                                }
                                //免考状态
                                if (etv.getBusinessType() == EApprovalBusiness.FREE_ASSESSMENT_STATE.getValue()) {
                                    StringBuilder newValueVal = new StringBuilder();
                                    String oldValueVal = "";
                                    bum.setNewValue(newValue(etv.getBusinessValueList()));
                                    nuc.setSingleAmount119(businessCostVO.getTradeAmount());
                                    if (etv.getBusinessValueList().size() > 1) {
                                        for (int i = 0; i < etv.getBusinessValueList().size(); i++) {
                                            if (i < etv.getBusinessValueList().size() - 1) {
                                                newValueVal.append(transactionMap.get(EnumsPrefixConstants.EFREE_ASSESSMENT_STATE + etv.getBusinessValueList().get(i))).append("/");
                                            } else {
                                                newValueVal.append(transactionMap.get(EnumsPrefixConstants.EFREE_ASSESSMENT_STATE + etv.getBusinessValueList().get(i)));
                                            }
                                        }
                                    } else {
                                        newValueVal = new StringBuilder(transactionMap.get(EnumsPrefixConstants.EFREE_ASSESSMENT_STATE + etv.getBusinessValueList().get(0)));
                                    }
                                    nbtvo.setNewValue(newValueVal.toString());
                                    sig.setNewValue(newValueVal.toString());
                                    bum.setOldValue(oldValueVal);
                                    sig.setOldValue(transactionMap.get(EnumsPrefixConstants.EFREE_ASSESSMENT_STATE + cov.getPurchaseStatus()) + "/" +
                                            transactionMap.get(EnumsPrefixConstants.EFREE_ASSESSMENT_STATE + cov.getShareStatus()));
                                    nuc.setOldAvoid(transactionMap.get(EnumsPrefixConstants.EFREE_ASSESSMENT_STATE + cov.getPurchaseStatus()) + "/" +
                                            transactionMap.get(EnumsPrefixConstants.EFREE_ASSESSMENT_STATE + cov.getShareStatus()));
                                    nuc.setNewAvoid(newValueVal.toString());
                                    break;
                                }

                            }
                        }
                    }
                    handleBusinessCostList.add(nbtvo);
                    signMemberList.add(sig);
                    businessMemberList.add(bum);
                }
            }
            businessNewMemberList.add(nuc);
        }

        businessSingleVO.setSignMemberList(signMemberList);
        businessSingleVO.setBusinessMemberList(businessMemberList);
        businessSingleVO.setHandleBusinessList(handleBusinessCostList);
        businessSingleVO.setBusinessOldMemberList(businessNewMemberList);
        businessSingleVO.setBusinessCostVOList(businessCostVOList);
        if (CollectionUtil.isNotEmpty(errorMemberList)) {
            return AjaxResult.error(504, TransactionUtils.getContent(ConfigMsgConstants.MEMBER_DATA_ERROR), errorMemberList);
        }
        if (CollectionUtil.isNotEmpty(errorMemberList)) {
            return AjaxResult.error(504, TransactionUtils.getContent(ConfigMsgConstants.MEMBER_DATA_ERROR), errorMemberList);
        }
        return AjaxResult.success(businessSingleVO);
    }


    /**
     * @description: 校验用户余额是否充足
     * @author: zhang jing
     * @date: 2023/6/7 11:33
     * @param: [businessSingleVO]
     * @return: com.hzs.common.core.web.domain.AjaxResult
     **/
    @Log(module = EOperationModule.HANDLE_BUSINESS, business = EOperationBusiness.BASE_BUSINESS, method = EOperationMethod.SELECT)
    @PostMapping("/balanceCheck")
    public AjaxResult balanceCheck(@RequestBody HandleBusinessVO businessSingleVO) {
        List<BusinessErrorVO> errorMemberList = new ArrayList<>();
        Integer pkCountry = SecurityUtils.getPkCountry();
        if (CollectionUtil.isEmpty(businessSingleVO.getBusinessCostVOList())) {
            return AjaxResult.error(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_DATA_ERROR));
        }
        //校验会员金额是否充足临时集合
        Map<Integer, Map<Long, BigDecimal>> map = new HashMap<>();
        for (BusinessCostVO bcv : businessSingleVO.getBusinessCostVOList()) {
            if (StringUtils.isNotNull(map.get(bcv.getPkAccount()))) {
                Map<Long, BigDecimal> map1 = map.get(bcv.getPkAccount());
                //累加金额
                if (StringUtils.isNotNull(map1.get(bcv.getPkMember()))) {
                    map1.put(bcv.getPkMember(), bcv.getTradeAmount().add(map1.get(bcv.getPkMember())));
                } else {
                    map1.put(bcv.getPkMember(), bcv.getTradeAmount());
                }
            } else {
                Map<Long, BigDecimal> map1 = new HashMap<>();
                map1.put(bcv.getPkMember(), bcv.getTradeAmount());
                map.put(bcv.getPkAccount(), map1);
            }
        }
        //接口查询金额是否足够
        BusinessCommissionDTO businessCommissionDTO = new BusinessCommissionDTO();
        businessCommissionDTO.setPkCountry(pkCountry);
        if (map.size() > 0) {
            map.forEach((key, value) -> {
                businessCommissionDTO.setPkAccount(key);
                //会员业务手续费集合
                List<MemberAmountDTO> memberAmountDTOList = new ArrayList<>();
                if (StringUtils.isNotNull(value) && value.size() > 0) {
                    value.forEach((key1, value1) -> {
                        MemberAmountDTO memberAmountDTO = new MemberAmountDTO();
                        memberAmountDTO.setPkMember(key1);
                        memberAmountDTO.setTradeAmount(value1);
                        memberAmountDTOList.add(memberAmountDTO);
                    });
                }
                businessCommissionDTO.setMemberAmountDTOList(memberAmountDTOList);
                if (CollectionUtil.isNotEmpty(memberAmountDTOList)) {
                    List<MemberBalanceDTO> memberBalanceList = cuMemberTradeService.selectBalanceNotEnoughMember(businessCommissionDTO);
                    if (CollectionUtil.isNotEmpty(memberBalanceList)) {
                        for (MemberBalanceDTO mdt : memberBalanceList) {
                            BusinessErrorVO bev = new BusinessErrorVO();
                            bev.setErrorMsg(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_BALANCE_INSUFFICIENT));
                            bev.setMemberCode(mdt.getMemberCode());
                            errorMemberList.add(bev);
                        }
                    }
                }
            });
        } else {
            return AjaxResult.error(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_DATA_ERROR));
        }
        if (CollectionUtil.isNotEmpty(errorMemberList)) {
            return AjaxResult.error(504, TransactionUtils.getContent(ConfigMsgConstants.MEMBER_DATA_ERROR), errorMemberList);
        } else {
            return success();
        }
    }

    /**
     * @description: 更新新值
     * @author: zhang jing
     * @date: 2023/3/20 12:11
     * @param: []
     * @return: java.lang.String
     **/
    private String newValue(List<Integer> businessValueList) {
        //更新会员新值
        StringBuilder newStr = new StringBuilder();
        if (businessValueList.size() > 1) {
            for (int i = 0; i < businessValueList.size(); i++) {
                if (i < businessValueList.size() - 1) {
                    newStr.append(businessValueList.get(i).toString()).append(",");
                } else {
                    newStr.append(businessValueList.get(i).toString());
                }
            }
        } else if (businessValueList.size() == 1) {
            newStr = new StringBuilder(businessValueList.get(0).toString());
        }
        return newStr.toString();
    }


    /**
     * @description: 重新申请办理业务
     * @author: zhang jing
     * @date: 2023/2/1 21:47
     * @param: [businessMemberVO]
     * @return: com.hzs.common.core.web.domain.AjaxResult
     **/
    @Log(module = EOperationModule.HANDLE_BUSINESS, business = EOperationBusiness.BASE_BUSINESS, method = EOperationMethod.SUBMIT)
    @PostMapping("/againBusiness")
    public AjaxResult againBusiness(@RequestBody CuMemberServiceLogVO cuMemberServiceLogVO) {
        if (StringUtils.isNull(cuMemberServiceLogVO.getBusinessNo())) {
            return AjaxResult.error(TransactionUtils.getContent(ConfigMsgConstants.WORK_NO_NOT_NULL));
        }
        if (StringUtils.isNull(cuMemberServiceLogVO.getEditType())) {
            return AjaxResult.error(TransactionUtils.getContent(ConfigMsgConstants.WORK_TYPE_NOT_NULL));
        }
        QueryWrapper<CuMemberServiceLog> querywrapper = new QueryWrapper<>();
        querywrapper.eq("APPROVE_STATUS", EApproveStatus.REJECTED.getValue());
        querywrapper.eq("BUSINESS_NO", cuMemberServiceLogVO.getBusinessNo());
        List<CuMemberServiceLog> cmslList = memberServiceLogService.list(querywrapper);
        if (CollectionUtil.isNotEmpty(cmslList)) {
            cuMemberServiceLogVO = memberServiceLogService.againBusiness(cmslList, cuMemberServiceLogVO);
        }
        return AjaxResult.success(cuMemberServiceLogVO);
    }

    /**
     * yh
     * 在线签呈(发起人)
     *
     * @return
     */
    @Log(module = EOperationModule.HANDLE_BUSINESS, business = EOperationBusiness.BASE_BUSINESS, method = EOperationMethod.SUBMIT)
    @PostMapping("online-petition")
    public AjaxResult signOnline(@RequestBody OnlinePetitionVo linePetitionVo) {
        SysUser loginUser = userTokenService.getLoginUser().getLoginSysUser();

        List<CuHandleBusiness> list = handleBusinessService.selectByOrderNumber(linePetitionVo.getOrderNumber());

        List<Integer> approvalBusinessList = list.stream().map(CuHandleBusiness::getEditType).collect(Collectors.toList());
        R<Map<Integer, ApprovalInfoDTO>> mapR = approvalServiceApi.queryApprovalInfo(approvalBusinessList, loginUser.getPkCountry());
        List<OnlinePetitionVo> onlinePetitionVoList = new ArrayList<>();
        for (CuHandleBusiness handleBusiness : list) {
            OnlinePetitionVo onlinePetitionVo = new OnlinePetitionVo();
            //发起部门
            onlinePetitionVo.setDeptId(loginUser.getPkDept());
            onlinePetitionVo.setDeptStr(loginUser.getDeptName());
            // 发起人
            onlinePetitionVo.setSponsorMemberId(loginUser.getUserId());
            onlinePetitionVo.setSponsorMemberStr(loginUser.getUserName());
            // 日期
            onlinePetitionVo.setApprovalDate(DateUtils.formatDate(new Date(), com.hzs.common.core.utils.DateUtils.YYYY_MM_DD_HH_MM_SS));

            // 抄送部门
            ApprovalInfoDTO approvalInfoDTO = mapR.getData().get(handleBusiness.getEditType());
            if (approvalInfoDTO != null) {
                List<String> collect = approvalInfoDTO.getItemList().stream().map(ApprovalItemInfoDTO::getDeptName).collect(Collectors.toList());
                onlinePetitionVo.setDeptList(collect);
            }

            //  业务诉求
            AnalysisBusinessAppealParam analysisBusinessAppealParam = new AnalysisBusinessAppealParam();
            // 业务大单号
            analysisBusinessAppealParam.setOrderNumber(handleBusiness.getOrderNumber());
            // 签呈类型
            onlinePetitionVo.setSignType(handleBusiness.getSignType());
            onlinePetitionVo.setEditType(handleBusiness.getEditType());
            // 小单号
            analysisBusinessAppealParam.setBusinessNo(handleBusiness.getBusinessNo());
            analysisBusinessAppealParam.setEditType(handleBusiness.getEditType());
            R<List<SignOnlineInfoVo>> signOnlineVoR = handleBusinessServiceApi.analysisBusinessAppeal(analysisBusinessAppealParam);
            onlinePetitionVo.setItemList(signOnlineVoR.getData());
            onlinePetitionVoList.add(onlinePetitionVo);
        }
        return AjaxResult.success(onlinePetitionVoList);
    }

    /**
     * 在线签呈-发起人-确认
     *
     * @return
     */
    @Log(module = EOperationModule.HANDLE_BUSINESS, business = EOperationBusiness.BASE_BUSINESS, method = EOperationMethod.CONFIRM)
    @PostMapping("/online-petition-confirm")
    public AjaxResult onlinePetitionConfirm(@RequestBody HandleBusinessVO handleBusinessVO) {
        LoginUser loginUser = userTokenService.getLoginUser();
        handleBusinessVO.setPkCountry(SecurityUtils.getPkCountry());
        Integer processType = handleBusinessVO.getProcessType();
        if (null == processType) {
            return AjaxResult.error("请选择按钮类型！");
        }
        return toAjax(cuHandleBusinessService.onlinePetitionConfirm(handleBusinessVO, loginUser));
    }


}
