From 5d19d8d9ccf07a76f733d0f57d8d7aeeac2eac32 Mon Sep 17 00:00:00 2001 From: yezian Date: Wed, 13 Mar 2024 00:03:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=A2=E5=8D=95=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E3=80=81=E8=AE=A2=E5=8D=95=E9=80=80=E6=AC=BE=E3=80=81?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=B0=81=E7=A6=81=E5=8A=9F=E8=83=BD=EF=BC=9B?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/BlockUser/index.jsx | 456 +++++++++++++++++ src/pages/CreateAndEditPost/index.jsx | 1 + .../ManualRechargeAndWithdrawal/index.jsx | 1 + src/pages/Op/data.jsx | 8 +- src/pages/Op/index.jsx | 10 +- src/pages/OrdersQuerry/index.jsx | 481 ++++++------------ src/pages/Refund/index.jsx | 87 ++++ src/routes/index.js | 10 + 8 files changed, 713 insertions(+), 341 deletions(-) create mode 100644 src/pages/BlockUser/index.jsx create mode 100644 src/pages/Refund/index.jsx diff --git a/src/pages/BlockUser/index.jsx b/src/pages/BlockUser/index.jsx new file mode 100644 index 0000000..4721a1b --- /dev/null +++ b/src/pages/BlockUser/index.jsx @@ -0,0 +1,456 @@ +import React, { useState, useRef, useEffect } from "react"; +import { Form, Input, Button, Space, Table, Menu, Image, Modal } from "antd"; +import { + Routes, + Route, + Navigate, + useNavigate, + useLocation, +} from "react-router-dom"; +import baseRequest from "../../utils/baseRequest"; + +const BlockUserContent = (props) => { + const { TextArea } = Input; + const current = props.current; + //表头 + const columns = [ + { + title: "用户信息", + dataIndex: "user", + key: "user", + onCell: (_, index) => ({ + rowSpan: _.rowSpan, + }), + render: (data) => ( +
+ +

+ 昵称:{data.name} +

+

+ ID:{data.user_id} +

+
+ ), + }, + { + title: "封禁内容", + dataIndex: "type", + key: "type", + render: (data) =>

{data === 0 && "主播发帖封禁"}

, + }, + { + title: "起始时间", + dataIndex: "ct", + key: "ct", + }, + { + title: "结束时间", + dataIndex: "end_time", + key: "end_time", + }, + { + title: "状态", + dataIndex: "status", + key: "status", + render: (data, record) => ( +
+

{data === 0 && "处罚中"}

+

{data === 1 && "正常结束"}

+

+ {data === 2 && `提前终止:${record.ut}`} +

+
+ ), + }, + { + title: "操作", + dataIndex: "opeartion", + key: "opeartion", + render: (_, record) => ( +
+ + + {current === "blocking" && ( + + )} + + +
+ ), + }, + ]; + //给表单绑定ref + const formRef = useRef(null); + //点击修改状态按钮 + const unblock = (record) => { + formRef.current.id = record.id; + formRef.current.btn = "unblock"; + formRef.current.submit(); + }; + //提交表单 + const handleSubmit = async (value) => { + //提交数据 + try { + const base = baseRequest(); + const _response = await fetch("/op/account_punishment/unblock", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + id: formRef.current.id, + ...base, + }), + }); + const _data = await _response.json(); + if (_data.ret === -1) { + alert(_data.msg); + return; + } + } catch (error) { + console.error(error); + } + //刷新页面 + window.location.reload(); + }; + + //获取数据 + const [data, setData] = useState([]); + const getData = async () => { + let querryUrl; + switch (current) { + case "blocking": + querryUrl = "/op/account_punishment/list"; + break; + case "terminated": + querryUrl = "/op/account_punishment/list_terminated"; + break; + default: + break; + } + try { + const base = baseRequest(); + const _response = await fetch(querryUrl, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + offset: 0, + limit: 10000, + ...base, + }), + }); + const _data = await _response.json(); + console.log(_data); + if (_data.ret === -1) { + alert(_data.msg); + return; + } + //将每人的每种封禁拆分 + const blockList = _data.data.list + .map((item1, index1) => + item1.account_punishments.map((item2, index2) => ({ + rowSpan: index2 === 0 ? item1.account_punishments.length : 0, + account: item1.account, + account_punishments: item2, + })) + ) + .flat(); + //匹配表格格式 + const structedData = blockList.map((item, index) => { + return { + key: index, + id: item.account_punishments.id, + rowSpan: item.rowSpan, + user: { + avatar: item.account.avatar?.images[0].urls[0], + user_id: item.account.user_id, + name: item.account.name, + }, + type: item.account_punishments.type, + ct: new Date(item.account_punishments.ct * 1000).toLocaleString(), + end_time: new Date( + item.account_punishments.end_time * 1000 + ).toLocaleString(), + status: item.account_punishments.status, + ut: new Date(item.account_punishments.ut * 1000).toLocaleString(), + }; + }); + setData([...data, ...structedData]); + } catch (error) { + console.error(error); + } + }; + useEffect(() => { + getData(); + }, [current]); + + //展示的数据 + const [showData, setShowData] = useState([]); + useEffect(() => { + setShowData(data); + }, [data]); + + //打开添加封禁Modal + const [isModalVisible, setIsModalVisible] = useState(false); + + //在modal中搜索用户 + const [userInfo, setUserInfo] = useState(); + const modalSearch = async (value) => { + try { + const base = baseRequest(); + const _response = await fetch(`/op/account/list_by_user_id`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + user_id: parseInt(value.userId, 10), + ...base, + }), + }); + const _data = await _response.json(); + console.log(_data); + if (_data.ret === -1) { + alert(_data.msg); + return; + } + setSelectedUser(); + setUserInfo(_data.data.account); + } catch (error) { + console.error(error); + } + }; + //选中用户 + const [selectedUser, setSelectedUser] = useState(); + const handleSelected = () => { + if (selectedUser) { + setSelectedUser(); + return; + } + setSelectedUser(userInfo.mid); + }; + //添加封禁 + const [form] = Form.useForm(); + const block = async (value) => { + if (!selectedUser) { + alert("还未选中用户"); + return; + } + try { + const base = baseRequest(); + const _response = await fetch("/op/account_punishment/create", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + mid: selectedUser, + type: parseInt(value.type, 10), + duration: parseInt(value.duration, 10), + ...base, + }), + }); + const _data = await _response.json(); + if (_data.ret === -1) { + alert(_data.msg); + return; + } + handleCancelModal(); + //刷新页面 + window.location.reload(); + } catch (error) { + console.error(error); + } + }; + + //关闭弹窗 + const handleCancelModal = () => { + form.resetFields(); + setUserInfo(); + setSelectedUser(); + setIsModalVisible(false); + }; + + //表单提交失败 + const onFinishFailed = (errorInfo) => { + console.log("Failed:", errorInfo); + }; + return ( +
+ +
+ + + {isModalVisible && ( + +

+ *请选中用户后再执行操作 +

+
+ + + + + + + + {userInfo && ( +
+ +
+

ID:{userInfo.user_id}

+

昵称:{userInfo.name}

+
+ +
+ )} +
+ + + + + + + + + + +
+ )} + + ); +}; + +export default function BlockUser() { + const navigate = useNavigate(); + //当前tab + const location = useLocation(); + const pathname = location.pathname.split("/")[2] || "blocking"; + const [current, setCurrent] = useState(pathname); + //tab名称 + const items = [ + { + label: "封禁中", + key: "blocking", + }, + { + label: "已结束", + key: "terminated", + }, + ]; + const onClick = (e) => { + setCurrent(e.key); + navigate(e.key); + window.location.reload(); + }; + + return ( +
+ + + } /> + } + /> + } + /> + +
+ ); +} diff --git a/src/pages/CreateAndEditPost/index.jsx b/src/pages/CreateAndEditPost/index.jsx index 802ece7..c87c4df 100644 --- a/src/pages/CreateAndEditPost/index.jsx +++ b/src/pages/CreateAndEditPost/index.jsx @@ -323,6 +323,7 @@ const CreateAndEditPostContent = (props) => { alert(data.msg); return; } + setSelectedUser(); setUserInfo(data.data.account); } catch (error) { console.error(error); diff --git a/src/pages/ManualRechargeAndWithdrawal/index.jsx b/src/pages/ManualRechargeAndWithdrawal/index.jsx index 61a5509..c8fa27c 100644 --- a/src/pages/ManualRechargeAndWithdrawal/index.jsx +++ b/src/pages/ManualRechargeAndWithdrawal/index.jsx @@ -149,6 +149,7 @@ const ManualRechargeAndWithdrawalContent = (props) => { alert(data.msg); return; } + setSelectedUser(); setUserInfo(data.data.account); } catch (error) { console.error(error); diff --git a/src/pages/Op/data.jsx b/src/pages/Op/data.jsx index d0ce155..45da47d 100644 --- a/src/pages/Op/data.jsx +++ b/src/pages/Op/data.jsx @@ -35,6 +35,10 @@ export default function Data() { }), }); const _data = await response.json(); + if (_data.ret === -1) { + alert(_data.msg); + return; + } const structedData = _data.data.list.map((item, index) => { return { key: index, @@ -54,10 +58,6 @@ export default function Data() { }; }); setData(structedData); - if (_data.ret === -1) { - alert(_data.msg); - return; - } } catch (error) { console.error(error); } diff --git a/src/pages/Op/index.jsx b/src/pages/Op/index.jsx index dab98bd..f955136 100644 --- a/src/pages/Op/index.jsx +++ b/src/pages/Op/index.jsx @@ -66,9 +66,13 @@ export default function Op() { getItem("手机号查询", "getPhoneNumber"), ]), // getItem("用户管理", "userManagement", ), - // getItem("订单管理", "orderManagement", , [ - // getItem("订单查询", "ordersQuerry"), - // ]), + getItem("订单管理", "orderManagement", , [ + getItem("查询", "ordersQuerry"), + getItem("退款", "refund"), + ]), + getItem("社区治理", "communityManagement", , [ + getItem("用户封禁", "blockUser"), + ]), getItem( "人工充值/提现", "manualRechargeAndWithdrawal", diff --git a/src/pages/OrdersQuerry/index.jsx b/src/pages/OrdersQuerry/index.jsx index 1391359..a27066a 100644 --- a/src/pages/OrdersQuerry/index.jsx +++ b/src/pages/OrdersQuerry/index.jsx @@ -1,354 +1,167 @@ -import React, { useState } from "react"; -import { Form, Input, Button, Space, Table, Checkbox, Image } from "antd"; +import React, { useState, useEffect } from "react"; +import baseRequest from "../../utils/baseRequest"; +import { DatePicker, Table, Form, Space, Button, Input, Radio } from "antd"; export default function OrdersQuerry() { - //展示的表头 - const [showColumns, setShowColumns] = useState([ - "orderId", - "orderStatus", - "orderTime", - "creatorId", - "creatorName", - "userId", - "userName", - "requirement", - "payment", - "comment", - ]); - //动态的表头 - const dynamicColumns = showColumns.map((item) => { - switch (item) { - case "orderId": - return { - title: "订单号", - dataIndex: "orderId", - key: "orderId", - }; - case "orderStatus": - return { - title: "订单状态", - dataIndex: "orderStatus", - key: "orderStatus", - }; - case "orderTime": - return { - title: "订单时间", - dataIndex: "orderTime", - key: "orderTime", - render: (orderTime) => ( -
    -
  • - 创建时间: - {orderTime.createTime} -
  • -
  • - 付款时间: - {orderTime.payTime} -
  • -
  • - 发货时间: - {orderTime.deliveryTime} -
  • -
  • - 完成时间: - {orderTime.finishTime} -
  • -
