| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace app\api\controller\v1\taxiUser;
- use app\api\controller\ApiController;
- use app\http\IResponse;
- use think\App;
- use app\api\service\JWTAuth as IAuth;
- class User extends ApiController
- {
- protected $model;
- public function __construct(App $app = null, IAuth $auth)
- {
- parent::__construct($app, $auth);
- $this->model = new \app\common\model\Users();
- $this->taxiUserModel = new \app\api\model\taxi\User();
- }
- /**
- * 司机用户信息
- * @return mixed
- * @throws \Lettered\Support\Exceptions\FailedException
- */
- public function info(){
- $params = $this->request->param();
- $taxiUser = $this->auth->guard('taxi_user')->user();
- if(!$taxiUser){
- return IResponse::failure('用户不存在,或已被冻结');
- }
- if(!$taxiUser['user_id']){
- return IResponse::failure('司机未绑定用户账号');
- }
- $user = $this->model->where(['id'=> $taxiUser['user_id']])
- ->field('id,parent_id,open_id,nickname,avatar_url,partnership,status')
- ->find();
- $type = isset($params['type'])? $params['type'] : 1;
- if($type == 2){
- $counts = [
- 'day_income'=> '0.00',
- 'total_income'=> '0.00',
- 'withdraw_income'=> $user['partnership'],
- 'day_order'=> '0',
- 'total_order'=> '0',
- 'wait_order'=> '0',
- ];
- $counts['day_income'] = model('common/TaxiOrder')
- ->where(['taxi_uid'=> $taxiUser['id']])
- ->whereIn('status',[4,5])
- ->where('created_at','>=', strtotime(date('Y-m-d')))
- ->sum('settle_price');
- $counts['total_income'] = model('common/TaxiOrder')
- ->where(['taxi_uid'=> $taxiUser['id']])
- ->whereIn('status',[4,5])
- ->sum('settle_price');
- $counts['day_order'] = model('common/TaxiOrder')
- ->where(['taxi_uid'=> $taxiUser['id']])
- ->whereIn('status',[3,4,5])
- ->where('created_at','>=', strtotime(date('Y-m-d')))
- ->count('id');
- $counts['total_order'] = model('common/TaxiOrder')
- ->where(['taxi_uid'=> $taxiUser['id']])
- ->whereIn('status',[3,4,5])
- ->count('id');
- $counts['wait_order'] = model('common/TaxiOrder')
- ->where(['taxi_uid'=> $taxiUser['id']])
- ->whereIn('status',[3])
- ->where('created_at','>=', strtotime(date('Y-m-d')))
- ->count('id');
- $taxiUser['counts'] = $counts;
- }
- unset($taxiUser['password']);
- $taxiUser['user'] = $user;
- return IResponse::success($taxiUser,'获取成功');
- }
- }
|