package com.czg;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.dto.req.*;
import com.czg.dto.resp.*;
import com.czg.exception.CzgException;
import com.czg.third.alipay.AlipayEntryManager;
import com.czg.third.alipay.AlipayIsvEntryManager;
import com.czg.third.wechat.WechatEntryManager;
import com.czg.utils.AssertUtil;
import com.czg.utils.AsyncTaskExecutor;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

/**
 * 进件管理
 *
 * @author yjjie
 * @date 2026/1/6 13:56
 */
public class EntryManager {

    /**
     * 查询银行支行列表
     *
     * @param province 省份 陕西省
     * @param city     城市 西安市
     * @param instId   顶级机构ID  CMB
     */
    public static List<BankBranchDto> queryBankBranchList(String province, String city, String instId) {
        return AlipayEntryManager.queryBankBranchList(null, instId, province, city);
    }

    /**
     * 查询银行支行列表
     * 走微信查询
     *
     * @param bankAliceCode 银行代码
     * @param cityCode  城市编码
     */
    public static WechatBankBranchRespDto queryBankBranchList(String bankAliceCode, String cityCode) {
        return WechatEntryManager.queryBankBranchList(null, bankAliceCode, cityCode, 0, 200);
    }

    /**
     * 查询微信进件状态
     *
     * @param merchantCode 商户编号, 进件时返回的批次号 {@link EntryRespDto#wechatApplyId}
     * @return 进件状态
     */
    public static QueryStatusResp queryWechatEntryStatus(String merchantCode) {
        return WechatEntryManager.queryMerchantEntryStatus(null, merchantCode);
    }

    /**
     * 查询支付宝进件状态
     *
     * @param batchNo 商户编号, 进件时返回的批次号 {@link EntryRespDto#alipayOrderId}
     * @return 进件状态
     */
    public static QueryStatusResp queryAlipayEntryStatus(String batchNo) {
        return AlipayIsvEntryManager.queryMerchantBatchStatus(null, batchNo);
    }

    /**
     * 进件
     * 请先执行:
     * 1. {@link com.czg.EntryManager#verifyEntryParam(AggregateMerchantDto)} 验证进件参数
     * 2. {@link com.czg.EntryManager#uploadParamImage(AggregateMerchantDto)} 上传图片至第三方
     *
     * @param reqDto   进件参数
     * @param platform 平台  {@link com.czg.PayCst.Platform}
     */
    public static EntryRespDto entryMerchant(AggregateMerchantDto reqDto, String... platform) {
        List<Supplier<EntryThirdRespDto>> tasks = new ArrayList<>();

        if (platform == null || platform.length == 0) {
            platform = new String[]{PayCst.Type.WECHAT, PayCst.Type.ALIPAY};
        }

        if (ArrayUtil.contains(platform, PayCst.Type.WECHAT)) {
            tasks.add(() -> WechatEntryManager.entryMerchant(null, reqDto));
        }
        if (ArrayUtil.contains(platform, PayCst.Type.ALIPAY)) {
            tasks.add(() -> AlipayIsvEntryManager.entryMerchant(null, reqDto));
        }

        // 执行所有任务
        List<AsyncTaskExecutor.TaskResult<EntryThirdRespDto>> results = AsyncTaskExecutor.executeAll(tasks);

        return getEntryRespDto(results);
    }

    @NotNull
    private static EntryRespDto getEntryRespDto(List<AsyncTaskExecutor.TaskResult<EntryThirdRespDto>> results) {
        EntryRespDto entryRespDto = new EntryRespDto();
        for (AsyncTaskExecutor.TaskResult<EntryThirdRespDto> result : results) {
            // 合并两个进件结果
            EntryThirdRespDto respDto = result.result();
            if (PayCst.Type.WECHAT.equals(respDto.getPlatform())) {
                entryRespDto.setWechatApplyId(respDto.getEntryId());
                entryRespDto.setWechatStatus(respDto.getStatus());
                entryRespDto.setWechatErrorMsg(respDto.getErrorMsg());
            } else if (PayCst.Type.ALIPAY.equals(respDto.getPlatform())) {
                entryRespDto.setAlipayOrderId(respDto.getEntryId());
                entryRespDto.setAlipayStatus(respDto.getStatus());
                entryRespDto.setAlipayErrorMsg(respDto.getErrorMsg());
                entryRespDto.setAlipayAuthInfo(respDto.getAlipayAuthInfo());
            }
        }
        return entryRespDto;
    }

