Goods - 副本.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\life\GoodsServer;
  5. class Goods extends BaseController
  6. {
  7. /**
  8. * Notes:获取健康超市商品列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/10/09
  12. */
  13. public function getGoodsList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = GoodsServer::getGoodsList($page, $limit, $keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:获取所有角色
  22. * @return \support\Response
  23. * User: ZQ
  24. * Date: 2022/9/19
  25. */
  26. public function getGoodsAll()
  27. {
  28. $result = GoodsServer::getGoodsAll();
  29. return json_success($result, '成功');
  30. }
  31. /**
  32. * Notes:修改健康超市商品
  33. * @return \support\Response
  34. * User: ZQ
  35. * Date: 2022/10/09
  36. */
  37. public function updateGoods()
  38. {
  39. $goods_id = $this->request->post('goods_id');
  40. $goods_name = $this->request->post('goods_name','');
  41. $goods_img = $this->request->post('goods_img','');
  42. $goods_category_id = $this->request->post('goods_category_id','');
  43. $goods_shop_id = $this->request->post('goods_shop_id');
  44. $goods_is_new = $this->request->post('goods_is_new');
  45. $goods_price = $this->request->post('goods_price');
  46. $goods_content = $this->request->post('goods_content');
  47. $goods_sell_num = $this->request->post('goods_sell_num');
  48. $goods_postage_id = $this->request->post('goods_postage_id');
  49. $goods_status = $this->request->post('goods_status');
  50. $goods_weight = $this->request->post('goods_weight');
  51. $goods_sort = $this->request->post('goods_sort');
  52. $goods_slide = $this->request->post('goods_slide','');
  53. $goods_pack_price = $this->request->post('goods_pack_price','');
  54. $food_attr = $this->request->post('goods_attr','');
  55. $food_varieties = $this->request->post('goods_varieties','');
  56. $food_packaging = $this->request->post('goods_packaging','');
  57. $food_storage = $this->request->post('goods_storage','');
  58. $admin_id = $this->request->admin_id;
  59. $this->validateCheck('life\GoodsValidate', ['goods_id' => $goods_id, 'goods_name' => $goods_name, 'goods_img' => $goods_img, 'goods_category_id' => $goods_category_id, 'goods_shop_id' => $goods_shop_id, 'goods_is_new' => $goods_is_new, 'goods_price' => $goods_price, 'goods_content' => $goods_content, 'goods_status' => $goods_status, 'goods_postage_id' => $goods_postage_id], 'update');
  60. $result = GoodsServer::updateGoods($goods_id,$goods_name,$goods_img,$goods_category_id,$goods_shop_id,$goods_is_new,$goods_price,$goods_content,$goods_sell_num,$goods_postage_id,$goods_status,$goods_weight,$goods_sort,$goods_slide,$goods_pack_price,$food_attr,$food_varieties,$food_packaging,$food_storage,$admin_id);
  61. return json_success($result, '修改成功');
  62. }
  63. /**
  64. * Notes:删除商品
  65. * @return \support\Response
  66. * User: ZQ
  67. * Date: 2022/9/13
  68. */
  69. public function delGoods()
  70. {
  71. $goods_id = $this->request->get('goods_id');
  72. $admin_id = $this->request->admin_id;
  73. $this->validateCheck('life\GoodsValidate', ['goods_id' => $goods_id], 'info');
  74. $result = GoodsServer::delGoods($goods_id,$admin_id);
  75. if ($result){
  76. return json_success($result, '删除成功');
  77. }else{
  78. throw new \Exception('删除失败!');
  79. }
  80. }
  81. /**
  82. * Notes:添加商品
  83. * @return \support\Response
  84. * User: ZQ
  85. * Date: 2022/9/13
  86. */
  87. public function addGoods()
  88. {
  89. $goods_name = $this->request->post('goods_name','');
  90. $goods_img = $this->request->post('goods_img');
  91. $goods_category_id = $this->request->post('goods_category_id');
  92. $goods_shop_id = $this->request->post('goods_shop_id');
  93. $goods_is_new = $this->request->post('goods_is_new');
  94. $goods_price = $this->request->post('goods_price');
  95. $goods_content = $this->request->post('goods_content');
  96. $goods_sell_num = $this->request->post('goods_sell_num');
  97. $goods_postage_id = $this->request->post('goods_postage_id');
  98. $goods_status = $this->request->post('goods_status');
  99. $goods_weight = $this->request->post('goods_weight');
  100. $goods_sort = $this->request->post('goods_sort');
  101. $goods_slide = $this->request->post('goods_slide','');
  102. $goods_pack_price = $this->request->post('goods_pack_price','');
  103. $food_attr = $this->request->post('goods_attr','');
  104. $food_varieties = $this->request->post('goods_varieties','');
  105. $food_packaging = $this->request->post('goods_packaging','');
  106. $food_storage = $this->request->post('goods_storage','');
  107. $admin_id = $this->request->admin_id;
  108. $this->validateCheck('life\GoodsValidate', ['goods_name' => $goods_name, 'goods_img' => $goods_img, 'goods_category_id' => $goods_category_id, 'goods_shop_id' => $goods_shop_id, 'goods_is_new' => $goods_is_new, 'goods_price' => $goods_price, 'goods_content' => $goods_content, 'goods_status' => $goods_status, 'goods_postage_id' => $goods_postage_id], 'create');
  109. $result = GoodsServer::insertGoods($goods_name,$goods_img,$goods_category_id,$goods_shop_id,$goods_is_new,$goods_price,$goods_content,$goods_sell_num,$goods_postage_id,$goods_status,$goods_weight,$goods_sort,$goods_slide,$goods_pack_price,$food_attr,$food_varieties,$food_packaging,$food_storage,$admin_id);
  110. return json_success($result, '添加成功');
  111. }
  112. /**
  113. * Notes:查询商品详情
  114. * @return \support\Response
  115. * User: ZQ
  116. * Date: 2022/9/13
  117. */
  118. public function goodsInfo()
  119. {
  120. $goods_id = $this->request->get('goods_id');
  121. $this->validateCheck('life\GoodsValidate', ['goods_id' => $goods_id], 'info');
  122. $result = GoodsServer::goodsInfo($goods_id);
  123. return json_success($result, '成功');
  124. }
  125. /**
  126. * Notes:商品上架下架
  127. * @return \support\Response
  128. * User: ZQ
  129. * Date: 2022/10/09
  130. */
  131. public function updateStatus()
  132. {
  133. $goods_id = $this->request->get('goods_id');
  134. $goods_status = $this->request->get('goods_status');
  135. $this->validateCheck('life\GoodsValidate', ['goods_id' => $goods_id], 'info');
  136. $result = GoodsServer::updateStatus($goods_id, $goods_status);
  137. return json_success($result, '修改成功');
  138. }
  139. }