45], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'user_id' => 'User ID', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'platform' => '登录渠道:h5,WXAPP、WECHAT、MP-WX', ]; } /** * 保存数据 * @param array $params * @return bool|UserLoginLog */ public static function setData(array $params) { try { if (!empty($params['user_id'])) { if (empty($model)) { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage()); return $model; } } catch (Exception $e) { self::$static_error = $e->getMessage(); return false; } } /** * 获取登录渠道 * @param $user_id * @return string */ public static function getAllPlatform($user_id){ $all_platform = ''; $where[]=['user_id'=>$user_id]; $select = 'user_id,platform'; $group = 'platform'; $params = ['where'=>$where,'select'=>$select,'group'=>$group]; $user_login_log = self::listPage($params); if(!empty($user_login_log['list'])){ foreach ($user_login_log['list'] as $v){ if(isset(User::TYPE_NAME_LIST[$v['platform']])){ $all_platform .=User::TYPE_NAME_LIST[$v['platform']].'/'; } } } return trim($all_platform,'/'); } }