using Library;
using MySystem.Service.Main1;
using System.Collections.Generic;
using MySystem.Service.KxsMain;
using System.Linq;
namespace MySystem.Service.Main1
{
    /// <summary>
    /// 直连商户表工具类
    /// </summary>
    public class MerchantInfoUtil
    {
        #region 通过创客编号查询商户Id
        /// <summary>
        /// 通过创客编号查询商户Id
        /// </summary>
        /// <param name="MakerCode">创客编号</param>
        /// <returns></returns>
        public static string QueryMerchantIdByMakerCode(string MakerCode)
        {
            var info = "";
            var userInfo = UsersService.QueryByMakerCode(MakerCode);
            if (userInfo.Id > 0)
            {
                List<RelationData> relationData = new List<RelationData>();
                var merInfo = MerchantInfoService.List(relationData, " and UserId=" + userInfo.Id + "", 1, 9999);
                var merIds = "";
                foreach (Dictionary<string, object> dic in merInfo)
                {
                    var MerchantId = int.Parse(dic["Id"].ToString());
                    merIds += MerchantId + ",";
                }
                info = merIds.TrimEnd(',');
            }
            else
            {
                return "创客编号" + MakerCode + "不存在";
            }
            return info;
        }
        #endregion

        #region 通过主体类型查询商户Id
        /// <summary>
        /// 通过主体类型查询商户Id
        /// </summary>
        /// <param name="SubjectType">主体类型</param>
        /// <returns></returns>
        public static string QueryMerchantIdBySubjectType(string SubjectType)
        {
            var info = "";
            List<RelationData> relationData = new List<RelationData>();
            var merAddInfo = MerchantAddInfoService.List(relationData, " and SubjectType='" + SubjectType + "'", 1, 999999);
            if (merAddInfo.Count > 0)
            {
                var merIds = "";
                foreach (Dictionary<string, object> dic in merAddInfo)
                {
                    var MerchantId = int.Parse(dic["Id"].ToString());
                    merIds += MerchantId + ",";
                }
                info = merIds.TrimEnd(',');
            }
            return info;
        }
        #endregion

        #region 获取已提交商户Id
        /// <summary>
        /// 获取已提交商户Id
        /// </summary>
        /// <returns></returns>
        public static string QuerySenedMerchantId()
        {
            var info = "";
            List<RelationData> relationData = new List<RelationData>();
            var merInfo = MerchantInfoService.List(relationData, " and Sort=1", 1, 9999999);
            if (merInfo.Count > 0)
            {
                var merIds = "";
                foreach (Dictionary<string, object> dic in merInfo)
                {
                    var MerchantId = int.Parse(dic["Id"].ToString());
                    merIds += MerchantId + ",";
                }
                info = merIds.TrimEnd(',');
            }
            return info;
        }
        #endregion


        #region 获取某一方已通过的商户Id
        /// <summary>
        /// 获取某一方已通过的商户Id
        /// </summary>
        /// <returns></returns>
        public static string QueryAnyIsOkMerchantId()
        {
            var info = "";
            List<RelationData> relationData = new List<RelationData>();
            var merInfo = MerchantInfoService.List(relationData, " and (Status=2 or QueryCount=2)", 1, 9999999);
            if (merInfo.Count > 0)
            {
                var merIds = "";
                foreach (Dictionary<string, object> dic in merInfo)
                {
                    var MerchantId = int.Parse(dic["Id"].ToString());
                    merIds += MerchantId + ",";
                }
                info = merIds.TrimEnd(',');
            }
            return info;
        }
        #endregion

        #region 获取是否激活商户Id
        /// <summary>
        /// 获取是否激活商户Id
        /// </summary>
        /// <param name="IsAct">激活状态(0 未激活 1 已激活)</param>
        /// <returns></returns>
        public static string QueryIsActMerchantId(int IsAct)
        {
            var info = "";
            List<RelationData> relationData = new List<RelationData>();
            var merInfo = MerchantInfoService.List(relationData, " and IsAct=" + IsAct + "", 1, 9999999);
            if (merInfo.Count > 0)
            {
                var merIds = "";
                foreach (Dictionary<string, object> dic in merInfo)
                {
                    var MerchantId = int.Parse(dic["Id"].ToString());
                    merIds += MerchantId + ",";
                }
                info = merIds.TrimEnd(',');
            }
            return info;
        }
        #endregion

