deploy: auto commit repo-root changes 2026-07-05 12:03:49

This commit is contained in:
hajimi
2026-07-05 12:03:49 +08:00
parent 074aa7ab3e
commit 1954948445
107 changed files with 161 additions and 125 deletions
+6 -23
View File
@@ -4,6 +4,7 @@ namespace app\common\model\ai;
use app\common\model\BaseModel;
use app\common\model\user\User;
use app\common\service\ai\AiQuotaService;
class AiUnlock extends BaseModel
{
@@ -33,7 +34,7 @@ class AiUnlock extends BaseModel
}
// VIP用户不限次数
if ($user->is_vip && $user->vip_expire_time > time()) {
if (AiQuotaService::isVip($user)) {
self::create([
'user_id' => $userId,
'match_id' => $matchId,
@@ -41,20 +42,14 @@ class AiUnlock extends BaseModel
return ['ok' => true, 'msg' => 'VIP解锁'];
}
// 重置每日次数(跨天时)
$today = date('Y-m-d');
if ($user->ai_free_date !== $today) {
$user->ai_free_count = 3;
$user->ai_free_date = $today;
$user->save();
}
$freeCount = AiQuotaService::resetDailyIfNeeded($user);
if ($user->ai_free_count <= 0) {
if ($freeCount <= 0) {
return ['ok' => false, 'msg' => '今日免费次数已用完,升级VIP可无限使用'];
}
// 扣次数 + 写解锁记录
$user->ai_free_count = $user->ai_free_count - 1;
$user->ai_free_count = $freeCount - 1;
$user->save();
self::create([
@@ -70,18 +65,6 @@ class AiUnlock extends BaseModel
*/
public static function getRemainCount(int $userId): int
{
$user = User::findOrEmpty($userId);
if ($user->isEmpty()) {
return 0;
}
// VIP不限
if ($user->is_vip && $user->vip_expire_time > time()) {
return 999;
}
$today = date('Y-m-d');
if ($user->ai_free_date !== $today) {
return 3;
}
return max(0, (int)$user->ai_free_count);
return AiQuotaService::getRemainCount($userId);
}
}