Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7505d37af6 | |||
| f9c3b18249 | |||
| 1834b97fe2 | |||
| 23f51a1ef4 | |||
| c46944aae1 |
@@ -54,10 +54,6 @@ function toUserSubscribePayload(values: SubscriptionFormValues) {
|
||||
};
|
||||
}
|
||||
|
||||
function resolvePlanSpeed(row: API.UserSubscribe) {
|
||||
return row.plan_speed_limit ?? row.subscribe?.speed_limit ?? 0;
|
||||
}
|
||||
|
||||
export default function UserSubscription({ userId }: { userId: number }) {
|
||||
const { t } = useTranslation("user");
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -319,11 +315,10 @@ export default function UserSubscription({ userId }: { userId: number }) {
|
||||
cell: ({ row }) => {
|
||||
const userSpeed = row.original.speed_limit ?? 0;
|
||||
const effectiveSpeed = row.original.effective_speed ?? 0;
|
||||
const planSpeed = resolvePlanSpeed(row.original);
|
||||
const planSpeed = row.original.subscribe?.speed_limit ?? 0;
|
||||
const speed = effectiveSpeed || userSpeed || planSpeed;
|
||||
const source = row.original.is_throttled
|
||||
? t("effectiveSpeed", "Effective Speed")
|
||||
: userSpeed > 0
|
||||
const source =
|
||||
userSpeed > 0
|
||||
? t("userOverride", "User Override")
|
||||
: t("subscriptionDefault", "Subscription Default");
|
||||
|
||||
@@ -340,16 +335,6 @@ export default function UserSubscription({ userId }: { userId: number }) {
|
||||
<span className="text-muted-foreground text-xs">
|
||||
{source}
|
||||
</span>
|
||||
<span className="text-muted-foreground text-xs">
|
||||
{t("userOverride", "User Override")}:{" "}
|
||||
<span className="inline-block">
|
||||
<Display type="trafficSpeed" value={userSpeed} />
|
||||
</span>{" "}
|
||||
/ {t("subscriptionDefault", "Subscription Default")}:{" "}
|
||||
<span className="inline-block">
|
||||
<Display type="trafficSpeed" value={planSpeed} />
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -87,12 +87,11 @@ function SpeedLimitCard({ subscriptionId }: { subscriptionId: number }) {
|
||||
|
||||
if (detail.status !== 1) return null;
|
||||
|
||||
const baseSpeed =
|
||||
detail.plan_speed_limit ?? detail.subscribe?.speed_limit ?? 0;
|
||||
const baseSpeed = detail.subscribe?.speed_limit ?? 0;
|
||||
const userSpeed = detail.speed_limit ?? 0;
|
||||
const effectiveSpeed = detail.effective_speed ?? 0;
|
||||
const isThrottled = detail.is_throttled;
|
||||
const rules = detail.user_traffic_limit || detail.traffic_limit || [];
|
||||
const rules = detail.traffic_limit || [];
|
||||
const hasLimitConfig =
|
||||
baseSpeed > 0 || userSpeed > 0 || effectiveSpeed > 0 || rules.length > 0;
|
||||
|
||||
|
||||
@@ -40,12 +40,6 @@ interface Props {
|
||||
|
||||
type SubscriptionTrafficLimitRule = API.UserSubscribeTrafficLimitRule;
|
||||
|
||||
function getUserTrafficLimitRules(
|
||||
data?: Pick<API.UserSubscribe, "traffic_limit" | "user_traffic_limit">
|
||||
) {
|
||||
return data?.user_traffic_limit || data?.traffic_limit || [];
|
||||
}
|
||||
|
||||
const defaultLimitRule: SubscriptionTrafficLimitRule = {
|
||||
stat_type: "day",
|
||||
stat_value: 1,
|
||||
@@ -104,7 +98,7 @@ export function SubscriptionForm({
|
||||
traffic: initialData?.traffic || 0,
|
||||
speed_limit: initialData?.speed_limit || 0,
|
||||
device_limit: initialData?.device_limit || 0,
|
||||
traffic_limit: getUserTrafficLimitRules(initialData),
|
||||
traffic_limit: initialData?.traffic_limit || [],
|
||||
upload: initialData?.upload || 0,
|
||||
download: initialData?.download || 0,
|
||||
expired_at: initialData?.expire_time || 0,
|
||||
|
||||
@@ -44,7 +44,7 @@ const WITHDRAWAL_METHOD_MAP: Record<number, string> = {
|
||||
0: "其他",
|
||||
1: "支付宝",
|
||||
2: "微信",
|
||||
3: "USDT(TRC20)",
|
||||
3: "银行卡",
|
||||
};
|
||||
|
||||
const rejectSchema = z.object({
|
||||
@@ -143,7 +143,7 @@ export default function WithdrawalPage() {
|
||||
const methodOptions = [
|
||||
{ value: "1", label: "支付宝" },
|
||||
{ value: "2", label: "微信" },
|
||||
{ value: "3", label: "USDT(TRC20)" },
|
||||
{ value: "3", label: "银行卡" },
|
||||
{ value: "0", label: "其他" },
|
||||
];
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ import { useGlobalStore } from "@/stores/global";
|
||||
const WITHDRAWAL_METHODS = [
|
||||
{ value: 1, label: "支付宝" },
|
||||
{ value: 2, label: "微信" },
|
||||
{ value: 3, label: "USDT(TRC20)" },
|
||||
{ value: 3, label: "银行卡" },
|
||||
{ value: 0, label: "其他" },
|
||||
] as const;
|
||||
|
||||
@@ -111,21 +111,13 @@ function QrCodeView({ url }: { url: string }) {
|
||||
<img
|
||||
alt="收款码"
|
||||
className="h-16 w-16 cursor-zoom-in object-cover"
|
||||
height={64}
|
||||
src={url}
|
||||
width={64}
|
||||
/>
|
||||
</button>
|
||||
{zoomOpen && (
|
||||
<Dialog onOpenChange={setZoomOpen} open={zoomOpen}>
|
||||
<DialogContent className="max-w-sm">
|
||||
<img
|
||||
alt="收款码"
|
||||
className="w-full"
|
||||
height={320}
|
||||
src={url}
|
||||
width={320}
|
||||
/>
|
||||
<img alt="收款码" className="w-full" src={url} />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)}
|
||||
@@ -161,16 +153,18 @@ const withdrawalFormSchema = z
|
||||
if (!data.account) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "USDT(TRC20) 地址为必填",
|
||||
message: "银行卡收款账号为必填",
|
||||
path: ["account"],
|
||||
});
|
||||
}
|
||||
} else if (data.method === 0) {
|
||||
if (!data.account && !data.content) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "收款账号和备注至少填一项",
|
||||
path: ["account"],
|
||||
});
|
||||
}
|
||||
} else if (data.method === 0 && !(data.account || data.content)) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "收款账号和备注至少填一项",
|
||||
path: ["account"],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -427,7 +421,9 @@ export default function Affiliate() {
|
||||
<FormItem>
|
||||
<FormLabel>
|
||||
收款码
|
||||
<span className="ml-1 text-destructive">*</span>
|
||||
<span className="ml-1 text-destructive">
|
||||
*
|
||||
</span>
|
||||
</FormLabel>
|
||||
{watchedQrCodeUrl ? (
|
||||
<div className="relative inline-block">
|
||||
@@ -450,9 +446,7 @@ export default function Affiliate() {
|
||||
returnType="file"
|
||||
>
|
||||
<div className="flex h-24 w-24 flex-col items-center justify-center rounded border-2 border-dashed text-muted-foreground text-xs">
|
||||
{qrUploading
|
||||
? "上传中..."
|
||||
: "点击上传\n收款码"}
|
||||
{qrUploading ? "上传中..." : "点击上传\n收款码"}
|
||||
</div>
|
||||
</UploadImage>
|
||||
)}
|
||||
@@ -480,7 +474,7 @@ export default function Affiliate() {
|
||||
<Input
|
||||
placeholder={
|
||||
watchedMethod === 3
|
||||
? "请输入 USDT(TRC20) 收款地址"
|
||||
? "请输入银行卡号或账户信息"
|
||||
: "请输入收款账号(与备注至少填一项)"
|
||||
}
|
||||
{...field}
|
||||
@@ -525,7 +519,9 @@ export default function Affiliate() {
|
||||
</Button>
|
||||
<Button
|
||||
disabled={
|
||||
submitting || qrUploading || availableCommission <= 0
|
||||
submitting ||
|
||||
qrUploading ||
|
||||
availableCommission <= 0
|
||||
}
|
||||
form="withdrawal-form"
|
||||
type="submit"
|
||||
|
||||
-4
@@ -2664,13 +2664,11 @@ declare namespace API {
|
||||
download: number;
|
||||
upload: number;
|
||||
speed_limit?: number;
|
||||
plan_speed_limit?: number;
|
||||
device_limit?: number;
|
||||
effective_speed?: number;
|
||||
is_throttled?: boolean;
|
||||
throttle_rule?: string;
|
||||
traffic_limit?: UserSubscribeTrafficLimitRule[];
|
||||
user_traffic_limit?: UserSubscribeTrafficLimitRule[];
|
||||
token: string;
|
||||
status: number;
|
||||
short: string;
|
||||
@@ -2701,10 +2699,8 @@ declare namespace API {
|
||||
download: number;
|
||||
upload: number;
|
||||
speed_limit?: number;
|
||||
plan_speed_limit?: number;
|
||||
device_limit?: number;
|
||||
traffic_limit?: UserSubscribeTrafficLimitRule[];
|
||||
user_traffic_limit?: UserSubscribeTrafficLimitRule[];
|
||||
token: string;
|
||||
status: number;
|
||||
effective_speed: number;
|
||||
|
||||
Reference in New Issue
Block a user