From 9f511cba435847c78c295d6570ac0bbd5df682b1 Mon Sep 17 00:00:00 2001 From: 18278715334 <18278715334@163.com> Date: Wed, 31 Dec 2025 12:40:55 +0800 Subject: [PATCH] add --- apps/web-antd/src/api/agent/agent.ts | 33 +++++ .../src/views/agent/agent-commission/data.ts | 40 +++++- .../src/views/agent/agent-commission/list.vue | 122 +++++++++++++++++- 3 files changed, 190 insertions(+), 5 deletions(-) diff --git a/apps/web-antd/src/api/agent/agent.ts b/apps/web-antd/src/api/agent/agent.ts index ac17fad..b0d955e 100644 --- a/apps/web-antd/src/api/agent/agent.ts +++ b/apps/web-antd/src/api/agent/agent.ts @@ -368,6 +368,37 @@ async function getAgentCommissionList( ); } +/** + * 更新代理佣金状态 + */ +async function updateAgentCommissionStatus( + id: number, + status: number, +) { + return requestClient.post<{ success: boolean }>( + '/agent/agent-commission/update-status', + { + id, + status, + }, + ); +} + +/** + * 批量解冻代理佣金 + */ +async function batchUnfreezeAgentCommission( + agentId?: number, +) { + return requestClient.post<{ + success: boolean; + count: number; + amount: number; + }>('/agent/agent-commission/batch-unfreeze', { + agent_id: agentId, + }); +} + /** * 获取代理奖励列表 */ @@ -541,6 +572,7 @@ async function getAgentLinkProductStatistics() { } export { + batchUnfreezeAgentCommission, getAgentCommissionDeductionList, getAgentCommissionList, getAgentLinkList, @@ -556,6 +588,7 @@ export { getMembershipRechargeOrderList, getWithdrawalStatistics, reviewBankCardWithdrawal, + updateAgentCommissionStatus, updateAgentMembershipConfig, updateAgentProductionConfig, }; diff --git a/apps/web-antd/src/views/agent/agent-commission/data.ts b/apps/web-antd/src/views/agent/agent-commission/data.ts index 7a9f715..1146d3c 100644 --- a/apps/web-antd/src/views/agent/agent-commission/data.ts +++ b/apps/web-antd/src/views/agent/agent-commission/data.ts @@ -1,8 +1,11 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { AgentApi } from '#/api'; // 佣金记录列表列配置 -export function useCommissionColumns(): VxeTableGridOptions['columns'] { +export function useCommissionColumns( + onActionClick?: (params: { code: string; row: AgentApi.AgentCommissionListItem }) => void, +): VxeTableGridOptions['columns'] { return [ { field: 'agent_id', @@ -46,6 +49,41 @@ export function useCommissionColumns(): VxeTableGridOptions['columns'] { sortable: true, sortType: 'string' as const, }, + { + align: 'center', + cellRender: { + name: 'CellOperation', + attrs: { + nameField: 'id', + nameTitle: '操作', + onClick: onActionClick, + }, + options: [ + { + code: 'unfreeze', + text: '解冻', + type: 'primary', + disabled: (row: AgentApi.AgentCommissionListItem) => row?.status !== 1, + }, + { + code: 'cancel', + text: '取消', + type: 'default', + disabled: (row: AgentApi.AgentCommissionListItem) => row?.status !== 1, + }, + { + code: 'settled', + text: '已结算', + type: 'success', + disabled: (row: AgentApi.AgentCommissionListItem) => row?.status !== 0, + }, + ], + }, + field: 'operation', + fixed: 'right', + title: '操作', + width: 300, + }, ]; } diff --git a/apps/web-antd/src/views/agent/agent-commission/list.vue b/apps/web-antd/src/views/agent/agent-commission/list.vue index edb4182..b3f0052 100644 --- a/apps/web-antd/src/views/agent/agent-commission/list.vue +++ b/apps/web-antd/src/views/agent/agent-commission/list.vue @@ -2,9 +2,14 @@ import { computed } from 'vue'; import { Page } from '@vben/common-ui'; +import { Button, message, Modal } from 'ant-design-vue'; import { useVbenVxeGrid } from '#/adapter/vxe-table'; -import { getAgentCommissionList } from '#/api/agent'; +import { + batchUnfreezeAgentCommission, + getAgentCommissionList, + updateAgentCommissionStatus, +} from '#/api/agent'; import { useCommissionColumns, useCommissionFormSchema } from './data'; @@ -24,14 +29,116 @@ const queryParams = computed(() => ({ ...(props.agentId ? { agent_id: props.agentId } : {}), })); +// 操作处理函数 +function onActionClick({ code, row }: { code: string; row: any }) { + switch (code) { + case 'unfreeze': + onUnfreeze(row); + break; + case 'cancel': + onCancel(row); + break; + } +} -const [Grid] = useVbenVxeGrid({ + +// 解冻佣金到用户余额 +async function onUnfreeze(row: any) { + if (row.status !== 1) { + message.warning('只有冻结中的佣金才能解冻'); + return; + } + + Modal.confirm({ + title: '确认解冻', + content: `确定要解冻佣金金额 ¥${row.amount.toFixed(2)} 吗?解冻后将转入用户钱包余额。`, + okText: '确认解冻', + cancelText: '取消', + onOk: async () => { + try { + await updateAgentCommissionStatus(row.id, 0); + message.success('佣金已解冻并转入用户钱包余额'); + onRefresh(); + } catch (error) { + message.error('操作失败,请重试'); + } + } + }); +} + +// 取消佣金 +async function onCancel(row: any) { + if (row.status !== 1) { + message.warning('只有冻结中的佣金才能取消'); + return; + } + + Modal.confirm({ + title: '确认取消', + content: `确定要取消佣金金额 ¥${row.amount.toFixed(2)} 吗?取消后将无法恢复。`, + okText: '确认取消', + cancelText: '返回', + onOk: async () => { + try { + await updateAgentCommissionStatus(row.id, 2); + message.success('佣金已取消'); + onRefresh(); + } catch (error) { + message.error('操作失败,请重试'); + } + } + }); +} + +// 刷新列表 +function onRefresh() { + gridApi.query(); +} + +// 批量解冻佣金 +async function onBatchUnfreeze() { + const content = props.agentId + ? '确定要一键解冻当前代理商所有冻结中的佣金吗?解冻后将全部转入用户钱包余额。' + : '确定要一键解冻所有冻结中的佣金吗?解冻后将全部转入用户钱包余额。'; + + Modal.confirm({ + title: '批量解冻确认', + content, + okText: '确认解冻', + cancelText: '取消', + onOk: async () => { + try { + const result = await batchUnfreezeAgentCommission(props.agentId); + message.success( + `批量解冻成功!共解冻 ${result.count} 条记录,总金额 ¥${result.amount.toFixed(2)}`, + ); + onRefresh(); + } catch (error) { + message.error('批量解冻失败,请重试'); + } + }, + }); +} + +const [Grid, gridApi] = useVbenVxeGrid({ formOptions: { schema: useCommissionFormSchema(), submitOnChange: true, }, gridOptions: { - columns: useCommissionColumns(), + columns: useCommissionColumns(onActionClick), + height: 'auto', + keepSource: true, + rowConfig: { + keyField: 'id', + }, + toolbarConfig: { + custom: true, + export: false, + refresh: { code: 'query' }, + search: true, + zoom: true, + }, proxyConfig: { ajax: { query: async ({ @@ -60,6 +167,13 @@ const [Grid] = useVbenVxeGrid({