Goodsservice.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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\GoodsService as GoodsServiceModel;
  12. class Goodsservice 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[] = [ 'service_name', 'like', '%' . $search_keys . '%' ];
  27. }
  28. $goods_attr_model = new GoodsServiceModel();
  29. $list = $goods_attr_model->getServicePageList($condition, $page_index, $page_size);
  30. return $list;
  31. } else {
  32. return $this->fetch('goodsservice/lists');
  33. }
  34. }
  35. /**
  36. * 商品服务添加
  37. */
  38. public function add()
  39. {
  40. if (request()->isAjax()) {
  41. $data = [
  42. 'site_id' => $this->site_id,
  43. 'service_name' => input('service_name', ''),
  44. 'desc' => input('desc', 0),
  45. 'icon' => input('icon', '')
  46. ];
  47. $model = new GoodsServiceModel();
  48. $res = $model->addService($data);
  49. return $res;
  50. }
  51. }
  52. /**
  53. * 商品服务编辑
  54. */
  55. public function edit()
  56. {
  57. if (request()->isAjax()) {
  58. $id = input('id', '');
  59. $data = [
  60. 'service_name' => input('service_name', ''),
  61. 'desc' => input('desc', 0),
  62. 'icon' => input('icon', '')
  63. ];
  64. $model = new GoodsServiceModel();
  65. $res = $model->editService($data, [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
  66. return $res;
  67. }
  68. }
  69. /**
  70. * 商品服务删除
  71. */
  72. public function delete()
  73. {
  74. if (request()->isAjax()) {
  75. $id = input("id", 0);
  76. $model = new GoodsServiceModel();
  77. $result = $model->deleteService([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
  78. return $result;
  79. }
  80. }
  81. }