Product.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php
  2. namespace app\admin\controller\medical;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\medical\MedicalCareProductServer;
  5. use app\admin\server\package\PackageGoodsServer;
  6. class Product extends BaseController
  7. {
  8. /**
  9. * Notes:获取商品列表
  10. * @return \support\Response
  11. * User: QJF
  12. * Date: 2022/9/23
  13. */
  14. public function getProductList()
  15. {
  16. [$page, $limit] = $this->getPage();
  17. $keywords = $this->request->get('keywords');
  18. $result = MedicalCareProductServer::getProductList($page, $limit,$keywords);
  19. return json_success($result, '成功');
  20. }
  21. /**
  22. * Notes:添加产品
  23. * @return \support\Response
  24. * User: QJF
  25. * Date: 2022/9/23
  26. *
  27. */
  28. public function addProduct()
  29. {
  30. $param = $this->request->post();
  31. $this->validateCheck('medical\MedicalCareProductValidate',
  32. [
  33. 'product_name' => $param['product_name'],
  34. 'product_shop_id' => $param['product_shop_id'],
  35. 'product_category_id' => $param['product_category_id'],
  36. 'product_is_show' => $param['product_is_show'],
  37. 'product_sort' => $param['product_sort'],
  38. 'product_sales' => $param['product_sales'],
  39. 'product_price' => $param['product_price'],
  40. 'product_cost' => $param['product_cost'],
  41. 'product_ot_price' => $param['product_ot_price'],
  42. 'product_stock' => $param['product_stock'],
  43. 'product_ficti' => $param['product_ficti'],
  44. 'product_image' => $param['product_image'],
  45. 'product_type' => $param['product_type'],
  46. 'product_postage_id' => $param['product_postage_id'],
  47. ],
  48. 'add');
  49. $result = MedicalCareProductServer::insertProduct($param);
  50. return json_success($result, '添加成功');
  51. }
  52. /**
  53. * Notes:修改产品
  54. * @return \support\Response
  55. * User: QJF
  56. * Date: 2022/9/23
  57. */
  58. public function updateProduct()
  59. {
  60. $param = $this->request->post();
  61. $this->validateCheck('medical\MedicalCareProductValidate',
  62. [
  63. 'product_id' => $param['product_id'],
  64. 'product_shop_id' => $param['product_shop_id'],
  65. 'product_category_id' => $param['product_category_id'],
  66. 'product_name' => $param['product_name'],
  67. 'product_is_show' => $param['product_is_show'],
  68. 'product_sort' => $param['product_sort'],
  69. 'product_sales' => $param['product_sales'],
  70. 'product_price' => $param['product_price'],
  71. 'product_cost' => $param['product_cost'],
  72. 'product_ot_price' => $param['product_ot_price'],
  73. 'product_stock' => $param['product_stock'],
  74. 'product_ficti' => $param['product_ficti'],
  75. 'product_image' => $param['product_image'],
  76. 'product_type' => $param['product_type'],
  77. 'product_postage_id' => $param['product_postage_id'],
  78. ], 'update');
  79. $result = MedicalCareProductServer::updateProduct($param);
  80. return json_success($result, '修改成功');
  81. }
  82. /**
  83. * Notes:删除权益包
  84. * @return \support\Response
  85. * User: QJF
  86. * Date: 2022/9/23
  87. */
  88. public function delProduct()
  89. {
  90. $product_id = $this->request->get('product_id');
  91. $this->validateCheck('medical\MedicalCareProductValidate', ['product_id' => $product_id], 'del');
  92. $result = MedicalCareProductServer::delProduct($product_id);
  93. if ($result){
  94. return json_success($result, '删除成功');
  95. }else{
  96. throw new \Exception('删除失败!');
  97. }
  98. }
  99. /**
  100. * Notes:查看产品详情
  101. * @return \support\Response
  102. * User: QJF
  103. * Date: 2022/9/23
  104. */
  105. public function infoProduct()
  106. {
  107. $product_id = $this->request->get('product_id');
  108. $this->validateCheck('medical\MedicalCareProductValidate', ['product_id' => $product_id], 'info');
  109. $result = MedicalCareProductServer::infoProduct($product_id);
  110. if ($result){
  111. return json_success($result, '获取成功');
  112. }else{
  113. throw new \Exception('获取失败!');
  114. }
  115. }
  116. //产品上下架
  117. public function showProduct(){
  118. $product_id = $this->request->get('product_id');
  119. $product_is_show = $this->request->get('product_is_show');
  120. $this->validateCheck('medical\MedicalCareProductValidate', ['product_id' => $product_id], 'del');
  121. $result = MedicalCareProductServer::showProduct($product_id,$product_is_show);
  122. if ($result){
  123. return json_success($result, '成功');
  124. }else{
  125. throw new \Exception('失败!');
  126. }
  127. }
  128. }