    /**
     * 上传图片至第三方
     * 请先执行 {@link com.czg.EntryManager#verifyEntryParam(AggregateMerchantDto)} 验证进件参数
     *
     * @param reqDto 进件参数
     */
    public static void uploadParamImage(AggregateMerchantDto reqDto) {
        List<Supplier<Void>> tasks = new ArrayList<>();

        MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo();
        // 联系人身份证反面
        tasks.add(() -> {
            uploadImageToThird(baseInfo.getContactIdCardBackPic());
            return null;
        });
        // 联系人身份证正面
        tasks.add(() -> {
            uploadImageToThird(baseInfo.getContactIdCardFrontPic());
            return null;
        });

        LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo();
        // 法人身份证反面
        tasks.add(() -> {
            uploadImageToThird(legalPersonInfo.getIdCardBackPic());
            return null;
        });
        // 法人身份证正面
        tasks.add(() -> {
            uploadImageToThird(legalPersonInfo.getIdCardFrontPic());
            return null;
        });
        // 法人手持身份证
        tasks.add(() -> {
            uploadImageToThird(legalPersonInfo.getIdCardHandPic());
            return null;
        });

        BusinessLicenceInfoDto businessLicenceInfo = reqDto.getBusinessLicenceInfo();
        // 营业执照
        tasks.add(() -> {
            uploadImageToThird(businessLicenceInfo.getLicensePic());
            return null;
        });

        SettlementInfoDto settlementInfo = reqDto.getSettlementInfo();
        // 银行卡背面
        tasks.add(() -> {
            uploadImageToThird(settlementInfo.getBankCardBackPic());
            return null;
        });
        // 银行卡正面
        tasks.add(() -> {
            uploadImageToThird(settlementInfo.getBankCardFrontPic());
            return null;
        });
        // 开户许可证
        tasks.add(() -> {
            uploadImageToThird(settlementInfo.getOpenAccountLicencePic());
            return null;
        });
        // 非法人手持授权函
        tasks.add(() -> {
            uploadImageToThird(settlementInfo.getNoLegalHandSettleAuthPic());
            return null;
        });
        // 非法人授权函
        tasks.add(() -> {
            uploadImageToThird(settlementInfo.getNoLegalSettleAuthPic());
            return null;
        });
        // 非法人身份证反面
        tasks.add(() -> {
            uploadImageToThird(settlementInfo.getNoLegalIdCardBackPic());
            return null;
        });
        // 非法人身份证正面
        tasks.add(() -> {
            uploadImageToThird(settlementInfo.getNoLegalIdCardFrontPic());
            return null;
        });

        StoreInfoDto storeInfo = reqDto.getStoreInfo();
        // 店内图片
        tasks.add(() -> {
            uploadImageToThird(storeInfo.getInsidePic());
            return null;
        });
        // 门店门头图片
        tasks.add(() -> {
            uploadImageToThird(storeInfo.getDoorPic());
            return null;
        });
        // 收银台图片
        tasks.add(() -> {
            uploadImageToThird(storeInfo.getCashierDeskPic());
            return null;
        });

        // 执行所有任务
        AsyncTaskExecutor.executeAll(tasks);
    }

    private static void uploadImageToThird(ImageDto dto) {
        if (dto != null && StrUtil.isNotBlank(dto.getUrl())) {
            if (StrUtil.isBlank(dto.getWechatId())) {
                String image = WechatEntryManager.uploadImage(null, dto.getUrl());
                dto.setWechatId(image);
            }
//            if (StrUtil.isBlank(dto.getAlipayId())) {
//                String image = AlipayEntryManager.uploadImage(null, dto.getUrl());
//                dto.setAlipayId(image);
//            }
        }
    }

