lock_order_designer.lua 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---
  2. --- Generated by EmmyLua(https://github.com/EmmyLua)
  3. --- Created by jlutt.
  4. --- DateTime: 2020-12-21 11:17
  5. --- 修图人员暂停重启订单数量变更
  6. local orderKey = KEYS[1]
  7. local imageKey = KEYS[2]
  8. local idUser = ARGV[1]
  9. local userMax = tonumber(ARGV[2])
  10. local imagePCount = tonumber(ARGV[3])
  11. local iKind = tonumber(ARGV[4])
  12. local nowCount = tonumber(redis.call('HGET', orderKey, idUser))
  13. if (nowCount == nil) then
  14. nowCount = 0
  15. end
  16. local afterNum = -1;
  17. if (iKind == 0) then
  18. -- 正常的分配或者处理
  19. --- 设置P数
  20. if (imagePCount < 0) then
  21. afterNum = redis.call("ZSCORE", imageKey, idUser)
  22. if ((afterNum == nil or tonumber(afterNum) <= 0)) then
  23. afterNum = 0
  24. else
  25. afterNum = redis.call("ZINCRBY", imageKey, imagePCount, idUser)
  26. end
  27. else
  28. afterNum = redis.call("ZINCRBY", imageKey, imagePCount, idUser)
  29. end
  30. elseif (iKind > 0) then
  31. --- 暂停
  32. if (nowCount < userMax) then
  33. afterNum = tonumber(redis.call("HINCRBY", orderKey, idUser, 1))
  34. --- 设置P数
  35. redis.call("ZINCRBY", imageKey, imagePCount, idUser)
  36. end
  37. else
  38. --- 重启
  39. afterNum = tonumber(redis.call("HINCRBY", orderKey, idUser, -1))
  40. --- 设置P数
  41. redis.call("ZINCRBY", imageKey, imagePCount, idUser)
  42. end
  43. return tostring(afterNum);