Goodsbrand.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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\admin\controller;
  13. use app\model\goods\GoodsBrand as GoodsBrandModel;
  14. /**
  15. * 商品品牌管理 控制器
  16. */
  17. class Goodsbrand extends BaseAdmin
  18. {
  19. /**
  20. * 商品品牌列表
  21. */
  22. public function lists()
  23. {
  24. if (request()->isAjax()) {
  25. $page_index = input('page', 1);
  26. $page_size = input('page_size', PAGE_LIST_ROWS);
  27. $search_keys = input('search_keys', "");
  28. $condition = [];
  29. if (!empty($search_keys)) {
  30. $condition[] = [ 'ngb.brand_name', 'like', '%' . $search_keys . '%' ];
  31. }
  32. $goods_brand_model = new GoodsBrandModel();
  33. $list = $goods_brand_model->getBrandPageList($condition, $page_index, $page_size);
  34. return $list;
  35. } else {
  36. $this->forthMenu();
  37. return $this->fetch('goodsbrand/lists');
  38. }
  39. }
  40. /**
  41. * 商品品牌添加
  42. */
  43. public function addBrand()
  44. {
  45. if (request()->isAjax()) {
  46. $brand_name = input('brand_name', '');
  47. $brand_initial = input('brand_initial', '');
  48. $image_url = input('image_url', "");
  49. $sort = input('sort', 0);
  50. $is_recommend = input('is_recommend', '');
  51. $data = [
  52. 'brand_name' => $brand_name,
  53. 'brand_initial' => $brand_initial,
  54. 'image_url' => $image_url,
  55. 'sort' => $sort,
  56. 'is_recommend' => $is_recommend
  57. ];
  58. $goods_brand_model = new GoodsBrandModel();
  59. $res = $goods_brand_model->addBrand($data);
  60. $this->addLog("添加商品品牌:" . $brand_name);
  61. return $res;
  62. } else {
  63. return $this->fetch('goodsbrand/add_brand');
  64. }
  65. }
  66. /**
  67. * 商品品牌编辑
  68. */
  69. public function editBrand()
  70. {
  71. $goods_brand_model = new GoodsBrandModel();
  72. if (request()->isAjax()) {
  73. $brand_id = input('brand_id', 0);
  74. $brand_name = input('brand_name', '');
  75. $brand_initial = input('brand_initial', '');
  76. $image_url = input('image_url', "");
  77. $sort = input('sort', 0);
  78. $is_recommend = input('is_recommend', '');
  79. $data = [
  80. 'brand_id' => $brand_id,
  81. 'brand_name' => $brand_name,
  82. 'brand_initial' => $brand_initial,
  83. 'image_url' => $image_url,
  84. 'sort' => $sort,
  85. 'is_recommend' => $is_recommend
  86. ];
  87. $res = $goods_brand_model->editBrand($data);
  88. $this->addLog("编辑商品品牌:" . $brand_name);
  89. return $res;
  90. } else {
  91. $brand_id = input('brand_id', 0);
  92. $brand_info = $goods_brand_model->getBrandInfo([ [ 'brand_id', '=', $brand_id ] ]);
  93. $brand_info = $brand_info['data'];
  94. $this->assign("brand_info", $brand_info);
  95. return $this->fetch('goodsbrand/edit_brand');
  96. }
  97. }
  98. /**
  99. * 商品品牌删除
  100. */
  101. public function deleteBrand()
  102. {
  103. if (request()->isAjax()) {
  104. $brand_ids = input("brand_ids", 0);
  105. $goods_brand_model = new GoodsBrandModel();
  106. $condition = [
  107. [ "brand_id", 'in', $brand_ids ]
  108. ];
  109. $this->addLog("删除商品品牌id:" . $brand_ids);
  110. $res = $goods_brand_model->deleteBrand($condition);
  111. return $res;
  112. }
  113. }
  114. /**
  115. * 修改排序
  116. */
  117. public function modifySort()
  118. {
  119. $sort = input('sort', 0);
  120. $brand_id = input('brand_id', 0);
  121. $goods_brand_model = new GoodsBrandModel();
  122. $res = $goods_brand_model->modifyBrandSort($sort, $brand_id);
  123. return $res;
  124. }
  125. /**
  126. * 转移品牌
  127. */
  128. public function modifySite()
  129. {
  130. $brand_ids = input('brand_ids', 0);
  131. $condition = [
  132. [ "brand_id", 'in', $brand_ids ]
  133. ];
  134. $goods_brand_model = new GoodsBrandModel();
  135. $res = $goods_brand_model->modifyBrandSite(0, $condition);
  136. return $res;
  137. }
  138. }