mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-21 07:02:32 +02:00
refactor: prepare for v2.3.0
This commit is contained in:
@@ -70,9 +70,24 @@ export default async function saveSubscription(request) {
|
||||
if (existAddon > 0) {
|
||||
updateSubscription.set('AllowedUsers', parseInt(existAddon));
|
||||
}
|
||||
if (credits > 0) {
|
||||
updateSubscription.set('AllowedCredits', credits);
|
||||
const isSameAsPrevPlan = subscription?.get('PlanCode') === planCode;
|
||||
if (isSameAsPrevPlan) {
|
||||
const planCredits = subscription?.get('PlanCredits');
|
||||
if (planCredits) {
|
||||
updateSubscription.set('AllowedCredits', planCredits);
|
||||
} else {
|
||||
if (credits > 0) {
|
||||
updateSubscription.set('AllowedCredits', credits);
|
||||
updateSubscription.set('PlanCredits', credits);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (credits > 0) {
|
||||
updateSubscription.set('AllowedCredits', credits);
|
||||
updateSubscription.set('PlanCredits', credits);
|
||||
}
|
||||
}
|
||||
|
||||
await updateSubscription.save(null, { useMasterKey: true });
|
||||
return { status: 'update subscription!' };
|
||||
} else {
|
||||
@@ -101,6 +116,7 @@ export default async function saveSubscription(request) {
|
||||
}
|
||||
if (credits > 0) {
|
||||
createSubscription.set('AllowedCredits', credits);
|
||||
createSubscription.set('PlanCredits', credits);
|
||||
}
|
||||
await createSubscription.save(null, { useMasterKey: true });
|
||||
return { status: 'create subscription!' };
|
||||
|
||||
Reference in New Issue
Block a user