PackageGoods.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace app\admin\controller\package;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\package\PackageGoodsServer;
  5. class PackageGoods extends BaseController
  6. {
  7. /**
  8. * Notes:获取产品列表
  9. * @return \support\Response
  10. * $param type_id 1:正常分页 2:获取1000条数据
  11. * User: QJF
  12. * Date: 2022/9/20
  13. */
  14. public function getPackageGoodsList()
  15. {
  16. [$page, $limit] = $this->getPage();
  17. $keywords = $this->request->get('keywords');
  18. $type_id = $this->request->get('type_id');
  19. //用于展示套餐包列表,不需要分页,所以默认第一页获取1000条数据
  20. if($type_id == 2){
  21. $limit = 1000;
  22. }
  23. $result = PackageGoodsServer::getPackageGoodsList($page, $limit, $keywords);
  24. return json_success($result, '成功');
  25. }
  26. /**
  27. * Notes:添加产品
  28. * @return \support\Response
  29. * User: QJF
  30. * Date: 2022/9/20
  31. *
  32. */
  33. public function addPackageGoods()
  34. {
  35. $param = $this->request->post();
  36. $this->validateCheck('package\PackageGoodsValidate',
  37. [
  38. 'goods_name' => $param['goods_name'],
  39. 'goods_titile' => $param['goods_titile'],
  40. 'goods_nape' => $param['goods_nape'],
  41. 'goods_price' => $param['goods_price'],
  42. 'goods_equity' => $param['goods_equity'],
  43. 'goods_img' => $param['goods_img'],
  44. 'goods_category_id' => $param['goods_category_id'],
  45. 'goods_num' => $param['goods_num'],
  46. 'goods_num_type' => $param['goods_num_type'],
  47. 'goods_num_unit' => $param['goods_num_unit'],
  48. 'goods_type' => $param['goods_type'],
  49. ],
  50. 'add');
  51. $result = PackageGoodsServer::insertPackage($param);
  52. return json_success($result, '添加成功');
  53. }
  54. /**
  55. * Notes:修改权益包
  56. * @return \support\Response
  57. * User: QJF
  58. * Date: 2022/9/19
  59. */
  60. public function updatePackageGoods()
  61. {
  62. $param = $this->request->post();
  63. $this->validateCheck('package\PackageGoodsValidate',
  64. [
  65. 'goods_id' => $param['goods_id'],
  66. ], 'update');
  67. $result = PackageGoodsServer::updatePackageGoods($param);
  68. return json_success($result, '修改成功');
  69. }
  70. /**
  71. * Notes:删除权益包
  72. * @return \support\Response
  73. * User: QJF
  74. * Date: 2022/9/19
  75. */
  76. public function delPackageGoods()
  77. {
  78. $goods_id = $this->request->get('goods_id');
  79. $goods_status = $this->request->get('goods_status');
  80. $this->validateCheck('package\PackageGoodsValidate', ['goods_id' => $goods_id], 'del');
  81. $result = PackageGoodsServer::delPackageGoods($goods_id,$goods_status);
  82. if ($result){
  83. return json_success($result, '成功');
  84. }else{
  85. throw new \Exception('失败!');
  86. }
  87. }
  88. /**
  89. * Notes:查看权益包详情
  90. * @return \support\Response
  91. * User: QJF
  92. * Date: 2022/9/19
  93. */
  94. public function infoPackageGoods()
  95. {
  96. $goods_id = $this->request->get('goods_id');
  97. $this->validateCheck('package\PackageGoodsValidate', ['goods_id' => $goods_id], 'info');
  98. $result = PackageGoodsServer::infoPackage($goods_id);
  99. if ($result){
  100. return json_success($result, '获取成功');
  101. }else{
  102. throw new \Exception('获取失败!');
  103. }
  104. }
  105. }