User.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\api\controller\v1\taxiUser;
  3. use app\api\controller\ApiController;
  4. use app\http\IResponse;
  5. use think\App;
  6. use app\api\service\JWTAuth as IAuth;
  7. class User extends ApiController
  8. {
  9. protected $model;
  10. public function __construct(App $app = null, IAuth $auth)
  11. {
  12. parent::__construct($app, $auth);
  13. $this->model = new \app\common\model\Users();
  14. $this->taxiUserModel = new \app\api\model\taxi\User();
  15. }
  16. /**
  17. * 司机用户信息
  18. * @return mixed
  19. * @throws \Lettered\Support\Exceptions\FailedException
  20. */
  21. public function info(){
  22. $params = $this->request->param();
  23. $taxiUser = $this->auth->guard('taxi_user')->user();
  24. if(!$taxiUser){
  25. return IResponse::failure('用户不存在,或已被冻结');
  26. }
  27. if(!$taxiUser['user_id']){
  28. return IResponse::failure('司机未绑定用户账号');
  29. }
  30. $user = $this->model->where(['id'=> $taxiUser['user_id']])
  31. ->field('id,parent_id,open_id,nickname,avatar_url,partnership,status')
  32. ->find();
  33. $type = isset($params['type'])? $params['type'] : 1;
  34. if($type == 2){
  35. $counts = [
  36. 'day_income'=> '0.00',
  37. 'total_income'=> '0.00',
  38. 'withdraw_income'=> $user['partnership'],
  39. 'day_order'=> '0',
  40. 'total_order'=> '0',
  41. 'wait_order'=> '0',
  42. ];
  43. $counts['day_income'] = model('common/TaxiOrder')
  44. ->where(['taxi_uid'=> $taxiUser['id']])
  45. ->whereIn('status',[4,5])
  46. ->where('created_at','>=', strtotime(date('Y-m-d')))
  47. ->sum('settle_price');
  48. $counts['total_income'] = model('common/TaxiOrder')
  49. ->where(['taxi_uid'=> $taxiUser['id']])
  50. ->whereIn('status',[4,5])
  51. ->sum('settle_price');
  52. $counts['day_order'] = model('common/TaxiOrder')
  53. ->where(['taxi_uid'=> $taxiUser['id']])
  54. ->whereIn('status',[3,4,5])
  55. ->where('created_at','>=', strtotime(date('Y-m-d')))
  56. ->count('id');
  57. $counts['total_order'] = model('common/TaxiOrder')
  58. ->where(['taxi_uid'=> $taxiUser['id']])
  59. ->whereIn('status',[3,4,5])
  60. ->count('id');
  61. $counts['wait_order'] = model('common/TaxiOrder')
  62. ->where(['taxi_uid'=> $taxiUser['id']])
  63. ->whereIn('status',[3])
  64. ->where('created_at','>=', strtotime(date('Y-m-d')))
  65. ->count('id');
  66. $taxiUser['counts'] = $counts;
  67. }
  68. unset($taxiUser['password']);
  69. $taxiUser['user'] = $user;
  70. return IResponse::success($taxiUser,'获取成功');
  71. }
  72. }