string lua = @"local counts=redis.call('HLEN',@yhKey) if tonumber(counts)>=tonumber(@places) then return 2 elseif redis.call('HEXISTS',@yhKey,@bankCard)==1 then return 3 elseif redis.call('EXISTS',@phone)==1 then return 4 elseif redis.call('EXISTS',@card)==1 then return 5 else redis.call('SELECT',8) local waits=redis.call('DBSIZE') if tonumber(counts)+tonumber(waits)<tonumber(@places) then redis.call('SETEX',@order,@expiry,@payEnti) redis.call('SELECT',7) redis.call('SETEX',@phone,@expiry,@payUrl) redis.call('SETEX',@card,@expiry,@bankCard) return 1 else return 6 end end";
string rr = cache.Do(db => db.ScriptEvaluate(LuaScript.Prepare(lua), new { yhKey = "HROKBank", places = conf.HuaRongPlaces,//名额 bankCard = bankCard, card = "HRBank:" + bankCard, phone = "HRPhone:" + user.phoneNo, order = "HROrder:" + OrderNo, expiry = conf.PayTime * 60,//过期时间单位为秒 payEnti = JsonConvert.SerializeObject(m), // OrderNo= OrderNo, payUrl = payUrl })).ToString();