feat(shopro): 添加俱乐部、球馆的访客记录功能

- 在 Club 控制器中添加访客记录逻辑
- 在 Gym 控制器中添加访客记录逻辑
- 在 Sys 控制器中添加获取访客记录的功能
This commit is contained in:
2025-06-05 14:55:16 +08:00
parent 582c52e3a1
commit 9223c1b127
11 changed files with 431 additions and 0 deletions

View File

@@ -2,6 +2,8 @@
namespace addons\shopro\controller\zy;
use app\admin\model\zy\link\Visitor;
class Gym extends Base
@@ -24,4 +26,28 @@ class Gym extends Base
$res = $query->paginate($params['pageSize'] ?? 10);
$this->success('Success', ['list' => $res->items(), 'count' => $res->total()]);
}
public function view()
{
$model = $this->model->get($this->request->param('id'));
if (empty($model)) {
$this->error(__('No rows were found'));
}
$user = auth_user();
$visitor = Visitor::where('type', 1)->where('obj_id', $model['id'])->where('user_id', $user['id'])->find();
if (empty($visitor)) {
$visitor = new Visitor;
}
$visitor->allowField(true)->save([
'type' => 1,
'obj_id' => $model['id'],
'user_id' => $user['id'],
'nickname' => $user['nickname'],
'avatar' => $user['avatar'],
'gender' => $user['gender'],
'times' => empty($visitor->times) ? 1 : $visitor->times + 1
]);
$this->success('Success', $model);
}
}