Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc29a025b0 | ||
|
|
85f9e68e32 | ||
|
|
7cd1a7cbe7 | ||
|
|
66ee6bb9fd | ||
|
|
b041bd3b01 | ||
|
|
385869604a |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "lanhu-admin",
|
||||
"version": "1.6.0",
|
||||
"version": "1.8.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -H 0.0.0.0 -p 3001 --turbopack",
|
||||
|
||||
@@ -9,8 +9,8 @@ if ($confrim -ne "y") {
|
||||
exit 0
|
||||
}
|
||||
|
||||
docker build -t repo.lanhuip.com:8554/lanhu/admin:latest .
|
||||
docker build -t repo.lanhuip.com:8554/lanhu/admin:$($args[0]) .
|
||||
docker build -t repo.lanhuip.com/lanhu/admin:latest .
|
||||
docker build -t repo.lanhuip.com/lanhu/admin:$($args[0]) .
|
||||
|
||||
docker push repo.lanhuip.com:8554/lanhu/admin:latest
|
||||
docker push repo.lanhuip.com:8554/lanhu/admin:$($args[0])
|
||||
docker push repo.lanhuip.com/lanhu/admin:latest
|
||||
docker push repo.lanhuip.com/lanhu/admin:$($args[0])
|
||||
|
||||
@@ -7,22 +7,28 @@ export async function getPagCoupon(params: { page: number; size: number }) {
|
||||
}
|
||||
|
||||
export async function createCoupon(data: {
|
||||
code: string
|
||||
name: string
|
||||
amount: number
|
||||
remark?: string
|
||||
min_amount?: number
|
||||
count: number
|
||||
status: number
|
||||
min_amount: number
|
||||
expire_at?: Date
|
||||
expire_in?: number
|
||||
expire_type: number
|
||||
}) {
|
||||
return callByUser<Coupon>("/api/admin/coupon/create", data)
|
||||
}
|
||||
|
||||
export async function updateCoupon(data: {
|
||||
code: string
|
||||
id: number
|
||||
name: string
|
||||
amount: number
|
||||
remark?: string
|
||||
min_amount?: number
|
||||
min_amount: number
|
||||
count: number
|
||||
status: number
|
||||
expire_type: number
|
||||
expire_at?: Date
|
||||
status?: number
|
||||
expire_in?: number
|
||||
}) {
|
||||
return callByUser<Coupon>("/api/admin/coupon/update", data)
|
||||
}
|
||||
@@ -32,3 +38,21 @@ export async function deleteCoupon(id: number) {
|
||||
id,
|
||||
})
|
||||
}
|
||||
|
||||
export async function getReleaseCoupon(data: {
|
||||
coupon_id: number
|
||||
user_id: number
|
||||
}) {
|
||||
return callByUser<Coupon>("/api/admin/coupon/update/assign", data)
|
||||
}
|
||||
|
||||
export async function getUserCoupon(data: {
|
||||
page: number
|
||||
size: number
|
||||
user_id: number
|
||||
}) {
|
||||
return callByUser<PageRecord<Coupon>>(
|
||||
"/api/admin/coupon-user/page/of-user",
|
||||
data,
|
||||
)
|
||||
}
|
||||
|
||||
10
src/actions/env.ts
Normal file
10
src/actions/env.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { toast } from "sonner"
|
||||
|
||||
const NODE_ENV = process.env.NODE_ENV
|
||||
|
||||
export async function getNodeEnv() {
|
||||
if (!NODE_ENV) {
|
||||
toast.error(`接口请求错误:NODE_ENV为空`)
|
||||
}
|
||||
return NODE_ENV
|
||||
}
|
||||
@@ -8,22 +8,21 @@ export async function getGatewayPage(params: { page: number; size: number }) {
|
||||
return callByUser<PageRecord<Gateway>>("/api/admin/proxy/page", params)
|
||||
}
|
||||
|
||||
|
||||
export async function createGateway(data: {
|
||||
mac: string
|
||||
ip: string
|
||||
host?: string
|
||||
type: number
|
||||
status: number
|
||||
secret: string
|
||||
}) {
|
||||
return callByUser<Gateway>("/api/admin/proxy/create", data)
|
||||
}
|
||||
|
||||
export async function updateGateway(data:{
|
||||
id: number,
|
||||
status: number}
|
||||
) {
|
||||
return callByUser<Gateway>("/api/admin/proxy/update/status",
|
||||
data
|
||||
)
|
||||
export async function updateGateway(data: { id: number; status: number }) {
|
||||
return callByUser<Gateway>("/api/admin/proxy/update/status", data)
|
||||
}
|
||||
|
||||
export async function clear(data: { proxy_id: number }) {
|
||||
return callByUser<PageRecord>("/api/admin/channel/sync/clear-expired", data)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from "lucide-react"
|
||||
import Link from "next/link"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { createContext, type ReactNode, useContext, useState } from "react"
|
||||
import { createContext, type ReactNode, Suspense, useContext, useState } from "react"
|
||||
import { twJoin } from "tailwind-merge"
|
||||
import { Auth } from "@/components/auth"
|
||||
import { Button } from "@/components/ui/button"
|
||||
@@ -54,6 +54,7 @@ import {
|
||||
ScopeUserReadNotBind,
|
||||
ScopeUserReadOne,
|
||||
} from "@/lib/scopes"
|
||||
import Logo from "./logo"
|
||||
|
||||
// Navigation Context
|
||||
interface NavigationContextType {
|
||||
@@ -255,7 +256,7 @@ const menuSections: { title: string; items: NavItemProps[] }[] = [
|
||||
href: "/gateway",
|
||||
icon: DoorClosedIcon,
|
||||
label: "网关列表",
|
||||
requiredScope:ScopeProxyRead
|
||||
requiredScope: ScopeProxyRead,
|
||||
},
|
||||
{
|
||||
href: "/admin",
|
||||
@@ -301,22 +302,13 @@ export default function Navigation() {
|
||||
<NavigationContext.Provider value={contextValue}>
|
||||
<aside
|
||||
className={twJoin(
|
||||
"bg-background border-r border-border transition-all duration-300 ease-in-out flex flex-col h-full",
|
||||
"bg-white border-r border-slate-200 transition-all duration-300 ease-in-out flex flex-col h-full",
|
||||
collapsed ? "w-16" : "w-64",
|
||||
)}
|
||||
>
|
||||
{/*Logo 区域 */}
|
||||
<div className="h-16 flex items-center justify-center border-b border-border p-4 shrink-0">
|
||||
{!collapsed ? (
|
||||
<span className="text-xl font-bold tracking-wide text-foreground">
|
||||
管理系统
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-xl font-bold mx-auto text-foreground">
|
||||
<ComputerIcon />
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<Suspense><Logo collapsed={collapsed} /></Suspense>
|
||||
|
||||
{/* Navigation Menu */}
|
||||
<ScrollArea className="flex-1 py-3 overflow-hidden">
|
||||
<nav className="space-y-3">
|
||||
29
src/app/(root)/_navigation/logo.tsx
Normal file
29
src/app/(root)/_navigation/logo.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
import { ComputerIcon } from "lucide-react"
|
||||
import { getNodeEnv } from "@/actions/env"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
export default async function Logo(props: { collapsed: boolean }) {
|
||||
const env = await getNodeEnv()
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
`h-16 flex items-center justify-between border-b px-4 shrink-0`,
|
||||
env === "production" && "bg-amber-100",
|
||||
)}
|
||||
>
|
||||
{!props.collapsed ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center">
|
||||
<ComputerIcon className="h-4 w-4" />
|
||||
</div>
|
||||
<span className="text-xl font-bold tracking-wide">管理系统</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full flex justify-center">
|
||||
<div className="w-8 h-8 bg-blue-100 rounded-lg flex items-center justify-center"></div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export default function BalancePage() {
|
||||
return (
|
||||
<Page>
|
||||
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<div className="flex items-end gap-4">
|
||||
<Controller
|
||||
name="phone"
|
||||
control={control}
|
||||
@@ -142,9 +142,7 @@ export default function BalancePage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
||||
<Button type="submit">搜索</Button>
|
||||
<Button
|
||||
type="button"
|
||||
@@ -157,7 +155,7 @@ export default function BalancePage() {
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</FieldGroup>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<Suspense>
|
||||
@@ -169,7 +167,7 @@ export default function BalancePage() {
|
||||
accessorFn: row => row.user?.phone || "",
|
||||
},
|
||||
{
|
||||
header: "账单号",
|
||||
header: "账单编号",
|
||||
accessorFn: row => row.bill?.bill_no || "",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -113,8 +113,8 @@ export default function BatchPage() {
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
>
|
||||
<FieldLabel>批次号</FieldLabel>
|
||||
<Input {...field} placeholder="请输入批次号" />
|
||||
<FieldLabel>提取编号</FieldLabel>
|
||||
<Input {...field} placeholder="请输入提取编号" />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</Field>
|
||||
)}
|
||||
@@ -256,7 +256,7 @@ export default function BatchPage() {
|
||||
accessorFn: row => row.user?.phone || "",
|
||||
},
|
||||
{ header: "套餐号", accessorKey: "resource.resource_no" },
|
||||
{ header: "批次号", accessorKey: "batch_no" },
|
||||
{ header: "提取编号", accessorKey: "batch_no" },
|
||||
{ header: "省份", accessorKey: "prov" },
|
||||
{ header: "城市", accessorKey: "city" },
|
||||
{ header: "用户IP", accessorKey: "ip" },
|
||||
|
||||
@@ -113,8 +113,8 @@ export default function ChannelPage() {
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
>
|
||||
<FieldLabel>批次号</FieldLabel>
|
||||
<Input {...field} placeholder="请输入批次号" />
|
||||
<FieldLabel>提取编号</FieldLabel>
|
||||
<Input {...field} placeholder="请输入提取编号" />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</Field>
|
||||
)}
|
||||
@@ -244,7 +244,7 @@ export default function ChannelPage() {
|
||||
accessorFn: row => row.user?.phone || "-",
|
||||
},
|
||||
{ header: "套餐号", accessorKey: "resource.resource_no" },
|
||||
{ header: "批次号", accessorKey: "batch_no" },
|
||||
{ header: "提取编号", accessorKey: "batch_no" },
|
||||
{
|
||||
header: "节点",
|
||||
accessorFn: row => row.ip || row.edge_ref || row.edge_id,
|
||||
|
||||
@@ -98,7 +98,7 @@ export default function BalancePage() {
|
||||
<span className="ml-2 text-gray-600">用户会员号: {userPhone}</span>
|
||||
</div>
|
||||
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<div className="flex items-end gap-4">
|
||||
<Controller
|
||||
name="bill_no"
|
||||
control={control}
|
||||
@@ -141,9 +141,7 @@ export default function BalancePage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
||||
|
||||
<Button type="submit">搜索</Button>
|
||||
<Button
|
||||
type="button"
|
||||
@@ -156,7 +154,7 @@ export default function BalancePage() {
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</FieldGroup>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<Suspense>
|
||||
|
||||
109
src/app/(root)/client/coupon/coupon.tsx
Normal file
109
src/app/(root)/client/coupon/coupon.tsx
Normal file
@@ -0,0 +1,109 @@
|
||||
"use client"
|
||||
import { useState } from "react"
|
||||
import { toast } from "sonner"
|
||||
import { getPagCoupon } from "@/actions/coupon"
|
||||
import { DataTable, useDataTable } from "@/components/data-table"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog"
|
||||
import type { Coupon } from "@/models/coupon"
|
||||
|
||||
export function IssueCouponForUser(props: {
|
||||
userId: number
|
||||
userPhone: string
|
||||
onSuccess?: () => void
|
||||
}) {
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
const table = useDataTable<Coupon>((page, size) =>
|
||||
getPagCoupon({ page, size }),
|
||||
)
|
||||
|
||||
const handleIssue = async (coupon: Coupon) => {
|
||||
// try {
|
||||
// const result = await issueCouponToUser({
|
||||
// user_id: props.userId,
|
||||
// coupon_id: coupon.id,
|
||||
// coupon_name: coupon.name,
|
||||
// })
|
||||
// if (result.success) {
|
||||
// toast.success(`成功发放「${coupon.name}」给用户 ${props.userPhone}`)
|
||||
// props.onSuccess?.()
|
||||
// setOpen(false)
|
||||
// } else {
|
||||
// toast.error(result.message || "发放失败")
|
||||
// }
|
||||
// } catch (error) {
|
||||
// const message = error instanceof Error ? error.message : "发放失败"
|
||||
// toast.error(`发放优惠券失败: ${message}`)
|
||||
// }
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
onOpenChange={newOpen => {
|
||||
setOpen(newOpen)
|
||||
if (newOpen) {
|
||||
table.refresh()
|
||||
}
|
||||
}}
|
||||
>
|
||||
<DialogTrigger asChild>
|
||||
<Button>发放优惠券</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent
|
||||
className="max-h-[85vh] overflow-y-auto"
|
||||
style={{ width: "auto", minWidth: "800px", maxWidth: "90vw" }}
|
||||
>
|
||||
<DialogHeader>
|
||||
<DialogTitle>发放优惠券给 {props.userPhone}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<DataTable<Coupon>
|
||||
{...table}
|
||||
columns={[
|
||||
{ header: "优惠券名称", accessorKey: "name" },
|
||||
{ header: "优惠券金额", accessorKey: "amount" },
|
||||
{ header: "最低消费金额", accessorKey: "min_amount" },
|
||||
{
|
||||
header: "状态",
|
||||
accessorKey: "status",
|
||||
cell: ({ row }) => {
|
||||
const status = row.original.status
|
||||
if (status === 0) {
|
||||
return <span className="text-yellow-600">禁用</span>
|
||||
}
|
||||
if (status === 1) {
|
||||
return <span className="text-green-600">正常</span>
|
||||
}
|
||||
return <span>-</span>
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "action",
|
||||
meta: { pin: "right" },
|
||||
header: "操作",
|
||||
cell: ({ row }) => (
|
||||
<Button size="sm" onClick={() => handleIssue(row.original)}>
|
||||
发放
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button variant="ghost">取消</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
275
src/app/(root)/client/coupon/page.tsx
Normal file
275
src/app/(root)/client/coupon/page.tsx
Normal file
@@ -0,0 +1,275 @@
|
||||
"use client"
|
||||
import { format } from "date-fns"
|
||||
import { useRouter, useSearchParams } from "next/navigation"
|
||||
import { Suspense, useState } from "react"
|
||||
import { toast } from "sonner"
|
||||
import { getUserCoupon } from "@/actions/coupon"
|
||||
import { DataTable, useDataTable } from "@/components/data-table"
|
||||
import { Page } from "@/components/page"
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
} from "@/components/ui/alert-dialog"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select"
|
||||
import type { Coupon } from "@/models/coupon"
|
||||
|
||||
export default function CouponPage() {
|
||||
const router = useRouter()
|
||||
const searchParams = useSearchParams()
|
||||
const userId = searchParams.get("userId")
|
||||
const userPhone = searchParams.get("phone")
|
||||
|
||||
const table = useDataTable<Coupon>((page, size) => {
|
||||
return getUserCoupon({
|
||||
user_id: Number(userId),
|
||||
page,
|
||||
size,
|
||||
})
|
||||
})
|
||||
console.log(table, "table")
|
||||
|
||||
const expireLabel = (coupon: Coupon) => {
|
||||
switch (coupon.expire_type) {
|
||||
case 0:
|
||||
return "永久有效"
|
||||
case 1:
|
||||
return coupon.expire_at
|
||||
? format(new Date(coupon.expire_at), "yyyy-MM-dd")
|
||||
: ""
|
||||
case 2:
|
||||
return coupon.expire_in ? `发放后${coupon.expire_in}天` : ""
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<Button onClick={() => router.back()} className="gap-2">
|
||||
返回上一级
|
||||
</Button>
|
||||
<span className="text-gray-600">用户手机号: {userPhone}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Suspense>
|
||||
<DataTable<Coupon>
|
||||
{...table}
|
||||
columns={[
|
||||
{ header: "优惠券名称", accessorKey: "name" },
|
||||
{ header: "券码", accessorKey: "code" },
|
||||
{ header: "金额", accessorKey: "amount" },
|
||||
{ header: "最低消费", accessorKey: "min_amount" },
|
||||
{
|
||||
header: "状态",
|
||||
accessorKey: "coupon_status",
|
||||
},
|
||||
{
|
||||
header: "过期信息",
|
||||
id: "expire",
|
||||
cell: ({ row }) => expireLabel(row.original),
|
||||
},
|
||||
{
|
||||
header: "发放时间",
|
||||
accessorKey: "issued_at",
|
||||
// cell: ({ row }) =>
|
||||
// format(new Date(row.original.issued_at), "yyyy-MM-dd HH:mm"),
|
||||
},
|
||||
{
|
||||
header: "备注",
|
||||
accessorKey: "remark",
|
||||
cell: ({ row }) => (
|
||||
<span className="text-gray-500">
|
||||
{row.original.remark || "-"}
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "action",
|
||||
meta: { pin: "right" },
|
||||
header: "操作",
|
||||
cell: ({ row }) => (
|
||||
<div className="flex gap-2">
|
||||
<UpdateStatusDialog
|
||||
coupon={row.original}
|
||||
userId={Number(userId)}
|
||||
onSuccess={table.refresh}
|
||||
/>
|
||||
<RevokeDialog
|
||||
coupon={row.original}
|
||||
userId={Number(userId)}
|
||||
onSuccess={table.refresh}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Suspense>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
||||
function UpdateStatusDialog({
|
||||
coupon,
|
||||
userId,
|
||||
onSuccess,
|
||||
}: {
|
||||
coupon: Coupon
|
||||
userId: number
|
||||
onSuccess?: () => void
|
||||
}) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [selectedStatus, setSelectedStatus] =
|
||||
useState(
|
||||
// String(coupon.coupon_status),
|
||||
)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const handleConfirm = async () => {
|
||||
// setLoading(true)
|
||||
// try {
|
||||
// const status = Number(selectedStatus)
|
||||
// const result = await updateUserCouponStatus({
|
||||
// user_id: userId,
|
||||
// coupon_id: coupon.id,
|
||||
// coupon_status: status,
|
||||
// })
|
||||
// if (result.success) {
|
||||
// toast.success("状态更新成功")
|
||||
// onSuccess?.()
|
||||
// setOpen(false)
|
||||
// } else {
|
||||
// toast.error(result.message || "更新失败")
|
||||
// }
|
||||
// } catch (error) {
|
||||
// const message = error instanceof Error ? error.message : "更新失败"
|
||||
// toast.error(`状态更新失败: ${message}`)
|
||||
// } finally {
|
||||
// setLoading(false)
|
||||
// }
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="sm" variant="secondary">
|
||||
修改状态
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="sm:max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle>修改优惠券状态</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="py-4">
|
||||
<p className="text-sm text-gray-600 mb-3">
|
||||
优惠券: {coupon.name} ({coupon.code})
|
||||
</p>
|
||||
<Select value={selectedStatus}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择状态" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="1">未使用</SelectItem>
|
||||
<SelectItem value="2">已使用</SelectItem>
|
||||
<SelectItem value="3">已过期</SelectItem>
|
||||
<SelectItem value="0">已撤销</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button variant="ghost">取消</Button>
|
||||
</DialogClose>
|
||||
<Button onClick={handleConfirm} disabled={loading}>
|
||||
确认
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
||||
function RevokeDialog({
|
||||
coupon,
|
||||
userId,
|
||||
onSuccess,
|
||||
}: {
|
||||
coupon: Coupon
|
||||
userId: number
|
||||
onSuccess?: () => void
|
||||
}) {
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const handleConfirm = async () => {
|
||||
// setLoading(true)
|
||||
// try {
|
||||
// const result = await revokeUserCoupon({
|
||||
// user_id: userId,
|
||||
// coupon_id: coupon.id,
|
||||
// })
|
||||
// if (result.success) {
|
||||
// toast.success("撤销成功")
|
||||
// onSuccess?.()
|
||||
// } else {
|
||||
// toast.error(result.message || "撤销失败")
|
||||
// }
|
||||
// } catch (error) {
|
||||
// const message = error instanceof Error ? error.message : "撤销失败"
|
||||
// toast.error(`撤销失败: ${message}`)
|
||||
// } finally {
|
||||
// setLoading(false)
|
||||
// }
|
||||
}
|
||||
|
||||
return (
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button size="sm" variant="destructive" disabled={loading}>
|
||||
撤销
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent size="sm">
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>确认撤销</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
确定要撤销「{coupon.name}」({coupon.code})
|
||||
吗?此操作将标记优惠券为已撤销状态。
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>取消</AlertDialogCancel>
|
||||
<AlertDialogAction variant="destructive" onClick={handleConfirm}>
|
||||
撤销
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
)
|
||||
}
|
||||
@@ -19,12 +19,7 @@ import {
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import {
|
||||
Field,
|
||||
FieldError,
|
||||
FieldGroup,
|
||||
FieldLabel,
|
||||
} from "@/components/ui/field"
|
||||
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import {
|
||||
ScopeBalanceActivityReadOfUser,
|
||||
@@ -111,15 +106,12 @@ export default function UserQueryPage() {
|
||||
return (
|
||||
<Page>
|
||||
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<div className="flex items-end gap-4">
|
||||
<Controller
|
||||
name="phone"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
>
|
||||
<Field data-invalid={fieldState.invalid} className="w-40 flex">
|
||||
<FieldLabel>手机号</FieldLabel>
|
||||
<Input {...field} placeholder="请输入手机号" />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
@@ -131,19 +123,13 @@ export default function UserQueryPage() {
|
||||
name="name"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
>
|
||||
<Field data-invalid={fieldState.invalid} className="w-40 flex">
|
||||
<FieldLabel>姓名</FieldLabel>
|
||||
<Input {...field} placeholder="请输入姓名" />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
||||
<Auth scope={ScopeUserWrite}>
|
||||
<AddUserDialog onSuccess={refreshTable} />
|
||||
</Auth>
|
||||
@@ -151,7 +137,7 @@ export default function UserQueryPage() {
|
||||
重置
|
||||
</Button>
|
||||
<Button type="submit">搜索</Button>
|
||||
</FieldGroup>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<Suspense>
|
||||
@@ -263,7 +249,7 @@ export default function UserQueryPage() {
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
router.push(
|
||||
`/client/trade?userId=${row.original.id}`,
|
||||
`/client/trade?userId=${row.original.id}&phone=${row.original.phone}`,
|
||||
)
|
||||
}}
|
||||
>
|
||||
@@ -274,7 +260,7 @@ export default function UserQueryPage() {
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
router.push(
|
||||
`/client/billing?userId=${row.original.id}`,
|
||||
`/client/billing?userId=${row.original.id}&phone=${row.original.phone}`,
|
||||
)
|
||||
}}
|
||||
>
|
||||
@@ -285,7 +271,7 @@ export default function UserQueryPage() {
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
router.push(
|
||||
`/client/resources?userId=${row.original.id}`,
|
||||
`/client/resources?userId=${row.original.id}&phone=${row.original.phone}`,
|
||||
)
|
||||
}}
|
||||
>
|
||||
@@ -296,7 +282,7 @@ export default function UserQueryPage() {
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
router.push(
|
||||
`/client/batch?userId=${row.original.id}`,
|
||||
`/client/batch?userId=${row.original.id}&phone=${row.original.phone}`,
|
||||
)
|
||||
}}
|
||||
>
|
||||
@@ -307,7 +293,7 @@ export default function UserQueryPage() {
|
||||
<DropdownMenuItem
|
||||
onClick={() => {
|
||||
router.push(
|
||||
`/client/channel?userId=${row.original.id}`,
|
||||
`/client/channel?userId=${row.original.id}&phone=${row.original.phone}`,
|
||||
)
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -122,7 +122,7 @@ export default function TradePage() {
|
||||
<span className="ml-2 text-gray-600">用户会员号: {userPhone}</span>
|
||||
</div>
|
||||
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<div className="flex items-end gap-4">
|
||||
<Controller
|
||||
name="inner_no"
|
||||
control={control}
|
||||
@@ -137,7 +137,6 @@ export default function TradePage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="method"
|
||||
control={control}
|
||||
@@ -161,7 +160,6 @@ export default function TradePage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="platform"
|
||||
control={control}
|
||||
@@ -182,7 +180,6 @@ export default function TradePage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="status"
|
||||
control={control}
|
||||
@@ -204,7 +201,6 @@ export default function TradePage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="created_at_start"
|
||||
control={control}
|
||||
@@ -219,7 +215,6 @@ export default function TradePage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
name="created_at_end"
|
||||
control={control}
|
||||
@@ -234,9 +229,6 @@ export default function TradePage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
||||
<Button type="submit">搜索</Button>
|
||||
<Button
|
||||
type="button"
|
||||
@@ -249,7 +241,7 @@ export default function TradePage() {
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</FieldGroup>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<Suspense>
|
||||
@@ -330,7 +322,7 @@ export default function TradePage() {
|
||||
? "电脑网站"
|
||||
: platform === 2
|
||||
? "手机网站"
|
||||
: "-"
|
||||
: ""
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -17,13 +17,49 @@ import {
|
||||
} from "@/components/ui/dialog"
|
||||
import { FieldError, FieldGroup, FieldLabel } from "@/components/ui/field"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select"
|
||||
|
||||
const schema = z.object({
|
||||
code: z.string().min(1, "请输入优惠券名称"),
|
||||
amount: z.string().min(1, "请输入优惠券金额"),
|
||||
remark: z.string().optional(),
|
||||
min_amount: z.string().optional(),
|
||||
name: z.string().min(1, "请输入优惠券名称"),
|
||||
amount: z.string()
|
||||
.min(1, "请输入优惠券金额")
|
||||
.regex(/^\d+(\.\d+)?$/, "请输入有效的金额数字")
|
||||
.refine(val => Number(val) > 0, "优惠券金额必须大于0"),
|
||||
count: z.string()
|
||||
.min(1, "请输入优惠券数量")
|
||||
.regex(/^\d+$/, "请输入正整数")
|
||||
.refine(val => Number(val) >= 1, "优惠券数量至少为1"),
|
||||
min_amount: z.string()
|
||||
.min(1, "请输入最低消费金额")
|
||||
.regex(/^\d+(\.\d+)?$/, "请输入有效的金额数字")
|
||||
.refine(val => Number(val) >= 0, "最低消费金额不能为负数"),
|
||||
expire_at: z.string().optional(),
|
||||
expire_type: z.string().min(1, "请选择过期类型"),
|
||||
expire_in: z.string().optional(),
|
||||
status:z.string().optional()
|
||||
}).superRefine((data, ctx) => {
|
||||
const expireType = Number(data.expire_type);
|
||||
if (!data.expire_type) return;
|
||||
if (expireType === 1 && !data.expire_at) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "请选择过期时间",
|
||||
path: ["expire_at"]
|
||||
});
|
||||
}
|
||||
if (expireType === 2 && !data.expire_in) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "请输入过期时长天数",
|
||||
path: ["expire_in"]
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
export function CreateDiscount(props: { onSuccess?: () => void }) {
|
||||
@@ -32,25 +68,33 @@ export function CreateDiscount(props: { onSuccess?: () => void }) {
|
||||
const form = useForm({
|
||||
resolver: zodResolver(schema),
|
||||
defaultValues: {
|
||||
code: "",
|
||||
remark: "",
|
||||
amount: "0",
|
||||
min_amount: "0",
|
||||
name: "",
|
||||
count: "",
|
||||
amount: "",
|
||||
min_amount: "",
|
||||
expire_at: "",
|
||||
expire_in: "",
|
||||
expire_type: "",
|
||||
status: "0",
|
||||
},
|
||||
mode: "onChange",
|
||||
})
|
||||
|
||||
const { control, handleSubmit, reset } = form
|
||||
const { control, handleSubmit, reset, watch } = form
|
||||
const watchExpireType = watch("expire_type")
|
||||
|
||||
const onSubmit = async (data: z.infer<typeof schema>) => {
|
||||
try {
|
||||
const expireType = Number(data.expire_type)
|
||||
const payload = {
|
||||
code: data.code,
|
||||
name: data.name,
|
||||
amount: Number(data.amount),
|
||||
remark: data?.remark,
|
||||
count: Number(data?.count),
|
||||
status:Number(data.status),
|
||||
min_amount: Number(data?.min_amount),
|
||||
expire_at: data?.expire_at ? new Date(data.expire_at) : undefined,
|
||||
expire_in: expireType === 2 ? Number(data.expire_in) : undefined,
|
||||
expire_type: expireType,
|
||||
}
|
||||
const resp = await createCoupon(payload)
|
||||
if (resp.success) {
|
||||
@@ -93,10 +137,10 @@ export function CreateDiscount(props: { onSuccess?: () => void }) {
|
||||
<FieldGroup>
|
||||
<Controller
|
||||
control={control}
|
||||
name="code"
|
||||
name="name"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">名称:</FieldLabel>
|
||||
<FieldLabel className="w-28 pt-2">优惠券名称:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
@@ -107,10 +151,10 @@ export function CreateDiscount(props: { onSuccess?: () => void }) {
|
||||
|
||||
<Controller
|
||||
control={control}
|
||||
name="remark"
|
||||
name="count"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">备注:</FieldLabel>
|
||||
<FieldLabel className="w-28 pt-2">优惠券数量:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
@@ -124,20 +168,9 @@ export function CreateDiscount(props: { onSuccess?: () => void }) {
|
||||
name="amount"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">金额:</FieldLabel>
|
||||
<FieldLabel className="w-28 pt-2">优惠券金额:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
type="number"
|
||||
min={0}
|
||||
step={5}
|
||||
{...field}
|
||||
onChange={e => {
|
||||
const value = e.target.value
|
||||
if (value === "" || parseFloat(value) >= 0) {
|
||||
field.onChange(value)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Input {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
@@ -148,43 +181,97 @@ export function CreateDiscount(props: { onSuccess?: () => void }) {
|
||||
name="min_amount"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">最低消费:</FieldLabel>
|
||||
<FieldLabel className="w-28 pt-2">最低消费金额:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
type="number"
|
||||
min={0}
|
||||
step={5}
|
||||
{...field}
|
||||
onChange={e => {
|
||||
const value = e.target.value
|
||||
if (value === "" || parseFloat(value) >= 0) {
|
||||
field.onChange(value)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Input {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
control={control}
|
||||
name="expire_at"
|
||||
name="status"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-30 pt-2">过期时间:</FieldLabel>
|
||||
<Input
|
||||
type="date"
|
||||
min={new Date().toISOString().split("T")[0]}
|
||||
{...field}
|
||||
/>
|
||||
<FieldLabel className="w-28 pt-2">优惠券状态:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择状态" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="0">禁用</SelectItem>
|
||||
<SelectItem value="1">正常</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
control={control}
|
||||
name="expire_type"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">过期类型:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择过期类型" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="0">不过期</SelectItem>
|
||||
<SelectItem value="1">固定日期</SelectItem>
|
||||
<SelectItem value="2">相对日期</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
{watchExpireType === "1" && (
|
||||
<Controller
|
||||
control={control}
|
||||
name="expire_at"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">过期时间:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
type="date"
|
||||
min={new Date().toISOString().split("T")[0]}
|
||||
{...field}
|
||||
/>
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{watchExpireType === "2" && (
|
||||
<Controller
|
||||
control={control}
|
||||
name="expire_in"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">过期时长(天):</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
type="number"
|
||||
min="0"
|
||||
placeholder="请输入过期天数"
|
||||
{...field}
|
||||
/>
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</FieldGroup>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { format } from "date-fns"
|
||||
import { Suspense, useState } from "react"
|
||||
import { toast } from "sonner"
|
||||
import { deleteCoupon, getPagCoupon } from "@/actions/coupon"
|
||||
import { Auth } from "@/components/auth"
|
||||
import { DataTable, useDataTable } from "@/components/data-table"
|
||||
import { Page } from "@/components/page"
|
||||
import {
|
||||
@@ -17,8 +18,10 @@ import {
|
||||
AlertDialogTrigger,
|
||||
} from "@/components/ui/alert-dialog"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { ScopeCouponWriteAssign } from "@/lib/scopes"
|
||||
import type { Coupon } from "@/models/coupon"
|
||||
import { CreateDiscount } from "./create"
|
||||
import { ReleaseCoupon } from "./release"
|
||||
import { UpdateCoupon } from "./update"
|
||||
|
||||
export default function CouponPage() {
|
||||
@@ -36,30 +39,59 @@ export default function CouponPage() {
|
||||
<DataTable<Coupon>
|
||||
{...table}
|
||||
columns={[
|
||||
{ header: "所属用户", accessorKey: "user_id" },
|
||||
{ header: "代码", accessorKey: "code" },
|
||||
{ header: "备注", accessorKey: "remark" },
|
||||
{ header: "金额", accessorKey: "amount" },
|
||||
{ header: "优惠券名称", accessorKey: "name" },
|
||||
{ header: "优惠券数量", accessorKey: "count" },
|
||||
{ header: "优惠券金额", accessorKey: "amount" },
|
||||
{ header: "最低消费金额", accessorKey: "min_amount" },
|
||||
{
|
||||
header: "状态",
|
||||
header: "优惠券状态",
|
||||
accessorKey: "status",
|
||||
cell: ({ row }) => {
|
||||
const status = row.original.status
|
||||
if (status === 0) {
|
||||
return <span className="text-yellow-600">未使用</span>
|
||||
return <span className="text-yellow-600">禁用</span>
|
||||
}
|
||||
if (status === 1) {
|
||||
return <span className="text-green-600">已使用</span>
|
||||
return <span className="text-green-600">正常</span>
|
||||
}
|
||||
return <span>-</span>
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "过期类型",
|
||||
accessorFn: row => {
|
||||
switch (row.expire_type) {
|
||||
case 0:
|
||||
return "不过期"
|
||||
case 1:
|
||||
return "固定日期"
|
||||
case 2:
|
||||
return "相对日期"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "过期时长(天)",
|
||||
accessorKey: "expire_in",
|
||||
},
|
||||
{
|
||||
header: "过期时间",
|
||||
accessorKey: "expire_at",
|
||||
cell: ({ row }) =>
|
||||
format(new Date(row.original.created_at), "yyyy-MM-dd HH:mm"),
|
||||
cell: ({ row }) => {
|
||||
const coupon = row.original
|
||||
if (coupon.expire_type === 2 && coupon.expire_in) {
|
||||
const expireDate = new Date(coupon.created_at)
|
||||
expireDate.setDate(expireDate.getDate() + coupon.expire_in)
|
||||
return format(expireDate, "yyyy-MM-dd HH:mm")
|
||||
}
|
||||
|
||||
if (coupon.expire_type === 1 && coupon.expire_at) {
|
||||
return format(new Date(coupon.expire_at), "yyyy-MM-dd HH:mm")
|
||||
}
|
||||
return <span>永久有效</span>
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "创建时间",
|
||||
@@ -67,12 +99,6 @@ export default function CouponPage() {
|
||||
cell: ({ row }) =>
|
||||
format(new Date(row.original.created_at), "yyyy-MM-dd HH:mm"),
|
||||
},
|
||||
{
|
||||
header: "更新时间",
|
||||
accessorKey: "updated_at",
|
||||
cell: ({ row }) =>
|
||||
format(new Date(row.original.updated_at), "yyyy-MM-dd HH:mm"),
|
||||
},
|
||||
{
|
||||
id: "action",
|
||||
meta: { pin: "right" },
|
||||
@@ -87,6 +113,12 @@ export default function CouponPage() {
|
||||
coupon={row.original}
|
||||
onSuccess={table.refresh}
|
||||
/>
|
||||
<Auth scope={ScopeCouponWriteAssign}>
|
||||
<ReleaseCoupon
|
||||
coupon={row.original}
|
||||
onSuccess={table.refresh}
|
||||
/>
|
||||
</Auth>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
@@ -135,7 +167,7 @@ function DeleteCoupon({
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>确认删除</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
确定要删除折扣「{coupon.code}」吗?此操作不可撤销。
|
||||
确定要删除折扣「{coupon.name}」吗?此操作不可撤销。
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
|
||||
349
src/app/(root)/coupon/release.tsx
Normal file
349
src/app/(root)/coupon/release.tsx
Normal file
@@ -0,0 +1,349 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { format } from "date-fns"
|
||||
import { Suspense, useCallback, useState } from "react"
|
||||
import { Controller, useForm } from "react-hook-form"
|
||||
import { toast } from "sonner"
|
||||
import z from "zod"
|
||||
import { getReleaseCoupon } from "@/actions/coupon"
|
||||
import { getPageUser } from "@/actions/user"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog"
|
||||
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import type { Coupon } from "@/models/coupon"
|
||||
import type { User } from "@/models/user"
|
||||
|
||||
interface UserQueryParams {
|
||||
account?: string
|
||||
name?: string
|
||||
}
|
||||
|
||||
const filterSchema = z.object({
|
||||
phone: z.string().optional(),
|
||||
name: z.string().optional(),
|
||||
})
|
||||
type FormValues = z.infer<typeof filterSchema>
|
||||
|
||||
export function ReleaseCoupon(props: {
|
||||
coupon: Coupon
|
||||
onSuccess?: () => void
|
||||
}) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const [userList, setUserList] = useState<User[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [currentFilters, setCurrentFilters] = useState<UserQueryParams>({})
|
||||
const { control, handleSubmit, reset } = useForm<FormValues>({
|
||||
resolver: zodResolver(filterSchema),
|
||||
defaultValues: {
|
||||
phone: "",
|
||||
name: "",
|
||||
},
|
||||
})
|
||||
|
||||
const fetchUsers = useCallback(async (filters: UserQueryParams = {}) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
setOpen(true)
|
||||
const res = await getPageUser(filters)
|
||||
if (res.success) {
|
||||
const data = Array.isArray(res.data) ? res.data : [res.data]
|
||||
setUserList(data)
|
||||
} else {
|
||||
toast.error(res.message || "获取用户失败")
|
||||
setUserList([])
|
||||
}
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : error
|
||||
toast.error(`获取用户失败: ${message}`)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const onFilter = handleSubmit((data: FormValues) => {
|
||||
const params: UserQueryParams = {}
|
||||
if (data.phone?.trim()) params.account = data.phone.trim()
|
||||
if (data.name?.trim()) params.name = data.name.trim()
|
||||
if (Object.keys(params).length === 0) {
|
||||
toast.info("请至少输入一个搜索条件")
|
||||
return
|
||||
}
|
||||
setCurrentFilters(params)
|
||||
fetchUsers(params)
|
||||
})
|
||||
|
||||
const handleReset = useCallback(() => {
|
||||
reset()
|
||||
setCurrentFilters({})
|
||||
setUserList([])
|
||||
}, [reset])
|
||||
|
||||
const handleIssueCoupon = useCallback(
|
||||
async (users: User[], coupon: Coupon) => {
|
||||
console.log(coupon, "couponcouponcoupon")
|
||||
|
||||
const targetUser = users[0]
|
||||
|
||||
if (!targetUser || !targetUser.id) {
|
||||
toast.error("用户信息无效")
|
||||
return
|
||||
}
|
||||
|
||||
if (!coupon || !coupon.id) {
|
||||
toast.error("优惠券信息无效")
|
||||
return
|
||||
}
|
||||
if (coupon.status !== 1) {
|
||||
toast.error("优惠券不可用,请检查优惠券状态")
|
||||
return
|
||||
}
|
||||
try {
|
||||
const result = await getReleaseCoupon({
|
||||
coupon_id: coupon.id,
|
||||
user_id: targetUser.id,
|
||||
})
|
||||
console.log({
|
||||
coupon_id: coupon.id,
|
||||
user_id: targetUser.id,
|
||||
})
|
||||
|
||||
console.log(result, "resultresultresultresultresult")
|
||||
if (result.success) {
|
||||
toast.success(
|
||||
`成功发放优惠券给用户 ${targetUser.phone || targetUser.username}`,
|
||||
)
|
||||
setOpen(false)
|
||||
handleReset()
|
||||
props.onSuccess?.()
|
||||
} else {
|
||||
toast.error("发放失败,请稍后重试")
|
||||
}
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "发放失败"
|
||||
toast.error(`发放优惠券失败: ${message}`)
|
||||
}
|
||||
},
|
||||
[props.onSuccess, handleReset],
|
||||
)
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
onOpenChange={newOpen => {
|
||||
setOpen(newOpen)
|
||||
if (!newOpen) {
|
||||
handleReset()
|
||||
}
|
||||
}}
|
||||
>
|
||||
<DialogTrigger asChild>
|
||||
<Button size="sm" variant="secondary">
|
||||
发放
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
|
||||
<DialogContent
|
||||
className="max-h-[85vh] overflow-y-auto"
|
||||
style={{ width: "auto", minWidth: "800px", maxWidth: "90vw" }}
|
||||
>
|
||||
<DialogHeader>
|
||||
<DialogTitle>发放优惠券</DialogTitle>
|
||||
</DialogHeader>
|
||||
<form onSubmit={onFilter} className="bg-card rounded-lg">
|
||||
<div className="flex items-end gap-4">
|
||||
<Controller
|
||||
name="phone"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Field data-invalid={fieldState.invalid} className="w-40 flex">
|
||||
<FieldLabel>手机号</FieldLabel>
|
||||
<Input {...field} placeholder="请输入手机号" />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
<Button type="button" variant="outline" onClick={handleReset}>
|
||||
重置
|
||||
</Button>
|
||||
<Button type="submit">搜索</Button>
|
||||
</div>
|
||||
</form>
|
||||
<Suspense fallback={<div className="py-8 text-center">加载中...</div>}>
|
||||
{loading ? (
|
||||
<div className="py-8 text-center">加载中...</div>
|
||||
) : userList.length === 0 ? (
|
||||
<div className="py-8 text-center text-gray-500">暂无用户数据</div>
|
||||
) : (
|
||||
<div className="space-y-4 max-h-[60vh] overflow-y-auto pr-1">
|
||||
{userList.map(user => (
|
||||
<div
|
||||
key={user.id}
|
||||
className="border rounded-lg overflow-hidden hover:shadow-md transition-shadow"
|
||||
>
|
||||
<div className="bg-gray-50 px-4 py-3 border-b flex items-center justify-between flex-wrap gap-2">
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="font-medium text-base">
|
||||
{user.phone || "未绑定手机"}
|
||||
</span>
|
||||
<div className="flex gap-2">
|
||||
<Badge
|
||||
variant={user.id_type === 1 ? "default" : "secondary"}
|
||||
className={
|
||||
user.id_type === 1
|
||||
? "bg-green-100 text-green-700 hover:bg-green-100"
|
||||
: "bg-gray-100 text-gray-600 hover:bg-gray-100"
|
||||
}
|
||||
>
|
||||
{user.id_type === 1 ? "✓ 已认证" : "○ 未认证"}
|
||||
</Badge>
|
||||
<Badge
|
||||
variant={
|
||||
user.status === 1 ? "default" : "destructive"
|
||||
}
|
||||
className={
|
||||
user.status === 1
|
||||
? "bg-green-100 text-green-700 hover:bg-green-100"
|
||||
: "bg-red-100 text-red-700 hover:bg-red-100"
|
||||
}
|
||||
>
|
||||
{user.status === 1 ? "正常" : "禁用"}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-sm text-gray-500">
|
||||
余额:
|
||||
<span
|
||||
className={`ml-1 font-semibold ${
|
||||
Number(user.balance) > 0
|
||||
? "text-green-600"
|
||||
: "text-orange-600"
|
||||
}`}
|
||||
>
|
||||
¥{(Number(user.balance) || 0).toFixed(2)}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="p-4">
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<div className="space-y-2">
|
||||
<div className="text-sm">
|
||||
<span className="text-gray-500 w-20 inline-block">
|
||||
姓名:
|
||||
</span>
|
||||
<span className="text-gray-900">
|
||||
{user.name || ""}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<span className="text-gray-500 w-20 inline-block">
|
||||
账号:
|
||||
</span>
|
||||
<span className="text-gray-900">
|
||||
{user.username || ""}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<span className="text-gray-500 w-20 inline-block">
|
||||
客户经理:
|
||||
</span>
|
||||
<span className="text-gray-900">
|
||||
{user.admin?.name || ""}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<div className="text-sm">
|
||||
<span className="text-gray-500 w-20 inline-block">
|
||||
客户来源:
|
||||
</span>
|
||||
<span className="text-gray-900">
|
||||
{(() => {
|
||||
const sourceMap: Record<number, string> = {
|
||||
0: "官网注册",
|
||||
1: "管理员添加",
|
||||
2: "代理商注册",
|
||||
3: "代理商添加",
|
||||
}
|
||||
return sourceMap[user.source] ?? "官网注册"
|
||||
})()}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<span className="text-gray-500 w-20 inline-block">
|
||||
联系方式:
|
||||
</span>
|
||||
<span className="text-gray-900">
|
||||
{user.contact_wechat || ""}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<span className="text-gray-500 w-20 inline-block">
|
||||
创建时间:
|
||||
</span>
|
||||
<span className="text-gray-900">
|
||||
{user.created_at
|
||||
? format(new Date(user.created_at), "yyyy-MM-dd")
|
||||
: ""}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<div className="text-sm">
|
||||
<span className="text-gray-500 w-20 inline-block">
|
||||
最后登录:
|
||||
</span>
|
||||
<span className="text-gray-900">
|
||||
{user.last_login
|
||||
? format(
|
||||
new Date(user.last_login),
|
||||
"yyyy-MM-dd HH:mm",
|
||||
)
|
||||
: "-"}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<span className="text-gray-500 w-20 inline-block">
|
||||
登录IP:
|
||||
</span>
|
||||
<span className="text-gray-900">
|
||||
{user.last_login_ip || "-"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Suspense>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button variant="ghost" onClick={handleReset}>
|
||||
取消
|
||||
</Button>
|
||||
</DialogClose>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => handleIssueCoupon(userList, props.coupon)}
|
||||
disabled={!userList || userList.length === 0}
|
||||
>
|
||||
发放优惠券
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
@@ -26,12 +26,40 @@ import {
|
||||
import type { Coupon } from "@/models/coupon"
|
||||
|
||||
const schema = z.object({
|
||||
code: z.string().min(1, "请输入优惠券名称"),
|
||||
amount: z.string().min(1, "请输入优惠券金额"),
|
||||
remark: z.string().optional(),
|
||||
min_amount: z.string().optional(),
|
||||
name: z.string().min(1, "请输入优惠券名称"),
|
||||
amount: z.string()
|
||||
.min(1, "请输入优惠券金额")
|
||||
.regex(/^\d+(\.\d+)?$/, "请输入有效的金额数字")
|
||||
.refine(val => Number(val) > 0, "优惠券金额必须大于0"),
|
||||
count: z.string()
|
||||
.min(1, "请输入优惠券数量")
|
||||
.regex(/^\d+$/, "请输入正整数")
|
||||
.refine(val => Number(val) >= 1, "优惠券数量至少为1"),
|
||||
min_amount: z.string()
|
||||
.min(1, "请输入最低消费金额")
|
||||
.regex(/^\d+(\.\d+)?$/, "请输入有效的金额数字")
|
||||
.refine(val => Number(val) >= 0, "最低消费金额不能为负数"),
|
||||
expire_at: z.string().optional(),
|
||||
status: z.string().optional(),
|
||||
expire_type: z.string().min(1, "请选择过期类型"),
|
||||
expire_in: z.string().optional(),
|
||||
status:z.string().optional()
|
||||
}).superRefine((data, ctx) => {
|
||||
const expireType = Number(data.expire_type);
|
||||
if (!data.expire_type) return;
|
||||
if (expireType === 1 && !data.expire_at) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "请选择过期时间",
|
||||
path: ["expire_at"]
|
||||
});
|
||||
}
|
||||
if (expireType === 2 && !data.expire_in) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "请输入过期时长天数",
|
||||
path: ["expire_in"]
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
export function UpdateCoupon(props: {
|
||||
@@ -43,32 +71,36 @@ export function UpdateCoupon(props: {
|
||||
const form = useForm({
|
||||
resolver: zodResolver(schema),
|
||||
defaultValues: {
|
||||
code: props.coupon.code || "",
|
||||
remark: props.coupon.remark || "",
|
||||
amount: String(props.coupon.amount || 0),
|
||||
min_amount: String(props.coupon.min_amount || 0),
|
||||
expire_at: props.coupon.expire_at
|
||||
? new Date(props.coupon.expire_at).toISOString().split("T")[0]
|
||||
name: props.coupon.name,
|
||||
amount: String(props.coupon.amount),
|
||||
min_amount: String(props.coupon.min_amount),
|
||||
expire_at: props?.coupon.expire_at
|
||||
? new Date(props?.coupon.expire_at).toISOString().split("T")[0]
|
||||
: "",
|
||||
status: String(props.coupon.status || "0"),
|
||||
status: String(props.coupon.status),
|
||||
count: String(props.coupon.count),
|
||||
expire_in: String(props?.coupon.expire_in),
|
||||
},
|
||||
mode: "onChange",
|
||||
})
|
||||
|
||||
const { control, handleSubmit, reset } = form
|
||||
|
||||
const { control, handleSubmit, reset, watch } = form
|
||||
const watchExpireType = watch("expire_type")
|
||||
const onSubmit = async (data: z.infer<typeof schema>) => {
|
||||
try {
|
||||
const expireType = Number(data.expire_type)
|
||||
const payload = {
|
||||
id: props.coupon.id,
|
||||
code: data.code,
|
||||
name: data.name,
|
||||
amount: Number(data.amount),
|
||||
remark: data.remark,
|
||||
min_amount: Number(data.min_amount),
|
||||
expire_at: data.expire_at ? new Date(data.expire_at) : undefined,
|
||||
count: Number(data.count),
|
||||
status: Number(data.status),
|
||||
expire_type: expireType,
|
||||
expire_at: data.expire_at ? new Date(data.expire_at) : undefined,
|
||||
expire_in: expireType === 2 ? Number(data.expire_in) : undefined,
|
||||
}
|
||||
const resp = await updateCoupon(payload)
|
||||
const resp = await updateCoupon(payload)
|
||||
if (resp.success) {
|
||||
toast.success("优惠券修改成功")
|
||||
props.onSuccess?.()
|
||||
@@ -85,14 +117,16 @@ export function UpdateCoupon(props: {
|
||||
const handleOpenChange = (value: boolean) => {
|
||||
if (value) {
|
||||
reset({
|
||||
code: props.coupon.code || "",
|
||||
remark: props.coupon.remark || "",
|
||||
amount: String(props.coupon.amount || 0),
|
||||
min_amount: String(props.coupon.min_amount || 0),
|
||||
name: props.coupon.name,
|
||||
count: String(props.coupon.count),
|
||||
amount: String(props.coupon.amount ),
|
||||
min_amount: String(props.coupon.min_amount),
|
||||
expire_at: props.coupon.expire_at
|
||||
? new Date(props.coupon.expire_at).toISOString().split("T")[0]
|
||||
: "",
|
||||
status: String(props.coupon.status || "0"),
|
||||
status: String(props.coupon.status),
|
||||
expire_type: String(props.coupon.expire_type),
|
||||
expire_in: String(props.coupon.expire_in),
|
||||
})
|
||||
}
|
||||
setOpen(value)
|
||||
@@ -115,10 +149,10 @@ export function UpdateCoupon(props: {
|
||||
<FieldGroup>
|
||||
<Controller
|
||||
control={control}
|
||||
name="code"
|
||||
name="name"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">名称:</FieldLabel>
|
||||
<FieldLabel className="w-28 pt-2">优惠券名称:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
@@ -129,10 +163,10 @@ export function UpdateCoupon(props: {
|
||||
|
||||
<Controller
|
||||
control={control}
|
||||
name="remark"
|
||||
name="count"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">备注:</FieldLabel>
|
||||
<FieldLabel className="w-28 pt-2">优惠券数量:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
@@ -146,20 +180,9 @@ export function UpdateCoupon(props: {
|
||||
name="amount"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">金额:</FieldLabel>
|
||||
<FieldLabel className="w-28 pt-2">优惠券金额:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
type="number"
|
||||
min={0}
|
||||
step={5}
|
||||
{...field}
|
||||
onChange={e => {
|
||||
const value = e.target.value
|
||||
if (value === "" || parseFloat(value) >= 0) {
|
||||
field.onChange(value)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Input {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
@@ -171,58 +194,28 @@ export function UpdateCoupon(props: {
|
||||
name="min_amount"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">最低消费:</FieldLabel>
|
||||
<FieldLabel className="w-28 pt-2">最低消费金额:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
type="number"
|
||||
min={0}
|
||||
step={5}
|
||||
{...field}
|
||||
onChange={e => {
|
||||
const value = e.target.value
|
||||
if (value === "" || parseFloat(value) >= 0) {
|
||||
field.onChange(value)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Input {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
control={control}
|
||||
name="expire_at"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">过期时间:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
type="date"
|
||||
min={new Date().toISOString().split("T")[0]}
|
||||
{...field}
|
||||
/>
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Controller
|
||||
control={control}
|
||||
name="status"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">状态:</FieldLabel>
|
||||
<FieldLabel className="w-28 pt-2">优惠券状态:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择状态" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="0">未使用</SelectItem>
|
||||
<SelectItem value="1">已使用</SelectItem>
|
||||
<SelectItem value="0">禁用</SelectItem>
|
||||
<SelectItem value="1">正常</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
@@ -230,6 +223,68 @@ export function UpdateCoupon(props: {
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
control={control}
|
||||
name="expire_type"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">过期类型:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Select value={field.value} onValueChange={field.onChange}>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="请选择过期类型" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="0">不过期</SelectItem>
|
||||
<SelectItem value="1">固定日期</SelectItem>
|
||||
<SelectItem value="2">相对日期</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
{watchExpireType === "1" && (
|
||||
<Controller
|
||||
control={control}
|
||||
name="expire_at"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">过期时间:</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
type="date"
|
||||
min={new Date().toISOString().split("T")[0]}
|
||||
{...field}
|
||||
/>
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{watchExpireType === "2" && (
|
||||
<Controller
|
||||
control={control}
|
||||
name="expire_in"
|
||||
render={({ field, fieldState }) => (
|
||||
<div className="flex items-start gap-4">
|
||||
<FieldLabel className="w-28 pt-2">过期时长(天):</FieldLabel>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
type="number"
|
||||
min="0"
|
||||
placeholder="请输入过期天数"
|
||||
{...field}
|
||||
/>
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</FieldGroup>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -18,12 +18,7 @@ import {
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import {
|
||||
Field,
|
||||
FieldError,
|
||||
FieldGroup,
|
||||
FieldLabel,
|
||||
} from "@/components/ui/field"
|
||||
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import {
|
||||
Select,
|
||||
@@ -37,6 +32,7 @@ import {
|
||||
ScopeBatchReadOfUser,
|
||||
ScopeBillReadOfUser,
|
||||
ScopeChannelReadOfUser,
|
||||
ScopeCouponWriteAssign,
|
||||
ScopeResourceRead,
|
||||
ScopeTradeReadOfUser,
|
||||
ScopeUserWrite,
|
||||
@@ -126,15 +122,12 @@ export default function CustPage() {
|
||||
return (
|
||||
<Page>
|
||||
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<div className="flex items-end gap-4">
|
||||
<Controller
|
||||
name="account"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-80 flex-none"
|
||||
>
|
||||
<Field data-invalid={fieldState.invalid} className="w-80 flex">
|
||||
<FieldLabel>账号/手机号/邮箱</FieldLabel>
|
||||
<Input {...field} placeholder="请输入账号/手机号/邮箱" />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
@@ -146,10 +139,7 @@ export default function CustPage() {
|
||||
name="name"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
>
|
||||
<Field data-invalid={fieldState.invalid} className="w-40 flex">
|
||||
<FieldLabel>姓名</FieldLabel>
|
||||
<Input {...field} placeholder="请输入姓名" />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
@@ -203,10 +193,7 @@ export default function CustPage() {
|
||||
name="created_at_start"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
>
|
||||
<Field data-invalid={fieldState.invalid} className="w-40 flex">
|
||||
<FieldLabel>开始时间</FieldLabel>
|
||||
<Input type="date" {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
@@ -218,19 +205,13 @@ export default function CustPage() {
|
||||
name="created_at_end"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
>
|
||||
<Field data-invalid={fieldState.invalid} className="w-40 flex">
|
||||
<FieldLabel>结束时间</FieldLabel>
|
||||
<Input type="date" {...field} />
|
||||
<FieldError>{fieldState.error?.message}</FieldError>
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
||||
<Auth scope={ScopeUserWrite}>
|
||||
<AddUserDialog onSuccess={refreshTable} />
|
||||
</Auth>
|
||||
@@ -246,7 +227,7 @@ export default function CustPage() {
|
||||
重置
|
||||
</Button>
|
||||
<Button type="submit">搜索</Button>
|
||||
</FieldGroup>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<Suspense>
|
||||
@@ -462,6 +443,17 @@ export default function CustPage() {
|
||||
余额明细
|
||||
</DropdownMenuItem>
|
||||
</Auth>
|
||||
<Auth scope={ScopeCouponWriteAssign}>
|
||||
<DropdownMenuItem
|
||||
onClick={() =>
|
||||
router.push(
|
||||
`/client/coupon?userId=${user.id}&phone=${user.phone}`,
|
||||
)
|
||||
}
|
||||
>
|
||||
优惠券
|
||||
</DropdownMenuItem>
|
||||
</Auth>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useState } from "react"
|
||||
import { Controller, useForm } from "react-hook-form"
|
||||
import { toast } from "sonner"
|
||||
import z from "zod"
|
||||
import { createGateway } from "@/actions/gateway"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Dialog,
|
||||
@@ -27,19 +29,26 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select"
|
||||
import { toast } from "sonner"
|
||||
import { createGateway } from "@/actions/gateway"
|
||||
|
||||
const schema = z.object({
|
||||
mac: z.string(),
|
||||
ip: z.string().regex(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/, {
|
||||
message: "IP地址格式不正确,请使用如 192.168.1.1 的格式"
|
||||
}),
|
||||
host: z.string().regex(/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/, {
|
||||
message: "域名格式不正确,请使用如 example.com 的格式"
|
||||
}).or(z.literal("")),
|
||||
mac: z.string().min(1, "请填写mac地址"),
|
||||
ip: z
|
||||
.string()
|
||||
.regex(
|
||||
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
|
||||
{
|
||||
message: "IP地址格式不正确,请使用如 192.168.1.1 的格式",
|
||||
},
|
||||
),
|
||||
host: z
|
||||
.string()
|
||||
.regex(/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/, {
|
||||
message: "域名格式不正确,请使用如 example.com 的格式",
|
||||
})
|
||||
.or(z.literal("")),
|
||||
type: z.string().optional(),
|
||||
status: z.string().optional(),
|
||||
secret: z.string().min(1, "请填写密钥"),
|
||||
})
|
||||
|
||||
export default function CreatePage(props: { onSuccess?: () => void }) {
|
||||
@@ -53,6 +62,7 @@ export default function CreatePage(props: { onSuccess?: () => void }) {
|
||||
host: "",
|
||||
type: "1",
|
||||
status: "0",
|
||||
secret: "",
|
||||
},
|
||||
})
|
||||
|
||||
@@ -61,22 +71,23 @@ export default function CreatePage(props: { onSuccess?: () => void }) {
|
||||
try {
|
||||
const payload = {
|
||||
mac: data.mac.trim(),
|
||||
ip: data.ip.trim(),
|
||||
host: data?.host.trim(),
|
||||
ip: data.ip.trim(),
|
||||
host: data?.host.trim(),
|
||||
type: data.type ? Number(data.type) : 0,
|
||||
status: data.status ? Number(data.status) : 0,
|
||||
secret: data.secret.trim(),
|
||||
}
|
||||
|
||||
|
||||
const res = await createGateway(payload)
|
||||
|
||||
|
||||
if (res.success) {
|
||||
toast.success("添加网关成功")
|
||||
setOpen(false)
|
||||
props.onSuccess?.()
|
||||
form.reset()
|
||||
}else {
|
||||
toast.error(res.message || "添加失败")
|
||||
}
|
||||
} else {
|
||||
toast.error(res.message || "添加失败")
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("添加网关失败:", error)
|
||||
const message = error instanceof Error ? error.message : error
|
||||
@@ -119,10 +130,7 @@ export default function CreatePage(props: { onSuccess?: () => void }) {
|
||||
<DialogTitle>添加网关</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<form
|
||||
id="gateway-create"
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
>
|
||||
<form id="gateway-create" onSubmit={form.handleSubmit(onSubmit)}>
|
||||
<FieldGroup>
|
||||
<Controller
|
||||
control={form.control}
|
||||
@@ -178,6 +186,24 @@ export default function CreatePage(props: { onSuccess?: () => void }) {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="secret"
|
||||
render={({ field, fieldState }) => (
|
||||
<Field>
|
||||
<FieldLabel htmlFor="gateway-create-secret">密匙:</FieldLabel>
|
||||
<Input
|
||||
id="gateway-create-secret"
|
||||
placeholder="请输入密匙"
|
||||
{...field}
|
||||
aria-invalid={fieldState.invalid}
|
||||
/>
|
||||
{fieldState.invalid && fieldState.error && (
|
||||
<FieldError errors={[fieldState.error]} />
|
||||
)}
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
<Controller
|
||||
control={form.control}
|
||||
name="type"
|
||||
@@ -240,4 +266,4 @@ export default function CreatePage(props: { onSuccess?: () => void }) {
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,30 +3,30 @@
|
||||
import { format } from "date-fns"
|
||||
import { Suspense, useCallback, useState } from "react"
|
||||
import { toast } from "sonner"
|
||||
import { getGatewayPage, updateGateway } from "@/actions/gateway"
|
||||
import { clear, getGatewayPage, updateGateway } from "@/actions/gateway"
|
||||
import { Auth } from "@/components/auth"
|
||||
import { DataTable, useDataTable } from "@/components/data-table"
|
||||
import { Page } from "@/components/page"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { ScopeProxyWrite } from "@/lib/scopes"
|
||||
import { ScopeChannelWriteClearExpired, ScopeProxyWrite } from "@/lib/scopes"
|
||||
import type { Gateway } from "@/models/gateway"
|
||||
import CreatePage from "./create"
|
||||
|
||||
export default function GatewayPage() {
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const getGatewayPageWrapper = useCallback((page: number, size: number) => {
|
||||
return getGatewayPage({ page, size })
|
||||
}, [])
|
||||
const getGatewayPageWrapper = useCallback((page: number, size: number) => {
|
||||
return getGatewayPage({ page, size })
|
||||
}, [])
|
||||
|
||||
const table = useDataTable(getGatewayPageWrapper)
|
||||
const table = useDataTable(getGatewayPageWrapper)
|
||||
|
||||
const handleToggle = async (id: number, status: number) => {
|
||||
const handleToggle = async (id: number, status: number) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
const result = await updateGateway({
|
||||
id:id,
|
||||
status: status === 0 ? 1 : 0
|
||||
id: id,
|
||||
status: status === 0 ? 1 : 0,
|
||||
})
|
||||
if (result.success) {
|
||||
toast.success(status === 0 ? "启用成功" : "停用成功")
|
||||
@@ -35,20 +35,44 @@ const table = useDataTable(getGatewayPageWrapper)
|
||||
toast.error(result.message || "操作失败")
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error("操作失败")
|
||||
const message = error instanceof Error ? error.message : error
|
||||
toast.error(`操作失败: ${message}`)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
const clearExpired = async (val: Gateway) => {
|
||||
setLoading(true)
|
||||
try {
|
||||
const result = await clear({
|
||||
proxy_id: val.id,
|
||||
})
|
||||
|
||||
if (result.success) {
|
||||
const count =
|
||||
result.data && "count" in result.data ? result.data.count : 0
|
||||
toast.success(`清理过期连接成功,共 ${count} 条`)
|
||||
} else {
|
||||
toast.error(result.message || "清理过期连接失败,请稍后重试一下~")
|
||||
}
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : error
|
||||
toast.error(`清理过期连接失败: ${message}`)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<Auth scope={ScopeProxyWrite}>
|
||||
<div className="flex justify-between items-stretch">
|
||||
<div className="flex gap-3">
|
||||
<div className="flex justify-between items-stretch">
|
||||
<div className="flex gap-3">
|
||||
<Auth scope={ScopeProxyWrite}>
|
||||
<CreatePage onSuccess={table.refresh} />
|
||||
</div>
|
||||
</Auth>
|
||||
</div>
|
||||
</Auth>
|
||||
</div>
|
||||
<Suspense>
|
||||
<DataTable<Gateway>
|
||||
{...table}
|
||||
@@ -63,6 +87,10 @@ const table = useDataTable(getGatewayPageWrapper)
|
||||
header: "MAC地址",
|
||||
accessorKey: "mac",
|
||||
},
|
||||
{
|
||||
header: "密钥",
|
||||
accessorKey: "secret",
|
||||
},
|
||||
{
|
||||
header: "类型",
|
||||
accessorKey: "type",
|
||||
@@ -86,12 +114,21 @@ const table = useDataTable(getGatewayPageWrapper)
|
||||
cell: ({ row }) => (
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
onClick={() => handleToggle(row.original.id, row.original.status)}
|
||||
disabled={loading}
|
||||
variant={row.original.status === 0 ? "default" : "destructive"}
|
||||
>
|
||||
{row.original.status === 0 ? "启用" : "停用"}
|
||||
</Button>
|
||||
onClick={() =>
|
||||
handleToggle(row.original.id, row.original.status)
|
||||
}
|
||||
disabled={loading}
|
||||
variant={
|
||||
row.original.status === 0 ? "default" : "destructive"
|
||||
}
|
||||
>
|
||||
{row.original.status === 0 ? "启用" : "停用"}
|
||||
</Button>
|
||||
<Auth scope={ScopeChannelWriteClearExpired}>
|
||||
<Button onClick={() => clearExpired(row.original)}>
|
||||
清理过期连接
|
||||
</Button>
|
||||
</Auth>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type ReactNode, Suspense } from "react"
|
||||
import { getProfile } from "@/actions/auth"
|
||||
import Navigation from "@/app/(root)/_navigation"
|
||||
import Appbar from "@/app/(root)/appbar"
|
||||
import Navigation from "@/app/(root)/navigation"
|
||||
import SetScopes from "./scopes"
|
||||
|
||||
export type RootLayoutProps = {
|
||||
|
||||
@@ -115,14 +115,14 @@ export default function TradePage() {
|
||||
<Page>
|
||||
{/* 筛选表单 */}
|
||||
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<div className="flex items-end gap-4">
|
||||
<Controller
|
||||
name="user_phone"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
className="w-40 flex"
|
||||
>
|
||||
<FieldLabel>会员号</FieldLabel>
|
||||
<Input {...field} placeholder="请输入会员号" />
|
||||
@@ -137,7 +137,7 @@ export default function TradePage() {
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
className="w-40 flex"
|
||||
>
|
||||
<FieldLabel>订单号</FieldLabel>
|
||||
<Input {...field} placeholder="请输入订单号" />
|
||||
@@ -219,7 +219,7 @@ export default function TradePage() {
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
className="w-40 flex"
|
||||
>
|
||||
<FieldLabel>开始时间</FieldLabel>
|
||||
<Input type="date" {...field} />
|
||||
@@ -234,7 +234,7 @@ export default function TradePage() {
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
className="w-40 flex"
|
||||
>
|
||||
<FieldLabel>结束时间</FieldLabel>
|
||||
<Input type="date" {...field} />
|
||||
@@ -242,9 +242,7 @@ export default function TradePage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
||||
|
||||
<Button type="submit">搜索</Button>
|
||||
<Button
|
||||
type="button"
|
||||
@@ -257,7 +255,7 @@ export default function TradePage() {
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</FieldGroup>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<Suspense>
|
||||
|
||||
@@ -13,7 +13,6 @@ import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Field,
|
||||
FieldError,
|
||||
FieldGroup,
|
||||
FieldLabel,
|
||||
} from "@/components/ui/field"
|
||||
import { Input } from "@/components/ui/input"
|
||||
@@ -63,14 +62,14 @@ export default function UserPage() {
|
||||
return (
|
||||
<Page>
|
||||
<form onSubmit={onFilter} className="bg-card p-4 rounded-lg">
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<div className="flex items-end gap-4">
|
||||
<Controller
|
||||
name="phone"
|
||||
control={control}
|
||||
render={({ field, fieldState }) => (
|
||||
<Field
|
||||
data-invalid={fieldState.invalid}
|
||||
className="w-40 flex-none"
|
||||
className="w-40 flex"
|
||||
>
|
||||
<FieldLabel>手机号</FieldLabel>
|
||||
<Input {...field} placeholder="请输入手机号" />
|
||||
@@ -78,9 +77,7 @@ export default function UserPage() {
|
||||
</Field>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<FieldGroup className="flex-row justify-start mt-4 gap-2">
|
||||
|
||||
<Button type="submit">搜索</Button>
|
||||
<Button
|
||||
type="button"
|
||||
@@ -89,11 +86,12 @@ export default function UserPage() {
|
||||
reset()
|
||||
setFilters({})
|
||||
setLoading(false)
|
||||
table.pagination.onPageChange(1)
|
||||
}}
|
||||
>
|
||||
重置
|
||||
</Button>
|
||||
</FieldGroup>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<Suspense>
|
||||
@@ -199,4 +197,4 @@ export default function UserPage() {
|
||||
</Suspense>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ export const ScopeUserWriteBind = "user:write:bind" // 用户认领
|
||||
export const ScopeCoupon = "coupon"
|
||||
export const ScopeCouponRead = "coupon:read" // 读取优惠券列表
|
||||
export const ScopeCouponWrite = "coupon:write" // 写入优惠券
|
||||
export const ScopeCouponWriteAssign = "coupon:write:assign" // 发放优惠券
|
||||
|
||||
// 批次
|
||||
export const ScopeBatch = "batch"
|
||||
@@ -89,4 +90,5 @@ export const ScopeBalanceActivityReadOfUser = "balance_activity:read:of_user" //
|
||||
export const ScopeProxy = "proxy"
|
||||
export const ScopeProxyRead = "proxy:read" // 读取代理列表
|
||||
export const ScopeProxyWrite = "proxy:write" // 写入代理
|
||||
export const ScopeProxyWriteStatus = "proxy:write:status" // 更改代理状态
|
||||
export const ScopeProxyWriteStatus = "proxy:write:status" // 更改代理状态
|
||||
export const ScopeChannelWriteClearExpired = "channel:write:clear_expired" //清理过期连接
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
export type Coupon = {
|
||||
id: number
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
name: string
|
||||
user_id: number
|
||||
code: string
|
||||
remark: string
|
||||
amount: number
|
||||
min_amount: number
|
||||
count: number
|
||||
status: number
|
||||
expire_type: number
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
expire_at: Date
|
||||
expire_in: number
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user