///<summary>
 /// 用户地址创建
 ///</summary>
 ///<param name="o">UserAddress</param>
 ///<returns></returns>
 public int UserAddressCreate(UserAddress o)
 {
     return(Try(nameof(UserAddressCreate), () =>
     {
         var cmd = SqlBuilder.Insert("UserAddress")
                   .Column("UserId", o.UserId)
                   .Column("GroupId", o.GroupId)
                   .Column("Consignee", o.Consignee)
                   .Column("CompanyName", o.CompanyName)
                   .Column("CountryId", o.CountryId)
                   .Column("RegionId", o.RegionId)
                   .Column("Province", o.Province)
                   .Column("City", o.City)
                   .Column("District", o.District)
                   .Column("Street", o.Street)
                   .Column("PostalCode", o.PostalCode)
                   .Column("Phone", o.Phone)
                   .Column("Mobile", o.Mobile)
                   .Column("IsDefault", o.IsDefault)
                   .Column("CreatedOn", o.CreatedOn)
                   .Column("ModifiedBy", o.ModifiedBy)
                   .Column("ModifiedOn", o.ModifiedOn)
                   .ToCommand(true);
         return PassportConn.ExecuteScalar <int>(cmd);
     }));
 }
        /// <summary>
        /// 用户Id获取
        /// 用于验证使用第三方帐号登录的用户是否已在系统内创建
        /// </summary>
        /// <param name="name">用户名</param>
        /// <param name="createdBy">创建者</param>
        /// <returns></returns>
        public int UserIdGet(string name, string createdBy)
        {
            return(Try(nameof(UserIdGet), () =>
            {
                var sql = @"select id from user where name=@name and createdBy=@createdBy";

                var cmd = SqlBuilder.Raw(sql, new { name, createdBy }).ToCommand();

                return PassportConn.ExecuteScalar <int>(cmd);
            }));
        }
        /// <summary>
        /// 用户Id获取
        /// </summary>
        /// <param name="uid">用户名/绑定邮箱/绑定手机号</param>
        /// <returns></returns>
        public int UserIdGet(string uid)
        {
            return(Try(nameof(UserIdGet), () =>
            {
                var sql = @"select id from user where name=@uid or mobile=@uid or email=@uid limit 1";

                var cmd = SqlBuilder.Raw(sql, new { uid }).ToCommand();

                return PassportConn.ExecuteScalar <int>(cmd);
            }));
        }
 ///<summary>
 /// 用户收藏信息创建
 ///</summary>
 ///<param name="o">用户收藏信息</param>
 ///<returns></returns>
 public int UserFavoriteCreate(UserFavorite o)
 {
     return(Try(nameof(UserFavoriteCreate), () =>
     {
         var cmd = SqlBuilder.Insert("UserFavorite")
                   .Column("UserId", o.UserId)
                   .Column("GroupId", o.GroupId)
                   .Column("Name", o.Name)
                   .Column("Value", o.Value)
                   .Column("Extra", o.Extra)
                   .Column("CreatedOn", o.CreatedOn)
                   .Column("ModifiedBy", o.ModifiedBy)
                   .Column("ModifiedOn", o.ModifiedOn)
                   .ToCommand(true);
         return PassportConn.ExecuteScalar <int>(cmd);
     }));
 }
 ///<summary>
 /// 用户发票模版创建
 ///</summary>
 ///<param name="o">用户发票模版</param>
 ///<returns></returns>
 public int UserInvoiceCreate(UserInvoice o)
 {
     return(Try(nameof(UserInvoiceCreate), () =>
     {
         var cmd = SqlBuilder.Insert("UserInvoice")
                   .Column("UserId", o.UserId)
                   .Column("GroupId", o.GroupId)
                   .Column("Title", o.Title)
                   .Column("Content", o.Content)
                   .Column("IsDefault", o.IsDefault)
                   .Column("CreatedOn", o.CreatedOn)
                   .Column("ModifiedBy", o.ModifiedBy)
                   .Column("ModifiedOn", o.ModifiedOn)
                   .ToCommand(true);
         return PassportConn.ExecuteScalar <int>(cmd);
     }));
 }
 ///<summary>
 /// 用户预注册信息创建
 ///</summary>
 ///<param name="o">用户预注册信息</param>
 ///<returns></returns>
 public int UserPreCreate(UserPre o)
 {
     return(Try(nameof(UserPreCreate), () =>
     {
         var cmd = SqlBuilder.Insert("UserPre")
                   .Column("Id", o.Id)
                   .Column("Name", o.Name)
                   .Column("Password", o.Password)
                   .Column("Browser", o.Browser)
                   .Column("UserAgent", o.UserAgent)
                   .Column("IpAddress", o.IpAddress)
                   .Column("UrlReferrer", o.UrlReferrer)
                   .Column("MediaId", o.MediaId)
                   .Column("TraceCode", o.TraceCode)
                   .Column("CreatedOn", o.CreatedOn)
                   .ToCommand(true);
         return PassportConn.ExecuteScalar <int>(cmd);
     }));
 }