Przeglądaj źródła

feta 增加宗门福利设置

Young 4 miesięcy temu
rodzic
commit
c62037a636

+ 17 - 0
config/routes.ts

@@ -111,6 +111,23 @@ export default [
     ],
   },
   {
+    path: '/settings/chat',
+    name: 'settings.chat',
+    icon: 'crown',
+    routes: [
+      {
+        path: '/settings/chat/redPacket',
+        name: 'redPacket',
+        component: './Settings/RedPacket',
+      },
+      {
+        path: '/settings/chat/vest',
+        name: 'vest',
+        component: './Settings/Vest',
+      },
+    ],
+  },
+  {
     path: '/system',
     name: 'system',
     icon: 'crown',

+ 2 - 0
src/locales/zh-CN/menu.ts

@@ -18,6 +18,8 @@ export default {
   'menu.settings.platform.peakWeal': '紫晶发放设置',
   'menu.settings.platform.visit': '拜访设置',
 
+  'menu.settings.chat.redPacket': '红包设置',
+
   'menu.peak': '峰管理',
   'menu.peak.peaks': '峰管理',
   'menu.peak.peakLevel': '峰等级管理',

+ 112 - 0
src/pages/Settings/ChatCnt.tsx

@@ -0,0 +1,112 @@
+import {ProForm, ProFormInstance, ProFormSelect, ProFormText} from '@ant-design/pro-components';
+import {message} from 'antd';
+import React, {useEffect, useRef, useState} from 'react';
+import {getConfigGetApi, postConfigSaveApi} from "@/services/swagger/configAdmin";
+import {getPeakLevelListTreeApi} from "@/services/swagger/peakLevelAdmin";
+
+type PeakLevelVO = {
+  /** 创建时间 */
+  createTime?: string;
+  /** 更新时间 */
+  updateTime?: string;
+  /** 自增 ID */
+  id?: number;
+  /** 父节点 */
+  parentId?: number;
+  /** 名称 */
+  name?: string;
+  /** 等级 */
+  level?: number;
+  /** 经验值 */
+  exp?: number;
+  /** 子节点 */
+  children?: PeakLevelVO[];
+};
+
+const options = [
+  {
+    value: 1,
+    label: '紫币',
+  },
+  {
+    value: 2,
+    label: '紫晶',
+  },
+]
+
+type WealSetting = {
+  level?: number;
+  wealCnt: number;
+  wealType: number;
+};
+
+export default () => {
+  const formRef = useRef<ProFormInstance>();
+
+  const [peakLevelList, setPeakLevelList] = useState<PeakLevelVO[]>([]);
+
+  useEffect(() => {
+    const fetchLevels = async () => {
+      const res = await getPeakLevelListTreeApi();
+      if (res.success) {
+        setPeakLevelList(res.data);
+      }
+    };
+
+    fetchLevels();
+  }, []);
+
+  return (
+    <ProForm
+      layout="horizontal"
+      title="签到设置"
+      formRef={formRef}
+      submitter={{}}
+      request={async () => {
+        const res = await getConfigGetApi({"code": "platform.peak.weal"})
+        if (res.success && res.data.content) {
+          const result: WealSetting[] = JSON.parse(res.data.content)
+          return result.reduce((acc: any, item: WealSetting) => {
+            acc[`${item.level}WealCnt`] = item.wealCnt;
+            acc[`${item.level}WealType`] = item.wealType;
+            return acc;
+          }, {});
+        }
+
+        return Promise.resolve({});
+      }}
+      onFinish={async (values) => {
+        const result: WealSetting[] = peakLevelList.map(peakLevel => ({
+          level: peakLevel.level,
+          wealCnt: parseInt(values[`${peakLevel.level}WealCnt`]),
+          wealType: parseInt(values[`${peakLevel.level}WealType`]),
+        }));
+
+        console.log("value " + values);
+        console.log("result " + result);
+
+        const res = await postConfigSaveApi({
+          "type": "json",
+          "code": "platform.peak.weal",
+          "remark": "宗门奖励发放设置",
+          "content": JSON.stringify(result)
+        })
+
+        if (res.success) {
+          message.success('提交成功');
+        } else {
+          message.error(res.errorMessage)
+        }
+        return res.success;
+      }}
+    >
+
+      {peakLevelList.map(level => (
+        <ProForm.Group key={level.name}>
+          <ProFormText name={`${level.level}WealCnt`} width="md" label={`${level.name}`}/>
+          <ProFormSelect name={`${level.level}WealType`} options={options} initialValue="1" width="xs"/>
+        </ProForm.Group>
+      ))}
+    </ProForm>
+  );
+};

+ 55 - 0
src/pages/Settings/RedPacket.tsx

@@ -0,0 +1,55 @@
+import {ProForm, ProFormInstance, ProFormText} from '@ant-design/pro-components';
+import {message} from 'antd';
+import React, {useRef} from 'react';
+import {getConfigGetApi, postConfigSaveApi} from "@/services/swagger/configAdmin";
+
+
+type RedPacketSend = {
+  minLimit: number
+};
+
+export default () => {
+  const formRef = useRef<ProFormInstance>();
+  return (
+    <ProForm
+      layout="horizontal"
+      title="签到设置"
+      formRef={formRef}
+      submitter={{}}
+      request={async () => {
+        const res = await getConfigGetApi({"code": "platform.redPacket.send"})
+        if (res.success && res.data.content) {
+          const result: RedPacketSend = JSON.parse(res.data.content)
+          return result;
+        }
+
+        return {
+          minLimit: 0,
+        }
+      }}
+      onFinish={async (values) => {
+        const result: RedPacketSend = {
+          minLimit: parseInt(values.minLimit),
+        };
+        console.log("value " + values);
+
+        const res = await postConfigSaveApi({
+          "type": "json",
+          "code": "platform.redPacket.send",
+          "remark": "红包发送设置",
+          "content": JSON.stringify(result)
+        })
+
+        if (res.success) {
+          message.success('提交成功');
+        } else {
+          message.error(res.errorMessage)
+        }
+        return res.success;
+      }}
+    >
+
+      <ProFormText name="minLimit" width="md" label={`每次发送红包至少`} addonAfter={"个"}/>
+    </ProForm>
+  );
+};