    /**
     * 验证进件参数
     *
     * @param reqDto 进件参数
     */
    public static void verifyEntryParam(AggregateMerchantDto reqDto) {
        AssertUtil.isBlank(reqDto.getMerchantCode(), "商户编号不能为空");

        AssertUtil.isNull(reqDto.getMerchantBaseInfo(), "商户基础信息不能为空");

        MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo();
        AssertUtil.isBlank(baseInfo.getUserType(), "商户类型不能为空");
        AssertUtil.isBlank(baseInfo.getShortName(), "商户简称不能为空");
        AssertUtil.isBlank(baseInfo.getMccCode(), "商户行业编码不能为空");
        AssertUtil.isBlank(baseInfo.getAlipayAccount(), "支付宝账号不能为空");
        AssertUtil.isBlank(baseInfo.getContactPersonType(), "联系人类型不能为空");
        if (!PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType()) && !PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType())) {
            throw new CzgException("联系人类型错误");
        }
        if (PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType())) {
            AssertUtil.isBlank(baseInfo.getCertType(), "证件类型不能为空");
            if (!"0".equals(baseInfo.getCertType())) {
                throw new CzgException("证件类型错误");
            }
            AssertUtil.isBlank(baseInfo.getContactName(), "联系人姓名不能为空");
            AssertUtil.isBlank(baseInfo.getContactPersonId(), "联系人身份证号不能为空");
            AssertUtil.isBlank(baseInfo.getContactPhone(), "联系人电话不能为空");
            AssertUtil.isBlank(baseInfo.getContactAddr(), "联系人地址不能为空");
            AssertUtil.isBlank(baseInfo.getContactEmail(), "联系人邮箱不能为空");
            AssertUtil.isBlank(baseInfo.getContactPersonIdStartDate(), "联系人身份证开始日期不能为空");
            AssertUtil.isBlank(baseInfo.getContactPersonIdEndDate(), "联系人身份证到期日期不能为空");
            AssertUtil.isNull(baseInfo.getContactIdCardBackPic(), "联系人身份证反面不能为空");
            AssertUtil.isBlank(baseInfo.getContactIdCardBackPic().getUrl(), "联系人身份证反面不能为空");
            AssertUtil.isNull(baseInfo.getContactIdCardFrontPic(), "联系人身份证正面不能为空");
            AssertUtil.isBlank(baseInfo.getContactIdCardFrontPic().getUrl(), "联系人身份证正面不能为空");
        }
        AssertUtil.isBlank(baseInfo.getCompanyChildType(), "商户类型不能为空");
        if ("0".equals(baseInfo.getUserType())) {
            // 个体商户, 暂无其他校验
        } else if ("1".equals(baseInfo.getUserType())) {
            if (!"1".equals(baseInfo.getCompanyChildType()) && !"2".equals(baseInfo.getCompanyChildType()) && !"3".equals(baseInfo.getCompanyChildType())) {
                throw new CzgException("商户类型错误");
            }
        } else {
            throw new CzgException("商户类型错误");
        }

        AssertUtil.isNull(reqDto.getBusinessLicenceInfo(), "营业执照信息不能为空");
        BusinessLicenceInfoDto businessLicenceInfo = reqDto.getBusinessLicenceInfo();
        AssertUtil.isBlank(businessLicenceInfo.getLicenceNo(), "营业执照编号不能为空");
        AssertUtil.isBlank(businessLicenceInfo.getLicenceName(), "营业执照名称不能为空");
        AssertUtil.isBlank(businessLicenceInfo.getRegisteredAddress(), "营业执照注册地址不能为空");
        AssertUtil.isBlank(businessLicenceInfo.getLicenceStartDate(), "营业执照开始日期不能为空");
        AssertUtil.isBlank(businessLicenceInfo.getLicenceEndDate(), "营业执照到期日期不能为空");
        AssertUtil.isNull(businessLicenceInfo.getLicensePic(), "营业执照名称不能为空");
        AssertUtil.isBlank(businessLicenceInfo.getLicensePic().getUrl(), "营业执照名称不能为空");


        AssertUtil.isNull(reqDto.getLegalPersonInfo(), "法人信息不能为空");
        LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo();
        AssertUtil.isBlank(legalPersonInfo.getLegalPersonName(), "法人姓名不能为空");
        AssertUtil.isBlank(legalPersonInfo.getLegalPersonId(), "法人身份证号不能为空");
        AssertUtil.isBlank(legalPersonInfo.getLegalIdPersonStartDate(), "法人身份证开始日期不能为空");
        AssertUtil.isBlank(legalPersonInfo.getLegalPersonIdEndDate(), "法人身份证到期日期不能为空");
        AssertUtil.isBlank(legalPersonInfo.getLegalPersonPhone(), "法人电话不能为空");
        AssertUtil.isBlank(legalPersonInfo.getLegalPersonEmail(), "法人邮箱不能为空");
        AssertUtil.isBlank(legalPersonInfo.getLegalGender(), "法人性别不能为空");
        AssertUtil.isBlank(legalPersonInfo.getLegalAddress(), "法人地址不能为空");
        AssertUtil.isNull(legalPersonInfo.getIdCardHandPic(), "法人身份证手持不能为空");
        AssertUtil.isBlank(legalPersonInfo.getIdCardHandPic().getUrl(), "法人身份证手持不能为空");
        AssertUtil.isNull(legalPersonInfo.getIdCardFrontPic(), "法人身份证正面不能为空");
        AssertUtil.isBlank(legalPersonInfo.getIdCardFrontPic().getUrl(), "法人身份证正面不能为空");
        AssertUtil.isNull(legalPersonInfo.getIdCardBackPic(), "法人身份证反面不能为空");
        AssertUtil.isBlank(legalPersonInfo.getIdCardBackPic().getUrl(), "法人身份证反面不能为空");

        AssertUtil.isNull(reqDto.getStoreInfo(), "门店信息不能为空");
        StoreInfoDto storeInfo = reqDto.getStoreInfo();
        AssertUtil.isBlank(storeInfo.getMercProvCode(), "门店省ID不能为空");
        AssertUtil.isBlank(storeInfo.getMercCityCode(), "门店市ID不能为空");
        AssertUtil.isBlank(storeInfo.getMercAreaCode(), "门店区ID不能为空");
        AssertUtil.isBlank(storeInfo.getMercProv(), "门店省不能为空");
        AssertUtil.isBlank(storeInfo.getMercCity(), "门店市不能为空");
        AssertUtil.isBlank(storeInfo.getMercArea(), "门店区不能为空");
        AssertUtil.isBlank(storeInfo.getBusinessAddress(), "门店营业地址不能为空");
        AssertUtil.isNull(storeInfo.getInsidePic(), "门店营业地址不能为空");
        AssertUtil.isBlank(storeInfo.getInsidePic().getUrl(), "门店营业地址不能为空");
        AssertUtil.isNull(storeInfo.getDoorPic(), "门店门头照不能为空");
        AssertUtil.isBlank(storeInfo.getDoorPic().getUrl(), "门店门头照不能为空");
        AssertUtil.isNull(storeInfo.getCashierDeskPic(), "门店收银台照不能为空");
        AssertUtil.isBlank(storeInfo.getCashierDeskPic().getUrl(), "门店收银台照不能为空");


        AssertUtil.isNull(reqDto.getSettlementInfo(), "结算信息不能为空");
        SettlementInfoDto settlementInfo = reqDto.getSettlementInfo();
        AssertUtil.isBlank(settlementInfo.getSettlementCardNo(), "结算卡号不能为空");
        AssertUtil.isBlank(settlementInfo.getSettlementName(), "结算账户户名不能为空");
        AssertUtil.isBlank(settlementInfo.getBankName(), "结算银行名称不能为空");
        AssertUtil.isBlank(settlementInfo.getBankInstId(), "结算银行缩写不能为空");
        AssertUtil.isBlank(settlementInfo.getBankMobile(), "结算银行预留手机号不能为空");
        AssertUtil.isBlank(settlementInfo.getSettlementCardType(), "结算卡类型不能为空");
        AssertUtil.isBlank(settlementInfo.getOpenAccProvinceId(), "结算开户行省ID不能为空");
        AssertUtil.isBlank(settlementInfo.getOpenAccCityId(), "结算开户行市ID不能为空");
        AssertUtil.isBlank(settlementInfo.getOpenAccAreaId(), "结算开户行区ID不能为空");
        AssertUtil.isBlank(settlementInfo.getOpenAccProvince(), "结算开户行省不能为空");
        AssertUtil.isBlank(settlementInfo.getOpenAccCity(), "结算开户行市不能为空");
        AssertUtil.isBlank(settlementInfo.getOpenAccArea(), "结算开户行区不能为空");
        if ("11".equals(settlementInfo.getSettlementCardType())) {
            // 11 对私借记卡（结算卡正面照、结算卡反面照图片必传）
            AssertUtil.isNull(settlementInfo.getBankCardFrontPic(), "结算卡正面照不能为空");
            AssertUtil.isBlank(settlementInfo.getBankCardFrontPic().getUrl(), "结算卡正面照不能为空");
            AssertUtil.isNull(settlementInfo.getBankCardBackPic(), "结算卡反面照不能为空");
            AssertUtil.isBlank(settlementInfo.getBankCardBackPic().getUrl(), "结算卡反面照不能为空");
            AssertUtil.isBlank(settlementInfo.getSettlementType(), "结算类型不能为空");
            if ("0".equals(settlementInfo.getSettlementType())) {
                // 非法人结算
                AssertUtil.isBlank(settlementInfo.getNoLegalName(), "非法人姓名不能为空");
                AssertUtil.isBlank(settlementInfo.getNoLegalId(), "非法人身份证号不能为空");
                AssertUtil.isNull(settlementInfo.getNoLegalIdCardFrontPic(), "非法人身份证正面不能为空");
                AssertUtil.isBlank(settlementInfo.getNoLegalIdCardFrontPic().getUrl(), "非法人身份证正面不能为空");
                AssertUtil.isNull(settlementInfo.getNoLegalIdCardBackPic(), "非法人身份证反面不能为空");
                AssertUtil.isBlank(settlementInfo.getNoLegalIdCardBackPic().getUrl(), "非法人身份证反面不能为空");
                AssertUtil.isNull(settlementInfo.getNoLegalSettleAuthPic(), "非法人结算授权书不能为空");
                AssertUtil.isBlank(settlementInfo.getNoLegalSettleAuthPic().getUrl(), "非法人结算授权书不能为空");
            } else if ("1".equals(settlementInfo.getSettlementType())) {
                // 法人结算 暂无处理
            } else {
                throw new CzgException("结算类型错误");
            }
        } else if ("21".equals(settlementInfo.getSettlementCardType())) {
            // 21 对公借记卡（只须结算卡正面照片）
            AssertUtil.isNull(settlementInfo.getOpenAccountLicencePic(), "开户许可证不能为空");
            AssertUtil.isBlank(settlementInfo.getOpenAccountLicencePic().getUrl(), "开户许可证不能为空");
        } else {
            throw new CzgException("结算卡类型错误");
        }

    }

    public static void main(String[] args) {

//        WechatBankBranchRespDto respDto = queryBankBranchList("1000009547", "931");
//        System.out.println(respDto);


        AggregateMerchantDto merchantDto = getTestMerchantEntryData();
//
        verifyEntryParam(merchantDto);
        uploadParamImage(merchantDto);
//
//        verifyEntryParam(merchantDto);
//        uploadParamImage(merchantDto);
////        System.out.println(merchantDto);
//        EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Type.WECHAT);
        EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Type.ALIPAY);
