where('UserID', $UserID)->first()) { self::query()->insert([ 'UserID' => $UserID, 'Source' => $Source, 'AdChannel' => $AdChannel ]); } // 类别添加 $key = 'adChannel_' . $AdChannel; $redisConnect = (new RedisConnect())->redis(); if (!$redisConnect->exists($key)) { $count = DB::table(TableName::agent() . 'account_source_class') ->where('ad_channel', $AdChannel)->count(); if (!$count) { DB::table(TableName::agent() . 'account_source_class') ->insert([ 'ad_channel' => $AdChannel, //'Source' => $Source ]); } $redisConnect->set($key, $AdChannel); } return true; } // 获取用户来源 public function getUserSource($UserID) { $list = cache()->remember($UserID . '_getUserSource', (60 * 24 * 10), function () use ($UserID) { return self::query()->where('UserID', $UserID)->value('Source'); }); return $list; } // 获取用户来源渠道 public function getUserAdChannel($UserID) { $list = cache()->remember($UserID . '_getUserAdChannel', (60 * 24 * 10), function () use ($UserID) { return self::query()->where('UserID', $UserID)->value('AdChannel'); }); return $list; } }