|
@@ -10,6 +10,7 @@ namespace app\index\controller;
|
|
|
use app\common\service\CommonService;
|
|
|
use app\index\exception\ApiException;
|
|
|
use app\index\model\UserModel;
|
|
|
+use app\index\model\VisitorModel;
|
|
|
use think\console\command\make\Model;
|
|
|
use think\facade\Cache;
|
|
|
use think\facade\Session;
|
|
@@ -26,14 +27,19 @@ class Index {
|
|
|
$data = CommonService::getSetData($channelId);
|
|
|
$info = (new UserModel())::where(['unionid' => Session::get('wxId'), 'channel_id' => $channelId])->find();
|
|
|
if (empty(Session::get('wxId')) || empty($info)){
|
|
|
- Cache::set(Session::get('wxId'), '');
|
|
|
header("Location:".CommonService::getAuthUrl($channelId));
|
|
|
die();
|
|
|
}
|
|
|
- if (empty(Cache::get(Session::get('wxId')))) {
|
|
|
- Cache::set(Session::get('wxId'), $visitorId);
|
|
|
+ $model = new VisitorModel();
|
|
|
+ $info = $model::where(['unionid' => Session::get('wxId')])->find();
|
|
|
+ if (empty($info)) {
|
|
|
+ $model::where(['unionid' => Session::get('wxId')])->insertGetId([
|
|
|
+ 'visitorId' => $visitorId,
|
|
|
+ 'unionid' => Session::get('wxId'),
|
|
|
+ ]);
|
|
|
+ } else {
|
|
|
+ $visitorId = $info['visitorId'];
|
|
|
}
|
|
|
- $visitorId = Cache::get(Session::get('wxId'));
|
|
|
// $params = [
|
|
|
// 'id' => $info['channel_id'],
|
|
|
// 'userid' => $info['unionid'],
|