PackageGoods.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\life\PackageGoodsServer;
  5. class PackageGoods extends BaseController
  6. {
  7. /**
  8. * Notes:获取套餐项目列表
  9. * @return \support\Response
  10. * User: YCP
  11. * Date: 2022/10/18
  12. */
  13. public function getPackageGoodsList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $result = PackageGoodsServer::getPackageGoodsList($page, $limit, $keywords);
  18. return json_success($result, '成功');
  19. }
  20. /**
  21. * Notes:获取所有
  22. * @return \support\Response
  23. * User: YCP
  24. * Date: 2022/10/18
  25. */
  26. public function getPackageGoodsAll()
  27. {
  28. $result = PackageGoodsServer::getPackageGoodsAll();
  29. return json_success($result, '成功');
  30. }
  31. /**
  32. * Notes:修改套餐项目
  33. * @return \support\Response
  34. * User: YCP
  35. * Date: 2022/10/18
  36. */
  37. public function updatePackageGoods()
  38. {
  39. $params = $this->request->post();
  40. $admin_id = $this->request->admin_id;
  41. $this->validateCheck('life\PackageGoodsValidate',
  42. [
  43. 'goods_id' => $params['goods_id']?? '',
  44. 'package_id' => $params['package_id']?? '',
  45. 'goods_name' => $params['goods_name']?? '',
  46. 'goods_num' => $params['goods_num']?? '',
  47. 'goods_price' => $params['goods_price']?? '',
  48. 'goods_weigh' => $params['goods_weigh']?? '',
  49. ],
  50. 'update');
  51. $result = PackageGoodsServer::updatePackageGoods($params, $admin_id);
  52. return json_success($result, '修改成功');
  53. }
  54. /**
  55. * Notes:删除套餐项目
  56. * @return \support\Response
  57. * User: YCP
  58. * Date: 2022/10/18
  59. */
  60. public function delPackageGoods()
  61. {
  62. $goods_id = $this->request->get('goods_id');
  63. $admin_id = $this->request->admin_id;
  64. $this->validateCheck('life\PackageGoodsValidate', ['goods_id' => $goods_id], 'info');
  65. $result = PackageGoodsServer::delPackageGoods($goods_id,$admin_id);
  66. if ($result){
  67. return json_success($result, '删除成功');
  68. }else{
  69. throw new \Exception('删除失败!');
  70. }
  71. }
  72. /**
  73. * Notes:添加套餐项目
  74. * @return \support\Response
  75. * User: YCP
  76. * Date: 2022/10/18
  77. */
  78. public function addPackageGoods()
  79. {
  80. $params = $this->request->post();
  81. $admin_id = $this->request->admin_id;
  82. $this->validateCheck('life\PackageGoodsValidate',
  83. [
  84. 'package_id' => $params['package_id']?? '',
  85. 'goods_name' => $params['goods_name']?? '',
  86. 'goods_num' => $params['goods_num']?? '',
  87. 'goods_price' => $params['goods_price']?? '',
  88. 'goods_weigh' => $params['goods_weigh']?? '',
  89. ],
  90. 'create');
  91. $result = PackageGoodsServer::insertPackageGoods($params, $admin_id);
  92. return json_success($result, '添加成功');
  93. }
  94. /**
  95. * Notes:查询套餐项目详情
  96. * @return \support\Response
  97. * User: YCP
  98. * Date: 2022/10/18
  99. */
  100. public function packageGoodsInfo()
  101. {
  102. $goods_id = $this->request->get('goods_id');
  103. $this->validateCheck('life\PackageGoodsValidate', ['goods_id' => $goods_id], 'info');
  104. $result = PackageGoodsServer::packageGoodsInfo($goods_id);
  105. return json_success($result, '成功');
  106. }
  107. }