add
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled

This commit is contained in:
2025-12-31 12:40:55 +08:00
parent 107b28752c
commit 9f511cba43
3 changed files with 190 additions and 5 deletions

View File

@@ -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,
};

View File

@@ -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,
},
];
}

View File

@@ -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({
<template>
<Page :auto-content-height="!agentId">
<Grid :table-title="agentId ? '佣金记录列表' : '所有佣金记录'" />
<Grid :table-title="agentId ? '佣金记录列表' : '所有佣金记录'">
<template #toolbar-tools>
<Button type="primary" @click="onBatchUnfreeze">
<span class="mr-1"></span>
一键解冻
</Button>
</template>
</Grid>
</Page>
</template>