交易明细操作检查订单页面添加完成订单接口调用 & 充值和扣款接口新增操作说明 字段
This commit is contained in:
@@ -44,7 +44,11 @@ export async function createCust(data: {
|
|||||||
return callByUser<PageRecord<User>>("/api/admin/user/create", data)
|
return callByUser<PageRecord<User>>("/api/admin/user/create", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getDeposit(params: { user_id: number; amount: string }) {
|
export async function getDeposit(params: {
|
||||||
|
user_id: number
|
||||||
|
amount: string
|
||||||
|
remark: string
|
||||||
|
}) {
|
||||||
return callByUser<PageRecord<User>>(
|
return callByUser<PageRecord<User>>(
|
||||||
"/api/admin/user/update/balance-inc",
|
"/api/admin/user/update/balance-inc",
|
||||||
params,
|
params,
|
||||||
@@ -54,6 +58,7 @@ export async function getDeposit(params: { user_id: number; amount: string }) {
|
|||||||
export async function getDeduction(params: {
|
export async function getDeduction(params: {
|
||||||
user_id: number
|
user_id: number
|
||||||
amount: string
|
amount: string
|
||||||
|
remark: string
|
||||||
}) {
|
}) {
|
||||||
return callByUser<PageRecord<User>>(
|
return callByUser<PageRecord<User>>(
|
||||||
"/api/admin/user/update/balance-dec",
|
"/api/admin/user/update/balance-dec",
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export async function updateTradeRemark(params: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PayCloseData = {
|
type PayCloseData = {
|
||||||
status: 0 | 1 | 2
|
Status: 0 | 1 | 2
|
||||||
TransId: string
|
TransId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,3 +49,27 @@ export async function getTradeCheckk(params: {
|
|||||||
}) {
|
}) {
|
||||||
return callByUser<PayCloseData>("/api/admin/trade/check", params)
|
return callByUser<PayCloseData>("/api/admin/trade/check", params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function tradeComplete(params: {
|
||||||
|
trade_no: string
|
||||||
|
method: number
|
||||||
|
user_id: number
|
||||||
|
}) {
|
||||||
|
return callByUser<PayCloseData>("/api/admin/trade/complete", params)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function tradeConvert(params: {
|
||||||
|
trade_no: string
|
||||||
|
method: number
|
||||||
|
user_id: number
|
||||||
|
}) {
|
||||||
|
return callByUser<PayCloseData>("/api/admin/trade/convert", params)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function tradeCancel(params: {
|
||||||
|
trade_no: string
|
||||||
|
method: number
|
||||||
|
user_id: number
|
||||||
|
}) {
|
||||||
|
return callByUser<PayCloseData>("/api/admin/trade/cancel", params)
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
} from "@/components/ui/dialog"
|
} from "@/components/ui/dialog"
|
||||||
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
|
import { Textarea } from "@/components/ui/textarea"
|
||||||
import type { User } from "@/models/user"
|
import type { User } from "@/models/user"
|
||||||
|
|
||||||
const Schema = z.object({
|
const Schema = z.object({
|
||||||
@@ -26,6 +27,7 @@ const Schema = z.object({
|
|||||||
.min(1, "请输入扣款金额")
|
.min(1, "请输入扣款金额")
|
||||||
.refine(val => !Number.isNaN(Number(val)), "请输入有效的数字")
|
.refine(val => !Number.isNaN(Number(val)), "请输入有效的数字")
|
||||||
.refine(val => Number(val) >= 0, "金额不能为负数"),
|
.refine(val => Number(val) >= 0, "金额不能为负数"),
|
||||||
|
remark: z.string().min(1, "请输入操作说明"),
|
||||||
})
|
})
|
||||||
|
|
||||||
type FormValues = z.infer<typeof Schema>
|
type FormValues = z.infer<typeof Schema>
|
||||||
@@ -52,6 +54,7 @@ export function DeductionDialog({
|
|||||||
resolver: zodResolver(Schema),
|
resolver: zodResolver(Schema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
deduction: "",
|
deduction: "",
|
||||||
|
remark: "",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -61,6 +64,7 @@ export function DeductionDialog({
|
|||||||
const result = await getDeduction({
|
const result = await getDeduction({
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
amount: data.deduction,
|
amount: data.deduction,
|
||||||
|
remark: data.remark,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -123,6 +127,15 @@ export function DeductionDialog({
|
|||||||
/>
|
/>
|
||||||
<FieldError>{errors.deduction?.message}</FieldError>
|
<FieldError>{errors.deduction?.message}</FieldError>
|
||||||
</Field>
|
</Field>
|
||||||
|
<Field data-invalid={!!errors.remark}>
|
||||||
|
<FieldLabel>操作说明</FieldLabel>
|
||||||
|
<Textarea
|
||||||
|
placeholder="请输入操作说明(必填)"
|
||||||
|
{...register("remark")}
|
||||||
|
rows={3}
|
||||||
|
/>
|
||||||
|
<FieldError>{errors.remark?.message}</FieldError>
|
||||||
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
} from "@/components/ui/dialog"
|
} from "@/components/ui/dialog"
|
||||||
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
import { Field, FieldError, FieldLabel } from "@/components/ui/field"
|
||||||
import { Input } from "@/components/ui/input"
|
import { Input } from "@/components/ui/input"
|
||||||
|
import { Textarea } from "@/components/ui/textarea"
|
||||||
import type { User } from "@/models/user"
|
import type { User } from "@/models/user"
|
||||||
|
|
||||||
const Schema = z.object({
|
const Schema = z.object({
|
||||||
@@ -26,6 +27,7 @@ const Schema = z.object({
|
|||||||
.min(1, "请输入余额")
|
.min(1, "请输入余额")
|
||||||
.refine(val => !Number.isNaN(Number(val)), "请输入有效的数字")
|
.refine(val => !Number.isNaN(Number(val)), "请输入有效的数字")
|
||||||
.refine(val => Number(val) >= 0, "余额不能为负数"),
|
.refine(val => Number(val) >= 0, "余额不能为负数"),
|
||||||
|
remark: z.string().min(1, "请输入操作说明"),
|
||||||
})
|
})
|
||||||
|
|
||||||
type FormValues = z.infer<typeof Schema>
|
type FormValues = z.infer<typeof Schema>
|
||||||
@@ -49,6 +51,7 @@ export function DepositDialog({ user, onSuccess }: UpdateDepositDialogProps) {
|
|||||||
resolver: zodResolver(Schema),
|
resolver: zodResolver(Schema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
deposit: "",
|
deposit: "",
|
||||||
|
remark: "",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -58,6 +61,7 @@ export function DepositDialog({ user, onSuccess }: UpdateDepositDialogProps) {
|
|||||||
const result = await getDeposit({
|
const result = await getDeposit({
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
amount: data.deposit,
|
amount: data.deposit,
|
||||||
|
remark: data.remark,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
@@ -120,6 +124,15 @@ export function DepositDialog({ user, onSuccess }: UpdateDepositDialogProps) {
|
|||||||
/>
|
/>
|
||||||
<FieldError>{errors.deposit?.message}</FieldError>
|
<FieldError>{errors.deposit?.message}</FieldError>
|
||||||
</Field>
|
</Field>
|
||||||
|
<Field data-invalid={!!errors.remark}>
|
||||||
|
<FieldLabel>操作说明</FieldLabel>
|
||||||
|
<Textarea
|
||||||
|
placeholder="请输入操作说明(必填)"
|
||||||
|
{...register("remark")}
|
||||||
|
rows={3}
|
||||||
|
/>
|
||||||
|
<FieldError>{errors.remark?.message}</FieldError>
|
||||||
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import { z } from "zod"
|
|||||||
import {
|
import {
|
||||||
getPageTrade,
|
getPageTrade,
|
||||||
getTradeCheckk,
|
getTradeCheckk,
|
||||||
|
tradeCancel,
|
||||||
|
tradeComplete,
|
||||||
|
tradeConvert,
|
||||||
updateTradeRemark,
|
updateTradeRemark,
|
||||||
} from "@/actions/trade"
|
} from "@/actions/trade"
|
||||||
import { DataTable, useDataTable } from "@/components/data-table"
|
import { DataTable, useDataTable } from "@/components/data-table"
|
||||||
@@ -119,7 +122,6 @@ export default function TradePage() {
|
|||||||
setFilters(result)
|
setFilters(result)
|
||||||
table.pagination.onPageChange(1)
|
table.pagination.onPageChange(1)
|
||||||
})
|
})
|
||||||
// console.log(...table.data.map(i => i.remark), "tabletabletabletable")
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
@@ -308,7 +310,8 @@ export default function TradePage() {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
},{
|
},
|
||||||
|
{
|
||||||
header: "订单金额",
|
header: "订单金额",
|
||||||
accessorKey: "amount",
|
accessorKey: "amount",
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
@@ -318,9 +321,7 @@ export default function TradePage() {
|
|||||||
: row.original.amount || 0
|
: row.original.amount || 0
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-1">
|
<div className="flex gap-1">
|
||||||
<span>
|
<span>¥{amount.toFixed(2)}</span>
|
||||||
¥{amount.toFixed(2)}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -406,7 +407,12 @@ export default function TradePage() {
|
|||||||
meta: { pin: "right" },
|
meta: { pin: "right" },
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<CheckOrder trade={row.original} />
|
{row.original.status === 0 && (
|
||||||
|
<CheckOrder
|
||||||
|
trade={row.original}
|
||||||
|
onSuccess={table.refresh}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<UpdateRole trade={row.original} onSuccess={table.refresh} />
|
<UpdateRole trade={row.original} onSuccess={table.refresh} />
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
@@ -418,10 +424,10 @@ export default function TradePage() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
type PayCloseData = {
|
type PayCloseData = {
|
||||||
status: 0 | 1 | 2
|
Status: 0 | 1 | 2
|
||||||
TransId?: string
|
TransId?: string
|
||||||
}
|
}
|
||||||
function CheckOrder(props: { trade: Trade }) {
|
function CheckOrder(props: { trade: Trade; onSuccess: () => void }) {
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false)
|
||||||
const [data, setData] = useState<PayCloseData | null>(null)
|
const [data, setData] = useState<PayCloseData | null>(null)
|
||||||
@@ -446,7 +452,78 @@ function CheckOrder(props: { trade: Trade }) {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
}, [props.trade.inner_no, props.trade.method])
|
}, [props])
|
||||||
|
|
||||||
|
const headerClick = useCallback(async () => {
|
||||||
|
setLoading(true)
|
||||||
|
try {
|
||||||
|
const result = await tradeComplete({
|
||||||
|
trade_no: props.trade.inner_no,
|
||||||
|
method: Number(props.trade.method),
|
||||||
|
user_id: Number(props.trade.user_id),
|
||||||
|
})
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
toast.success("订单已完成")
|
||||||
|
props.onSuccess?.()
|
||||||
|
} else {
|
||||||
|
toast.error(result.message)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : error
|
||||||
|
toast.error(`检查失败,请重试: ${message}`)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
}, [props])
|
||||||
|
|
||||||
|
const convert = useCallback(async () => {
|
||||||
|
setLoading(true)
|
||||||
|
try {
|
||||||
|
const result = await tradeConvert({
|
||||||
|
trade_no: props.trade.inner_no,
|
||||||
|
method: Number(props.trade.method),
|
||||||
|
user_id: Number(props.trade.user_id),
|
||||||
|
})
|
||||||
|
console.log(result, "resultresultresult")
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
toast.success("补到余额完成")
|
||||||
|
props.onSuccess?.()
|
||||||
|
} else {
|
||||||
|
toast.error(result.message)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : error
|
||||||
|
toast.error(`补到余额失败,请重试: ${message}`)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
}, [props])
|
||||||
|
|
||||||
|
const cancel = useCallback(async () => {
|
||||||
|
setLoading(true)
|
||||||
|
try {
|
||||||
|
const result = await tradeCancel({
|
||||||
|
trade_no: props.trade.inner_no,
|
||||||
|
method: Number(props.trade.method),
|
||||||
|
user_id: Number(props.trade.user_id),
|
||||||
|
})
|
||||||
|
console.log(result, "resultresultresult")
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
toast.success("取消订单完成")
|
||||||
|
props.onSuccess?.()
|
||||||
|
} else {
|
||||||
|
toast.error(result.message)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : error
|
||||||
|
toast.error(`取消订单失败,请重试: ${message}`)
|
||||||
|
} finally {
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
}, [props])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -463,20 +540,33 @@ function CheckOrder(props: { trade: Trade }) {
|
|||||||
{data && (
|
{data && (
|
||||||
<div className="py-4">
|
<div className="py-4">
|
||||||
<div
|
<div
|
||||||
className={`p-4 rounded-lg ${data.status === 1 ? "bg-green-50" : "bg-red-50"}`}
|
className={`p-4 rounded-lg ${data.Status === 1 ? "bg-green-100" : "bg-red-100"}`}
|
||||||
>
|
>
|
||||||
<p className="font-medium">创建时间:{data?.TransId}</p>
|
<p className="font-medium">创建时间:{data?.TransId}</p>
|
||||||
<p className="mt-2">
|
<p className="mt-2">
|
||||||
支付状态:
|
支付状态:
|
||||||
{data?.status === 1
|
{data?.Status === 1
|
||||||
? "已支付"
|
? "已支付"
|
||||||
: data?.status === 0
|
: data?.Status === 0
|
||||||
? "待支付"
|
? "待支付"
|
||||||
: "已取消"}
|
: "已取消"}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{props && props.trade.status === 0 && (
|
||||||
|
<>
|
||||||
|
<Button size="sm" className="w-32" onClick={headerClick}>
|
||||||
|
完成订单
|
||||||
|
</Button>
|
||||||
|
<Button size="sm" className="w-32" onClick={convert}>
|
||||||
|
补到余额
|
||||||
|
</Button>
|
||||||
|
<Button size="sm" className="w-32" onClick={cancel}>
|
||||||
|
取消订单
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<DialogClose asChild>
|
<DialogClose asChild>
|
||||||
|
|||||||
Reference in New Issue
Block a user