//        entryMerchant(merchantDto, PayCst.Type.WECHAT, PayCst.Type.ALIPAY);
        System.out.println(respDto);
    }

    private static AggregateMerchantDto getTestMerchantEntryData() {
        AggregateMerchantDto merchantDto = new AggregateMerchantDto();
        merchantDto.setMerchantCode("CZG20260112151202011");

        String baseInfo = "{\"alipayAccount\":\"18191655977\",\"certType\":\"0\",\"companyChildType\":\"1\",\"contactAddr\":\"西安市沣东新城石化大道西段106号沣东科技园5号楼1层5-037室\",\"contactEmail\":\"892675422@qq.com\",\"contactIdCardBackPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/ce731859ee644df8a4a46104b49c7696.png\",\"wechatId\":\"V1_S-iU_YpBpSKoSZFhQw3plh53G4PXHmNlhi1s88_VTk7A943tAxrkIcKErRcpFPkxG7vkMzhkT4ecN3IWxv71JwLJOzY9eQhmv6giwKWUAjk\"},\"contactIdCardFrontPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/e0d259f9fbcf4897b7f93f3f7d1b8e9a.png\",\"wechatId\":\"V1_oYXFrsrx4sZqiHXURjDBMB53G4PXHmPB0jH4yl2JSowqJDinBqRYIZmHrRcpFPkxsGFO-6Ci3dGvLAs-X2g2DQLJOzY9eQhmv6giwKWUAjk\"},\"contactName\":\"\",\"contactPersonId\":\"612501199212187875\",\"contactPersonIdEndDate\":\"2039-02-01\",\"contactPersonIdStartDate\":\"2019-02-01\",\"contactPersonType\":\"LEGAL\",\"contactPhone\":\"18191655977\",\"mccCode\":\"A0001_B0001\",\"shortName\":\"菲慕斯博\",\"userType\":\"1\"}";
        merchantDto.setMerchantBaseInfo(JSONObject.parseObject(baseInfo, MerchantBaseInfoDto.class));

        String legalPersonInfo = "{\"idCardBackPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/bb0f77b0b3404bbd9975a4f8497494df.png\",\"wechatId\":\"V1_Kt7wB6u_YhTp_V97CU_V_x53G4PXHmOeC1YpTSt8JenBIbhCzXjNIZWHrRcpFPkxHwsAu6WQfWU6BYJ3glMBnALJOzY9eQhmv6giwKWUAjk\"},\"idCardFrontPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/196a6f37c5954fc395d621e5b0289cb5.png\",\"wechatId\":\"V1__G9UoJplQHSY_ychzdk7QR53G4PXHmMm845pnkw_19i0CeVtQ34dIbOHrRcpFPkxsIEMvoVq19SdOFHTsw6b3wLJOzY9eQhmv6giwKWUAjk\"},\"idCardHandPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/eaa5e0f9352d4e77bbf5fa133ed54564.jpg\",\"wechatId\":\"V1_mWQpc12PTPL7P7kkdUOR6h53G4PXHmPbBEOZTTwh_KJ8RdecGr9kIZuGrRcpFPkx-jdQCaZuUWIQRmxr8pm-7QLJOzY9eQhmv6giwKWUAjk\"},\"legalAddress\":\"西安市沣东新城石化大道西段106号沣东科技园5号楼1层5-037室\",\"legalGender\":\"0\",\"legalIdPersonStartDate\":\"2019-02-01\",\"legalPersonEmail\":\"892675422@qq.com\",\"legalPersonId\":\"612501199212187875\",\"legalPersonIdEndDate\":\"2039-02-01\",\"legalPersonName\":\"蔺佳佳\",\"legalPersonPhone\":\"18191655977\"}";
        merchantDto.setLegalPersonInfo(JSONObject.parseObject(legalPersonInfo, LegalPersonInfoDto.class));

        String businessInfo = "{\"licenceEndDate\":\"2099-12-31\",\"licenceName\":\"西安菲慕斯博市场营销策划有限公司\",\"licenceNo\":\"91610131MA6TXACP28\",\"licenceStartDate\":\"2021-02-25\",\"licensePic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/81b60f3a25494c8586159a193389aa2d.jpg\",\"wechatId\":\"V1_-Vbealekn9NZb3mT37ggpB53G4PXHmNEw41rkFGHdR1KJkYqgc5QId-HrRcpFPkxJLlN6u4U4s24lzVyTVoxPgLJOzY9eQhmv6giwKWUAjk\"},\"registeredAddress\":\"陕西省西安市高新区科技路37号海星城市广场B座2002-080室\"}";
        merchantDto.setBusinessLicenceInfo(JSONObject.parseObject(businessInfo, BusinessLicenceInfoDto.class));

        String storeInfo = "{\"businessAddress\":\"西安市沣东新城石化大道西段106号沣东科技园5号楼1层5-037室\",\"cashierDeskPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/4e52859aac754670aaf9be1c923da827.jpg\",\"wechatId\":\"V1_qFmvcdaX1XSUmknkcwKzMh53G4PXHmNYVJzGUiEs-qE-2ERQMr6XIemErRcpFPkxyCyY2DFU5QIBiaW6WamZmwLJOzY9eQhmv6giwKWUAjk\"},\"doorPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/2c207c6f4a764ad18e501ed10fbfad59.png\",\"wechatId\":\"V1_JPI6iQUmEXiUL2JogtdaJR53G4PXHmO3QpILvqWkLccmvi-vX4OJIdmBrRcpFPkxwNCa-m1w5XissHoA_ynwKQLJOzY9eQhmv6giwKWUAjk\"},\"insidePic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/394b4834698a47e9b75419a5fd7f7de7.jpg\",\"wechatId\":\"V1_djcTvjUKESKADtVCmtLqmR53G4PXHmOLw9uEV3te3o7OebPqjdklIdGBrRcpFPkxy6JbIGyYEZT6XatGXNQ2YQLJOzY9eQhmv6giwKWUAjk\"},\"mercArea\":\"雁塔区\",\"mercAreaCode\":\"610113\",\"mercCity\":\"西安市\",\"mercCityCode\":\"610100\",\"mercProv\":\"陕西省\",\"mercProvCode\":\"610000\"}";
        merchantDto.setStoreInfo(JSONObject.parseObject(storeInfo, StoreInfoDto.class));

        String settlementInfo = "{\"bankBranchCode\":\"313791000427\",\"bankBranchName\":\"西安银行高新四路支行\",\"bankCardBackPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/3f3bb30f89fd4441985808f4a451c9c7.jpg\",\"wechatId\":\"V1_KAo5J49VNaCiC7twEi6NfB53G4PXHmNqgVl38ZojoETk3a9m_ZLvIaeHrRcpFPkxmQ3bRK2ytADSD8Fe8v-mpALJOzY9eQhmv6giwKWUAjk\"},\"bankCardFrontPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/413f9170ca1d4f0893e05fd72b5e2b0e.jpg\",\"wechatId\":\"V1_GNhNtE1UYUCeRAuLsxdimR53G4PXHmNn9A4-gDbYgq47MiHxjki-IarByRcpFPkxfqldVa9taQ7W5KtWL35ppwLJOzY9eQhmv6giwKWUAjk\"},\"bankInstId\":\"XAB\",\"bankMobile\":\"18191655977\",\"bankName\":\"其他银行\",\"bankType\":\"\",\"noLegalHandSettleAuthPic\":{\"alipayId\":\"\",\"url\":\"\",\"wechatId\":\"\"},\"noLegalId\":\"\",\"noLegalIdCardBackPic\":{\"alipayId\":\"\",\"url\":\"\",\"wechatId\":\"\"},\"noLegalIdCardFrontPic\":{\"alipayId\":\"\",\"url\":\"\",\"wechatId\":\"\"},\"noLegalName\":\"\",\"noLegalSettleAuthPic\":{\"alipayId\":\"\",\"url\":\"\",\"wechatId\":\"\"},\"openAccArea\":\"雁塔区\",\"openAccAreaId\":\"610113\",\"openAccCity\":\"西安市\",\"openAccCityId\":\"610100\",\"openAccProvince\":\"陕西省\",\"openAccProvinceId\":\"610000\",\"openAccountLicencePic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/6e5dca0822f742649ecf1666f91ad1b3.jpg\",\"wechatId\":\"V1_1S62SpAFYecG5T-DC9ewHR53G4PXHmMA49fy0uVVk5j35lE5L5njIfSGrRcpFPkxU9Fm6P6bYLY3t010FYkmAQLJOzY9eQhmv6giwKWUAjk\"},\"settlementCardNo\":\"611011580000054186\",\"settlementCardType\":\"21\",\"settlementName\":\"西安菲慕斯博市场营销策划有限公司\",\"settlementType\":\"1\"}";
        merchantDto.setSettlementInfo(JSONObject.parseObject(settlementInfo, SettlementInfoDto.class));


//        merchantDto.setMerchantCode("20220106000000000001");
//
//        MerchantBaseInfoDto baseInfoDto = new MerchantBaseInfoDto();
//        baseInfoDto.setUserType("1");
//        baseInfoDto.setCompanyChildType("1");
//        baseInfoDto.setShortName("测试商户");
//        baseInfoDto.setAlipayAccount("1157756119@qq.com");
//        baseInfoDto.setMccCode("A0001_B0001");
//        baseInfoDto.setContactPersonType(PayCst.ContactPersonType.SUPER);
//        baseInfoDto.setContactName("张三");
//        baseInfoDto.setContactPersonId("110101199001011234");
//        baseInfoDto.setContactPersonIdStartDate("2021-01-01");
//        baseInfoDto.setContactPersonIdEndDate("2025-01-01");
//        baseInfoDto.setContactPhone("13800000000");
//        baseInfoDto.setContactEmail("1157756119@qq.com");
//        baseInfoDto.setContactAddr("广东省深圳市南山区");
//        baseInfoDto.setContactIdCardFrontPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        baseInfoDto.setContactIdCardBackPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        merchantDto.setMerchantBaseInfo(baseInfoDto);
//
//        BusinessLicenceInfoDto businessLicenceInfoDto = new BusinessLicenceInfoDto();
//        businessLicenceInfoDto.setLicenceName("测试商户");
//        businessLicenceInfoDto.setLicenceNo("110101199001011234");
//        businessLicenceInfoDto.setLicenceStartDate("2021-01-01");
//        businessLicenceInfoDto.setLicenceEndDate("2052-01-01");
//        businessLicenceInfoDto.setRegisteredAddress("广东省深圳市南山区");
//        businessLicenceInfoDto.setLicensePic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        merchantDto.setBusinessLicenceInfo(businessLicenceInfoDto);
//
//        LegalPersonInfoDto legalPersonInfoDto = new LegalPersonInfoDto();
//        legalPersonInfoDto.setLegalPersonName("张三");
//        legalPersonInfoDto.setLegalPersonId("110101199001011234");
//        legalPersonInfoDto.setLegalIdPersonStartDate("2021-01-01");
//        legalPersonInfoDto.setLegalPersonIdEndDate("2055-01-01");
//        legalPersonInfoDto.setLegalPersonPhone("13800000000");
//        legalPersonInfoDto.setLegalPersonEmail("1157756119@qq.com");
//        legalPersonInfoDto.setLegalGender("1");
//        legalPersonInfoDto.setLegalAddress("广东省深圳市南山区");
//        legalPersonInfoDto.setIdCardHandPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        legalPersonInfoDto.setIdCardFrontPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        legalPersonInfoDto.setIdCardBackPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        merchantDto.setLegalPersonInfo(legalPersonInfoDto);
//
//        StoreInfoDto storeInfoDto = new StoreInfoDto();
//        storeInfoDto.setMercProvCode("440000");
//        storeInfoDto.setMercCityCode("440300");
//        storeInfoDto.setMercAreaCode("440303");
//        storeInfoDto.setMercProv("广东省");
//        storeInfoDto.setMercCity("深圳市");
//        storeInfoDto.setMercArea("南山区");
//        storeInfoDto.setBusinessAddress("广东省深圳市南山区");
//        storeInfoDto.setInsidePic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        storeInfoDto.setDoorPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        storeInfoDto.setCashierDeskPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        merchantDto.setStoreInfo(storeInfoDto);
//
//        SettlementInfoDto settlementInfoDto = new SettlementInfoDto();
//        settlementInfoDto.setSettlementType("1");
//        settlementInfoDto.setSettlementCardType("21");
//        settlementInfoDto.setSettlementName("张三");
//        settlementInfoDto.setSettlementCardNo("110101199001011234");
//        settlementInfoDto.setBankMobile("13800000000");
//        settlementInfoDto.setOpenAccProvinceId("440000");
//        settlementInfoDto.setOpenAccCityId("440300");
//        settlementInfoDto.setOpenAccAreaId("440303");
//        settlementInfoDto.setOpenAccProvince("广东省");
//        settlementInfoDto.setOpenAccCity("深圳市");
//        settlementInfoDto.setOpenAccArea("南山区");
//        settlementInfoDto.setBankName("中国工商银行");
//        settlementInfoDto.setBankInstId("ICBC");
//        settlementInfoDto.setBankType("1");
//        settlementInfoDto.setBankBranchName("广东省深圳市南山区");
//        settlementInfoDto.setBankBranchCode("440300");
//        settlementInfoDto.setBankCardFrontPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        settlementInfoDto.setBankCardBackPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        settlementInfoDto.setOpenAccountLicencePic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
//        merchantDto.setSettlementInfo(settlementInfoDto);

        return merchantDto;
    }
}
