ShopLevel.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\model\shop;
  13. use think\facade\Cache;
  14. use app\model\BaseModel;
  15. /**
  16. * 店铺等级(暂不考虑)
  17. */
  18. class ShopLevel extends BaseModel
  19. {
  20. /**
  21. * 添加店铺等级
  22. * @param array $data
  23. */
  24. public function addLevel($data)
  25. {
  26. $res = model('shop_level')->add($data);
  27. Cache::tag("shop_level")->clear();
  28. return $this->success($res);
  29. }
  30. /**
  31. * 修改店铺等级
  32. * @param array $data
  33. */
  34. public function editLevel($data)
  35. {
  36. $res = model('shop_level')->update($data, [ 'level_id', '=', $data['level_id'] ]);
  37. //修改对应店铺
  38. model('shop')->update(['level_name' => $data['level_name']], [ 'level_id', '=', $data['level_id'] ]);
  39. Cache::tag("shop_level")->clear();
  40. return $this->success($res);
  41. }
  42. /**
  43. * 删除店铺等级
  44. * @param unknown $condition
  45. */
  46. public function deleteLevel($condition)
  47. {
  48. $res = model('shop_level')->delete($condition);
  49. Cache::tag("shop_level")->clear();
  50. return $this->success($res);
  51. }
  52. /**
  53. * 获取店铺等级信息
  54. * @param unknown $condition
  55. * @param string $field
  56. */
  57. public function getLevelInfo($condition, $field = '*')
  58. {
  59. $data = json_encode([ $condition, $field]);
  60. $cache = Cache::get("shop_level_getLevelInfo_" . $data);
  61. if (!empty($cache)) {
  62. return $this->success($cache);
  63. }
  64. $res = model('shop_level')->getInfo( $condition, $field);
  65. Cache::tag("shop_level")->set("shop_level_getLevelInfo_" . $data, $res);
  66. return $this->success($res);
  67. }
  68. /**
  69. * 获取店铺等级列表
  70. * @param array $condition
  71. * @param string $field
  72. * @param string $order
  73. * @param string $limit
  74. */
  75. public function getLevelList($condition = [], $field = '*', $order = '', $limit = null)
  76. {
  77. $data = json_encode([ $condition, $field, $order, $limit ]);
  78. $cache = Cache::get("shop_level_getLevelList_" . $data);
  79. if (!empty($cache)) {
  80. return $this->success($cache);
  81. }
  82. $list = model('shop_level')->getList($condition, $field, $order, '', '', '', $limit);
  83. Cache::tag("shop_level")->set("shop_level_getLevelList_" . $data, $list);
  84. return $this->success($list);
  85. }
  86. /**
  87. * 获取店铺等级分页列表
  88. * @param array $condition
  89. * @param number $page
  90. * @param string $page_size
  91. * @param string $order
  92. * @param string $field
  93. */
  94. public function getLevelPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*')
  95. {
  96. $data = json_encode([ $condition, $field, $order, $page, $page_size ]);
  97. $cache = Cache::get("shop_level_getLevelPageList_" . $data);
  98. if (!empty($cache)) {
  99. return $this->success($cache);
  100. }
  101. $list = model('shop_level')->pageList($condition, $field, $order, $page, $page_size);
  102. Cache::tag("shop_level")->set("shop_level_getLevelPageList_" . $data, $list);
  103. return $this->success($list);
  104. }
  105. }