        #region 获取指定时间段激活商户Id
        /// <summary>
        /// 获取指定时间段激活商户Id
        /// </summary>
        /// <param name="StartDate">开始时间</param>
        /// <param name="EndDate">结束时间</param>
        /// <returns></returns>
        public static string QueryActDateMerchantId(string StartDate,string EndDate)
        {
            var info = "";
            List<RelationData> relationData = new List<RelationData>();
            var merInfo = MerchantInfoService.List(relationData, " and UpdateDate>='" + StartDate + " 00:00:00' and UpdateDate<='" + EndDate + " 23:59:59'", 1, 9999999);
            if (merInfo.Count > 0)
            {
                var merIds = "";
                foreach (Dictionary<string, object> dic in merInfo)
                {
                    var MerchantId = int.Parse(dic["MerchantId"].ToString());
                    merIds += MerchantId + ",";
                }
                info = merIds.TrimEnd(',');
            }
            return info;
        }
        #endregion

        #region 主体类型
        /// <summary>
        /// 主体类型
        /// </summary>
        /// <returns></returns>
        public static Dictionary<string, string> GetSubjects()
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("SUBJECT_TYPE_INDIVIDUAL", "个体户");
            dic.Add("SUBJECT_TYPE_ENTERPRISE", "企业");
            // dic.Add("SUBJECT_TYPE_INSTITUTIONS", "党政、机关及事业单位");
            // dic.Add("SUBJECT_TYPE_OTHERS", "其他组织");
            return dic;
        }
        #endregion

        #region 通过主体类型获取经营类型
        /// <summary>
        /// 通过主体类型获取经营类型
        /// </summary>
        /// <param name="Kind"></param>
        /// <returns></returns>
        public static List<SettleData> GetSettles(string Kind)
        {
            if (Kind == "SUBJECT_TYPE_INDIVIDUAL")
            {
                return GetPersonSettleItems();
            }
            return GetBusinessSettleItems();
        }
        #endregion

        #region 个体经营类型
        /// <summary>
        /// 个体经营类型
        /// </summary>
        /// <returns></returns>
        public static List<SettleData> GetPersonSettleItems()
        {
            List<SettleData> dic = new List<SettleData>();
            dic.Add(new SettleData() { ptext = "食品生鲜", text = "肉、禽、蛋及水产品等", value = "719", code = "A0002_B0202" });
            dic.Add(new SettleData() { ptext = "健身运动服务", text = "健身房", value = "719", code = "A0004_B0064" });
            dic.Add(new SettleData() { ptext = "健身运动服务", text = "体育场馆", value = "719", code = "A0004_B0068" });
            dic.Add(new SettleData() { ptext = "居民生活服务", text = "公共交通", value = "719", code = "A0006_B0088" });
            dic.Add(new SettleData() { ptext = "景区/酒店", text = "旅行住宿", value = "719", code = "A0010_B0157" });
            dic.Add(new SettleData() { ptext = "居民生活服务", text = "生活服务", value = "719", code = "A0003_B0116" });
            dic.Add(new SettleData() { ptext = "零售", text = "百货商城", value = "719", code = "A0002_B0017" });
            dic.Add(new SettleData() { ptext = "服饰鞋包", text = "服饰鞋包", value = "719", code = "A0002_B0026" });
            dic.Add(new SettleData() { ptext = "零售", text = "家居家纺建材", value = "719", code = "A0002_B0216" });
            dic.Add(new SettleData() { ptext = "零售", text = "母婴玩具", value = "719", code = "A0002_B0032" });
            dic.Add(new SettleData() { ptext = "零售", text = "数码家电", value = "719", code = "A0003_B0051" });
            dic.Add(new SettleData() { ptext = "零售", text = "图书音像", value = "719", code = "A0002_B0031" });
            dic.Add(new SettleData() { ptext = "居民生活服务", text = "文化玩乐宠物", value = "719", code = "A0004_B0070" });
            dic.Add(new SettleData() { ptext = "咨询/娱乐票务", text = "娱乐票务", value = "719", code = "A0004_B0065" });
            dic.Add(new SettleData() { ptext = "零售", text = "办公用品", value = "719", code = "A0002_B0203" });
            dic.Add(new SettleData() { ptext = "零售", text = "工业产品", value = "719", code = "A0002_B0042" });
            dic.Add(new SettleData() { ptext = "咨询/娱乐票务", text = "专业咨询", value = "719", code = "A0008_B0139" });
            dic.Add(new SettleData() { ptext = "其他", text = "其他类别", value = "716", code = "A0002_B0043" });


            // dic.Add(new SettleData() { ptext = "餐饮", text = "餐饮", code = "C_C05_5814", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "食品生鲜", text = "酒类", code = "C_C05_5921", value = "719", special = 1});
            // dic.Add(new SettleData() { ptext = "食品生鲜", text = "肉、禽、蛋及水产品等", code = "C_C05_5422", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "私立/民营医院/诊所", text = "医疗服务", code = "P_P01_8011", value = "719", special = 1});
            // dic.Add(new SettleData() { ptext = "保健器械/医疗器械/非处方药品", text = "药品、药品经营者（批发商）", code = "B_B04_5122", value = "719", special = 1});
            // dic.Add(new SettleData() { ptext = "保健器械/医疗器械/非处方药品", text = "医疗器械", code = "B_B04_5047", value = "719", special = 1});
            // dic.Add(new SettleData() { ptext = "游艺厅/KTV/网吧", text = "游艺厅/KTV", code = "D_D01_7999", value = "719", special = 1});
            // dic.Add(new SettleData() { ptext = "游艺厅/KTV/网吧", text = "网吧", code = "D_D01_7999", value = "719", special = 1});
            // dic.Add(new SettleData() { ptext = "宠物医院", text = "宠物及宠物用品", code = "C_C10_5995", value = "719", special = 1});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "公共交通", code = "A_A01_4121", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "旅行住宿", code = "A_A04_7011", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "公共仓储、集装整理", code = "A_A02_4225", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "商业服务", code = "S_S05_7338", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "汽车租赁和服务", code = "S_S10_7512", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "生活服务", code = "S_S08_7295", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "百货商城", code = "C_C04_5411", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "服饰鞋包", code = "C_C06_5699", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "家居家纺建材", code = "C_C03_5211", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "母婴玩具", code = "C_C02_5641", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "数码家电", code = "C_C07_5732", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "图书音像", code = "C_C09_5942", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "文化玩乐宠物", code = "C_C10_5995", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "彩票", code = "D_D03_7995", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "娱乐票务", code = "D_D01_7999", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "法律咨询和律师事务所", code = "P_P04_8111", value = "719", special = 1});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "办公用品", code = "B_B01_5943", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "工业产品", code = "B_B02_5065", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "汽车和运输工具", code = "B_B03_5599", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/其他", text = "专业咨询", code = "P_P04_8999", value = "719", special = 0});
            // dic.Add(new SettleData() { ptext = "话费通讯", text = "话费充值与缴费", code = "D_D04_4815", value = "720", special = 1});
            // dic.Add(new SettleData() { ptext = "加油", text = "加油站、服务站", code = "B_B03_5541", value = "721", special = 1});
            return dic;
        }
        #endregion

