Exemplo n.º 1
0
        /// <summary>
        /// 修改会员信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateCustInfo(CustModel model)
        {
            var sqlStr = new StringBuilder("update cust_info set ");
            sqlStr.Append(Helper.CreateField(model).Trim().TrimEnd(','));
            sqlStr.Append(" where innerid = @innerid");

            using (var conn = Helper.GetConnection())
            {
                var tran = conn.BeginTransaction();
                try
                {
                    conn.Execute(sqlStr.ToString(), model, tran);
                    tran.Commit();
                    return 1;
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    return 0;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <returns></returns>
        public int CustRegister(CustModel userInfo)
        {
            //插入账户基本信息
            const string sql = @"INSERT INTO cust_info(innerid, custname, password, mobile, telephone, email, headportrait, status, authstatus, provid, cityid, area, sex, brithday, qq, signature, totalpoints, level, type, recommendedid, createdtime)
                        VALUES (@innerid, @custname, @password, @mobile, @telephone, @email, @headportrait, @status, @authstatus, @provid, @cityid, @area, @sex, @brithday, @qq, @signature, @totalpoints, @level, @type, @recommendedid, @createdtime);";
            using (var conn = Helper.GetConnection())
            {
                var tran = conn.BeginTransaction();
                try
                {
                    //获取销售编号
                    if (userInfo.Wechat != null)
                    {
                        userInfo.RecommendedId = conn.Query<string>("select scenestr from wechat_friend where openid=@openid;", new { openid = userInfo.Wechat.Openid }).FirstOrDefault();
                    }

                    //插入会员信息
                    conn.Execute(sql, userInfo, tran);

                    //插入会员的总数信息
                    const string sqlTotal = "insert into cust_total_info (innerid, custid) values (uuid(),@custid);";
                    conn.Execute(sqlTotal, new { custid = userInfo.Innerid }, tran);

                    //插入关联
                    if (userInfo.Wechat != null)
                    {
                        const string sqlwechat =
                            @"INSERT INTO cust_wechat(innerid,custid,openid,createdtime) VALUES(uuid(),@custid,@openid,@createdtime);";
                        conn.Execute(sqlwechat, new
                        {
                            custid = userInfo.Innerid,
                            openid = userInfo.Wechat.Openid,
                            createdtime = userInfo.Createdtime
                        }, tran);
                    }
                    tran.Commit();
                    return 1;
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    return 0;
                }
            }
        }
Exemplo n.º 3
0
 public ActionResult CheckBusinessLogin(CustModel customerinfo)
 {
     Session.Timeout = 120;
     Session["CustModel"] = customerinfo;
     return Json(new { code = 1, message = "登录成功" });
 }