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,'获取成功'); } }