        #region 企业经营类型
        /// <summary>
        /// 企业经营类型
        /// </summary>
        /// <returns></returns>
        public static List<SettleData> GetBusinessSettleItems()
        {
            List<SettleData> dic = new List<SettleData>();
            dic.Add(new SettleData() { ptext = "餐饮", text = "餐饮", value = "716", code = "A0001_B0001" });
            dic.Add(new SettleData() { ptext = "食品生鲜", text = "肉、禽、蛋及水产品等", value = "716", code = "A0002_B0202" });
            dic.Add(new SettleData() { ptext = "健身运动服务", text = "健身房", value = "716", code = "A0004_B0064" });
            dic.Add(new SettleData() { ptext = "健身运动服务", text = "体育场馆", value = "716", code = "A0004_B0068" });
            dic.Add(new SettleData() { ptext = "城市公共交通", text = "公共交通", value = "716", code = "A0006_B0088" });
            dic.Add(new SettleData() { ptext = "景区/酒店", text = "旅行住宿", value = "716", code = "A0010_B0157" });
            dic.Add(new SettleData() { ptext = "居民生活服务", text = "生活服务", value = "716", code = "A0003_B0116" });
            dic.Add(new SettleData() { ptext = "零售", text = "百货商城", value = "716", code = "A0002_B0017" });
            dic.Add(new SettleData() { ptext = "服饰鞋包", text = "服饰鞋包", value = "716", code = "A0002_B0026" });
            dic.Add(new SettleData() { ptext = "零售", text = "家居家纺建材", value = "716", code = "A0002_B0216" });
            dic.Add(new SettleData() { ptext = "零售", text = "母婴玩具", value = "716", code = "A0002_B0032" });
            dic.Add(new SettleData() { ptext = "零售", text = "数码家电", value = "716", code = "A0003_B0051" });
            dic.Add(new SettleData() { ptext = "零售", text = "图书音像", value = "716", code = "A0002_B0031" });
            dic.Add(new SettleData() { ptext = "居民生活服务", text = "文化玩乐宠物", value = "716", code = "A0004_B0070" });
            dic.Add(new SettleData() { ptext = "咨询/娱乐票务", text = "娱乐票务", value = "716", code = "A0004_B0065" });
            dic.Add(new SettleData() { ptext = "零售", text = "办公用品", value = "716", code = "A0002_B0203" });
            dic.Add(new SettleData() { ptext = "零售", text = "工业产品", value = "716", code = "A0002_B0042" });
            dic.Add(new SettleData() { ptext = "婚介平台/就业信息平台/其他信息服务平台", text = "婚介服务", value = "720", code = "A0003_B0053" });
            dic.Add(new SettleData() { ptext = "零售", text = "其它类别", value = "716", code = "A0002_B0043" });


            // dic.Add(new SettleData() { ptext = "餐饮", text = "餐饮", code = "C_C05_5814", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "电商平台", text = "电商平台", code = "C_C05_5814", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "食品生鲜", text = "酒类", code = "C_C05_5921", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "食品生鲜", text = "肉、禽、蛋及水产品等", code = "C_C05_5422", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "电信运营商/宽带收费", text = "电信通讯", code = "D_D04_4814", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "私立/民营医院/诊所", text = "医疗服务", code = "P_P01_8011", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "保健器械/医疗器械/非处方药品", text = "医疗器械", code = "B_B04_5047", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "保健器械/医疗器械/非处方药品", text = "药品、药品经营者（批发商）", code = "B_B04_5122", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "游艺厅/KTV/网吧", text = "游艺厅/KTV", code = "D_D01_7999", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "游艺厅/KTV/网吧", text = "网吧", code = "D_D01_7999", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "宠物医院", text = "宠物及宠物用品", code = "C_C10_5995", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "旅行社", text = "旅行社和旅游服务", code = "A_A04_4722", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "宗教组织", text = "宗教物品", code = "C_C10_5973", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "宗教组织", text = "其他宗教服务", code = "P_P04_8999", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "文物经营/文物复制品销售", text = "文物经营/文物复制品销售", code = "C_C10_5971", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "拍卖典当", text = "典当行", code = "S_S04_5933", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "公共交通", code = "A_A01_4121", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "旅行住宿", code = "A_A04_7011", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "公共仓储、集装整理", code = "A_A02_4225", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "商业服务", code = "S_S05_7338", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "汽车租赁和服务", code = "S_S10_7512", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "生活服务", code = "S_S08_7295", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "百货商城", code = "C_C04_5411", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "服饰鞋包", code = "C_C06_5699", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "家居家纺建材", code = "C_C03_5211", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "母婴玩具", code = "C_C02_5641", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "数码家电", code = "C_C07_5732", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "图书音像", code = "C_C09_5942", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "文化玩乐宠物", code = "C_C10_5995", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "彩票", code = "D_D03_7995", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "娱乐票务", code = "D_D01_7999", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "法律咨询和律师事务所", code = "P_P04_8111", value = "716", special = 1});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "办公用品", code = "B_B01_5943", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "工业产品", code = "B_B02_5065", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "汽车和运输工具", code = "B_B03_5599", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "零售批发/生活娱乐/网上商城/其他", text = "专业咨询", code = "P_P04_8999", value = "716", special = 0});
            // dic.Add(new SettleData() { ptext = "话费通讯", text = "话费充值与缴费", code = "D_D04_4815", value = "728", special = 1});
            // dic.Add(new SettleData() { ptext = "婚介平台/就业信息平台/其他", text = "婚介服务", code = "S_S08_7273", value = "728", special = 0});
            // dic.Add(new SettleData() { ptext = "门户论坛/网络广告及推广/软件开发/其他互联网服务", text = "计算机服务/其他", code = "D_D05_7372", value = "711", special = 0});
            // dic.Add(new SettleData() { ptext = "快递", text = "快递服务", code = "A_A02_4215", value = "717", special = 1});
            // dic.Add(new SettleData() { ptext = "加油", text = "加油站、服务站", code = "B_B03_5541", value = "717", special = 1});
            // dic.Add(new SettleData() { ptext = "公共事业（水电煤气）", text = "公共事业（电、气、水）", code = "S_S06_4900", value = "730", special = 1});
            // dic.Add(new SettleData() { ptext = "公共事业（水电煤气）", text = "公共事业-电力缴费", code = "S_S06_4901", value = "730", special = 1});
            // dic.Add(new SettleData() { ptext = "公共事业（水电煤气）", text = "公共事业-煤气缴费", code = "S_S06_4902", value = "730", special = 1});
            // dic.Add(new SettleData() { ptext = "公共事业（水电煤气）", text = "公共事业-自来水缴费", code = "S_S06_4903", value = "730", special = 1});
            return dic;
        }
        #endregion

        #region 账户类型
        /// <summary>
        /// 账户类型
        /// </summary>
        /// <returns></returns>
        public static Dictionary<string, string> GetAccountTypes()
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("BANK_ACCOUNT_TYPE_CORPORATE", "对公银行账户");
            dic.Add("BANK_ACCOUNT_TYPE_PERSONAL", "经营者个人银行卡");
            return dic;
        }
        #endregion
    }
}