Food.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\life\FoodServer;
  5. class Food extends BaseController
  6. {
  7. /**
  8. * Notes:获取健康美食列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/10/17
  12. */
  13. public function getFoodList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = FoodServer::getFoodList($page, $limit, $keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:获取所有健康美食单品
  22. * @return \support\Response
  23. * User: ZQ
  24. * Date: 2022/10/17
  25. */
  26. public function getFoodAll()
  27. {
  28. $food_category_id = $this->request->get('food_category_id','');
  29. $result = FoodServer::getFoodAll($food_category_id);
  30. return json_success($result, '成功');
  31. }
  32. /**
  33. * Notes:修改健康美食
  34. * @return \support\Response
  35. * User: ZQ
  36. * Date: 2022/10/17
  37. */
  38. public function updateFood()
  39. {
  40. $food_id = $this->request->post('food_id');
  41. $food_name = $this->request->post('food_name');
  42. $food_img = $this->request->post('food_img');
  43. $food_price = $this->request->post('food_price');
  44. $food_category_id = $this->request->post('food_category_id');
  45. $food_pack_price = $this->request->post('food_pack_price');
  46. $food_materials = $this->request->post('food_materials','');
  47. $food_condiment = $this->request->post('food_condiment','');
  48. $food_type = $this->request->post('food_type');
  49. $food_package = $this->request->post('food_package','');
  50. $food_label = $this->request->post('food_label');
  51. $food_content = $this->request->post('food_content','');
  52. $food_status = $this->request->post('food_status');
  53. //新增字段
  54. $food_silde = $this->request->post('food_silde','');
  55. $food_shop_id = $this->request->post('food_shop_id');
  56. $food_storage = $this->request->post('food_storage');
  57. $food_packaging = $this->request->post('food_packaging');
  58. $food_varieties = $this->request->post('food_varieties');
  59. $food_attr = $this->request->post('food_attr');
  60. $food_postage_id = $this->request->post('food_postage_id');
  61. $food_weight = $this->request->post('food_weight','');
  62. $food_cater_time = $this->request->post('food_cater_time','');
  63. $food_cater_type = $this->request->post('food_cater_type','');
  64. $food_package_num = $this->request->post('food_package_num','');
  65. $food_week = $this->request->post('food_week','');
  66. $admin_id = $this->request->admin_id;
  67. $this->validateCheck('life\FoodValidate', ['food_id'=>$food_id,'food_name'=>$food_name,'food_img'=>$food_img,'food_price'=>$food_price,'food_category_id'=>$food_category_id,'food_pack_price'=>$food_pack_price,'food_type'=>$food_type,'food_label'=>$food_label,'food_status'=>$food_status,'food_content'=>$food_content], 'update');
  68. $result = FoodServer::updateFood($food_silde, $food_shop_id, $food_storage, $food_packaging, $food_varieties, $food_attr, $food_postage_id, $food_weight, $food_id, $food_name, $food_img, $food_price, $food_category_id, $food_pack_price, $food_materials, $food_condiment, $food_type, $food_package, $food_label, $food_status, $food_content,$food_cater_time,$food_cater_type,$food_package_num, $food_week, $admin_id);
  69. return json_success($result, '修改成功');
  70. }
  71. /**
  72. * Notes:删除健康美食
  73. * @return \support\Response
  74. * User: ZQ
  75. * Date: 2022/10/17
  76. */
  77. public function delFood()
  78. {
  79. $food_id = $this->request->get('food_id');
  80. $admin_id = $this->request->admin_id;
  81. $this->validateCheck('life\FoodValidate', ['food_id' => $food_id], 'info');
  82. $result = FoodServer::delFood($food_id,$admin_id);
  83. if ($result){
  84. return json_success($result, '删除成功');
  85. }else{
  86. throw new \Exception('删除失败!');
  87. }
  88. }
  89. /**
  90. * Notes:添加健康美食
  91. * @return \support\Response
  92. * User: ZQ
  93. * Date: 2022/10/17
  94. */
  95. public function addFood()
  96. {
  97. $food_name = $this->request->post('food_name');
  98. $food_img = $this->request->post('food_img');
  99. $food_price = $this->request->post('food_price');
  100. $food_category_id = $this->request->post('food_category_id');
  101. $food_pack_price = $this->request->post('food_pack_price');
  102. $food_materials = $this->request->post('food_materials','');
  103. $food_condiment = $this->request->post('food_condiment','');
  104. $food_type = $this->request->post('food_type');
  105. $food_package = $this->request->post('food_package','');
  106. $food_label = $this->request->post('food_label');
  107. $food_content = $this->request->post('food_content','');
  108. $food_status = $this->request->post('food_status');
  109. //新增字段
  110. $food_silde = $this->request->post('food_silde','');
  111. $food_shop_id = $this->request->post('food_shop_id');
  112. $food_storage = $this->request->post('food_storage');
  113. $food_packaging = $this->request->post('food_packaging');
  114. $food_varieties = $this->request->post('food_varieties');
  115. $food_attr = $this->request->post('food_attr');
  116. $food_postage_id = $this->request->post('food_postage_id');
  117. $food_weight = $this->request->post('food_weight','');
  118. $food_cater_time = $this->request->post('food_cater_time','');
  119. $food_cater_type = $this->request->post('food_cater_type','');
  120. $food_package_num = $this->request->post('food_package_num','');
  121. $food_week = $this->request->post('food_week','');
  122. $admin_id = $this->request->admin_id;
  123. $this->validateCheck('life\FoodValidate', ['food_name'=>$food_name,'food_img'=>$food_img,'food_price'=>$food_price,'food_category_id'=>$food_category_id,'food_pack_price'=>$food_pack_price,'food_type'=>$food_type,'food_label'=>$food_label,'food_content'=>$food_content,'food_status'=>$food_status], 'create');
  124. $result = FoodServer::insertFood($food_silde, $food_shop_id, $food_storage, $food_packaging, $food_varieties, $food_attr, $food_postage_id, $food_weight, $food_name, $food_img, $food_price, $food_category_id, $food_pack_price, $food_materials, $food_condiment, $food_type, $food_package, $food_label, $food_status, $food_content,$food_cater_time,$food_cater_type,$food_package_num, $food_week, $admin_id);
  125. return json_success($result, '添加成功');
  126. }
  127. /**
  128. * Notes:查询健康美食详情
  129. * @return \support\Response
  130. * User: ZQ
  131. * Date: 2022/10/17
  132. */
  133. public function foodInfo()
  134. {
  135. $food_id = $this->request->get('food_id');
  136. $this->validateCheck('life\FoodValidate', ['food_id' => $food_id], 'info');
  137. $result = FoodServer::foodInfo($food_id);
  138. return json_success($result, '成功');
  139. }
  140. /**
  141. * Notes:健康美食上架下架
  142. * @return \support\Response
  143. * User: ZQ
  144. * Date: 2022/10/17
  145. */
  146. public function updateStatus()
  147. {
  148. $food_id = $this->request->get('food_id');
  149. $food_status = $this->request->get('food_status');
  150. $this->validateCheck('life\FoodValidate', ['food_id' => $food_id], 'info');
  151. $result = FoodServer::updateStatus($food_id, $food_status);
  152. return json_success($result, '修改成功');
  153. }
  154. }