feat: 后台订单列表新增手动激活按钮
- API 层新增 activateOrder 方法 (POST /v1/admin/order/activate) - pending(1) 和 cancelled(3) 状态的订单显示 Activate 按钮 - 点击后调用后端手动激活接口,强制发放订阅权益
This commit is contained in:
parent
778e78ac68
commit
31803a1d24
@ -13,6 +13,7 @@ import {
|
||||
} from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { cn } from "@workspace/ui/lib/utils";
|
||||
import {
|
||||
activateOrder,
|
||||
getOrderList,
|
||||
updateOrderStatus,
|
||||
} from "@workspace/ui/services/admin/order";
|
||||
@ -180,6 +181,14 @@ export default function Order() {
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "payment",
|
||||
header: t("method", "Payment Method"),
|
||||
cell: ({ row }) => {
|
||||
const order = row.original as API.Order;
|
||||
return order.payment?.name || order.payment?.platform || "--";
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "user_id",
|
||||
header: t("user", "User"),
|
||||
@ -206,19 +215,33 @@ export default function Order() {
|
||||
);
|
||||
if ([1, 3, 4].includes(row.getValue("status"))) {
|
||||
return (
|
||||
<Combobox<number, false>
|
||||
className={cn(option?.className)}
|
||||
onChange={async (value) => {
|
||||
await updateOrderStatus({
|
||||
id: order.id,
|
||||
status: value,
|
||||
});
|
||||
ref.current?.refresh();
|
||||
}}
|
||||
options={statusOptions}
|
||||
placeholder={t("status.0", "Status")}
|
||||
value={order.status}
|
||||
/>
|
||||
<div className="flex items-center gap-1">
|
||||
<Combobox<number, false>
|
||||
className={cn(option?.className)}
|
||||
onChange={async (value) => {
|
||||
await updateOrderStatus({
|
||||
id: order.id,
|
||||
status: value,
|
||||
});
|
||||
ref.current?.refresh();
|
||||
}}
|
||||
options={statusOptions}
|
||||
placeholder={t("status.0", "Status")}
|
||||
value={order.status}
|
||||
/>
|
||||
{[1, 3].includes(order.status) && (
|
||||
<Button
|
||||
onClick={async () => {
|
||||
await activateOrder({ order_no: order.order_no });
|
||||
ref.current?.refresh();
|
||||
}}
|
||||
size="sm"
|
||||
variant="outline"
|
||||
>
|
||||
{t("activate", "Activate")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
|
||||
@ -55,3 +55,21 @@ export async function updateOrderStatus(
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** Manually activate order POST /v1/admin/order/activate */
|
||||
export async function activateOrder(
|
||||
body: { order_no: string },
|
||||
options?: { [key: string]: any }
|
||||
) {
|
||||
return request<API.Response & { data?: any }>(
|
||||
`${import.meta.env.VITE_API_PREFIX || ""}/v1/admin/order/activate`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user