Goodslabel.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\shop\controller;
  11. use app\model\goods\GoodsLabel as GoodsLabelModel;
  12. class GoodsLabel extends BaseShop
  13. {
  14. /**
  15. * 商品分组列表
  16. */
  17. public function lists()
  18. {
  19. if (request()->isAjax()) {
  20. $page_index = input('page', 1);
  21. $page_size = input('page_size', PAGE_LIST_ROWS);
  22. $search_keys = input('search_keys', "");
  23. $condition = [];
  24. $condition[] = ['site_id', '=', $this->site_id];
  25. if (!empty($search_keys)) {
  26. $condition[] = ['label_name', 'like', '%' . $search_keys . '%'];
  27. }
  28. //排序
  29. $link_sort = input('order', 'sort');
  30. $sort = input('sort', 'desc');
  31. if($link_sort == 'sort'){
  32. $order_by = $link_sort . ' ' . $sort;
  33. }else{
  34. $order_by = $link_sort . ' ' . $sort.',sort desc';
  35. }
  36. $goods_attr_model = new GoodsLabelModel();
  37. $list = $goods_attr_model->getLabelPageList($condition, $page_index, $page_size, $order_by);
  38. return $list;
  39. } else {
  40. return $this->fetch('goodslabel/lists');
  41. }
  42. }
  43. /**
  44. * 商品分组添加
  45. */
  46. public function add()
  47. {
  48. if (request()->isAjax()) {
  49. $label_name = input('label_name', '');
  50. $data = [
  51. 'site_id' => $this->site_id,
  52. 'label_name' => $label_name,
  53. 'desc' => input('desc', 0)
  54. ];
  55. $model = new GoodsLabelModel();
  56. $res = $model->addLabel($data);
  57. return $res;
  58. }
  59. }
  60. /**
  61. * 商品分组编辑
  62. */
  63. public function edit()
  64. {
  65. if (request()->isAjax()) {
  66. $data = [
  67. 'id' => input('id', ''),
  68. 'site_id' => $this->site_id,
  69. 'label_name' => input('label_name', ''),
  70. 'desc' => input('desc', 0)
  71. ];
  72. $model = new GoodsLabelModel();
  73. $res = $model->editLabel($data);
  74. return $res;
  75. }
  76. }
  77. /**
  78. * 商品分组删除
  79. */
  80. public function delete()
  81. {
  82. if (request()->isAjax()) {
  83. $id = input("id", 0);
  84. $model = new GoodsLabelModel();
  85. $result = $model->deleteLabel([['id', '=', $id], ['site_id', '=', $this->site_id]]);
  86. return $result;
  87. }
  88. }
  89. /**
  90. * 修改排序
  91. */
  92. public function modifySort()
  93. {
  94. if (request()->isAjax()) {
  95. $sort = input("sort", 0);
  96. $id = input("id", 0);
  97. $model = new GoodsLabelModel();
  98. $result = $model->modifySort($sort, $id, $this->site_id);
  99. return $result;
  100. }
  101. }
  102. }