From b46c9ee82779971e7927851ec247426b0a392d75 Mon Sep 17 00:00:00 2001 From: "bai.zixv" Date: Wed, 15 May 2024 11:45:50 +0800 Subject: [PATCH] feat/sancongtou-v4 (#984) Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/984 Co-authored-by: bai.zixv Co-committed-by: bai.zixv --- .../core/RemoteSchemaComponent.tsx | 6 +- .../schema-settings/GeneralSchemaDesigner.tsx | 4 +- .../@hera/plugin-sancongtou/package.json | 2 +- .../plugin-sancongtou/src/server/plugin.ts | 8 +- .../src/server/sqls/view_order_demi.sql | 29 ++++++ .../src/server/sqls/view_order_stat.sql | 91 +++++++++++++++++++ .../src/client/block/ChartBlock.tsx | 4 +- .../src/client/block/ChartDataProvider.tsx | 4 +- .../client/configure/ChartConfigProvider.tsx | 4 +- .../src/client/filter/FilterProvider.tsx | 4 +- .../src/client/MobileClientProvider.tsx | 4 +- .../src/client/core/index.tsx | 13 ++- .../schema/initializers/BlockInitializers.ts | 5 + .../src/client/devices/iOS6.tsx | 8 +- .../src/client/devices/index.tsx | 8 +- .../src/client/router/Application.tsx | 4 +- 16 files changed, 167 insertions(+), 31 deletions(-) create mode 100644 packages/plugins/@hera/plugin-sancongtou/src/server/sqls/view_order_demi.sql create mode 100644 packages/plugins/@hera/plugin-sancongtou/src/server/sqls/view_order_stat.sql diff --git a/packages/core/client/src/schema-component/core/RemoteSchemaComponent.tsx b/packages/core/client/src/schema-component/core/RemoteSchemaComponent.tsx index 18d9b161d..60a755213 100644 --- a/packages/core/client/src/schema-component/core/RemoteSchemaComponent.tsx +++ b/packages/core/client/src/schema-component/core/RemoteSchemaComponent.tsx @@ -1,7 +1,7 @@ import { createForm } from '@tachybase/schema'; import { Schema } from '@tachybase/schema'; -import { Spin } from 'antd'; -import React, { useMemo } from 'react'; +// import { Spin } from 'antd'; +import React, { PropsWithChildren, useMemo } from 'react'; import { useRequest } from '../../api-client'; import { useSchemaComponentContext } from '../hooks'; import { FormProvider } from './FormProvider'; @@ -58,6 +58,6 @@ const RequestSchemaComponent: React.FC = (props) => ); }; -export const RemoteSchemaComponent: React.FC = (props) => { +export const RemoteSchemaComponent: React.FC> = (props) => { return props.uid ? : null; }; diff --git a/packages/core/client/src/schema-settings/GeneralSchemaDesigner.tsx b/packages/core/client/src/schema-settings/GeneralSchemaDesigner.tsx index dad031aa7..70bceee64 100644 --- a/packages/core/client/src/schema-settings/GeneralSchemaDesigner.tsx +++ b/packages/core/client/src/schema-settings/GeneralSchemaDesigner.tsx @@ -3,7 +3,7 @@ import { css } from '@emotion/css'; import { useField, useFieldSchema } from '@tachybase/schema'; import { Space } from 'antd'; import classNames from 'classnames'; -import React, { FC, useEffect, useMemo, useRef } from 'react'; +import React, { FC, PropsWithChildren, useEffect, useMemo, useRef } from 'react'; import { useTranslation } from 'react-i18next'; import { SchemaToolbarProvider, useSchemaInitializerRender, useSchemaSettingsRender } from '../application'; import { useDataSourceManager } from '../data-source/data-source/DataSourceManagerProvider'; @@ -62,7 +62,7 @@ export interface GeneralSchemaDesignerProps { /** * @deprecated use `SchemaToolbar` instead */ -export const GeneralSchemaDesigner: FC = (props: any) => { +export const GeneralSchemaDesigner: FC> = (props: any) => { const { disableInitializer, title, diff --git a/packages/plugins/@hera/plugin-sancongtou/package.json b/packages/plugins/@hera/plugin-sancongtou/package.json index 24cc3ce00..f54e9d4ca 100644 --- a/packages/plugins/@hera/plugin-sancongtou/package.json +++ b/packages/plugins/@hera/plugin-sancongtou/package.json @@ -1,7 +1,7 @@ { "name": "@hera/plugin-sancongtou", "displayName": "Mobile client: Sancongtou Customization", - "version": "0.21.26", + "version": "0.0.4", "description": "Provide mobile client customization for the sancongtou project.", "main": "dist/server/index.js", "dependencies": { diff --git a/packages/plugins/@hera/plugin-sancongtou/src/server/plugin.ts b/packages/plugins/@hera/plugin-sancongtou/src/server/plugin.ts index 8ff487392..55d43bbf5 100644 --- a/packages/plugins/@hera/plugin-sancongtou/src/server/plugin.ts +++ b/packages/plugins/@hera/plugin-sancongtou/src/server/plugin.ts @@ -1,11 +1,17 @@ +import { SqlLoader } from '@hera/plugin-core'; import { Plugin } from '@tachybase/server'; +import { Container } from '@tachybase/utils'; +import path from 'path'; export class PluginSancongtouServer extends Plugin { async afterAdd() {} async beforeLoad() {} - async load() {} + async load() { + const sqlLoader = Container.get(SqlLoader); + await sqlLoader.loadSqlFiles(path.join(__dirname, './sqls')); + } async install() {} diff --git a/packages/plugins/@hera/plugin-sancongtou/src/server/sqls/view_order_demi.sql b/packages/plugins/@hera/plugin-sancongtou/src/server/sqls/view_order_demi.sql new file mode 100644 index 000000000..86c01cb93 --- /dev/null +++ b/packages/plugins/@hera/plugin-sancongtou/src/server/sqls/view_order_demi.sql @@ -0,0 +1,29 @@ +CREATE OR REPLACE VIEW + public.view_order_demi AS +SELECT + business_id, + '推广总数' AS "label", + "orderTotalCount" AS "value" +FROM + public.view_order_stat +UNION ALL +SELECT + business_id, + '有效总数' AS "label", + "orderYouXiaoCount" AS "value" +FROM + public.view_order_stat +UNION ALL +SELECT + business_id, + '跟进总数' AS "label", + "orderGenJinCount" AS "value" +FROM + public.view_order_stat +UNION ALL +SELECT + business_id, + '异常总数' AS "label", + "orderYiChangCount" AS "value" +FROM + public.view_order_stat diff --git a/packages/plugins/@hera/plugin-sancongtou/src/server/sqls/view_order_stat.sql b/packages/plugins/@hera/plugin-sancongtou/src/server/sqls/view_order_stat.sql new file mode 100644 index 000000000..0bc62df38 --- /dev/null +++ b/packages/plugins/@hera/plugin-sancongtou/src/server/sqls/view_order_stat.sql @@ -0,0 +1,91 @@ +--- 三聪头, 转化订单数据, 用于统计分析 +--- 原始数据, 是订单数据, 包含订单号, 订单创建时间, 关联的代理商, +--- 订单的金额, 订单的佣金, 订单的状态, +--- 新的数据表: 订单编号, 代理商, 订单金额, 订单佣金, 订单的创建时间, 订单的展平状态, +--- 推广总数(每个代理商关联的订单总数); +--- 有效总数(订单达到首充状态的订单数); +--- 跟进总数(下单成功, 但是物流异常, 或者物流正常但是没有首充的订单数) +--- 异常总数(下单没有成功的数量) +CREATE OR REPLACE VIEW + public.view_order_stat AS +WITH + orders_need_fields_all AS ( + SELECT + "createdAt" AT TIME ZONE 'Asia/Shanghai' AS "createDate", + "updatedAt" AT TIME ZONE 'Asia/Shanghai' AS "updateDate", + "createdById", + "updatedById", + business_id, + order_id, + amount, + --- 订单状态 + status_order, + --- 物流状态 + status_logistics, + --- 激活状态 + activation_status, + --- 充值状态 + status_recharge, + --- 结算状态 + status_settlement + FROM + orders + ), + --- 推广总数 + orders_tuiguang AS ( + SELECT + business_id, + COALESCE(COUNT(*), 0) AS "orderTotalCount" + FROM + orders_need_fields_all + GROUP BY + business_id + ), + --- 有效总数 + order_youxiao AS ( + SELECT + business_id, + COALESCE(COUNT(*), 0) AS "orderYouXiaoCount" + FROM + orders_need_fields_all + WHERE + status_recharge = '1' --- 0/未充值, 1/已充值 + GROUP BY + business_id + ), + --- 跟进总数 + order_genjin AS ( + SELECT + business_id, + COALESCE(COUNT(*), 0) AS "orderGenJinCount" + FROM + orders_need_fields_all + WHERE + status_order = '3' --- 1/审核中, 2/审核失败, 3/审核成功 + AND status_recharge = '0' --- 0/未充值, 1/已充值 + GROUP BY + business_id + ), + --- 异常总数 + order_yichang AS ( + SELECT + business_id, + COALESCE(COUNT(*), 0) AS "orderYiChangCount" + FROM + orders_need_fields_all + WHERE + status_order = '2' --- 1/审核中, 2/审核失败, 3/审核成功 + GROUP BY + business_id + ) +SELECT + orders_tuiguang.business_id, + orders_tuiguang."orderTotalCount", + order_youxiao."orderYouXiaoCount", + order_genjin."orderGenJinCount", + order_yichang."orderYiChangCount" +FROM + orders_tuiguang + LEFT JOIN order_youxiao ON orders_tuiguang.business_id = order_youxiao.business_id + LEFT JOIN order_genjin ON orders_tuiguang.business_id = order_genjin.business_id + LEFT JOIN order_yichang ON orders_tuiguang.business_id = order_yichang.business_id diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/block/ChartBlock.tsx b/packages/plugins/@nocobase/plugin-data-visualization/src/client/block/ChartBlock.tsx index 14de79bd6..9712277db 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/block/ChartBlock.tsx +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/block/ChartBlock.tsx @@ -1,12 +1,12 @@ import { SchemaComponentOptions, SchemaInitializerContext, useSchemaInitializer } from '@tachybase/client'; -import React, { useState } from 'react'; +import React, { PropsWithChildren, useState } from 'react'; import { ChartConfigProvider } from '../configure'; import { ChartDataProvider } from './ChartDataProvider'; import { ChartRenderer, ChartRendererProvider } from '../renderer'; import { ChartFilterBlockProvider, ChartFilterBlockDesigner } from '../filter'; import { ChartFilterProvider } from '../filter/FilterProvider'; -export const ChartV2Block: React.FC = (props) => { +export const ChartV2Block: React.FC = (props) => { const [initialVisible, setInitialVisible] = useState(false); const schemaInitializerContextData = useSchemaInitializer(); return ( diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/block/ChartDataProvider.tsx b/packages/plugins/@nocobase/plugin-data-visualization/src/client/block/ChartDataProvider.tsx index aba624d9b..72e9fc7d0 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/block/ChartDataProvider.tsx +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/block/ChartDataProvider.tsx @@ -1,4 +1,4 @@ -import React, { createContext, useState } from 'react'; +import React, { createContext, useState, PropsWithChildren } from 'react'; import { useMemoizedFn } from 'ahooks'; type ChartData = { @@ -15,7 +15,7 @@ export const ChartDataContext = createContext<{ }>({} as any); ChartDataContext.displayName = 'ChartDataContext'; -export const ChartDataProvider: React.FC = (props) => { +export const ChartDataProvider: React.FC = (props) => { const [charts, setCharts] = useState<{ [uid: string]: ChartData; }>({}); diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/configure/ChartConfigProvider.tsx b/packages/plugins/@nocobase/plugin-data-visualization/src/client/configure/ChartConfigProvider.tsx index a6d958664..b268aa587 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/configure/ChartConfigProvider.tsx +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/configure/ChartConfigProvider.tsx @@ -1,5 +1,5 @@ import { ISchema } from '@tachybase/schema'; -import React, { createContext, useState } from 'react'; +import React, { PropsWithChildren, createContext, useState } from 'react'; import { ChartRendererProvider } from '../renderer'; import { ChartConfigure } from './ChartConfigure'; import { useDesignable } from '@tachybase/client'; @@ -26,7 +26,7 @@ export const ChartConfigContext = createContext<{ }); ChartConfigContext.displayName = 'ChartConfigContext'; -export const ChartConfigProvider: React.FC = (props) => { +export const ChartConfigProvider: React.FC = (props) => { const { insertAdjacent } = useDesignable(); const [visible, setVisible] = useState(false); const [current, setCurrent] = useState({} as any); diff --git a/packages/plugins/@nocobase/plugin-data-visualization/src/client/filter/FilterProvider.tsx b/packages/plugins/@nocobase/plugin-data-visualization/src/client/filter/FilterProvider.tsx index cbf6e2948..fd9e05d7f 100644 --- a/packages/plugins/@nocobase/plugin-data-visualization/src/client/filter/FilterProvider.tsx +++ b/packages/plugins/@nocobase/plugin-data-visualization/src/client/filter/FilterProvider.tsx @@ -1,4 +1,4 @@ -import React, { createContext, useEffect, useState } from 'react'; +import React, { PropsWithChildren, createContext, useEffect, useState } from 'react'; import { useMemoizedFn } from 'ahooks'; type FilterField = { @@ -28,7 +28,7 @@ export const ChartFilterContext = createContext<{ }>({} as any); ChartFilterContext.displayName = 'ChartFilterContext'; -export const ChartFilterProvider: React.FC = (props) => { +export const ChartFilterProvider: React.FC = (props) => { const [ready, setReady] = useState(false); const [enabled, _setEnabled] = useState(false); const [fields, setFields] = useState({}); diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/MobileClientProvider.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/MobileClientProvider.tsx index e72464ed5..2d27a4534 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/MobileClientProvider.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/MobileClientProvider.tsx @@ -1,8 +1,8 @@ -import React, { useEffect } from 'react'; +import React, { PropsWithChildren, useEffect } from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; import { isJSBridge } from './core/bridge'; -export const MobileClientProvider = React.memo((props) => { +export const MobileClientProvider = React.memo((props: PropsWithChildren) => { const location = useLocation(); const navigation = useNavigate(); diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/index.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/index.tsx index a1a58124b..063e6cbcf 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/index.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/index.tsx @@ -1,5 +1,5 @@ import { SchemaComponentOptions } from '@tachybase/client'; -import React from 'react'; +import React, { PropsWithChildren } from 'react'; import { MMenuBlockInitializer, MMenu, @@ -44,7 +44,7 @@ import { import './bridge'; import './assets/svg'; -export const MobileCore: React.FC = (props) => { +export const MobileCore: React.FC = (props) => { return ( { MPage, MHeader, MSettings, + + SwiperBlockInitializer, + SwiperBlock, + SwiperPage, + TabSearch, TabSearchProvider, TabSearchBlockInitializer, @@ -64,9 +69,7 @@ export const MobileCore: React.FC = (props) => { TabSearchCollapsibleInputItem, TabSearchCollapsibleInputMItem, TabSearchFieldSchemaInitializerGadget, - SwiperBlockInitializer, - SwiperBlock, - SwiperPage, + ImageSearchView: ImageSearchView, ImageSearchInitializer: ImageSearchInitializer, ImageSearchProvider: ImageSearchProvider, diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/initializers/BlockInitializers.ts b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/initializers/BlockInitializers.ts index 392dae2c5..9b8c18346 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/initializers/BlockInitializers.ts +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/core/schema/initializers/BlockInitializers.ts @@ -128,6 +128,11 @@ export const mBlockInitializers = new CompatibleSchemaInitializer( type: 'item', Component: 'NoticeBlockInitializer', }, + { + name: 'chartV2', + title: '{{t("Charts")}}', + Component: 'ChartV2BlockInitializer', + }, ], }, { diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/iOS6.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/iOS6.tsx index 4c2e95dab..146db0b82 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/iOS6.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/devices/iOS6.tsx @@ -1,9 +1,11 @@ import { css, cx } from '@tachybase/client'; -import React from 'react'; +import React, { PropsWithChildren } from 'react'; -const iOS6: React.FC<{ +type IProps = PropsWithChildren<{ className: string; -}> = (props) => { +}>; + +const iOS6: React.FC = (props) => { return (
{ +export const MobileDevice: React.FC = (props) => { return (
{ box-shadow: 0 0 15px rgba(0, 0, 0, 0.3); `} {...props} - > + />
); }; diff --git a/packages/plugins/@tachybase/plugin-mobile-client/src/client/router/Application.tsx b/packages/plugins/@tachybase/plugin-mobile-client/src/client/router/Application.tsx index 6f92c3b1e..f9ef23f7e 100644 --- a/packages/plugins/@tachybase/plugin-mobile-client/src/client/router/Application.tsx +++ b/packages/plugins/@tachybase/plugin-mobile-client/src/client/router/Application.tsx @@ -1,6 +1,6 @@ import { ActionContextProvider, AdminProvider, css, cx, RemoteSchemaComponent, useViewport } from '@tachybase/client'; import { DrawerProps, ModalProps } from 'antd'; -import React, { useMemo } from 'react'; +import React, { PropsWithChildren, useMemo } from 'react'; import { Outlet, useParams } from 'react-router-dom'; import { MobileCore } from '../core'; import { useInterfaceContext } from './InterfaceProvider'; @@ -71,7 +71,7 @@ const useMobileSchemaUid = () => { return 'nocobase-mobile-container'; }; -const MApplication: React.FC = (props) => { +const MApplication: React.FC = (props) => { const mobileSchemaUid = useMobileSchemaUid(); const params = useParams<{ name: string }>(); const interfaceContext = useInterfaceContext();