User.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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\supplier\user;
  12. use app\services\user\UserSpreadServices;
  13. use think\facade\App;
  14. use app\services\user\UserServices;
  15. use app\controller\supplier\AuthController;
  16. use app\services\product\product\StoreProductLogServices;
  17. class User extends AuthController
  18. {
  19. /**
  20. * user constructor.
  21. * @param App $app
  22. * @param UserServices $services
  23. */
  24. public function __construct(App $app, UserServices $services)
  25. {
  26. parent::__construct($app);
  27. $this->services = $services;
  28. }
  29. /**
  30. * 显示用户信息
  31. *
  32. * @param int $id
  33. * @return \think\Response
  34. */
  35. public function read($id)
  36. {
  37. if (is_string($id)) {
  38. $id = (int)$id;
  39. }
  40. return $this->success($this->services->read($id));
  41. }
  42. /**
  43. * 获取单个用户信息
  44. * @param $id 用户id
  45. * @return mixed
  46. */
  47. public function oneUserInfo($id)
  48. {
  49. $data = $this->request->getMore([
  50. ['type', ''],
  51. ]);
  52. $id = (int)$id;
  53. if ($data['type'] == '') return $this->fail('缺少参数');
  54. return $this->success($this->services->oneUserInfo($id, $data['type']));
  55. }
  56. /**
  57. * 商品浏览记录
  58. * @param $id
  59. * @param StoreProductLogServices $services
  60. * @return mixed
  61. * @throws \think\db\exception\DataNotFoundException
  62. * @throws \think\db\exception\DbException
  63. * @throws \think\db\exception\ModelNotFoundException
  64. */
  65. public function visitList($id, StoreProductLogServices $services)
  66. {
  67. $where['uid'] = (int)$id;
  68. $where['type'] = 'visit';
  69. return app('json')->success($services->getList($where, 'product_id'));
  70. }
  71. /**
  72. * 获取推广人记录
  73. * @param $id
  74. * @param UserSpreadServices $services
  75. * @return mixed
  76. * @throws \think\db\exception\DataNotFoundException
  77. * @throws \think\db\exception\DbException
  78. * @throws \think\db\exception\ModelNotFoundException
  79. */
  80. public function spreadList($id, UserSpreadServices $services)
  81. {
  82. $where['store_id'] = 0;
  83. $where['staff_id'] = 0;
  84. $where['uid'] = $id;
  85. return app('json')->success($services->getSpreadList($where, '*', ['spreadUser', 'admin'], false));
  86. }
  87. }