using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LitJson;
using MySystem;
using MySystem.Models.Main;

namespace MySystem
{
    /// <summary>
    /// 添加分账接收方账户参数赋值
    /// </summary>
    public class AddOpenDivideAccountsUtil
    {
        public static AddOpenDivideAccounts AddValue(MerchantAddInfo AddInfo)
        {
            AddOpenDivideAccounts addOpenDivideAccounts = new AddOpenDivideAccounts();

            // addOpenDivideAccounts.acctNo = ""; //非必须 用户编码（创建分账接收方失败或者审核驳回时，修改信息时填写）
            addOpenDivideAccounts.userType = "1"; //必须 用户类型 1-企业,2-个人
            addOpenDivideAccounts.userName = "蒲晓敏"; //必须 用户名，个人填写身份证姓名，企业填写法人姓名
            addOpenDivideAccounts.compNm = "四川省润观米科技有限公司"; //企业必须 企业名称
            // addOpenDivideAccounts.mobile=""; //非必须 手机号
            addOpenDivideAccounts.legalCertType = "1"; //必须 法人证明类型 1身份证 2护照 3港澳台居民通行证（废弃不用）4外国人永久居留证 5香港来往内地通行证 6澳门来往内地通行证 7台湾同胞来往内地通行证
            addOpenDivideAccounts.userCardNo = "511304198607137628"; //必须 身份证号
            addOpenDivideAccounts.userCardStartDate = "20150302"; //必须 法人证件开始日期
            addOpenDivideAccounts.userCardEndDate = "20350302"; //必须 法人证件结束日期
            addOpenDivideAccounts.acctNm = "四川省润观米科技有限公司"; //必须 账户名称
            addOpenDivideAccounts.acctType = "0"; //必须 账户类型（0-对公、1-对私）
            addOpenDivideAccounts.bankCardNo = "11360000000324886"; //必须 银行卡号
            addOpenDivideAccounts.acctBankNo = "304100040000"; //必须 总行行号
            addOpenDivideAccounts.acctBankNm = "华夏银行"; //必须 总行名称
            addOpenDivideAccounts.acctZbankNo = "304651010227"; //必须 支行行号
            addOpenDivideAccounts.acctZbankNm = "华夏银行股份有限公司成都天府支行"; //必须 支行名称
            addOpenDivideAccounts.acctZbankCode = "510122"; //必须 开户支行地区码
            // addOpenDivideAccounts.reservedPhone=""; //非必须 预留手机号。个人和企业对私必填
            addOpenDivideAccounts.licNo = "91510106MA6C7RRTXR"; //企业必须 营业执照号
            addOpenDivideAccounts.licStartDate = "20171212"; //企业必须 营业执照开始日期
            addOpenDivideAccounts.licEndDate = "长期"; //企业必须 营业执照结束日期
            addOpenDivideAccounts.businessAddressCode = "510106"; //企业必须 企业经营地区码
            addOpenDivideAccounts.businessAddress = "四川省成都市金牛区星辉西路9号1栋7层11号"; //企业必须 企业经营详细地址
            addOpenDivideAccounts.regAddressCode = "510106"; //企业必须 企业注册地址地区码
            addOpenDivideAccounts.regAddress = "四川省成都市金牛区星辉西路9号1栋7层11号"; //企业必须 企业注册详细地址
            // addOpenDivideAccounts.compTel=""; //非必须 固定电话
            addOpenDivideAccounts.businessMcc = "4816"; //企业必须 经营范围mcc
            List<ImageItem> imageList = new List<ImageItem>();
            ImageItem imageItem = new ImageItem();
            //身份证正面
            JsonData tokenInfo = new JsonData();
            tokenInfo = JsonMapper.ToObject(HaoDaHelper.Instance.GetToken("/static/upload/2023/8/14/1.jpg".Substring("/static/upload/2023/8/14/1.jpg".LastIndexOf("/")).Trim('/'), "0", AddInfo.BrandId));
            if (tokenInfo["code"].ToString() == "1")
            {
                var returnInfo = HaoDaHelper.Instance.ReturnFileName(tokenInfo["token"].ToString(), "/static/upload/2023/8/14/1.jpg", AddInfo.BrandId);
                if (returnInfo != "false")
                {
                    imageItem = new ImageItem();
                    imageItem.name = "idCardFront";
                    imageItem.value = returnInfo;
                    imageList.Add(imageItem);
                }
            }
            //身份证反面
            tokenInfo = JsonMapper.ToObject(HaoDaHelper.Instance.GetToken("/static/upload/2023/8/14/2.jpg".Substring("/static/upload/2023/8/14/2.jpg".LastIndexOf("/")).Trim('/'), "0", AddInfo.BrandId));
            if (tokenInfo["code"].ToString() == "1")
            {
                var returnInfo = HaoDaHelper.Instance.ReturnFileName(tokenInfo["token"].ToString(), "/static/upload/2023/8/14/2.jpg", AddInfo.BrandId);
                if (returnInfo != "false")
                {
                    imageItem = new ImageItem();
                    imageItem.name = "idCardBack";
                    imageItem.value = returnInfo;
                    imageList.Add(imageItem);
                }
            }
            //法人手持身份证正面
            tokenInfo = JsonMapper.ToObject(HaoDaHelper.Instance.GetToken("/static/upload/2023/8/14/3.jpg".Substring("/static/upload/2023/8/14/3.jpg".LastIndexOf("/")).Trim('/'), "0", AddInfo.BrandId));
            if (tokenInfo["code"].ToString() == "1")
            {
                var returnInfo = HaoDaHelper.Instance.ReturnFileName(tokenInfo["token"].ToString(), "/static/upload/2023/8/14/3.jpg", AddInfo.BrandId);
                if (returnInfo != "false")
                {
                    imageItem = new ImageItem();
                    imageItem.name = "personWithIdCard";
                    imageItem.value = returnInfo;
                    imageList.Add(imageItem);
                }
            }
            //结算银行卡照片
            tokenInfo = JsonMapper.ToObject(HaoDaHelper.Instance.GetToken("/static/upload/2023/8/14/00.jpg".Substring("/static/upload/2023/8/14/00.jpg".LastIndexOf("/")).Trim('/'), "0", AddInfo.BrandId));
            if (tokenInfo["code"].ToString() == "1")
            {
                var returnInfo = HaoDaHelper.Instance.ReturnFileName(tokenInfo["token"].ToString(), "/static/upload/2023/8/14/00.jpg", AddInfo.BrandId);
                if (returnInfo != "false")
                {
                    imageItem = new ImageItem();
                    imageItem.name = "bankCard";
                    imageItem.value = returnInfo;
                    imageList.Add(imageItem);
                }
            }
            //营业执照
            tokenInfo = JsonMapper.ToObject(HaoDaHelper.Instance.GetToken("/static/upload/2023/8/14/5.jpg".Substring("/static/upload/2023/8/14/5.jpg".LastIndexOf("/")).Trim('/'), "0", AddInfo.BrandId));
            if (tokenInfo["code"].ToString() == "1")
            {
                var returnInfo = HaoDaHelper.Instance.ReturnFileName(tokenInfo["token"].ToString(), "/static/upload/2023/8/14/5.jpg", AddInfo.BrandId);
                if (returnInfo != "false")
                {
                    imageItem = new ImageItem();
                    imageItem.name = "license";
                    imageItem.value = returnInfo;
                    imageList.Add(imageItem);
                }
            }
            //开户许可证(对公凭证)
            tokenInfo = JsonMapper.ToObject(HaoDaHelper.Instance.GetToken("/static/upload/2023/8/14/00.jpg".Substring("/static/upload/2023/8/14/00.jpg".LastIndexOf("/")).Trim('/'), "0", AddInfo.BrandId));
            if (tokenInfo["code"].ToString() == "1")
            {
                var returnInfo = HaoDaHelper.Instance.ReturnFileName(tokenInfo["token"].ToString(), "/static/upload/2023/8/14/00.jpg", AddInfo.BrandId);
                if (returnInfo != "false")
                {
                    imageItem = new ImageItem();
                    imageItem.name = "openAccountLicenses";
                    imageItem.value = returnInfo;
                    imageList.Add(imageItem);
                }
            }

            addOpenDivideAccounts.images = imageList; //图片
            return addOpenDivideAccounts;
        }
    }
}