HealthyProduct.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. namespace app\admin\controller\healthy;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\healthy\HealthyProductServer;
  5. class HealthyProduct extends BaseController
  6. {
  7. /**
  8. * Notes:获取健康产品列表
  9. * @return \support\Response
  10. * User: ZQ
  11. * Date: 2022/10/31
  12. */
  13. public function getProductList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = HealthyProductServer::getProductList($page, $limit, $keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:获取所有健康产品
  22. * @return \support\Response
  23. * User: ZQ
  24. * Date: 2022/10/31
  25. */
  26. public function getProductAll()
  27. {
  28. $result = HealthyProductServer::getProductAll();
  29. return json_success($result, '成功');
  30. }
  31. /**
  32. * Notes:修改健康产品
  33. * @return \support\Response
  34. * User: ZQ
  35. * Date: 2022/10/31
  36. */
  37. public function updateProduct()
  38. {
  39. $product_id = $this->request->post('product_id');
  40. $product_name = $this->request->post('product_name');
  41. $product_shop_id = $this->request->post('product_shop_id');
  42. $product_pack_price = $this->request->post('product_pack_price');
  43. $product_postage_id = $this->request->post('product_postage_id');
  44. $product_category_id = $this->request->post('product_category_id');
  45. $product_label = $this->request->post('product_label','');
  46. $product_price = $this->request->post('product_price');
  47. $product_status = $this->request->post('product_status');
  48. $product_weight = $this->request->post('product_weight','');
  49. $product_image = $this->request->post('product_image','');
  50. $product_image_list = $this->request->post('product_image_list','');
  51. $product_limit = $this->request->post('product_limit','');
  52. $product_notice = $this->request->post('product_notice','');
  53. $product_guarantee = $this->request->post('product_guarantee','');
  54. $product_type = $this->request->post('product_type');
  55. $product_package = $this->request->post('product_package','');
  56. $product_rule = $this->request->post('product_rule','');
  57. $product_detail = $this->request->post('product_detail','');
  58. $product_sort = $this->request->post('product_sort','');
  59. $admin_id = $this->request->admin_id;
  60. $this->validateCheck('healthy\HealthyProductValidate', ['product_id'=>$product_id,'product_name'=>$product_name,'product_price'=>$product_price,'product_pack_price'=>$product_pack_price,'product_category_id'=>$product_category_id,'product_shop_id'=>$product_shop_id,'product_status'=>$product_status,'product_postage_id'=>$product_postage_id,'product_weight'=>$product_weight,'product_type'=>$product_type], 'update');
  61. $result = HealthyProductServer::updateProduct($product_id, $product_name, $product_pack_price, $product_postage_id, $product_category_id, $product_weight, $product_label, $product_status, $product_image, $product_image_list, $product_limit, $product_notice, $product_guarantee, $product_type, $product_package, $product_rule, $product_shop_id, $product_price, $product_detail, $product_sort, $admin_id);
  62. return json_success($result, '修改成功');
  63. }
  64. /**
  65. * Notes:删除健康产品
  66. * @return \support\Response
  67. * User: ZQ
  68. * Date: 2022/10/31
  69. */
  70. public function delProduct()
  71. {
  72. $product_id = $this->request->get('product_id');
  73. $admin_id = $this->request->admin_id;
  74. $this->validateCheck('healthy\HealthyProductValidate', ['product_id' => $product_id], 'info');
  75. $result = HealthyProductServer::delProduct($product_id,$admin_id);
  76. if ($result){
  77. return json_success($result, '删除成功');
  78. }else{
  79. throw new \Exception('删除失败!');
  80. }
  81. }
  82. /**
  83. * Notes:添加健康产品
  84. * @return \support\Response
  85. * User: ZQ
  86. * Date: 2022/10/31
  87. */
  88. public function addProduct()
  89. {
  90. $product_name = $this->request->post('product_name');
  91. $product_shop_id = $this->request->post('product_shop_id');
  92. $product_pack_price = $this->request->post('product_pack_price');
  93. $product_postage_id = $this->request->post('product_postage_id');
  94. $product_category_id = $this->request->post('product_category_id');
  95. $product_label = $this->request->post('product_label','');
  96. $product_price = $this->request->post('product_price');
  97. $product_status = $this->request->post('product_status');
  98. $product_weight = $this->request->post('product_weight','');
  99. $product_image = $this->request->post('product_image','');
  100. $product_image_list = $this->request->post('product_image_list','');
  101. $product_limit = $this->request->post('product_limit','');
  102. $product_notice = $this->request->post('product_notice','');
  103. $product_guarantee = $this->request->post('product_guarantee','');
  104. $product_type = $this->request->post('product_type');
  105. $product_package = $this->request->post('product_package','');
  106. $product_rule = $this->request->post('product_rule','');
  107. $product_detail = $this->request->post('product_detail','');
  108. $product_sort = $this->request->post('product_sort','');
  109. $admin_id = $this->request->admin_id;
  110. $this->validateCheck('healthy\HealthyProductValidate', ['product_name'=>$product_name,'product_price'=>$product_price,'product_pack_price'=>$product_pack_price,'product_category_id'=>$product_category_id,'product_shop_id'=>$product_shop_id,'product_status'=>$product_status,'product_postage_id'=>$product_postage_id,'product_weight'=>$product_weight,'product_type'=>$product_type], 'create');
  111. $result = HealthyProductServer::insertProduct($product_name, $product_pack_price, $product_postage_id, $product_category_id, $product_weight, $product_label, $product_status, $product_image, $product_image_list, $product_limit, $product_notice, $product_guarantee, $product_type, $product_package, $product_rule, $product_shop_id, $product_price, $product_detail, $product_sort, $admin_id);
  112. return json_success($result, '添加成功');
  113. }
  114. /**
  115. * Notes:查询健康产品详情
  116. * @return \support\Response
  117. * User: ZQ
  118. * Date: 2022/10/31
  119. */
  120. public function productInfo()
  121. {
  122. $product_id = $this->request->get('product_id');
  123. $this->validateCheck('healthy\HealthyProductValidate', ['product_id' => $product_id], 'info');
  124. $result = HealthyProductServer::productInfo($product_id);
  125. return json_success($result, '成功');
  126. }
  127. /**
  128. * Notes:健康产品上架下架
  129. * @return \support\Response
  130. * User: ZQ
  131. * Date: 2022/10/09
  132. */
  133. public function updateStatus()
  134. {
  135. $product_id = $this->request->get('product_id');
  136. $product_status = $this->request->get('product_status');
  137. $this->validateCheck('healthy\HealthyProductValidate', ['product_id' => $product_id], 'info');
  138. $result = HealthyProductServer::updateStatus($product_id, $product_status);
  139. return json_success($result, '修改成功');
  140. }
  141. /**
  142. * Notes:健康产品审核
  143. * @return \support\Response
  144. * User: ZQ
  145. * Date: 2022/10/09
  146. */
  147. public function autoProduct()
  148. {
  149. $product_id = $this->request->post('product_id');
  150. $product_auto = $this->request->post('product_auto');
  151. $product_msg = $this->request->post('product_msg','');
  152. $this->validateCheck('healthy\HealthyProductValidate', ['product_id' => $product_id], 'auto');
  153. $result = HealthyProductServer::autoProduct($product_id, $product_auto,$product_msg);
  154. return json_success($result, '审核成功');
  155. }
  156. }