|
|
@@ -26,7 +26,7 @@ class PointsService
|
|
|
/**
|
|
|
* AI对话(chatForAce / addChatForAce单剧集 / reGenerateAnimeForAce单剧集 / regenerateSegmentScript剧集模式)单次扣费积分数
|
|
|
*/
|
|
|
- const CHAT_CHARGE_POINTS = 0;
|
|
|
+ const CHAT_CHARGE_POINTS = 10;
|
|
|
|
|
|
/**
|
|
|
* 获取视频模型应扣积分数(公共方法)
|
|
|
@@ -255,18 +255,30 @@ class PointsService
|
|
|
->paginate($pageSize);
|
|
|
|
|
|
// 汇总统计:当前积分余额、累计消耗/退回积分、累计消耗token
|
|
|
+ // 排除带 test_mode 标记的测试记录,保证统计口径与用户表实际余额一致
|
|
|
+ $excludeTestRecords = function ($query) {
|
|
|
+ $query->whereNull('charge_info')
|
|
|
+ ->orWhereNull('charge_info->test_mode')
|
|
|
+ ->orWhere('charge_info->test_mode', '!=', 'true');
|
|
|
+ };
|
|
|
+
|
|
|
$user = DB::table('mp_manage_users')->where('id', $uid)->first();
|
|
|
$summary = [
|
|
|
'points_balance' => (float)getProp($user, 'points', 0),
|
|
|
'total_points_consumed' => (float)MpUserPointsDetail::where('uid', $uid)
|
|
|
->where('points_consumed', '>', 0)
|
|
|
+ ->where($excludeTestRecords)
|
|
|
->sum('points_consumed'),
|
|
|
'total_points_refunded' => (float)MpUserPointsDetail::where('uid', $uid)
|
|
|
->where('points_consumed', '<', 0)
|
|
|
+ ->where($excludeTestRecords)
|
|
|
->sum('points_consumed'),
|
|
|
'total_tokens_consumed' => (int)MpUserPointsDetail::where('uid', $uid)
|
|
|
+ ->where($excludeTestRecords)
|
|
|
->sum('tokens_consumed'),
|
|
|
- 'total_count' => (int)MpUserPointsDetail::where('uid', $uid)->count(),
|
|
|
+ 'total_count' => (int)MpUserPointsDetail::where('uid', $uid)
|
|
|
+ ->where($excludeTestRecords)
|
|
|
+ ->count(),
|
|
|
];
|
|
|
|
|
|
return [
|
|
|
@@ -664,6 +676,12 @@ class PointsService
|
|
|
$isTestUser = $this->isTestUser($uid, (int)getProp($user, 'cpid', 0));
|
|
|
$pointsAfter = $isTestUser ? $pointsBefore : $pointsBefore - $points;
|
|
|
|
|
|
+ // 测试标记落库:charge_info 写入 test_mode,remark 追加 [测试],便于统计排除与历史排查
|
|
|
+ if ($isTestUser) {
|
|
|
+ $chargeInfo['test_mode'] = true;
|
|
|
+ $remark = trim(($remark ? $remark . ';' : '') . '[测试]仅记账不扣费');
|
|
|
+ }
|
|
|
+
|
|
|
if (!$isTestUser && $pointsBefore < $points) {
|
|
|
dLog('points')->warning('用户积分不足,扣费后积分为负数', [
|
|
|
'task_id' => $taskId,
|