public ActionResult AddOrderChannellink(ThirdPartyOrderChannelModel channelModel, List <ThirdPartyOrderChannellinkModel> linkList)
        {
            Encoding gb2312          = Encoding.GetEncoding("GB2312");
            string   s               = Pinyin.ConvertEncoding(channelModel.OrderChannel, Encoding.UTF8, gb2312);
            string   orderChannelEng = Pinyin.GetInitials(s, gb2312).Replace("_", "");

            foreach (var item in linkList)
            {
                item.CreateBy     = User.Identity.Name;
                item.LastUpdateBy = User.Identity.Name;
                if (!item.AdditionalRequirement.Contains("无"))
                {
                    if (item.AdditionalRequirement.Contains("IsAggregatePage"))
                    {
                        item.IsAggregatePage = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsAuthorizedLogin"))
                    {
                        item.IsAuthorizedLogin = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsPartnerReceivSilver"))
                    {
                        item.IsPartnerReceivSilver = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsOrderBack"))
                    {
                        item.IsOrderBack = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsViewOrders"))
                    {
                        item.IsViewOrders = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsViewCoupons"))
                    {
                        item.IsViewCoupons = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsContactUserService"))
                    {
                        item.IsContactUserService = true;
                    }
                    if (item.AdditionalRequirement.Contains("IsBackTop"))
                    {
                        item.IsBackTop = true;
                    }
                }
                else
                {
                    continue;
                }
            }
            bool isSuccess = ChannellinkManager.AddOrderChannellink(channelModel, orderChannelEng, linkList);

            return(Json(new { data = isSuccess }));
        }
 /// <summary>
 /// 向三方订单渠道表插入第三方订单渠道key
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int AddThirdPartyOrderChannel(ThirdPartyOrderChannelModel model)
 {
     try
     {
         return(DataAccess.DAO.DALThirdPartyOrderChannelLink.AddThirdPartyOrderChannel(model));
     }
     catch (Exception ex)
     {
         Logger.Error("AddThirdPartyOrderChannel", ex);
         throw ex;
     }
 }
        /// <summary>
        /// 插入第三方订单渠道key
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int AddThirdPartyOrderChannel(ThirdPartyOrderChannelModel model)
        {
            var sql = @"INSERT INTO Tuhu_thirdparty.[dbo].[tbl_ThirdPartyOrderChannel]
                                ( OrderChannel
                                 ,CreateDatetime
                                 ,LastUpdateDateTime
                                )
                        VALUES  ( @OrderChannel , 
                                  GETDATE() ,
                                  GETDATE()
                                 )
                        SELECT  SCOPE_IDENTITY();";

            using (var conn = new SqlConnection(ConnectionHelper.GetDecryptConn("ThirdParty")))
            {
                var parameters = new[]
                {
                    new SqlParameter("@OrderChannel", model.OrderChannel),
                };
                return(Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, parameters)));
            }
        }
        /// <summary>
        /// 添加渠道链接
        /// </summary>
        /// <param name="channelModel"></param>
        /// <param name="linkList"></param>
        /// <returns></returns>
        public bool AddOrderChannellink(ThirdPartyOrderChannelModel channelModel, string orderChannelEng, List <ThirdPartyOrderChannellinkModel> linkList)
        {
            int    orderChanneID = 0;            //订单渠道key的PKID
            int    linkCount     = 0;            //某订单渠道key下已拥有的渠道链接条数
            int    recordCount   = 0;
            string channelEng    = string.Empty; //订单渠道key简称
            string channel       = channelModel.OrderChannel;
            string source        = string.Empty; //第三方id
            bool   isSuccess     = false;
            //判断是否有与orderChannel相等的订单渠道key
            var orderLinkList = GetTPOrderChannellinkList(out recordCount, channel, "");

            if (orderLinkList.Count >= 1)
            {
                orderChanneID = orderLinkList[0].OrderChanneID;
                channelEng    = orderLinkList[0].OrderChannelEngName.Split('_')[0] + "_" + orderLinkList[0].OrderChannelEngName.Split('_')[1];
                foreach (var item in linkList)
                {
                    linkCount = GetOrderChannelLinkByOrderChanneID(orderChanneID).Count + 1;
                    item.OrderChannelEngName = source = channelEng + "_" + linkCount;
                    item.OrderChanneID       = orderChanneID;
                    if (item.InitialPagelink.IndexOf('?') >= 0)
                    {
                        item.FinalPagelink = "https://wx.tuhu.cn/link/" + source + ".html?url=" + Uri.EscapeDataString(item.InitialPagelink + "&source=" + source);
                    }
                    else
                    {
                        item.FinalPagelink = "https://wx.tuhu.cn/link/" + source + ".html?url=" + Uri.EscapeDataString(item.InitialPagelink + "?source=" + source);
                    }
                    isSuccess = AddThirdPartyOrderChannellink(item);
                }
            }
            else
            {
                orderChanneID = AddThirdPartyOrderChannel(channelModel);
                //判断是否有与orderChannelEng相同的拼音
                var diffPinYinCount = GetTPOrderChannelDiffPinYin(orderChannelEng);
                if (diffPinYinCount == 0)
                {
                    channelEng = orderChannelEng + "_1";
                }
                else
                {
                    channelEng = orderChannelEng + "_" + (diffPinYinCount + 1);
                }
                foreach (var item in linkList)
                {
                    linkCount = GetOrderChannelLinkByOrderChanneID(orderChanneID).Count + 1;
                    item.OrderChannelEngName = source = channelEng + "_" + linkCount;
                    item.OrderChanneID       = orderChanneID;
                    if (item.InitialPagelink.IndexOf('?') >= 0)
                    {
                        item.FinalPagelink = "https://wx.tuhu.cn/link/" + source + ".html?url=" + Uri.EscapeDataString(item.InitialPagelink + "&source=" + source);
                    }
                    else
                    {
                        item.FinalPagelink = "https://wx.tuhu.cn/link/" + source + ".html?url=" + Uri.EscapeDataString(item.InitialPagelink + "?source=" + source);
                    }
                    isSuccess = AddThirdPartyOrderChannellink(item);
                }
            }
            return(isSuccess);
        }