Blame view

src/rdsscripts/insertEmail.lua 1.1 KB
dc9d814f   zhouhaihai   邮件
1
2
3
4
5
6
7
8
9
  local EMAIL_LIMIT = KEYS[1]
  local roleId = KEYS[2]
  local emailId = KEYS[3] or 0
  local createTime = KEYS[4]
  local con = KEYS[5] or cmsgpack.pack({})
  local att = KEYS[6] or cmsgpack.pack({})
  local title = KEYS[7] or ""
  local content = KEYS[8] or ""
  local attachments = KEYS[9] or ""
314bc5df   zhengshouren   提交服务器初始代码
10
  
dc9d814f   zhouhaihai   邮件
11
12
  
  -- local roleInfo = redis.call("HGET", string.format("role:%d", roleId), "delete")
314bc5df   zhengshouren   提交服务器初始代码
13
14
15
  
  -- if tonumber(roleInfo) == 1 then return end
  
dc9d814f   zhouhaihai   邮件
16
17
18
  local id = redis.call("HINCRBY", string.format("role:%d:autoincr", roleId), "email", 1)
  redis.call("LPUSH", string.format("role:%d:emailIds", roleId), id)
  local deleteIds = redis.call("LRANGE", string.format("role:%d:emailIds", roleId), EMAIL_LIMIT, -1)
314bc5df   zhengshouren   提交服务器初始代码
19
  for _, deleteId in ipairs(deleteIds) do
dc9d814f   zhouhaihai   邮件
20
  	redis.call("DEL", string.format("email:%d:%d", roleId, deleteId))
314bc5df   zhengshouren   提交服务器初始代码
21
22
  end
  
dc9d814f   zhouhaihai   邮件
23
24
25
26
27
28
29
30
31
32
33
34
  redis.call("LTRIM", string.format("role:%d:emailIds", roleId), 0, EMAIL_LIMIT - 1)
  redis.call("HMSET", string.format("email:%d:%d", roleId, id), 
  	"id", tostring(id), 
  	"emailId", emailId,
  	"status", "0", 
  	"createtime", createTime,
  	"contentPms", con, 
  	"rewardPms", att, 
  	"title", title, 
  	"content", content, 
  	"attachments", attachments
  )