- ), - }; - case "creatorId": - return { - title: "名人ID", - dataIndex: "creatorId", - key: "creatorId", - }; - case "creatorName": - return { - title: "名人昵称", - dataIndex: "creatorName", - key: "creatorName", - }; - case "userId": - return { - title: "用户ID", - dataIndex: "userId", - key: "userId", - }; - case "userName": - return { - title: "用户昵称", - dataIndex: "userName", - key: "userName", - }; - case "requirement": - return { - title: "拍摄要求", - dataIndex: "requirement", - key: "requirement", - render: (requirement) => ( -
    -
  • - 给谁: - {requirement.to} -
  • -
  • - 拍摄要求: - {requirement.requirement} -
  • -
  • - 备注: - {requirement.remark} -
  • -
- ), - }; - case "payment": - return { - title: "实付款", - dataIndex: "payment", - key: "payment", - }; - case "media": - return { - title: "成品", - dataIndex: "media", - key: "media", - render: (media) => - media.type === "img" ? ( - - ) : ( -
diff --git a/src/pages/Refund/index.jsx b/src/pages/Refund/index.jsx new file mode 100644 index 0000000..3d666a7 --- /dev/null +++ b/src/pages/Refund/index.jsx @@ -0,0 +1,87 @@ +import React from "react"; +import { Form, Input, Space, Button, message, Radio } from "antd"; +import baseRequest from "../../utils/baseRequest"; + +const RefundContent = (props) => { + const [form] = Form.useForm(); + + //提交退款 + const handleRefund = async (value) => { + try { + const base = baseRequest(); + const _response = await fetch( + `op/vas/${ + value.type === "coin" ? "refund_coin_order" : "refund_order" + }`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + order_id: value.orderId, + operator: value.operator, + ...base, + }), + } + ); + const _data = await _response.json(); + console.log(_data); + if (_data.ret === -1) { + alert(_data.msg); + return; + } + form.resetFields(); + message.success("退款成功"); + } catch (error) { + console.error(error); + } + }; + //表单提交失败 + const onFinishFailed = (errorInfo) => { + console.log("Failed:", errorInfo); + }; + + return ( +
+
+ + + + + + + + + + 退金币 + 退现金 + + + + + +
+ ); +}; + +export default function Refund() { + return ; +} diff --git a/src/routes/index.js b/src/routes/index.js index 99d1164..065285d 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -19,6 +19,8 @@ import CreateAndEditPost from "../pages/CreateAndEditPost"; import TopPosts from "../pages/TopPosts"; import PostMachineReview from "../pages/PostMachineReview"; import GetPhoneNumber from "../pages/GetPhoneNumber"; +import Refund from "../pages/Refund"; +import BlockUser from "../pages/BlockUser"; const routes = [ { @@ -105,6 +107,14 @@ const routes = [ path: "getPhoneNumber/*", element: , }, + { + path: "refund/*", + element: , + }, + { + path: "blockUser/*", + element: , + }, ], }, ]; -- 2.41.0