feat: add software subscription orders
This commit is contained in:
@@ -4,6 +4,7 @@ from django import forms
|
||||
from django.conf import settings
|
||||
|
||||
from apps.billing.models import RechargeOrder
|
||||
from apps.licensing.models import ClientDevice, SoftwareOrder, SoftwarePlan
|
||||
|
||||
|
||||
class ApiKeyCreateForm(forms.Form):
|
||||
@@ -52,3 +53,25 @@ class RechargeCreateForm(forms.Form):
|
||||
if amount > max_amount:
|
||||
raise forms.ValidationError(f"单笔充值金额不能超过 {max_amount:.2f} CNY")
|
||||
return amount
|
||||
|
||||
|
||||
class SoftwareOrderCreateForm(forms.Form):
|
||||
plan = forms.ModelChoiceField(
|
||||
label="套餐",
|
||||
queryset=SoftwarePlan.objects.none(),
|
||||
empty_label=None,
|
||||
widget=forms.Select(attrs={"class": "form-select"}),
|
||||
)
|
||||
pay_method = forms.ChoiceField(
|
||||
label="支付方式",
|
||||
choices=((SoftwareOrder.PayMethod.WEIXIN, "微信"),),
|
||||
initial=SoftwareOrder.PayMethod.WEIXIN,
|
||||
widget=forms.RadioSelect(attrs={"class": "form-check-input"}),
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["plan"].queryset = SoftwarePlan.objects.filter(
|
||||
product_code=ClientDevice.ProductCode.CMSHOPEE,
|
||||
status=SoftwarePlan.Status.ACTIVE,
|
||||
).order_by("name", "id")
|
||||
|
||||
Reference in New Issue
Block a user