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

UpdateCustWeChatPayBack() public method

支付回调更新会员信息
public UpdateCustWeChatPayBack ( string orderNo ) : int
orderNo string
return int
        public int UpdateCustWeChatPayBack(string orderNo)
        {
            var expirestime = DateTime.Now;

            //更新订单状态为已支付
            const string sqlU = "update cust_wxpay_info set status=2 where orderno=@orderno;";
            //更新会员状态 level 为 1是正式VIP,2是体验版VIP
            const string sqlL = "update cust_info set level=@level,expirestime=@expirestime where innerid=@innerid;";

            using (var conn = Helper.GetConnection())
            {
                var tran = conn.BeginTransaction();
                try
                {

                    const string sqlCust = "select custid,type from cust_wxpay_info where orderno=@orderno;";
                    var cwp = conn.Query<CustWxPayModel>(sqlCust, new { orderno = orderNo }).FirstOrDefault();

                    if (cwp == null)
                    {
                        return 0;
                    }
                    if (cwp.type == "1")
                    {
                        expirestime = new DateTime(expirestime.AddYears(1).Year, expirestime.Month, expirestime.Day, 23, 59, 59);
                    }
                    else
                    {
                        var days = 7;
                        var bateday = ConfigHelper.GetAppSettings("betavip_day");
                        if (!string.IsNullOrWhiteSpace(bateday))
                            days = Convert.ToInt32(ConfigHelper.GetAppSettings("betavip_day"));

                        expirestime = new DateTime(expirestime.Year, expirestime.Month, expirestime.AddDays(days).Day, 23, 59, 59);
                    }

                    //升级VIP
                    conn.Execute(sqlU, new { orderno = orderNo }, tran);
                    conn.Execute(sqlL, new { innerid = cwp.Custid, level = cwp.type, expirestime }, tran);

                    tran.Commit();
                    return 1;
                }
                catch (Exception ex)
                {
                    LoggerFactories.CreateLogger().Write("支付回调更新会员信息异常:", TraceEventType.Error, ex);
                    tran.Rollback();
                    return 0;
                }
            }
        }