Package.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. namespace app\admin\controller\life;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\life\PackageServer;
  5. class Package extends BaseController
  6. {
  7. /**
  8. * Notes:获取套餐列表
  9. * @return \support\Response
  10. * User: YCP
  11. * Date: 2022/10/18
  12. */
  13. public function getPackageList()
  14. {
  15. [$page, $limit] = $this->getPage();
  16. $keywords = $this->request->get('keywords');
  17. $package_type = $this->request->get('package_type');
  18. $result = PackageServer::getPackageList($page, $limit, $keywords,$package_type);
  19. return json_success($result, '成功');
  20. }
  21. /**
  22. * Notes:获取所有
  23. * @return \support\Response
  24. * User: YCP
  25. * Date: 2022/10/18
  26. */
  27. public function getPackageAll()
  28. {
  29. $result = PackageServer::getPackageAll();
  30. return json_success($result, '成功');
  31. }
  32. /**
  33. * Notes:修改套餐
  34. * @return \support\Response
  35. * User: YCP
  36. * Date: 2022/10/18
  37. */
  38. public function updatePackage()
  39. {
  40. $params = $this->request->post();
  41. $admin_id = $this->request->admin_id;
  42. $this->validateCheck('life\PackageValidate',
  43. [
  44. 'package_id' => $params['package_id']?? '',
  45. 'package_category_id' => $params['package_category_id']?? '',
  46. 'shop_id' => $params['shop_id']?? '',
  47. 'package_name' => $params['package_name']?? '',
  48. 'package_type' => $params['package_type']?? '',
  49. 'package_image' => $params['package_image']?? '',
  50. 'package_images' => $params['package_images']?? '',
  51. 'package_usetime' => $params['package_usetime']?? '',
  52. 'package_tags' => $params['package_tags']?? '',
  53. 'package_price' => $params['package_price']?? '',
  54. 'package_grade' => $params['package_grade']?? '',
  55. 'package_usefulday' => $params['package_usefulday']?? '',
  56. 'package_starttime' => $params['package_starttime']?? '',
  57. 'package_endtime' => $params['package_endtime']?? '',
  58. 'package_intro' => $params['package_intro']?? '',
  59. 'package_sales' => $params['package_sales']?? '',
  60. 'package_limit' => $params['package_limit']?? '',
  61. 'package_notice' => $params['package_notice']?? '',
  62. 'package_guarantee' => $params['package_guarantee']?? '',
  63. ],
  64. 'update');
  65. $result = PackageServer::updatePackage($params, $admin_id);
  66. return json_success($result, '修改成功');
  67. }
  68. /**
  69. * Notes:删除套餐
  70. * @return \support\Response
  71. * User: YCP
  72. * Date: 2022/10/18
  73. */
  74. public function delPackage()
  75. {
  76. $package_id = $this->request->get('package_id');
  77. $admin_id = $this->request->admin_id;
  78. $this->validateCheck('life\PackageValidate', ['package_id' => $package_id], 'info');
  79. $result = PackageServer::delPackage($package_id,$admin_id);
  80. if ($result){
  81. return json_success($result, '删除成功');
  82. }else{
  83. throw new \Exception('删除失败!');
  84. }
  85. }
  86. /**
  87. * Notes:添加套餐
  88. * @return \support\Response
  89. * User: YCP
  90. * Date: 2022/10/18
  91. */
  92. public function addPackage()
  93. {
  94. $params = $this->request->post();
  95. $admin_id = $this->request->admin_id;
  96. $this->validateCheck('life\PackageValidate',
  97. [
  98. 'shop_id' => $params['shop_id']?? '',
  99. 'package_category_id' => $params['package_category_id']?? '',
  100. 'package_name' => $params['package_name']?? '',
  101. 'package_type' => $params['package_type']?? '',
  102. 'package_image' => $params['package_image']?? '',
  103. 'package_images' => $params['package_images']?? '',
  104. 'package_usetime' => $params['package_usetime']?? '',
  105. 'package_tags' => $params['package_tags']?? '',
  106. 'package_price' => $params['package_price']?? '',
  107. 'package_grade' => $params['package_grade']?? '',
  108. 'package_usefulday' => $params['package_usefulday']?? '',
  109. 'package_starttime' => $params['package_starttime']?? '',
  110. 'package_endtime' => $params['package_endtime']?? '',
  111. 'package_intro' => $params['package_intro']?? '',
  112. 'package_sales' => $params['package_sales']?? '',
  113. 'package_limit' => $params['package_limit']?? '',
  114. 'package_notice' => $params['package_notice']?? '',
  115. 'package_guarantee' => $params['package_guarantee']?? '',
  116. ],
  117. 'create');
  118. $result = PackageServer::insertPackage($params, $admin_id);
  119. return json_success($result, '添加成功');
  120. }
  121. /**
  122. * Notes:查询套餐详情
  123. * @return \support\Response
  124. * User: YCP
  125. * Date: 2022/10/18
  126. */
  127. public function packageInfo()
  128. {
  129. $package_id = $this->request->get('package_id');
  130. $this->validateCheck('life\PackageValidate', ['package_id' => $package_id], 'info');
  131. $result = PackageServer::packageInfo($package_id);
  132. return json_success($result, '成功');
  133. }
  134. }