Skip to content

Let's use AI to Earn!

钱包交易问题修改 怎加账户选择 增加账户记录多类型

daoyianb44925f7b705
diff --git a/package.json b/package.json
index 2553c3f0..a8c278eb 100644
--- a/package.json
+++ b/package.json
@@ -59,6 +59,7 @@
"image-size": "^1.2.0",
"lodash": "^4.17.21",
"mime-types": "^2.1.35",
+ "moment": "^2.30.1",
"node-cache": "^5.1.2",
"node-schedule": "^2.1.1",
"os": "^0.1.2",
diff --git a/src/router/index.tsx b/src/router/index.tsx
index be30878d..5acee57b 100644
--- a/src/router/index.tsx
+++ b/src/router/index.tsx
@@ -41,7 +41,7 @@ import Task from '@/views/task';
// import VideoTask from '@/views/task/videoTask';
// import MineTask from '@/views/task/mineTask';
import UserWalletAccount from '@/views/finance/userWalletAccount';
-import Finance from '@/views/finance/index';
+import Finance from '@/views/finance/finance';
import UserWalletRecord from '@/views/finance/userWalletRecord';
import Reply from '@/views/reply';
import Replyother from '@/views/replyother/replyother';
diff --git a/src/views/finance/components/addWalletAccount.tsx b/src/views/finance/components/addWalletAccount.tsx
index 97e9fd53..96f58b2a 100644
--- a/src/views/finance/components/addWalletAccount.tsx
+++ b/src/views/finance/components/addWalletAccount.tsx
@@ -12,13 +12,17 @@ export interface AddWalletAccountRef {
init: () => Promise<void>;
}
+interface AddWalletAccountProps {
+ onSuccess?: (res: any) => void;
+}
+
import {
CreateUserWalletAccountParams,
WalletAccountType,
} from '@/api/types/userWalletAccount';
import { financeApi } from '@/api/finance';
-const Com = forwardRef<AddWalletAccountRef>((props: any, ref) => {
+const Com = forwardRef<AddWalletAccountRef, AddWalletAccountProps>((props, ref) => {
const [isModalOpen, setIsModalOpen] = useState(false);
const [form] = Form.useForm<CreateUserWalletAccountParams>();
diff --git a/src/views/finance/index.tsx b/src/views/finance/finance.tsx
similarity index 93%
rename from src/views/finance/index.tsx
rename to src/views/finance/finance.tsx
index 62ab964f..27709a6a 100644
--- a/src/views/finance/index.tsx
+++ b/src/views/finance/finance.tsx
@@ -20,20 +20,22 @@ export default function Page() {
useEffect(() => {
getBalance();
+ // 默认导航到提现记录界面
+ navigate('userWalletRecord', { replace: true });
}, []);
const getBalance = async () => {
try {
const res = await financeApi.getUserWalletInfo();
// console.log('getBalance','res',res);
- setBalance(res.balance);
+ setBalance(res.balance || 0);
} catch (error) {
console.error('获取余额失败:', error);
}
};
return (
- <div className={styles.finance}>
+ <div className={styles.finance}>
<div className={styles.header}>
<Card className={styles.balanceCard} bordered={false}>
<Row align="middle" justify="space-between">
diff --git a/src/views/finance/userWalletAccount.tsx b/src/views/finance/userWalletAccount.tsx
index 9aa1bb7b..649c54e0 100644
--- a/src/views/finance/userWalletAccount.tsx
+++ b/src/views/finance/userWalletAccount.tsx
@@ -63,7 +63,9 @@ export default function Page() {
dataIndex: 'type',
key: 'type',
render: (type: string) => (
- <Tag color={type === '支付宝' ? 'blue' : 'green'}>{type}</Tag>
+ <Tag color={type === 'ZFB' ? 'blue' : 'green'}>
+ {type === 'ZFB' ? '支付宝' : '微信'}
+ </Tag>
),
},
{
@@ -71,17 +73,17 @@ export default function Page() {
dataIndex: 'userName',
key: 'userName',
},
- {
- title: '操作',
- key: 'action',
- render: (_: any, record: UserWalletAccount) => (
- <Space size="middle">
- <Button type="link" onClick={() => handleView(record)}>
- 查看
- </Button>
- </Space>
- ),
- },
+ // {
+ // title: '操作',
+ // key: 'action',
+ // render: (_: any, record: UserWalletAccount) => (
+ // <Space size="middle">
+ // <Button type="link" onClick={() => handleView(record)}>
+ // 查看
+ // </Button>
+ // </Space>
+ // ),
+ // },
];
const handleView = (record: UserWalletAccount) => {
@@ -107,7 +109,13 @@ export default function Page() {
loading={loading}
pagination={false}
/>
- <AddWalletAccount ref={Ref_AddWalletAccountRef} />
+ <AddWalletAccount
+ ref={Ref_AddWalletAccountRef}
+ onSuccess={() => {
+ message.success('添加账户成功');
+ getTaskList(); // 添加成功后刷新列表
+ }}
+ />
</div>
);
}
diff --git a/src/views/finance/userWalletRecord.tsx b/src/views/finance/userWalletRecord.tsx
index d8a0f017..7bf0ba70 100644
--- a/src/views/finance/userWalletRecord.tsx
+++ b/src/views/finance/userWalletRecord.tsx
@@ -5,19 +5,21 @@
* @LastEditors: nevin
* @Description: 用户金额记录 userWalletRecord
*/
-import { Button, Table, Space, Tag, message, Modal, Input, Form, Card, Typography } from 'antd';
+import { Button, Table, Space, Tag, message, Modal, Input, Form, Card, Typography, Select } from 'antd';
import { useState, useEffect, useRef } from 'react';
import AddWalletAccount from './components/addWalletAccount';
import { financeApi } from '@/api/finance';
import { AddWalletAccountRef } from './components/addWalletAccount';
import { UserWalletRecord } from '@/api/types/finance';
+import { UserWalletAccount } from '@/api/types/userWalletAccount';
import { PlusOutlined, ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons';
import styles from './userWalletRecord.module.scss';
-
+import moment from 'moment';
const { Title } = Typography;
export default function Page() {
const [walletAccountList, setWalletAccountList] = useState<UserWalletRecord[]>([]);
+ const [walletAccounts, setWalletAccounts] = useState<UserWalletAccount[]>([]);
const [loading, setLoading] = useState(false);
const [isWithdrawModalVisible, setIsWithdrawModalVisible] = useState(false);
const [form] = Form.useForm();
@@ -39,10 +41,21 @@ export default function Page() {
}
}
- const handleWithdraw = async (values: { amount: number }) => {
+ // 获取提现账户列表
+ async function getWalletAccounts() {
+ try {
+ const res = await financeApi.getUserWalletAccountList();
+ setWalletAccounts(res);
+ } catch (error) {
+ console.error('获取提现账户列表失败:', error);
+ message.error('获取提现账户列表失败');
+ }
+ }
+
+ const handleWithdraw = async (values: { amount: number; walletAccountId: string }) => {
try {
await financeApi.addUserWalletRecord({
- walletAccountId: '1', // 这里需要传入实际的账户ID
+ walletAccountId: values.walletAccountId,
balance: values.amount
});
message.success('提现申请提交成功');
@@ -57,6 +70,7 @@ export default function Page() {
useEffect(() => {
getDataList();
+ getWalletAccounts();
}, []);
const columns = [
@@ -66,19 +80,29 @@ export default function Page() {
key: 'type',
render: (type: string) => (
<Tag color={type === 'withdraw' ? 'red' : 'green'}>
- {type === 'withdraw' ? '提现' : '充值'}
+ {type === 'WITHDRAW' ? '提现' : '充值'}
</Tag>
),
},
+ {
+ title: '账户',
+ dataIndex: 'account',
+ key: 'account',
+ render: (account: any) => (
+ <Space>
+ {account.type === 'ZFB' ? '支付宝' : '微信'} - {account.account}
+ </Space>
+ ),
+ },
{
title: '金额',
dataIndex: 'balance',
key: 'balance',
- render: (amount: number) => (
+ render: (amount: number, record: UserWalletRecord) => (
<Space>
- {amount > 0 ? <ArrowUpOutlined style={{ color: '#52c41a' }} /> : <ArrowDownOutlined style={{ color: '#ff4d4f' }} />}
+ {/* {amount > 9999 ? <ArrowUpOutlined style={{ color: '#52c41a' }} /> : <ArrowDownOutlined style={{ color: '#ff4d4f' }} />} */}
<span style={{ color: amount < 0 ? '#ff4d4f' : '#52c41a' }}>
- {amount > 0 ? '+' : ''}{amount}
+ {record.type === 'WITHDRAW' ? '-' : '+'} {amount}
</span>
</Space>
),
@@ -87,16 +111,19 @@ export default function Page() {
title: '状态',
dataIndex: 'status',
key: 'status',
- render: (status: string) => (
- <Tag color={status === 'pending' ? 'orange' : status === 'success' ? 'green' : 'red'}>
- {status === 'pending' ? '处理中' : status === 'success' ? '成功' : '失败'}
+ render: (status: any) => (
+ <Tag color={status == 0 ? 'orange' : status == 1 ? 'green' : 'red'}>
+ {status == 0 ? '处理中' : status == 1 ? '成功' : '失败'}
</Tag>
),
},
{
title: '创建时间',
- dataIndex: 'payTime',
- key: 'payTime',
+ dataIndex: 'createTime',
+ key: 'createTime',
+ render: (createTime: string) => {
+ return moment(createTime).format('YYYY-MM-DD HH:mm:ss');
+ },
},
];
@@ -134,12 +161,24 @@ export default function Page() {
className={styles.modal}
>
<Form form={form} onFinish={handleWithdraw}>
+ <Form.Item
+ name="walletAccountId"
+ label="提现账户"
+ rules={[{ required: true, message: '请选择提现账户' }]}
+ >
+ <Select placeholder="请选择提现账户">
+ {walletAccounts.map(account => (
+ <Select.Option key={account.id} value={account.id}>
+ {account.type === 'ZFB' ? '支付宝' : '微信'} - {account.account}
+ </Select.Option>
+ ))}
+ </Select>
+ </Form.Item>
<Form.Item
name="amount"
label="提现金额"
rules={[
{ required: true, message: '请输入提现金额' },
- { type: 'number', message: '请输入有效的金额' },
{ min: 0, message: '提现金额必须大于0' }
]}
>
diff --git a/src/views/trending/index.tsx b/src/views/trending/index.tsx
index 8269c269..1b7a0cdf 100644
--- a/src/views/trending/index.tsx
+++ b/src/views/trending/index.tsx
@@ -2116,7 +2116,7 @@ const Trending: React.FC = () => {
}`}
onClick={() => handleRankingSelect(ranking)}
>
- {ranking.name}
+ {ranking.name }
</button>
))}
</div>