CCN.Modules.Customer.DataAccess.CustomerDA.UpdateOpenid C# (CSharp) Method

UpdateOpenid() public method

更新绑定openid
public UpdateOpenid ( string custid, string openid ) : int
custid string
openid string
return int
        public int UpdateOpenid(string custid, string openid)
        {
            using (var conn = Helper.GetConnection())
            {
                int result;
                const string sqlSelect = "select count(1) from cust_wechat where custid=@custid;";
                var i = conn.Query<int>(sqlSelect, new { custid }).FirstOrDefault();
                if (i == 0)
                {
                    const string sql = "INSERT INTO cust_wechat(innerid,custid,openid,createdtime) VALUES(uuid(),@custid,@openid,@createdtime);";
                    result = Helper.Execute(sql, new
                    {
                        custid,
                        openid,
                        createdtime = DateTime.Now
                    });
                }
                else
                {
                    const string sql = "update cust_wechat set openid=@openid,modifiedtime=@modifiedtime where custid=@custid;";
                    result = Helper.Execute(sql, new
                    {
                        custid,
                        openid,
                        modifiedtime = DateTime.Now
                    });
                }

                return result;
            }
        }