| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace app\modules\alliance\behaviors;
- use app\models\SaasUser;
- use yii\base\ActionFilter;
- use yii\web\Response;
- class AgentFrontDriver extends ActionFilter
- {
- public function beforeAction($action)
- {
- $access_token = input_params('access_token');
- $saas_user = SaasUser::findIdentityByAccessToken($access_token);
- if (!$saas_user) {
- \Yii::$app->response->format = Response::FORMAT_JSON;
- \Yii::$app->response->data = [
- 'code' => 401,
- 'msg' => '登录失败'
- ];
- return false;
- }
- $agentFrontDriver = \app\models\Driver::findOne(['saas_user_id' => $saas_user->id, 'is_delete' => 0]);
- if (!$agentFrontDriver) {
- \Yii::$app->response->format = Response::FORMAT_JSON;
- \Yii::$app->response->data = [
- 'code' => 1,
- 'msg' => '非仓库司机'
- ];
- return false;
- }
- if (!intval($agentFrontDriver->status)) {
- \Yii::$app->response->format = Response::FORMAT_JSON;
- \Yii::$app->response->data = [
- 'code' => 1,
- 'msg' => '司机账户已经被禁用'
- ];
- return false;
- }
- $action->controller->agentFrontDriverId = $agentFrontDriver->id;
- $action->controller->agentFrontId = $agentFrontDriver->admin_id;
- return parent::beforeAction($action);
- }
- }
|