ship相关的一些定义

This commit is contained in:
Xu Chang 2025-02-26 10:04:42 +08:00
parent 2b4a60be99
commit 3b1a3b8d90
4 changed files with 27 additions and 17 deletions

View File

@ -27,9 +27,9 @@ export default OakComponent({
wpProductChangable: false,
},
lifetimes: {
ready() {
async ready() {
const systemId = this.features.application.getApplication()!.systemId;
const wpProducts = this.features.cache.get('wpProduct', {
const { data: wpProducts } = await this.features.cache.refresh('wpProduct', {
data: {
id: 1,
application: {
@ -46,10 +46,9 @@ export default OakComponent({
},
},
});
assert(wpProducts.length);
if (this.isCreation()) {
this.update({
wpProductId: wpProducts[0]!.id,
wpProductId: wpProducts?.[0]?.id,
sort: 9999,
systemId,
disabled: false,

View File

@ -32,14 +32,15 @@ export interface Schema extends EntityShape {
extraPaths?: Paths;
};
type IState = 'unshipped' | 'shipping' | 'givenUp' | 'received' | 'rejected';
type IAction = 'ship' | 'receive' | 'giveUp' | 'reject';
type IState = 'unshipped' | 'shipping' | 'givenUp' | 'received' | 'rejected' | 'unknown';
type IAction = 'ship' | 'receive' | 'giveUp' | 'reject' | 'unknow';
export const IActionDef: ActionDef<IAction, IState> = {
stm: {
ship: ['unshipped', 'shipping'],
receive: ['shipping', 'received'],
giveUp: [['unshipped', 'shipping'], 'givenUp'],
reject: ['shipping', 'rejected'],
ship: [['unshipped', 'unknown'], 'shipping'],
receive: [['shipping', 'unknown'], 'received'],
giveUp: [['unshipped', 'shipping', 'unknown'], 'givenUp'],
reject: [['shipping', 'unknown'], 'rejected'],
unknow: [['unshipped', 'shipping'], 'unknown'],
},
is: 'unshipped',
}
@ -104,6 +105,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
received: '已收货',
rejected: '已拒绝',
givenUp: '已放弃',
unknown: '不明',
},
type: {
virtual: '虚拟',
@ -116,6 +118,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
receive: '收货',
giveUp: '放弃',
reject: '拒收',
unknow: '使未知',
},
},
},
@ -126,7 +129,8 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
shipping: '#1E90FF',
received: '#90EE90',
rejected: '#FF0000',
givenUp: '#A9A9A9'
givenUp: '#A9A9A9',
unknown: '#424242',
},
type: {
virtual: '#EB984E',
@ -139,6 +143,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
receive: '',
giveUp: '',
reject: '',
unknow: '',
},
},
};

View File

@ -2,8 +2,17 @@ import { EntityDict } from '../oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
export default interface ShipClazz {
// 绑定bizId
bindBizId(bizId: string): Promise<void>;
// 解绑bizId
unbindBizId(bizId: string): Promise<void>;
// 下单
eOrder(ship: EntityDict['ship']['Schema'], context: BRC): Promise<string>;
eOrder(bizId: string, ship: EntityDict['ship']['Schema'], context: BRC): Promise<string>;
// 预下单(上门提)
preOrder(ship: EntityDict['ship']['Schema'], context: BRC): Promise<string | void>;
// 取消
cancelOrder(ship: EntityDict['ship']['Schema'], context: BRC): Promise<void>;

View File

@ -124,16 +124,13 @@ export function registerPayClazzEntity<ED extends EntityDict & BaseEntityDict, T
clazzConstructor: PayClazzConstructor;
accountEntity: keyof ED;
}, schema: StorageSchema<ED>) {
if (!MODULE_USED) {
assert(!MODULE_USED);
}
assert(!MODULE_USED);
PayClazzEntityDict[entity as string] = {
accountEntity: def.accountEntity as string,
clazzConstructor: def.clazzConstructor,
};
// 检查此entity是否符合注册要求
const { attributes } = schema[entity];
const { attributes: payAttr } = schema.pay;
const { attributes: accountAttr } = schema[def.accountEntity];
@ -147,7 +144,7 @@ export function registerPayClazzEntity<ED extends EntityDict & BaseEntityDict, T
export async function getPayClazz(entity: EntityDict['pay']['OpSchema']['entity'], entityId: string, context: BRC) {
if (!MODULE_USED) {
assert(!MODULE_USED);
MODULE_USED = true;
}
const key = entity === 'account' ? entity : `${entity}.${entityId}`;
if (PayChannelDict.hasOwnProperty(key)) {