GoodsController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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){
  26. return message(2043, false,[],405);
  27. }
  28. if($pickerStatus!= 1){
  29. return message(2063, false,[],406);
  30. }
  31. $datas = GoodsService::make()->getDataList($params, $pageSize);
  32. return message(1010, true, $datas);
  33. }
  34. /**
  35. * 详情
  36. */
  37. public function info()
  38. {
  39. $params = request()->all();
  40. $id = isset($params['id'])? intval($params['id']) : 0;
  41. if(empty($id)){
  42. return message(1036, false);
  43. }
  44. $userInfo = MemberService::make()->getInfo($this->userId,[], true);
  45. $confirmStatus = isset($userInfo['confirm_status'])? $userInfo['confirm_status'] : 0;
  46. $pickerStatus = isset($userInfo['picker_status'])? $userInfo['picker_status'] : 0;
  47. if($confirmStatus != 1){
  48. return message(2043, false,[],405);
  49. }
  50. if($pickerStatus!= 1){
  51. return message(2063, false,[],406);
  52. }
  53. if($info = GoodsService::make()->getInfo($id)){
  54. return message(1010, true, $info);
  55. }else{
  56. return message(1009, false);
  57. }
  58. }
  59. }