diff --git a/package.json b/package.json index 33b794e..a5f3edb 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "connected-react-router": "^6.5.2", "cross-env": "^7.0.2", "dagre": "^0.8.5", + "dayjs": "^1.11.10", "less": "^3.11.1", "less-loader": "^5.0.0", "moment": "^2.24.0", diff --git a/src/package/SimpleTrade/api/index.ts b/src/package/SimpleTrade/api/index.ts index 47c44e1..e634679 100644 --- a/src/package/SimpleTrade/api/index.ts +++ b/src/package/SimpleTrade/api/index.ts @@ -9,5 +9,26 @@ export default { // 登录 login(params: object): Promise> { return $axios.post('/admin/login', params) + }, + + // 首页用户统计 + user_statistics(): Promise> { + return $axios.post('/admin/userAmount') + }, + + // 首页充值提现统计 + recharge_withdraw_statistics(): Promise> { + return $axios.post('/admin/depositWithdrawal') + }, + + /** + * @description 交易统计 + * @param {number} end_time 结束时间 + * @param {number} start_time 开始时间 + * @param {number} type 1.今日交易订单统计 2.周期交易订单统计 + */ + transaction_statistics(params?: object): Promise> { + return $axios.post('/admin/prodruct', params) } + } diff --git a/src/package/SimpleTrade/pages/client/recharge/index.tsx b/src/package/SimpleTrade/pages/client/recharge/index.tsx index 2cc12e9..1ffd4a8 100644 --- a/src/package/SimpleTrade/pages/client/recharge/index.tsx +++ b/src/package/SimpleTrade/pages/client/recharge/index.tsx @@ -2,23 +2,42 @@ import React, { FC } from "react"; import clientApi from "@/package/SimpleTrade/api/client"; import MyTable from "@/components/MyTable"; import { Input } from "antd"; -import { getTime, splitAddress } from "@/utils"; +import { copy, getTime, splitAddress } from "@/utils"; +import { CopyOutlined } from "@ant-design/icons"; const RechargeRecord: FC = () => { const columns = [ { - title: '用户ID', - dataIndex: 'user_id' + title: '账号ID', + dataIndex: 'a_mt4_login' }, { title: 'from地址', dataIndex: 'from_address', - render: (_val) => (
{splitAddress(_val)}
) + render: (address) => ( +
+
{splitAddress(address, 5)}
+
copy(address)}> + +
+
+ ) }, { title: 'to地址', dataIndex: 'to_address', - render: (_val) => (
{splitAddress(_val)}
) + render: (address) => ( +
+
{splitAddress(address, 5)}
+
copy(address)}> + +
+
+ ) + }, + { + title: '充值状态', + dataIndex: 'status' }, { title: '链ID', diff --git a/src/package/SimpleTrade/pages/client/user/index.tsx b/src/package/SimpleTrade/pages/client/user/index.tsx index 33b24af..209faef 100644 --- a/src/package/SimpleTrade/pages/client/user/index.tsx +++ b/src/package/SimpleTrade/pages/client/user/index.tsx @@ -41,10 +41,26 @@ const UserList: FC = () => { title: 'A账号', dataIndex: 'a_mt4_login' }, + { + title: 'A仓余额', + dataIndex: 'a_mt4_balance' + }, + { + title: 'A仓订单数量', + dataIndex: 'a_product' + }, { title: 'B账号', dataIndex: 'b_mt4_login' }, + { + title: 'B仓余额', + dataIndex: 'b_mt4_balance' + }, + { + title: 'B仓订单数量', + dataIndex: 'b_product' + }, { title: '手数', dataIndex: 'volume' @@ -58,7 +74,10 @@ const UserList: FC = () => { }, { title: '保险开关', - dataIndex: 'insurance' + dataIndex: 'insurance', + render: (status) => ( +
{status === 1 ? '开' : '关'}
+ ) }, { title: '邀请码', diff --git a/src/package/SimpleTrade/pages/client/withdraw/index.tsx b/src/package/SimpleTrade/pages/client/withdraw/index.tsx index bef8c48..d87da74 100644 --- a/src/package/SimpleTrade/pages/client/withdraw/index.tsx +++ b/src/package/SimpleTrade/pages/client/withdraw/index.tsx @@ -12,8 +12,8 @@ const WithdrawRecord: FC = () => { const columns = [ { - title: '用户ID', - dataIndex: 'user_id' + title: '账号ID', + dataIndex: 'a_mt4_login' }, { title: '交易ID', @@ -27,10 +27,6 @@ const WithdrawRecord: FC = () => { ) }, - { - title: '账号ID', - dataIndex: 'login_id' - }, { title: '链ID', dataIndex: 'chain_id' @@ -56,8 +52,8 @@ const WithdrawRecord: FC = () => { dataIndex: 'symbol' }, { - title: '状态', - dataIndex: 'handle_status' + title: '提现状态', + dataIndex: 'status' }, { title: '处理时间', diff --git a/src/package/SimpleTrade/pages/home/index.css b/src/package/SimpleTrade/pages/home/index.css new file mode 100644 index 0000000..faf1375 --- /dev/null +++ b/src/package/SimpleTrade/pages/home/index.css @@ -0,0 +1,38 @@ +.home .box { + width: 100%; + margin-top: 20px; + border-radius: 10px; + padding: 20px; + box-sizing: border-box; + min-height: 280px; +} +.home .box .solid { + min-height: 200px; + width: 1px; +} +.home .box .img-box { + width: 60px; + height: 60px; + background-color: #44D600; + border-radius: 6px; + display: flex; + justify-content: center; + align-items: center; +} +.home .box .img-box img { + width: 30px; + height: 30px; + object-fit: cover; +} +.row { + display: flex; +} +.row-items { + display: flex; + align-items: center; +} +.row-between { + display: flex; + align-items: center; + justify-content: space-between; +} diff --git a/src/package/SimpleTrade/pages/home/index.less b/src/package/SimpleTrade/pages/home/index.less new file mode 100644 index 0000000..070cbf3 --- /dev/null +++ b/src/package/SimpleTrade/pages/home/index.less @@ -0,0 +1,47 @@ +.home { + + .box { + width: 100%; + margin-top: 20px; + border-radius: 10px; + padding: 20px; + box-sizing: border-box; + min-height: 280px; + + .solid{ + min-height: 200px; + width: 1px; + } + + .img-box{ + width: 60px; + height: 60px; + background-color: #44D600; + border-radius: 6px; + display: flex; + justify-content: center; + align-items: center; + + img{ + width: 30px; + height: 30px; + object-fit: cover; + } + } + } +} + +.row{ + display: flex; +} + +.row-items{ + display: flex; + align-items: center; +} + +.row-between{ + display: flex; + align-items: center; + justify-content: space-between; +} diff --git a/src/package/SimpleTrade/pages/home/index.tsx b/src/package/SimpleTrade/pages/home/index.tsx index 78ccd91..57a5953 100644 --- a/src/package/SimpleTrade/pages/home/index.tsx +++ b/src/package/SimpleTrade/pages/home/index.tsx @@ -1,18 +1,262 @@ -import React, { FC } from 'react' -import { Col, Row } from 'antd' +import React, { FC, useEffect, useState } from 'react' +import './index.less' +import { useSelector } from 'react-redux' +import api from '@/package/SimpleTrade/api' +import { DatePicker } from 'antd'; +import dayjs from 'dayjs'; +import customParseFormat from 'dayjs/plugin/customParseFormat'; +import weekday from "dayjs/plugin/weekday" +import localeData from "dayjs/plugin/localeData" +dayjs.extend(customParseFormat); +dayjs.extend(weekday); +dayjs.extend(localeData); +const { RangePicker } = DatePicker; +const dateFormat = 'YYYY-MM-DD'; const Home: FC = () => { + + const theme = useSelector((state: any) => state.storeData.theme) + + const [userTable, setUserTable] = useState([]) + const [newToDay, setNewToDay] = useState(0) //今日新增 + const [userTotal, setUserTotal] = useState(0) //用户统计 + const start_time = dayjs().subtract(7, 'days') + const end_time = dayjs() + + const [defaultValue, setDefaultValue] = useState([start_time, end_time] as any) + + const [toDayTx, setToDayTx] = useState([ + { title: '今日订单金额', value: '0' }, + { title: '今日订单数量', value: '0' }, + { title: '盈利订单数量', value: '0', color: '#3BB900' }, + { title: '亏损订单数量', value: '0', color: '#F4002C' }, + { title: '盈利订单金额', value: '0', color: '#3BB900' }, + { title: '亏损订单金额', value: '0', color: '#F4002C' }, + ]) + + const [weekTx, setWeekTx] = useState([ + { title: '订单总金额', value: '0' }, + { title: '订单总数量', value: '0' }, + { title: '盈利订单数量', value: '0', color: '#3BB900' }, + { title: '亏损订单数量', value: '0', color: '#F4002C' }, + { title: '盈利订单金额', value: '0', color: '#3BB900' }, + { title: '亏损订单金额', value: '0', color: '#F4002C' }, + ]) + + const [transaction, setTransaction] = useState([]) + + // 用户统计 + const getUserData = async () => { + const res: any = await api.user_statistics() + if (res.code === 0) { + setNewToDay(res.data.NewToday) + setUserTotal(res.data.total_amount) + setUserTable(res.data.AdminUserAmountList) + } + } + + // 周期合约交易订单统计 + const getWeekTxOrderStatic = async () => { + const start = Math.floor(defaultValue[0].valueOf() / 1000) + const end = Math.floor(defaultValue[1].valueOf() / 1000) + const res: any = await api.transaction_statistics({ + end_time: end, + start_time: start, + type: 2 + }) + if (res.code === 0) { + weekTx[0].value = res.data.product_amount + weekTx[1].value = res.data.product_num + weekTx[2].value = res.data.profit_num + weekTx[3].value = res.data.loss_num + weekTx[4].value = res.data.profit_amount + weekTx[5].value = res.data.loss_amount + setWeekTx([...weekTx]) + } + } + + // 今日合约交易订单统计 + const getDayTxOrderStatic = async () => { + const res: any = await api.transaction_statistics({ + type: 1 + }) + console.log(res); + + if (res.code === 0) { + toDayTx[0].value = res.data.product_amount + toDayTx[1].value = res.data.product_num + toDayTx[2].value = res.data.profit_num + toDayTx[3].value = res.data.loss_num + toDayTx[4].value = res.data.profit_amount + toDayTx[5].value = res.data.loss_amount + setToDayTx([...toDayTx]) + } + } + + // 充值提现统计 + const getRechargeAndWithdraw = async () => { + const res: any = await api.recharge_withdraw_statistics() + if (res.code === 0) { + setTransaction(res.data) + } + console.log(res); + } + + useEffect(() => { + getUserData() + getDayTxOrderStatic() + getRechargeAndWithdraw() + }, []) + + useEffect(() => { + getWeekTxOrderStatic() + }, [defaultValue]) + return ( -
- - - - - - - - -
+
+

Hello, Randy!

+
Today is a good day to start trading crypto assets!
+ {/* */} +
+
用户统计
+
+
+

{userTotal.toLocaleString()}

+
+
+ +
+
+
+{newToDay.toLocaleString()}
+
今日新增
+
+
+
+
+
+
+
类型
+
截止昨日
+
今日新增
+
+
+ { + userTable.map((item, index) => ( +
+
{item.type}
+
+
{Number(item.yesterday_amount).toLocaleString()}
+
{item.yesterday_percentage}
+
+
+
{Number(item.new_today_amount).toLocaleString()}
+
{item.new_today_percentage}
+
+
+ )) + } +
+
+
+
+ {/* */} +
+
+
今日合约交易订单统计
+
+ { + toDayTx.map((item, index) => ( +
+
{item.title}
+
{Number(item.value).toLocaleString()}
+
+ )) + } +
+
+
+
+
+
+
周期合约交易订单统计
+
+ +
+
+
+
导出
+
+
+
+ { + weekTx.map((item, index) => ( +
+
{item.title}
+
{Number(item.value).toLocaleString()}
+
+ )) + } +
+
+
+ {/* */} + {transaction[0] && transaction[1] &&
+
+
{transaction[0].symbol} 充值提现
+ {/*
净入金:2131223
+
充值提现比:150%
*/} +
+
+
总充值
+
{Number(transaction[0].deposit_amount).toLocaleString()}
+
+
+
充值笔数
+
{transaction[0].deposit_num}
+
+
+
+
+
总提现
+
{Number(transaction[0].withdrawal_amount).toLocaleString()}
+
+
+
提现笔数
+
{transaction[0].withdrawal_num}
+
+
+
+
+
+
{transaction[1].symbol} 充值提现
+
+
+
总充值
+
{Number(transaction[1].deposit_amount).toLocaleString()}
+
+
+
充值笔数
+
{transaction[1].deposit_num}
+
+
+
+
+
总提现
+
{Number(transaction[1].withdrawal_amount).toLocaleString()}
+
+
+
提现笔数
+
{transaction[1].withdrawal_num}
+
+
+
+
} +
+
) } diff --git a/src/package/SimpleTrade/pages/home/vector.png b/src/package/SimpleTrade/pages/home/vector.png new file mode 100644 index 0000000..2176906 Binary files /dev/null and b/src/package/SimpleTrade/pages/home/vector.png differ diff --git a/yarn.lock b/yarn.lock index e5cb8bc..2eeacd7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4437,6 +4437,11 @@ date-fns@^1.27.2: resolved "https://registry.nlark.com/date-fns/download/date-fns-1.30.1.tgz?cache=0&sync_timestamp=1620446304247&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdate-fns%2Fdownload%2Fdate-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c" integrity sha1-LnG/CxGRU9u0zE6I2epaz7UNwFw= +dayjs@^1.11.10: + version "1.11.10" + resolved "https://registry.npmmirror.com/dayjs/-/dayjs-1.11.10.tgz#68acea85317a6e164457d6d6947564029a6a16a0" + integrity sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ== + debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.nlark.com/debug/download/debug-2.6.9.tgz?cache=0&sync_timestamp=1618847042350&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdebug%2Fdownload%2Fdebug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"