UserController.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\pc;
  12. use app\Request;
  13. use app\services\pc\UserServices;
  14. use app\services\user\UserRelationServices;
  15. use app\services\user\UserBrokerageServices;
  16. use app\services\user\UserMoneyServices;
  17. /**
  18. * pc端用户信息类
  19. * Class UserController
  20. * @package app\controller\api\pc
  21. */
  22. class UserController
  23. {
  24. protected $services;
  25. public function __construct(UserServices $services)
  26. {
  27. $this->services = $services;
  28. }
  29. /**
  30. * 用户记录0:所有余额1:余额消费2:余额充值3:佣金4:提现
  31. * @param Request $request
  32. * @param $type
  33. * @return mixed
  34. */
  35. public function getBalanceRecord(Request $request, $type)
  36. {
  37. $data = $request->getMore([
  38. ['start', 0],
  39. ['stop', 0],
  40. ['keyword', ''],
  41. ]);
  42. $uid = (int)$request->uid();
  43. switch ((int)$type) {
  44. case 0:
  45. case 1:
  46. case 2:
  47. /** @var UserMoneyServices $services */
  48. $services = app()->make(UserMoneyServices::class);
  49. $data = $services->userMoneyList($uid, (int)$type);
  50. break;
  51. case 3:
  52. /** @var UserBrokerageServices $services */
  53. $services = app()->make(UserBrokerageServices::class);
  54. $data = $services->userBrokerageList($uid, $data);
  55. break;
  56. case 4:
  57. /** @var UserBrokerageServices $services */
  58. $services = app()->make(UserBrokerageServices::class);
  59. $data = $services->userExtractList($uid);
  60. break;
  61. default:
  62. $data = [];
  63. }
  64. return app('json')->successful($data);
  65. }
  66. /**
  67. * 获取收藏列表
  68. * @param Request $request
  69. * @param UserRelationServices $services
  70. * @return mixed
  71. * @throws \think\db\exception\DataNotFoundException
  72. * @throws \think\db\exception\DbException
  73. * @throws \think\db\exception\ModelNotFoundException
  74. */
  75. public function getCollectList(Request $request, UserRelationServices $services)
  76. {
  77. $uid = (int)$request->uid();
  78. $list = $services->getUserRelationList($uid);
  79. $count = $services->getUserCount($uid);
  80. return app('json')->successful(compact('list', 'count'));
  81. }
  82. }