shopAdapt.lua 843 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --[[
  2. Descripttion:商城配置
  3. version:
  4. Author: Neo,Huang
  5. Date: 2022-08-19 17:36:25
  6. LastEditors: Neo,Huang
  7. LastEditTime: 2022-08-31 20:25:35
  8. --]]
  9. local baseAdapt = require "base.baseAdapt"
  10. local root = {}
  11. -- 商品信息
  12. function root:goods_get_info(gid)
  13. if gid == nil then
  14. return
  15. end
  16. local shConf = baseAdapt:getConfig("GoodsConfig")
  17. for k, v in ipairs(shConf) do
  18. if v.id == gid then
  19. return v
  20. end
  21. end
  22. end
  23. -- 获取商品价格
  24. function root:goods_get_rmb(gid)
  25. local conf = self:goods_get_info(gid)
  26. if conf and conf.rmb then
  27. return conf.rmb
  28. end
  29. return 0
  30. end
  31. -- 商品物品
  32. function root:goods_get_items(gid)
  33. local conf = self:goods_get_info(gid)
  34. if conf and not is_empty(conf.items) then
  35. return table.copy(conf.items)
  36. end
  37. end
  38. return root