| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace app\modules\alliance\behaviors;
- use app\models\Admin;
- use app\models\Salesman;
- use app\models\SalesmanNewStore;
- use app\models\Supplier;
- use yii\base\ActionFilter;
- use yii\helpers\Json;
- use Yii;
- use yii\web\Response;
- class SalesmanStoreUserAdmin extends ActionFilter
- {
- // 接口白名单
- public static $allow_list = [
- ];
- public function beforeAction($action)
- {
- $params_r = $_REQUEST['r'];
- if (in_array($params_r, self::$allow_list)) {
- return true;
- }
- $saas_user = get_saas_user();
- if (!$saas_user) {
- //未登录
- \Yii::$app->response->format = Response::FORMAT_JSON;
- \Yii::$app->response->data = [
- 'code' => 401,
- 'msg' => '登陆状态异常,请重新登陆'
- ];
- return false;
- }
- $salesman = Salesman::findOne(['saas_user_id' => $saas_user->id, 'is_delete' => 0]);
- if (!$salesman) {
- //不是业务员
- \Yii::$app->response->format = Response::FORMAT_JSON;
- \Yii::$app->response->data = [
- 'code' => 1,
- 'msg' => '不是业务员'
- ];
- return false;
- }
- $s_id = input_params('s_id', 0);
- $salesman_new_store = SalesmanNewStore::findOne(['id' => $s_id, 'is_delete' => 0, 'salesman_saas_id' => $saas_user->id]);
- if (!$salesman_new_store) {
- //数据错误
- \Yii::$app->response->format = Response::FORMAT_JSON;
- \Yii::$app->response->data = [
- 'code' => 1,
- 'msg' => '数据错误,非当前业务员数据'
- ];
- return false;
- }
- $is_food = 0;
- if ($salesman_new_store->store_params) {
- $store_params = json_decode($salesman_new_store->store_params, true);
- if (!empty($store_params)) {
- $is_food = $store_params['is_food'];
- }
- }
- $action->controller->is_food = (int)$is_food;
- $action->controller->store_id = $salesman_new_store->store_id;
- $action->controller->s_id = $s_id;
- $action->controller->mini_id = $salesman_new_store->store_mini_id;
- $action->controller->ali_mini_id = $salesman_new_store->store_ali_mini_id;
- return parent::beforeAction($action);
- }
- }
|