Blame view

src/rdsscripts/insertEmail.lua 1.17 KB
dc9d814f   zhouhaihai   邮件
1
2
3
4
  local EMAIL_LIMIT = KEYS[1]
  local roleId = KEYS[2]
  local emailId = KEYS[3] or 0
  local createTime = KEYS[4]
3df73a9e   zhouhaihai   复兴奖励
5
6
  local contentPms = KEYS[5] or cmsgpack.pack({})
  local rewardPms = KEYS[6] or cmsgpack.pack({})
dc9d814f   zhouhaihai   邮件
7
  local title = KEYS[7] or ""
eb4b0152   zhouhaihai   邮件增加 stitle
8
9
10
  local stitle = KEYS[8] or ""
  local content = KEYS[9] or ""
  local attachments = KEYS[10] or ""
314bc5df   zhengshouren   提交服务器初始代码
11
  
dc9d814f   zhouhaihai   邮件
12
13
  
  -- local roleInfo = redis.call("HGET", string.format("role:%d", roleId), "delete")
314bc5df   zhengshouren   提交服务器初始代码
14
15
16
  
  -- if tonumber(roleInfo) == 1 then return end
  
dc9d814f   zhouhaihai   邮件
17
18
19
  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   提交服务器初始代码
20
  for _, deleteId in ipairs(deleteIds) do
dc9d814f   zhouhaihai   邮件
21
  	redis.call("DEL", string.format("email:%d:%d", roleId, deleteId))
314bc5df   zhengshouren   提交服务器初始代码
22
23
  end
  
dc9d814f   zhouhaihai   邮件
24
25
26
27
28
29
  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,
3df73a9e   zhouhaihai   复兴奖励
30
31
  	"contentPms", contentPms, 
  	"rewardPms", rewardPms, 
dc9d814f   zhouhaihai   邮件
32
  	"title", title, 
eb4b0152   zhouhaihai   邮件增加 stitle
33
  	"stitle", stitle, 
dc9d814f   zhouhaihai   邮件
34
35
36
  	"content", content, 
  	"attachments", attachments
  )