feat(billing): add dual formulas, disable 10yuan gift, retry auto-renew
Memind CI / Test, build, and release guards (push) Successful in 3m43s
Memind CI / Test, build, and release guards (push) Successful in 3m43s
Turn off the low-balance 10 CNY signup bonus while keeping the 5 CNY registration credit, split metering into independent formula A/B scopes, and retry expired auto-renew subscriptions after recharge or hourly worker. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+8
-4
@@ -2109,12 +2109,12 @@ export function createTkmindProxy({
|
||||
return upstream.json();
|
||||
}
|
||||
|
||||
async function resolveSessionBillingTokenState(sessionId, tokenStateRaw) {
|
||||
async function resolveSessionBillingTokenState(sessionId, tokenStateRaw, userId = null) {
|
||||
return resolveBillingTokenState(tokenStateRaw, {
|
||||
sessionId,
|
||||
fetchSession: fetchSessionBillingCost,
|
||||
loadEstimateConfig: billingConfigService?.getEffectiveCostEstimateConfig
|
||||
? () => billingConfigService.getEffectiveCostEstimateConfig()
|
||||
? () => billingConfigService.getEffectiveCostEstimateConfig({ userId })
|
||||
: null,
|
||||
});
|
||||
}
|
||||
@@ -2218,7 +2218,7 @@ export function createTkmindProxy({
|
||||
}
|
||||
if (!finishResult.ok) throw finishResult.error;
|
||||
const finish = finishResult.value;
|
||||
const tokenState = await resolveSessionBillingTokenState(sessionId, finish.tokenState);
|
||||
const tokenState = await resolveSessionBillingTokenState(sessionId, finish.tokenState, userId);
|
||||
if (tokenState && userAuth.billSessionUsage) {
|
||||
await userAuth
|
||||
.billSessionUsage(userId, sessionId, tokenState, requestId)
|
||||
@@ -2720,7 +2720,11 @@ export function createTkmindProxy({
|
||||
.catch(() => {});
|
||||
}
|
||||
const billingRequestId = event.request_id ?? event.chat_request_id ?? null;
|
||||
const tokenState = await resolveSessionBillingTokenState(sessionId, event.token_state);
|
||||
const tokenState = await resolveSessionBillingTokenState(
|
||||
sessionId,
|
||||
event.token_state,
|
||||
req.currentUser.id,
|
||||
);
|
||||
const result = await userAuth.billSessionUsage(
|
||||
req.currentUser.id,
|
||||
sessionId,
|
||||
|
||||
Reference in New Issue
Block a user