GoodsController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Http\Controllers\Api\v1;
  3. use App\Http\Controllers\Api\webApp;
  4. use App\Services\Api\GoodsService;
  5. use App\Services\Api\MemberService;
  6. /**
  7. * 商品管理
  8. * @package App\Http\Controllers\Api
  9. */
  10. class GoodsController extends webApp
  11. {
  12. /**
  13. * 列表
  14. * @return array
  15. */
  16. public function index()
  17. {
  18. $params =request()->post();
  19. $pageSize = request()->post('pageSize', 12);
  20. $params['picker_status'] = 1;
  21. $params['user_id'] = $this->userId;
  22. $userInfo = MemberService::make()->getInfo($this->userId,[], true);
  23. $confirmStatus = isset($userInfo['confirm_status'])? $userInfo['confirm_status'] : 0;
  24. $pickerStatus = isset($userInfo['picker_status'])? $userInfo['picker_status'] : 0;
  25. if($confirmStatus != 1 || $pickerStatus!= 1){
  26. return message(2043, false);
  27. }
  28. $datas = GoodsService::make()->getDataList($params, $pageSize);
  29. return message(1010, true, $datas);
  30. }
  31. /**
  32. * 详情
  33. */
  34. public function info()
  35. {
  36. $params = request()->all();
  37. $id = isset($params['id'])? intval($params['id']) : 0;
  38. if(empty($id)){
  39. return message(1036, false);
  40. }
  41. $userInfo = MemberService::make()->getInfo($this->userId,[], true);
  42. $confirmStatus = isset($userInfo['confirm_status'])? $userInfo['confirm_status'] : 0;
  43. $pickerStatus = isset($userInfo['picker_status'])? $userInfo['picker_status'] : 0;
  44. if($confirmStatus != 1 || $pickerStatus!= 1){
  45. return message(2043, false,[],405);
  46. }
  47. if($info = GoodsService::make()->getInfo($id)){
  48. return message(1010, true, $info);
  49. }else{
  50. return message(1009, false);
  51. }
  52. }
  53. }