shenwu hai 7 meses
pai
achega
3ee5cbacbd

+ 20 - 0
src/models/global.tsx

@@ -34,6 +34,7 @@ export function reducer(state: State, action: Action) {
 export default (): {
   state: State;
   init: () => void;
+  getEnum: (enumName: string, type: "map" | "arr" | "obj") => any;
   getLabelAndClassList: (params?: { workDirection: number | string }) => Promise<boolean>;
 } => {
   const [state, dispatch] = useReducer(reducer, {});
@@ -105,9 +106,28 @@ export default (): {
     dispatch({ type: 'setAll', params: { ...state, labelList, categoryList } });
     return true;
   };
+  const getEnum = (enumName: string, type: "map" | "arr" | "obj") => {
+    let arr = state?.enumList?.[enumName]?.values
+    // console.log("arr",enumName,arr)
+    switch (type) {
+        case "map":
+            return new Map(arr?.map(({ value, description }: any) => [value, description]))
+        case "arr":
+            return arr?.map(({ value, description }: any) => ({ value, key: value, label: description, disabled: false }))
+        case "obj":
+            let obj: any = {}
+            if (arr) {
+                for (let item of arr) {
+                    obj[item?.value] = { text: item?.description, disabled: false }
+                }
+            }
+            return obj
+    }
+}
   return {
     state,
     init,
+    getEnum,
     getLabelAndClassList,
   };
 };

+ 5 - 4
src/pages/distribution/miniprogram/weChatInfo/tableConfig.tsx

@@ -1,6 +1,6 @@
 import { ProColumns } from '@ant-design/pro-components';
 import { Tag, Button, Popconfirm, Space, Switch, Tooltip } from 'antd';
-
+import Users from './user'
 export const columns = (
   edit: (b: boolean, v: any) => void,
   del: (id: any) => void,
@@ -76,8 +76,8 @@ export const columns = (
       tooltip: "ios的特殊性,此版本号与IOS支付模块关联,小程序版本号<=此版本号IOS才会出现支付功能,(微信)小程序发布线上后必须设置",
       dataIndex: 'iosPayment',
       hideInSearch: true,
-      render:(_,d)=>{
-        return d.iosPayment ?<Tag color="processing"  bordered={false}>{d.iosPayment}</Tag>  : <Tag color="error"  bordered={false}>IOS无法支付</Tag>
+      render: (_, d) => {
+        return d.iosPayment ? <Tag color="processing" bordered={false}>{d.iosPayment}</Tag> : <Tag color="error" bordered={false}>IOS无法支付</Tag>
       }
     },
     {
@@ -113,7 +113,7 @@ export const columns = (
       ellipsis: true,
       hideInSearch: true,
     },
-    
+
     {
       title: '状态',
       dataIndex: 'enabled',
@@ -199,6 +199,7 @@ export const columns = (
             >
               指派
             </Button>
+            <Users data={b} />
           </Space>
         );
       },

+ 53 - 0
src/pages/distribution/miniprogram/weChatInfo/user/bookList/index.tsx

@@ -0,0 +1,53 @@
+import { ActionType, ProTable } from "@ant-design/pro-components"
+import { columns } from "./tableConfig"
+import { useAjax } from "@/Hook/useAjax"
+import {  useRef, useState } from "react"
+import { Button, Drawer, Modal } from "antd"
+import { shelfLisOfPage } from "@/services/distribution/MiniAppUser"
+type Props={
+    data: {
+        appId: number
+        id: number
+    }
+}
+const Page: React.FC<Props> = (props) => {
+    const [open, setOpen] = useState(false)
+    const actionRef = useRef<ActionType>();
+    let getList = useAjax((params) => shelfLisOfPage(params), { type: 'table' })
+    return <>
+        <Button
+            size="small"
+            type="link"
+            onClick={()=>{setOpen(true)}}
+        >书架列表</Button>
+        <Modal
+            open={open}
+            footer={false}
+            onCancel={()=>{setOpen(false)}}
+            title={"书架列表"}
+            width={"50%"}
+            destroyOnClose
+        >
+            <ProTable<any, any>
+                actionRef={actionRef}
+                scroll={{ x: true ,y:'50vh'}}
+                headerTitle={false}
+                rowKey={(r) => r.id}
+                search={false}
+                params={{
+                    appId:props.data.appId,
+                    userId:props.data.id
+                }}
+                request={async (params) => {
+                    if (params?.appId) {
+                        return await getList.run(params)
+                    }
+                }}
+                columns={columns()}
+            // bordered
+            />
+        </Modal>
+    </>
+
+}
+export default Page

+ 51 - 0
src/pages/distribution/miniprogram/weChatInfo/user/bookList/tableConfig.tsx

@@ -0,0 +1,51 @@
+import { ProColumns } from "@ant-design/pro-components";
+import { Image } from "antd";
+
+export const columns = (): ProColumns<any>[] => {
+    return [
+        {
+            title: '封面',
+            dataIndex: 'picUrl',
+            key: 'picUrl',
+            width: 90,
+            ellipsis: true,
+            align: 'center',
+            hideInSearch: true,
+            render: (a: any, b: any) => {
+               let book = b?.shortBookInfo?.bookInfo || b?.longBookInfo?.bookInfo
+              return (
+                <div style={{ position: 'relative' }}>
+                  <Image
+                    src={book?.picUrl}
+                    style={{ width: 50 }}
+                    onError={(e: any) => {
+                      e.target.src = localStorage.getItem('nocover');
+                    }}
+                  />
+                </div>
+              );
+            },
+          },
+        {
+            title: "书名",
+            dataIndex: 'bookName',
+            key: "bookName",
+            align: "center",
+            render: (a: any, b: any) => {
+                let book = b?.shortBookInfo?.bookInfo || b?.longBookInfo?.bookInfo
+               return book?.bookName
+             },
+        },
+        {
+            title: "最近阅读时间",
+            dataIndex: 'lastReadingTime',
+            key: "lastReadingTime",
+            align: "center",
+            render: (a: any, b: any) => {
+                let book = b?.shortBookInfo || b?.longBookInfo
+               return book?.lastReadingTime
+             },
+        },
+
+    ];
+}

+ 69 - 0
src/pages/distribution/miniprogram/weChatInfo/user/index.tsx

@@ -0,0 +1,69 @@
+import { ActionType, ProTable } from "@ant-design/pro-components"
+import { columns } from "./tableConfig"
+import { useAjax } from "@/Hook/useAjax"
+import { useModel } from "@umijs/max"
+import { useCallback, useRef, useState } from "react"
+import { Button, Drawer, message, Modal } from "antd"
+import { miniAppusers, updateEnabled } from "@/services/distribution/MiniAppUser"
+type Props={
+    data:{
+        wechatAppId:string
+        id:number
+        appName:string
+    }
+}
+const Page: React.FC<Props> = (props) => {
+    const [open, setOpen] = useState(false)
+    const actionRef = useRef<ActionType>();
+    let { enumList } = useModel("global", (model) => ({
+        enumList: model.state.enumList
+    }))
+    let getList = useAjax((params) => miniAppusers(params), { type: 'table' })
+    let upDateApi = useAjax((params) => updateEnabled(params))
+
+    const upDate = useCallback((params: { id: any, enabled: boolean }) => {
+        upDateApi.run(params).then(res => {
+            if (res.code === 200) {
+                message.success("修改状态成功!")
+                actionRef.current?.reload()//刷新
+            }
+        })
+    }, [])
+    return <>
+        <Button
+            size="small"
+            type="link"
+            onClick={()=>{setOpen(true)}}
+        >用户列表</Button>
+        <Drawer
+            open={open}
+            footer={false}
+            onClose={()=>{setOpen(false)}}
+            title={props?.data?.appName}
+            width={"85%"}
+            destroyOnClose
+        >
+            <ProTable<any, any>
+                actionRef={actionRef}
+                scroll={{ x: true }}
+                headerTitle={"微信小程序用户列表"}
+                rowKey={(r) => r.id}
+                search={{
+                    labelWidth: 120,
+                }}
+                params={{
+                    appId:props.data.id
+                }}
+                request={async (params) => {
+                    if (params?.appId) {
+                        return await getList.run(params)
+                    }
+                }}
+                columns={columns({ enumList: enumList || [], upDate })}
+            // bordered
+            />
+        </Drawer>
+    </>
+
+}
+export default Page

+ 53 - 0
src/pages/distribution/miniprogram/weChatInfo/user/loginList/index.tsx

@@ -0,0 +1,53 @@
+import { ActionType, ProTable } from "@ant-design/pro-components"
+import { columns } from "./tableConfig"
+import { useAjax } from "@/Hook/useAjax"
+import { useRef, useState } from "react"
+import { Button, Modal } from "antd"
+import { loginListOfPage } from "@/services/distribution/MiniAppUser"
+type Props = {
+    data: {
+        appId: number
+        id: number
+    }
+}
+const Page: React.FC<Props> = (props) => {
+    const [open, setOpen] = useState(false)
+    const actionRef = useRef<ActionType>();
+    let getList = useAjax((params) => loginListOfPage(params), { type: 'table' })
+    return <>
+        <Button
+            size="small"
+            type="link"
+            onClick={() => { setOpen(true) }}
+        >登录记录</Button>
+        <Modal
+            open={open}
+            footer={false}
+            onCancel={()=>{setOpen(false)}}
+            title={"登录记录"}
+            width={"50%"}
+            destroyOnClose
+        >
+            <ProTable<any, any>
+                 actionRef={actionRef}
+                 scroll={{ x: true ,y:'50vh'}}
+                 headerTitle={false}
+                 rowKey={(r) => r.id}
+                 search={false}
+                params={{
+                    appId:props.data.appId,
+                    userId:props.data.id
+                }}
+                request={async (params) => {
+                    if (params?.appId) {
+                        return await getList.run(params)
+                    }
+                }}
+                columns={columns()}
+            // bordered
+            />
+        </Modal>
+    </>
+
+}
+export default Page

+ 24 - 0
src/pages/distribution/miniprogram/weChatInfo/user/loginList/tableConfig.tsx

@@ -0,0 +1,24 @@
+import { ProColumns } from "@ant-design/pro-components";
+
+export const columns = (): ProColumns<any>[] => {
+    return [
+        {
+            title: "登录平台",
+            dataIndex: 'appName',
+            key: "appName",
+            align: "center",
+        },
+        {
+            title: "登录时间",
+            dataIndex: 'loginTime',
+            key: "loginTime",
+            align: "center",
+        },
+        {
+            title: "登录IP",
+            dataIndex: 'loginIp',
+            key: "loginIp",
+            align: "center",
+        },
+    ];
+}

+ 138 - 0
src/pages/distribution/miniprogram/weChatInfo/user/tableConfig.tsx

@@ -0,0 +1,138 @@
+import { ProColumns } from "@ant-design/pro-components";
+import {  Space, Switch } from "antd";
+import BookList from './bookList';
+import LoginList from "./loginList";
+
+export const columns = (params: { enumList: { [key: string]: any },  upDate: (params: { id: any, enabled: boolean }) => void }): ProColumns<any>[] => {
+    let { enumList, upDate } = params
+    return [
+        {
+            title: "openId",
+            dataIndex: 'openId',
+            key: "openId",
+            align: "center",
+            // hideInSearch: true,
+        },
+        {
+            title: "unionId",
+            dataIndex: 'unionId',
+            key: "unionId",
+            align: "center",
+        },
+        {
+            title: "用户昵称",
+            dataIndex: 'nickname',
+            key: "nickname",
+            align: "center",
+        },
+        {
+            title: "手机号",
+            dataIndex: 'phoneNum',
+            key: "phoneNum",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "用户身份",
+            dataIndex: 'userStanding',
+            key: "userStanding",
+            valueType: 'select',
+            valueEnum: new Map(enumList?.USER_STANDING?.values?.map(({ value, description }: any) => [value, description])),
+            align: "center",
+            render: (a: any, b: any) => {
+                let arr: any = new Map(enumList?.USER_STANDING?.values?.map(({ value, description }: any) => [value, description]))
+                return arr.get(b?.userStanding) || '-'
+            }
+        },
+        {
+            title: "书币余额",
+            dataIndex: 'coinNumMin',
+            key: "coinNumMin",
+            valueType: 'digit',
+            align: "center",
+            render:(a,b)=>{
+                return b?.coinNum
+            }
+        },
+        {
+            title: "最近登录IP",
+            dataIndex: 'lastLoginIp',
+            key: "lastLoginIp",
+            align: "center",
+            hideInSearch: true,
+        },
+        {
+            title: "最近登录时间",
+            dataIndex: 'lastLoginTime',
+            key: "lastLoginTime",
+            align: "center",
+            hideInSearch: true,
+        },
+        {
+            title: "注册时间",
+            dataIndex: 'createTime',
+            key: "createTime",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "更新时间",
+            dataIndex: 'updateTime',
+            key: "updateTime",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "状态",
+            dataIndex: 'enabled',
+            key: "enabled",
+            align: "center",
+            valueType: 'select',
+            valueEnum: { true: "正常", false: "禁用" },
+            render: (a, b) => {
+                return <Switch checked={b.enabled} size="default" checkedChildren="正常" unCheckedChildren="禁用" onChange={(enabled) => { upDate({ id: b.id, enabled }) }} />
+            }
+        },
+        {
+            title: '操作',
+            dataIndex: 'cz',
+            key: 'cz',
+            width: 90,
+            ellipsis: true,
+            align: 'center',
+            hideInSearch: true,
+            render: (a: any, b: any) => {
+                return <Space size={0}>
+                    <BookList data={b} />
+                    <LoginList data={b} />
+                </Space>
+            }
+        },
+        // 搜索条件
+        {
+            title: "最早登录时间",
+            dataIndex: 'lastLoginTimeMin',
+            valueType: 'date',
+            hideInTable: true
+        },
+        {
+            title: "最晚登录时间",
+            dataIndex: 'lastLoginTimeMax',
+            valueType: 'date',
+            hideInTable: true
+        },
+        {
+            title: "注册开始时间",
+            dataIndex: 'startTime',
+            valueType: 'date',
+            hideInTable: true
+        },
+        {
+            title: "注册结束时间",
+            dataIndex: 'endTime',
+            valueType: 'date',
+            hideInTable: true
+        },
+
+    ];
+}

+ 22 - 12
src/pages/distribution/orderLog/long/tableConfig.tsx

@@ -1,23 +1,18 @@
 import { ProColumns } from '@ant-design/pro-components';
+import { useModel } from '@umijs/max';
 
 export const columns = (): ProColumns<any>[] => {
+  let { getEnum } = useModel('global')
   return [
     {
-      title: 'ID',
-      dataIndex: 'id',
-      key: 'id',
-      align: 'center',
-      width: 70,
-      ellipsis: true,
-      hideInSearch: true,
-    },
-    {
-      title: 'userId',
-      dataIndex: 'userId',
-      key: 'userId',
+      title: 'openId',
+      dataIndex: 'openId',
       align: 'center',
       width: 70,
       ellipsis: true,
+      render: (_, row) => {
+        return row?.wechatMiniappUser?.openId
+      }
     },
     {
       title: '小说名称',
@@ -96,6 +91,7 @@ export const columns = (): ProColumns<any>[] => {
       align: 'center',
       ellipsis: true,
       hideInSearch: true,
+      valueEnum:getEnum("PAY_CHANNEL","map")
     },
     {
       title: '支付状态',
@@ -103,6 +99,7 @@ export const columns = (): ProColumns<any>[] => {
       width: 170,
       align: 'center',
       ellipsis: true,
+      valueEnum:getEnum("ORDER_STATUS","map")
     },
     {
       title: '支付场景',
@@ -127,6 +124,19 @@ export const columns = (): ProColumns<any>[] => {
       ellipsis: true,
       hideInSearch: true,
     },
+    {
+      title: '归因渠道',
+      dataIndex: 'userChannel',
+      width: 170,
+      align: 'center',
+      ellipsis: true,
+      valueType: 'select',
+      valueEnum: getEnum("USER_CHANNEL", "map"),
+      render: (_, row) => {
+        let str = getEnum("USER_CHANNEL", "map").get(row?.wechatMiniappUser?.userChannel)
+        return str
+      }
+    },
     // 搜索
     {
       title: '支付金额',

+ 22 - 12
src/pages/distribution/orderLog/short/tableConfig.tsx

@@ -1,23 +1,18 @@
 import { ProColumns } from '@ant-design/pro-components';
+import { useModel } from '@umijs/max';
 
 export const columns = (): ProColumns<any>[] => {
+  let { getEnum } = useModel('global')
   return [
     {
-      title: 'ID',
-      dataIndex: 'id',
-      key: 'id',
-      align: 'center',
-      width: 70,
-      ellipsis: true,
-      hideInSearch: true,
-    },
-    {
-      title: 'userId',
-      dataIndex: 'userId',
-      key: 'userId',
+      title: 'openId',
+      dataIndex: 'openId',
       align: 'center',
       width: 70,
       ellipsis: true,
+      render: (_, row) => {
+        return row?.wechatMiniappUser?.openId
+      }
     },
     {
       title: '小说名称',
@@ -96,6 +91,7 @@ export const columns = (): ProColumns<any>[] => {
       align: 'center',
       ellipsis: true,
       hideInSearch: true,
+      valueEnum:getEnum("PAY_CHANNEL","map")
     },
     {
       title: '支付状态',
@@ -103,6 +99,7 @@ export const columns = (): ProColumns<any>[] => {
       width: 170,
       align: 'center',
       ellipsis: true,
+      valueEnum:getEnum("ORDER_STATUS","map")
     },
     {
       title: '支付场景',
@@ -127,6 +124,19 @@ export const columns = (): ProColumns<any>[] => {
       ellipsis: true,
       hideInSearch: true,
     },
+    {
+      title: '归因渠道',
+      dataIndex: 'userChannel',
+      width: 170,
+      align: 'center',
+      ellipsis: true,
+      valueType: 'select',
+      valueEnum: getEnum("USER_CHANNEL", "map"),
+      render: (_, row) => {
+        let str = getEnum("USER_CHANNEL", "map").get(row?.wechatMiniappUser?.userChannel)
+        return str
+      }
+    },
     // 搜索
     {
       title: '支付金额',

+ 7 - 12
src/pages/distribution/payLog/long/tableConfig.tsx

@@ -1,23 +1,18 @@
 import { ProColumns } from '@ant-design/pro-components';
+import { useModel } from '@umijs/max';
 
 export const columns = (): ProColumns<any>[] => {
+  let { getEnum } = useModel('global')
   return [
     {
-      title: 'ID',
-      dataIndex: 'id',
-      key: 'id',
-      align: 'center',
-      width: 70,
-      ellipsis: true,
-      hideInSearch: true,
-    },
-    {
-      title: 'userId',
-      dataIndex: 'userId',
-      key: 'userId',
+      title: 'openId',
+      dataIndex: 'openId',
       align: 'center',
       width: 70,
       ellipsis: true,
+      render: (_, row) => {
+        return row?.wechatMiniappUser?.openId
+      }
     },
     {
       title: '小说名称',

+ 7 - 12
src/pages/distribution/payLog/short/tableConfig.tsx

@@ -1,23 +1,18 @@
 import { ProColumns } from '@ant-design/pro-components';
+import { useModel } from '@umijs/max';
 
 export const columns = (): ProColumns<any>[] => {
+  let { getEnum } = useModel('global')
   return [
     {
-      title: 'ID',
-      dataIndex: 'id',
-      key: 'id',
-      align: 'center',
-      width: 70,
-      ellipsis: true,
-      hideInSearch: true,
-    },
-    {
-      title: 'userId',
-      dataIndex: 'userId',
-      key: 'userId',
+      title: 'openId',
+      dataIndex: 'openId',
       align: 'center',
       width: 70,
       ellipsis: true,
+      render: (_, row) => {
+        return row?.wechatMiniappUser?.openId
+      }
     },
     {
       title: '小说名称',

+ 7 - 12
src/pages/distribution/readLog/long/tableConfig.tsx

@@ -1,23 +1,18 @@
 import { ProColumns } from '@ant-design/pro-components';
+import { useModel } from '@umijs/max';
 
 export const columns = (): ProColumns<any>[] => {
+  let { getEnum } = useModel('global')
   return [
     {
-      title: 'ID',
-      dataIndex: 'id',
-      key: 'id',
-      align: 'center',
-      width: 70,
-      ellipsis: true,
-      hideInSearch: true,
-    },
-    {
-      title: 'userId',
-      dataIndex: 'userId',
-      key: 'userId',
+      title: 'openId',
+      dataIndex: 'openId',
       align: 'center',
       width: 70,
       ellipsis: true,
+      render: (_, row) => {
+        return row?.wechatMiniappUser?.openId
+      }
     },
     {
       title: '小说名称',

+ 7 - 12
src/pages/distribution/readLog/short/tableConfig.tsx

@@ -1,23 +1,18 @@
 import { ProColumns } from '@ant-design/pro-components';
+import { useModel } from '@umijs/max';
 
 export const columns = (): ProColumns<any>[] => {
+  let { getEnum } = useModel('global')
   return [
     {
-      title: 'ID',
-      dataIndex: 'id',
-      key: 'id',
-      align: 'center',
-      width: 70,
-      ellipsis: true,
-      hideInSearch: true,
-    },
-    {
-      title: 'userId',
-      dataIndex: 'userId',
-      key: 'userId',
+      title: 'openId',
+      dataIndex: 'openId',
       align: 'center',
       width: 70,
       ellipsis: true,
+      render: (_, row) => {
+        return row?.wechatMiniappUser?.openId
+      }
     },
     {
       title: '小说名称',

+ 42 - 0
src/services/distribution/MiniAppUser/index.tsx

@@ -0,0 +1,42 @@
+import { api } from '@/services/api';
+import { request } from '@umijs/max';
+
+/**
+ * 小程序用户列表
+ */
+export async function miniAppusers(params: any) {
+  return request(api + `/bookDistributionPlatform/admin/wechatMiniappUser/listOfPage`, {
+    method: 'GET',
+    params,
+  });
+}
+
+/**
+ * 小程序用户书架列表
+ */
+export async function shelfLisOfPage(params: any) {
+  return request(api + `/bookDistributionPlatform/admin/wechatMiniappUser/shelfLisOfPage`, {
+    method: 'GET',
+    params,
+  });
+}
+
+/**
+ * 小程序用户登录日志
+ */
+export async function loginListOfPage(params: any) {
+  return request(api + `/bookDistributionPlatform/admin/wechatMiniappUser/loginListOfPage`, {
+    method: 'GET',
+    params,
+  });
+}
+/**
+ * 小程序用户状态
+ */
+export async function updateEnabled(params: any) {
+  let {id,...param} = params
+  return request(api + `/bookDistributionPlatform/admin/wechatMiniappUser/updateEnabled/${id}`, {
+    method: 'PUT',
+    params:param,
+  });
+}