fix(governance): batch activate subscriptions excludes failed and dirty renewal orders

This commit is contained in:
萝卜
2026-03-16 20:15:33 +08:00
parent 115e94644d
commit 2f4e727c1b

View File

@@ -1461,10 +1461,20 @@ class PlatformOrderController extends Controller
} }
// 只处理“可同步”的订单(双保险,避免误操作) // 只处理“可同步”的订单(双保险,避免误操作)
// 口径需与 applyFilters(syncable_only=1) 一致:
// - 已支付 + 已生效
// - 未同步subscription_activation.subscription_id 为空)
// - 非失败subscription_activation_error.message 为空)
// - 排除:续费但未绑定订阅(脏数据,避免串单风险)
$query = $query $query = $query
->where('payment_status', 'paid') ->where('payment_status', 'paid')
->where('status', 'activated') ->where('status', 'activated')
->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation.subscription_id') IS NULL"); ->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation.subscription_id') IS NULL")
->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation_error.message') IS NULL")
->where(function (Builder $q) {
$q->where('order_type', '!=', 'renewal')
->orWhereNotNull('site_subscription_id');
});
$limit = (int) $request->input('limit', 50); $limit = (int) $request->input('limit', 50);
$limit = max(1, min(500, $limit)); $limit = max(1, min(500, $limit));