From 061c0bb2cf5ff159b57b9141419563e0a0e60e20 Mon Sep 17 00:00:00 2001 From: Xc Date: Tue, 4 Mar 2025 09:22:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BA=86shipAccount=E4=B8=AD?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=9A=84bizId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/components/AbstractComponents.d.ts | 17 +++---- es/components/AbstractComponents.js | 4 -- .../wechatMpShip/upsert/locales/zh-CN.json | 1 - .../ship/wechatMpShip/upsert/web.pc.js | 7 --- es/components/ship/wechatMpShip/web.pc.js | 1 - es/data/i18n.js | 1 - es/entities/AbstractShipAccount.d.ts | 1 - es/entities/AbstractShipAccount.js | 1 - es/entities/WechatMpShip.js | 1 - .../AbstractShipAccount/Storage.js | 6 --- .../AbstractShipAccount/_baseSchema.d.ts | 6 +-- .../AbstractShipAccount/locales/zh_CN.json | 1 - es/oak-app-domain/WechatMpShip/Storage.js | 6 --- .../WechatMpShip/_baseSchema.d.ts | 6 +-- .../WechatMpShip/locales/zh_CN.json | 1 - es/utils/shipClazz/index.d.ts | 9 ++++ es/utils/shipClazz/index.js | 25 +++++++++++ lib/data/i18n.js | 1 - lib/entities/AbstractShipAccount.d.ts | 1 - lib/entities/AbstractShipAccount.js | 1 - lib/entities/WechatMpShip.js | 1 - .../AbstractShipAccount/Storage.js | 6 --- .../AbstractShipAccount/_baseSchema.d.ts | 6 +-- .../AbstractShipAccount/locales/zh_CN.json | 1 - lib/oak-app-domain/WechatMpShip/Storage.js | 6 --- .../WechatMpShip/_baseSchema.d.ts | 6 +-- .../WechatMpShip/locales/zh_CN.json | 1 - lib/triggers/withdraw.d.ts | 2 +- lib/utils/shipClazz/index.d.ts | 9 ++++ lib/utils/shipClazz/index.js | 31 +++++++++++++ src/components/AbstractComponents.ts | 3 -- .../wechatMpShip/upsert/locales/zh-CN.json | 1 - .../ship/wechatMpShip/upsert/web.pc.tsx | 13 ------ src/components/ship/wechatMpShip/web.pc.tsx | 1 - src/data/i18n.ts | 1 - src/entities/AbstractShipAccount.ts | 2 - src/entities/WechatMpShip.ts | 1 - src/utils/shipClazz/index.ts | 45 +++++++++++++++++++ 38 files changed, 130 insertions(+), 103 deletions(-) create mode 100644 es/utils/shipClazz/index.d.ts create mode 100644 es/utils/shipClazz/index.js create mode 100644 lib/utils/shipClazz/index.d.ts create mode 100644 lib/utils/shipClazz/index.js create mode 100644 src/utils/shipClazz/index.ts diff --git a/es/components/AbstractComponents.d.ts b/es/components/AbstractComponents.d.ts index 852d9e50..780e2571 100644 --- a/es/components/AbstractComponents.d.ts +++ b/es/components/AbstractComponents.d.ts @@ -18,10 +18,10 @@ declare const List: (props: ReactComponentProps[]; loading: boolean; tablePagination?: React.ReactNode; - rowSelection?: import("antd/es/table/interface").TableRowSelection> | undefined; + rowSelection?: any; hideHeader?: boolean | undefined; disableSerialNumber?: boolean | undefined; - size?: "small" | "middle" | "large" | undefined; + size?: "small" | "large" | "middle" | undefined; scroll?: ({ x?: string | number | true | undefined; y?: string | number | undefined; @@ -46,21 +46,16 @@ declare const ListPro: (props: { data: RowWithActions[]; loading?: boolean | undefined; tablePagination?: any; - rowSelection?: import("antd/es/table/interface").TableRowSelection> | undefined; + rowSelection?: any; disableSerialNumber?: boolean | undefined; - size?: "small" | "middle" | "large" | undefined; - scroll?: ({ - x?: string | number | true | undefined; - y?: string | number | undefined; - } & { - scrollToFirstRowOnChange?: boolean | undefined; - }) | undefined; + size?: "small" | "large" | "middle" | undefined; + scroll?: any; empty?: any; opWidth?: number | undefined; oakPath?: string | undefined; }) => React.ReactElement; declare const Detail: (props: ReactComponentProps | undefined; + column?: number | Record | undefined; entity: T; attributes: OakAbsAttrDef[]; data: Partial; diff --git a/es/components/AbstractComponents.js b/es/components/AbstractComponents.js index 45f55231..38db9750 100644 --- a/es/components/AbstractComponents.js +++ b/es/components/AbstractComponents.js @@ -1,7 +1,3 @@ -/** - * 抽象组件在业务层根据EntityDict的重新声明 - * by Xc 20230807 - */ import AbsFilterPanel from 'oak-frontend-base/es/components/filterPanel'; import AbsList from 'oak-frontend-base/es/components/list'; import AbsListPro from 'oak-frontend-base/es/components/listPro'; diff --git a/es/components/ship/wechatMpShip/upsert/locales/zh-CN.json b/es/components/ship/wechatMpShip/upsert/locales/zh-CN.json index 742c9448..caee7028 100644 --- a/es/components/ship/wechatMpShip/upsert/locales/zh-CN.json +++ b/es/components/ship/wechatMpShip/upsert/locales/zh-CN.json @@ -1,6 +1,5 @@ { "help": { - "bizId": "如果设置了面单Id,在下快递单时就会默认使用这个Id,但仍然可以在下单时传入新的面单Id来覆盖。如果没有设置,在下单时也不传入,则按微信小程序物流的文档,对顺丰和德邦会使用散单Id,其余物流报错。见https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/introduction.html", "disabled": "小程序支付的物流能力默认必须开启,如果您申请的小程序是特殊行业,已向微信申请取消物流能力,在此可以关闭", "sort": "小程序关联物流默认拥有最高的优先级,不需要调整" } diff --git a/es/components/ship/wechatMpShip/upsert/web.pc.js b/es/components/ship/wechatMpShip/upsert/web.pc.js index 7c5c7f3e..d77aaf94 100644 --- a/es/components/ship/wechatMpShip/upsert/web.pc.js +++ b/es/components/ship/wechatMpShip/upsert/web.pc.js @@ -11,13 +11,6 @@ export default function render(props) { wpProductId: value, }); }}/> : } - - - { - update({ - bizId: currentTarget.value, - }); - }}/> { diff --git a/es/components/ship/wechatMpShip/web.pc.js b/es/components/ship/wechatMpShip/web.pc.js index 95b60e95..cae0edbc 100644 --- a/es/components/ship/wechatMpShip/web.pc.js +++ b/es/components/ship/wechatMpShip/web.pc.js @@ -30,7 +30,6 @@ export default function render(props) { setUpsertId(ele.id); }}/>}> diff --git a/es/data/i18n.js b/es/data/i18n.js index 5cea609c..4aff2ab3 100644 --- a/es/data/i18n.js +++ b/es/data/i18n.js @@ -332,7 +332,6 @@ const i18ns = [ position: "src/components/ship/wechatMpShip/upsert", data: { "help": { - "bizId": "如果设置了面单Id,在下快递单时就会默认使用这个Id,但仍然可以在下单时传入新的面单Id来覆盖。如果没有设置,在下单时也不传入,则按微信小程序物流的文档,对顺丰和德邦会使用散单Id,其余物流报错。见https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/introduction.html", "disabled": "小程序支付的物流能力默认必须开启,如果您申请的小程序是特殊行业,已向微信申请取消物流能力,在此可以关闭", "sort": "小程序关联物流默认拥有最高的优先级,不需要调整" } diff --git a/es/entities/AbstractShipAccount.d.ts b/es/entities/AbstractShipAccount.d.ts index 622626d6..92c91e1c 100644 --- a/es/entities/AbstractShipAccount.d.ts +++ b/es/entities/AbstractShipAccount.d.ts @@ -2,7 +2,6 @@ import { String, Int, Decimal } from 'oak-domain/lib/types/DataType'; import { EntityShape } from 'oak-domain/lib/types/Entity'; import { EntityDesc } from 'oak-domain/lib/types'; export interface Schema extends EntityShape { - bizId?: String<128>; sort: Decimal<12, 8>; phatom1?: Int<8>; phatom2?: String<64>; diff --git a/es/entities/AbstractShipAccount.js b/es/entities/AbstractShipAccount.js index 746b8e22..ce452cd5 100644 --- a/es/entities/AbstractShipAccount.js +++ b/es/entities/AbstractShipAccount.js @@ -6,7 +6,6 @@ export const entityDesc = { attr: { phatom1: '备用属性一', phatom2: '备用属性二', - bizId: '面单Id', sort: '排序', }, }, diff --git a/es/entities/WechatMpShip.js b/es/entities/WechatMpShip.js index 0126019a..46ccb36f 100644 --- a/es/entities/WechatMpShip.js +++ b/es/entities/WechatMpShip.js @@ -4,7 +4,6 @@ export const entityDesc = { zh_CN: { name: '微信小程序快递帐号', attr: { - bizId: '面单Id', sort: '排序', phatom1: '备用属性一', phatom2: '备用属性二', diff --git a/es/oak-app-domain/AbstractShipAccount/Storage.js b/es/oak-app-domain/AbstractShipAccount/Storage.js index 02f30c65..1926f94d 100644 --- a/es/oak-app-domain/AbstractShipAccount/Storage.js +++ b/es/oak-app-domain/AbstractShipAccount/Storage.js @@ -1,12 +1,6 @@ import { genericActions as actions } from "oak-domain/lib/actions/action"; export const desc = { attributes: { - bizId: { - type: "varchar", - params: { - length: 128 - } - }, sort: { notNull: true, type: "decimal", diff --git a/es/oak-app-domain/AbstractShipAccount/_baseSchema.d.ts b/es/oak-app-domain/AbstractShipAccount/_baseSchema.d.ts index 818c9011..07a15dca 100644 --- a/es/oak-app-domain/AbstractShipAccount/_baseSchema.d.ts +++ b/es/oak-app-domain/AbstractShipAccount/_baseSchema.d.ts @@ -1,9 +1,8 @@ import { Q_DateValue, Q_NumberValue, Q_StringValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { GenericAction } from "oak-domain/lib/actions/action"; -import { String, Decimal, Int } from "oak-domain/lib/types/DataType"; +import { Decimal, Int, String } from "oak-domain/lib/types/DataType"; export type OpSchema = EntityShape & { - bizId?: String<128> | null; sort: Decimal<12, 8>; phatom1?: Int<8> | null; phatom2?: String<64> | null; @@ -16,7 +15,6 @@ export type OpFilter = { $$createAt$$: Q_DateValue; $$seq$$: Q_NumberValue; $$updateAt$$: Q_DateValue; - bizId: Q_StringValue; sort: Q_NumberValue; phatom1: Q_NumberValue; phatom2: Q_StringValue; @@ -28,7 +26,6 @@ export type OpProjection = { $$createAt$$?: number; $$updateAt$$?: number; $$seq$$?: number; - bizId?: number; sort?: number; phatom1?: number; phatom2?: number; @@ -38,7 +35,6 @@ export type OpSortAttr = Partial<{ $$createAt$$: number; $$seq$$: number; $$updateAt$$: number; - bizId: number; sort: number; phatom1: number; phatom2: number; diff --git a/es/oak-app-domain/AbstractShipAccount/locales/zh_CN.json b/es/oak-app-domain/AbstractShipAccount/locales/zh_CN.json index 07080265..3404cff6 100644 --- a/es/oak-app-domain/AbstractShipAccount/locales/zh_CN.json +++ b/es/oak-app-domain/AbstractShipAccount/locales/zh_CN.json @@ -3,7 +3,6 @@ "attr": { "phatom1": "备用属性一", "phatom2": "备用属性二", - "bizId": "面单Id", "sort": "排序" } } diff --git a/es/oak-app-domain/WechatMpShip/Storage.js b/es/oak-app-domain/WechatMpShip/Storage.js index 5f688759..3f525756 100644 --- a/es/oak-app-domain/WechatMpShip/Storage.js +++ b/es/oak-app-domain/WechatMpShip/Storage.js @@ -1,12 +1,6 @@ import { genericActions as actions } from "oak-domain/lib/actions/action"; export const desc = { attributes: { - bizId: { - type: "varchar", - params: { - length: 128 - } - }, sort: { notNull: true, type: "decimal", diff --git a/es/oak-app-domain/WechatMpShip/_baseSchema.d.ts b/es/oak-app-domain/WechatMpShip/_baseSchema.d.ts index c17d9141..30e70808 100644 --- a/es/oak-app-domain/WechatMpShip/_baseSchema.d.ts +++ b/es/oak-app-domain/WechatMpShip/_baseSchema.d.ts @@ -2,9 +2,8 @@ import { ForeignKey } from "oak-domain/lib/types/DataType"; import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { GenericAction } from "oak-domain/lib/actions/action"; -import { String, Decimal, Int, Boolean } from "oak-domain/lib/types/DataType"; +import { Decimal, Int, String, Boolean } from "oak-domain/lib/types/DataType"; export type OpSchema = EntityShape & { - bizId?: String<128> | null; sort: Decimal<12, 8>; phatom1?: Int<8> | null; phatom2?: String<64> | null; @@ -20,7 +19,6 @@ export type OpFilter = { $$createAt$$: Q_DateValue; $$seq$$: Q_NumberValue; $$updateAt$$: Q_DateValue; - bizId: Q_StringValue; sort: Q_NumberValue; phatom1: Q_NumberValue; phatom2: Q_StringValue; @@ -35,7 +33,6 @@ export type OpProjection = { $$createAt$$?: number; $$updateAt$$?: number; $$seq$$?: number; - bizId?: number; sort?: number; phatom1?: number; phatom2?: number; @@ -48,7 +45,6 @@ export type OpSortAttr = Partial<{ $$createAt$$: number; $$seq$$: number; $$updateAt$$: number; - bizId: number; sort: number; phatom1: number; phatom2: number; diff --git a/es/oak-app-domain/WechatMpShip/locales/zh_CN.json b/es/oak-app-domain/WechatMpShip/locales/zh_CN.json index 16e662ab..fa405ea5 100644 --- a/es/oak-app-domain/WechatMpShip/locales/zh_CN.json +++ b/es/oak-app-domain/WechatMpShip/locales/zh_CN.json @@ -1,7 +1,6 @@ { "name": "微信小程序快递帐号", "attr": { - "bizId": "面单Id", "sort": "排序", "phatom1": "备用属性一", "phatom2": "备用属性二", diff --git a/es/utils/shipClazz/index.d.ts b/es/utils/shipClazz/index.d.ts new file mode 100644 index 00000000..fefeddcb --- /dev/null +++ b/es/utils/shipClazz/index.d.ts @@ -0,0 +1,9 @@ +import { EntityDict } from '../../oak-app-domain'; +import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; +import ShipClazz from '../../types/ShipClazz'; +import { BRC } from '../../types/RuntimeCxt'; +import { StorageSchema } from 'oak-domain/lib/types/Storage'; +type ShipClazzConstructor = (entityId: string, context: BRC) => Promise; +export declare function registerShipClazzEntity(entity: T, clazzConstructor: ShipClazzConstructor, schema: StorageSchema): void; +export declare function getShipClazz(ship: EntityDict['ship']['OpSchema'], context: BRC): Promise; +export {}; diff --git a/es/utils/shipClazz/index.js b/es/utils/shipClazz/index.js new file mode 100644 index 00000000..1d8b884c --- /dev/null +++ b/es/utils/shipClazz/index.js @@ -0,0 +1,25 @@ +import assert from 'assert'; +let MODULE_USED = false; +const ShipClazzDict = {}; +const ShipClazzEntityDict = {}; +export function registerShipClazzEntity(entity, clazzConstructor, schema) { + assert(!MODULE_USED); + assert(!ShipClazzEntityDict.hasOwnProperty(entity)); + const { attributes } = schema[entity]; + assert(attributes.bizId && attributes.bizId.type === 'varchar'); + assert(attributes.sort && attributes.sort.type === 'decimal'); + ShipClazzEntityDict[entity] = clazzConstructor; +} +export async function getShipClazz(ship, context) { + if (!MODULE_USED) { + MODULE_USED = true; + } + const { entity, entityId } = ship; + const key = `${entity}.${entityId}`; + if (ShipClazzDict[key]) { + return ShipClazzDict[key]; + } + const clazz = await ShipClazzEntityDict[entity](entityId, context); + ShipClazzDict[key] = clazz; + return clazz; +} diff --git a/lib/data/i18n.js b/lib/data/i18n.js index 7e0a944e..6b3f1ca5 100644 --- a/lib/data/i18n.js +++ b/lib/data/i18n.js @@ -334,7 +334,6 @@ const i18ns = [ position: "src/components/ship/wechatMpShip/upsert", data: { "help": { - "bizId": "如果设置了面单Id,在下快递单时就会默认使用这个Id,但仍然可以在下单时传入新的面单Id来覆盖。如果没有设置,在下单时也不传入,则按微信小程序物流的文档,对顺丰和德邦会使用散单Id,其余物流报错。见https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/introduction.html", "disabled": "小程序支付的物流能力默认必须开启,如果您申请的小程序是特殊行业,已向微信申请取消物流能力,在此可以关闭", "sort": "小程序关联物流默认拥有最高的优先级,不需要调整" } diff --git a/lib/entities/AbstractShipAccount.d.ts b/lib/entities/AbstractShipAccount.d.ts index 622626d6..92c91e1c 100644 --- a/lib/entities/AbstractShipAccount.d.ts +++ b/lib/entities/AbstractShipAccount.d.ts @@ -2,7 +2,6 @@ import { String, Int, Decimal } from 'oak-domain/lib/types/DataType'; import { EntityShape } from 'oak-domain/lib/types/Entity'; import { EntityDesc } from 'oak-domain/lib/types'; export interface Schema extends EntityShape { - bizId?: String<128>; sort: Decimal<12, 8>; phatom1?: Int<8>; phatom2?: String<64>; diff --git a/lib/entities/AbstractShipAccount.js b/lib/entities/AbstractShipAccount.js index 4c602706..7c828fc7 100644 --- a/lib/entities/AbstractShipAccount.js +++ b/lib/entities/AbstractShipAccount.js @@ -9,7 +9,6 @@ exports.entityDesc = { attr: { phatom1: '备用属性一', phatom2: '备用属性二', - bizId: '面单Id', sort: '排序', }, }, diff --git a/lib/entities/WechatMpShip.js b/lib/entities/WechatMpShip.js index 02ae7d45..cb3e0c74 100644 --- a/lib/entities/WechatMpShip.js +++ b/lib/entities/WechatMpShip.js @@ -7,7 +7,6 @@ exports.entityDesc = { zh_CN: { name: '微信小程序快递帐号', attr: { - bizId: '面单Id', sort: '排序', phatom1: '备用属性一', phatom2: '备用属性二', diff --git a/lib/oak-app-domain/AbstractShipAccount/Storage.js b/lib/oak-app-domain/AbstractShipAccount/Storage.js index cabd7652..34fd55c4 100644 --- a/lib/oak-app-domain/AbstractShipAccount/Storage.js +++ b/lib/oak-app-domain/AbstractShipAccount/Storage.js @@ -4,12 +4,6 @@ exports.desc = void 0; const action_1 = require("oak-domain/lib/actions/action"); exports.desc = { attributes: { - bizId: { - type: "varchar", - params: { - length: 128 - } - }, sort: { notNull: true, type: "decimal", diff --git a/lib/oak-app-domain/AbstractShipAccount/_baseSchema.d.ts b/lib/oak-app-domain/AbstractShipAccount/_baseSchema.d.ts index 818c9011..07a15dca 100644 --- a/lib/oak-app-domain/AbstractShipAccount/_baseSchema.d.ts +++ b/lib/oak-app-domain/AbstractShipAccount/_baseSchema.d.ts @@ -1,9 +1,8 @@ import { Q_DateValue, Q_NumberValue, Q_StringValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { GenericAction } from "oak-domain/lib/actions/action"; -import { String, Decimal, Int } from "oak-domain/lib/types/DataType"; +import { Decimal, Int, String } from "oak-domain/lib/types/DataType"; export type OpSchema = EntityShape & { - bizId?: String<128> | null; sort: Decimal<12, 8>; phatom1?: Int<8> | null; phatom2?: String<64> | null; @@ -16,7 +15,6 @@ export type OpFilter = { $$createAt$$: Q_DateValue; $$seq$$: Q_NumberValue; $$updateAt$$: Q_DateValue; - bizId: Q_StringValue; sort: Q_NumberValue; phatom1: Q_NumberValue; phatom2: Q_StringValue; @@ -28,7 +26,6 @@ export type OpProjection = { $$createAt$$?: number; $$updateAt$$?: number; $$seq$$?: number; - bizId?: number; sort?: number; phatom1?: number; phatom2?: number; @@ -38,7 +35,6 @@ export type OpSortAttr = Partial<{ $$createAt$$: number; $$seq$$: number; $$updateAt$$: number; - bizId: number; sort: number; phatom1: number; phatom2: number; diff --git a/lib/oak-app-domain/AbstractShipAccount/locales/zh_CN.json b/lib/oak-app-domain/AbstractShipAccount/locales/zh_CN.json index 07080265..3404cff6 100644 --- a/lib/oak-app-domain/AbstractShipAccount/locales/zh_CN.json +++ b/lib/oak-app-domain/AbstractShipAccount/locales/zh_CN.json @@ -3,7 +3,6 @@ "attr": { "phatom1": "备用属性一", "phatom2": "备用属性二", - "bizId": "面单Id", "sort": "排序" } } diff --git a/lib/oak-app-domain/WechatMpShip/Storage.js b/lib/oak-app-domain/WechatMpShip/Storage.js index 71bb7493..6b02e73e 100644 --- a/lib/oak-app-domain/WechatMpShip/Storage.js +++ b/lib/oak-app-domain/WechatMpShip/Storage.js @@ -4,12 +4,6 @@ exports.desc = void 0; const action_1 = require("oak-domain/lib/actions/action"); exports.desc = { attributes: { - bizId: { - type: "varchar", - params: { - length: 128 - } - }, sort: { notNull: true, type: "decimal", diff --git a/lib/oak-app-domain/WechatMpShip/_baseSchema.d.ts b/lib/oak-app-domain/WechatMpShip/_baseSchema.d.ts index c17d9141..30e70808 100644 --- a/lib/oak-app-domain/WechatMpShip/_baseSchema.d.ts +++ b/lib/oak-app-domain/WechatMpShip/_baseSchema.d.ts @@ -2,9 +2,8 @@ import { ForeignKey } from "oak-domain/lib/types/DataType"; import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { GenericAction } from "oak-domain/lib/actions/action"; -import { String, Decimal, Int, Boolean } from "oak-domain/lib/types/DataType"; +import { Decimal, Int, String, Boolean } from "oak-domain/lib/types/DataType"; export type OpSchema = EntityShape & { - bizId?: String<128> | null; sort: Decimal<12, 8>; phatom1?: Int<8> | null; phatom2?: String<64> | null; @@ -20,7 +19,6 @@ export type OpFilter = { $$createAt$$: Q_DateValue; $$seq$$: Q_NumberValue; $$updateAt$$: Q_DateValue; - bizId: Q_StringValue; sort: Q_NumberValue; phatom1: Q_NumberValue; phatom2: Q_StringValue; @@ -35,7 +33,6 @@ export type OpProjection = { $$createAt$$?: number; $$updateAt$$?: number; $$seq$$?: number; - bizId?: number; sort?: number; phatom1?: number; phatom2?: number; @@ -48,7 +45,6 @@ export type OpSortAttr = Partial<{ $$createAt$$: number; $$seq$$: number; $$updateAt$$: number; - bizId: number; sort: number; phatom1: number; phatom2: number; diff --git a/lib/oak-app-domain/WechatMpShip/locales/zh_CN.json b/lib/oak-app-domain/WechatMpShip/locales/zh_CN.json index 16e662ab..fa405ea5 100644 --- a/lib/oak-app-domain/WechatMpShip/locales/zh_CN.json +++ b/lib/oak-app-domain/WechatMpShip/locales/zh_CN.json @@ -1,7 +1,6 @@ { "name": "微信小程序快递帐号", "attr": { - "bizId": "面单Id", "sort": "排序", "phatom1": "备用属性一", "phatom2": "备用属性二", diff --git a/lib/triggers/withdraw.d.ts b/lib/triggers/withdraw.d.ts index e69f8d6e..979a44c8 100644 --- a/lib/triggers/withdraw.d.ts +++ b/lib/triggers/withdraw.d.ts @@ -6,6 +6,6 @@ import { BRC } from '../types/RuntimeCxt'; * @param context * @param refunds */ -export declare function updateWithdrawState(context: BRC, id: string): Promise<0 | 1>; +export declare function updateWithdrawState(context: BRC, id: string): Promise<1 | 0>; declare const triggers: Trigger[]; export default triggers; diff --git a/lib/utils/shipClazz/index.d.ts b/lib/utils/shipClazz/index.d.ts new file mode 100644 index 00000000..fefeddcb --- /dev/null +++ b/lib/utils/shipClazz/index.d.ts @@ -0,0 +1,9 @@ +import { EntityDict } from '../../oak-app-domain'; +import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; +import ShipClazz from '../../types/ShipClazz'; +import { BRC } from '../../types/RuntimeCxt'; +import { StorageSchema } from 'oak-domain/lib/types/Storage'; +type ShipClazzConstructor = (entityId: string, context: BRC) => Promise; +export declare function registerShipClazzEntity(entity: T, clazzConstructor: ShipClazzConstructor, schema: StorageSchema): void; +export declare function getShipClazz(ship: EntityDict['ship']['OpSchema'], context: BRC): Promise; +export {}; diff --git a/lib/utils/shipClazz/index.js b/lib/utils/shipClazz/index.js new file mode 100644 index 00000000..72b3ba51 --- /dev/null +++ b/lib/utils/shipClazz/index.js @@ -0,0 +1,31 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getShipClazz = exports.registerShipClazzEntity = void 0; +const tslib_1 = require("tslib"); +const assert_1 = tslib_1.__importDefault(require("assert")); +let MODULE_USED = false; +const ShipClazzDict = {}; +const ShipClazzEntityDict = {}; +function registerShipClazzEntity(entity, clazzConstructor, schema) { + (0, assert_1.default)(!MODULE_USED); + (0, assert_1.default)(!ShipClazzEntityDict.hasOwnProperty(entity)); + const { attributes } = schema[entity]; + (0, assert_1.default)(attributes.bizId && attributes.bizId.type === 'varchar'); + (0, assert_1.default)(attributes.sort && attributes.sort.type === 'decimal'); + ShipClazzEntityDict[entity] = clazzConstructor; +} +exports.registerShipClazzEntity = registerShipClazzEntity; +async function getShipClazz(ship, context) { + if (!MODULE_USED) { + MODULE_USED = true; + } + const { entity, entityId } = ship; + const key = `${entity}.${entityId}`; + if (ShipClazzDict[key]) { + return ShipClazzDict[key]; + } + const clazz = await ShipClazzEntityDict[entity](entityId, context); + ShipClazzDict[key] = clazz; + return clazz; +} +exports.getShipClazz = getShipClazz; diff --git a/src/components/AbstractComponents.ts b/src/components/AbstractComponents.ts index 51dbec40..54cc9858 100644 --- a/src/components/AbstractComponents.ts +++ b/src/components/AbstractComponents.ts @@ -2,9 +2,6 @@ * 抽象组件在业务层根据EntityDict的重新声明 * by Xc 20230807 */ - - - // @ts-nocheck import React from 'react'; import { EntityDict } from '../oak-app-domain'; diff --git a/src/components/ship/wechatMpShip/upsert/locales/zh-CN.json b/src/components/ship/wechatMpShip/upsert/locales/zh-CN.json index 7331c754..2c79e47a 100644 --- a/src/components/ship/wechatMpShip/upsert/locales/zh-CN.json +++ b/src/components/ship/wechatMpShip/upsert/locales/zh-CN.json @@ -1,6 +1,5 @@ { "help": { - "bizId": "如果设置了面单Id,在下快递单时就会默认使用这个Id,但仍然可以在下单时传入新的面单Id来覆盖。如果没有设置,在下单时也不传入,则按微信小程序物流的文档,对顺丰和德邦会使用散单Id,其余物流报错。见https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/express/business/introduction.html", "disabled": "小程序支付的物流能力默认必须开启,如果您申请的小程序是特殊行业,已向微信申请取消物流能力,在此可以关闭", "sort": "小程序关联物流默认拥有最高的优先级,不需要调整" } diff --git a/src/components/ship/wechatMpShip/upsert/web.pc.tsx b/src/components/ship/wechatMpShip/upsert/web.pc.tsx index 9079616b..05128226 100644 --- a/src/components/ship/wechatMpShip/upsert/web.pc.tsx +++ b/src/components/ship/wechatMpShip/upsert/web.pc.tsx @@ -37,19 +37,6 @@ export default function render(props: WebComponentProps } - - { - update({ - bizId: currentTarget.value!, - }); - }} - /> - ; // 全局的面单id,可以不设置,在下单的时候传业务逻辑中的bizId来代替 sort: Decimal<12, 8>; // 优先级高的会被优先使用来下快递 phatom1?: Int<8>; phatom2?: String<64>; @@ -25,7 +24,6 @@ export const entityDesc: EntityDesc = { attr: { phatom1: '备用属性一', phatom2: '备用属性二', - bizId: '面单Id', sort: '排序', }, }, diff --git a/src/entities/WechatMpShip.ts b/src/entities/WechatMpShip.ts index db148c08..9f708a22 100644 --- a/src/entities/WechatMpShip.ts +++ b/src/entities/WechatMpShip.ts @@ -25,7 +25,6 @@ export const entityDesc: EntityDesc = { zh_CN: { name: '微信小程序快递帐号', attr: { - bizId: '面单Id', sort: '排序', phatom1: '备用属性一', phatom2: '备用属性二', diff --git a/src/utils/shipClazz/index.ts b/src/utils/shipClazz/index.ts new file mode 100644 index 00000000..758b6644 --- /dev/null +++ b/src/utils/shipClazz/index.ts @@ -0,0 +1,45 @@ +import { EntityDict } from '../../oak-app-domain'; +import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity'; +import ShipClazz from '../../types/ShipClazz'; +import { BRC } from '../../types/RuntimeCxt'; +import assert from 'assert'; +import { StorageSchema } from 'oak-domain/lib/types/Storage'; +let MODULE_USED = false; + +type ShipClazzConstructor = (entityId: string, context: BRC) => Promise; +const ShipClazzDict: Record = {}; +const ShipClazzEntityDict: Record = {}; + +export function registerShipClazzEntity( + entity: T, + clazzConstructor: ShipClazzConstructor, + schema: StorageSchema +) { + assert(!MODULE_USED); + assert(!ShipClazzEntityDict.hasOwnProperty(entity)); + + const { attributes } = schema[entity]; + assert(attributes.bizId && attributes.bizId.type === 'varchar'); + assert(attributes.sort && attributes.sort.type === 'decimal'); + + ShipClazzEntityDict[entity as string] = clazzConstructor; +} + + +export async function getShipClazz(ship: EntityDict['ship']['OpSchema'], context: BRC) { + if (!MODULE_USED) { + MODULE_USED = true; + } + + const { entity, entityId } = ship; + const key = `${entity}.${entityId}`; + + if (ShipClazzDict[key]) { + return ShipClazzDict[key]; + } + + const clazz = await ShipClazzEntityDict[entity!](entityId!, context); + ShipClazzDict[key] = clazz; + + return clazz; +} \ No newline at end of file