FarmGoods.php 5.3 KB

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