settlePlan 增加 结算时间、关闭时间 字段

This commit is contained in:
lxy 2025-08-08 09:45:19 +08:00
parent a536132e2c
commit 4389f8d5a2
15 changed files with 107 additions and 8 deletions

View File

@ -6,6 +6,8 @@ export interface Schema extends EntityShape {
when?: Datetime; when?: Datetime;
order: Order; order: Order;
price: Price; price: Price;
settledAt?: Datetime;
closedAt?: Datetime;
} }
type IState = 'unsettled' | 'settled' | 'closed'; type IState = 'unsettled' | 'settled' | 'closed';
type IAction = 'settle' | 'close'; type IAction = 'settle' | 'close';

View File

@ -15,6 +15,8 @@ export const entityDesc = {
order: '订单', order: '订单',
price: '结算金额', price: '结算金额',
iState: '结算计划状态', iState: '结算计划状态',
settledAt: '结算时间',
closedAt: '关闭时间'
}, },
action: { action: {
settle: '结算', settle: '结算',

View File

@ -13,6 +13,12 @@ export const desc = {
notNull: true, notNull: true,
type: "money" type: "money"
}, },
settledAt: {
type: "datetime"
},
closedAt: {
type: "datetime"
},
iState: { iState: {
type: "enum", type: "enum",
enumeration: ["unsettled", "settled", "closed"] enumeration: ["unsettled", "settled", "closed"]

View File

@ -7,6 +7,8 @@ export type OpSchema = EntityShape & {
when?: Datetime | null; when?: Datetime | null;
orderId: ForeignKey<"order">; orderId: ForeignKey<"order">;
price: Price; price: Price;
settledAt?: Datetime | null;
closedAt?: Datetime | null;
iState?: IState | null; iState?: IState | null;
} & { } & {
[A in ExpressionKey]?: any; [A in ExpressionKey]?: any;
@ -20,6 +22,8 @@ export type OpFilter = {
when: Q_DateValue; when: Q_DateValue;
orderId: Q_StringValue; orderId: Q_StringValue;
price: Q_NumberValue; price: Q_NumberValue;
settledAt: Q_DateValue;
closedAt: Q_DateValue;
iState: Q_EnumValue<IState>; iState: Q_EnumValue<IState>;
} & ExprOp<OpAttr | string>; } & ExprOp<OpAttr | string>;
export type OpProjection = { export type OpProjection = {
@ -32,6 +36,8 @@ export type OpProjection = {
when?: number; when?: number;
orderId?: number; orderId?: number;
price?: number; price?: number;
settledAt?: number;
closedAt?: number;
iState?: number; iState?: number;
} & Partial<ExprOp<OpAttr | string>>; } & Partial<ExprOp<OpAttr | string>>;
export type OpSortAttr = Partial<{ export type OpSortAttr = Partial<{
@ -42,6 +48,8 @@ export type OpSortAttr = Partial<{
when: number; when: number;
orderId: number; orderId: number;
price: number; price: number;
settledAt: number;
closedAt: number;
iState: number; iState: number;
[k: string]: any; [k: string]: any;
} | ExprOp<OpAttr | string>>; } | ExprOp<OpAttr | string>>;

View File

@ -4,7 +4,9 @@
"when": "结算时间", "when": "结算时间",
"order": "订单", "order": "订单",
"price": "结算金额", "price": "结算金额",
"iState": "结算计划状态" "iState": "结算计划状态",
"settledAt": "结算时间",
"closedAt": "关闭时间"
}, },
"action": { "action": {
"settle": "结算", "settle": "结算",

View File

@ -69,7 +69,7 @@ const triggers = [
asRoot: true, asRoot: true,
priority: 99, priority: 99,
fn: async ({ operation }, context, option) => { fn: async ({ operation }, context, option) => {
const { filter } = operation; const { filter, data } = operation;
const settlePlans = await context.select('settlePlan', { const settlePlans = await context.select('settlePlan', {
data: { data: {
id: 1, id: 1,
@ -119,6 +119,15 @@ const triggers = [
}, option); }, option);
} }
} }
//为settlePlan赋上settledAt
if (data instanceof Array) {
for (const d of data) {
d.settledAt = now;
}
}
else {
data.settledAt = now;
}
return settlePlans.length; return settlePlans.length;
}, },
}, },
@ -176,7 +185,7 @@ const triggers = [
asRoot: true, asRoot: true,
priority: 99, priority: 99,
fn: async ({ operation }, context, option) => { fn: async ({ operation }, context, option) => {
const { filter } = operation; const { filter, data } = operation;
const settlePlans = await context.select('settlePlan', { const settlePlans = await context.select('settlePlan', {
data: { data: {
id: 1, id: 1,
@ -215,6 +224,15 @@ const triggers = [
} }
}, option); }, option);
} }
//为settlePlan赋上closedAt
if (data instanceof Array) {
for (const d of data) {
d.closedAt = now;
}
}
else {
data.closedAt = now;
}
return settlePlans.length; return settlePlans.length;
}, },
}, },

View File

@ -6,6 +6,8 @@ export interface Schema extends EntityShape {
when?: Datetime; when?: Datetime;
order: Order; order: Order;
price: Price; price: Price;
settledAt?: Datetime;
closedAt?: Datetime;
} }
type IState = 'unsettled' | 'settled' | 'closed'; type IState = 'unsettled' | 'settled' | 'closed';
type IAction = 'settle' | 'close'; type IAction = 'settle' | 'close';

View File

@ -18,6 +18,8 @@ exports.entityDesc = {
order: '订单', order: '订单',
price: '结算金额', price: '结算金额',
iState: '结算计划状态', iState: '结算计划状态',
settledAt: '结算时间',
closedAt: '关闭时间'
}, },
action: { action: {
settle: '结算', settle: '结算',

View File

@ -16,6 +16,12 @@ exports.desc = {
notNull: true, notNull: true,
type: "money" type: "money"
}, },
settledAt: {
type: "datetime"
},
closedAt: {
type: "datetime"
},
iState: { iState: {
type: "enum", type: "enum",
enumeration: ["unsettled", "settled", "closed"] enumeration: ["unsettled", "settled", "closed"]

View File

@ -7,6 +7,8 @@ export type OpSchema = EntityShape & {
when?: Datetime | null; when?: Datetime | null;
orderId: ForeignKey<"order">; orderId: ForeignKey<"order">;
price: Price; price: Price;
settledAt?: Datetime | null;
closedAt?: Datetime | null;
iState?: IState | null; iState?: IState | null;
} & { } & {
[A in ExpressionKey]?: any; [A in ExpressionKey]?: any;
@ -20,6 +22,8 @@ export type OpFilter = {
when: Q_DateValue; when: Q_DateValue;
orderId: Q_StringValue; orderId: Q_StringValue;
price: Q_NumberValue; price: Q_NumberValue;
settledAt: Q_DateValue;
closedAt: Q_DateValue;
iState: Q_EnumValue<IState>; iState: Q_EnumValue<IState>;
} & ExprOp<OpAttr | string>; } & ExprOp<OpAttr | string>;
export type OpProjection = { export type OpProjection = {
@ -32,6 +36,8 @@ export type OpProjection = {
when?: number; when?: number;
orderId?: number; orderId?: number;
price?: number; price?: number;
settledAt?: number;
closedAt?: number;
iState?: number; iState?: number;
} & Partial<ExprOp<OpAttr | string>>; } & Partial<ExprOp<OpAttr | string>>;
export type OpSortAttr = Partial<{ export type OpSortAttr = Partial<{
@ -42,6 +48,8 @@ export type OpSortAttr = Partial<{
when: number; when: number;
orderId: number; orderId: number;
price: number; price: number;
settledAt: number;
closedAt: number;
iState: number; iState: number;
[k: string]: any; [k: string]: any;
} | ExprOp<OpAttr | string>>; } | ExprOp<OpAttr | string>>;

View File

@ -4,7 +4,9 @@
"when": "结算时间", "when": "结算时间",
"order": "订单", "order": "订单",
"price": "结算金额", "price": "结算金额",
"iState": "结算计划状态" "iState": "结算计划状态",
"settledAt": "结算时间",
"closedAt": "关闭时间"
}, },
"action": { "action": {
"settle": "结算", "settle": "结算",

View File

@ -72,7 +72,7 @@ const triggers = [
asRoot: true, asRoot: true,
priority: 99, priority: 99,
fn: async ({ operation }, context, option) => { fn: async ({ operation }, context, option) => {
const { filter } = operation; const { filter, data } = operation;
const settlePlans = await context.select('settlePlan', { const settlePlans = await context.select('settlePlan', {
data: { data: {
id: 1, id: 1,
@ -122,6 +122,15 @@ const triggers = [
}, option); }, option);
} }
} }
//为settlePlan赋上settledAt
if (data instanceof Array) {
for (const d of data) {
d.settledAt = now;
}
}
else {
data.settledAt = now;
}
return settlePlans.length; return settlePlans.length;
}, },
}, },
@ -179,7 +188,7 @@ const triggers = [
asRoot: true, asRoot: true,
priority: 99, priority: 99,
fn: async ({ operation }, context, option) => { fn: async ({ operation }, context, option) => {
const { filter } = operation; const { filter, data } = operation;
const settlePlans = await context.select('settlePlan', { const settlePlans = await context.select('settlePlan', {
data: { data: {
id: 1, id: 1,
@ -218,6 +227,15 @@ const triggers = [
} }
}, option); }, option);
} }
//为settlePlan赋上closedAt
if (data instanceof Array) {
for (const d of data) {
d.closedAt = now;
}
}
else {
data.closedAt = now;
}
return settlePlans.length; return settlePlans.length;
}, },
}, },

View File

@ -10,6 +10,8 @@ export interface Schema extends EntityShape {
when?: Datetime; when?: Datetime;
order: Order; order: Order;
price: Price; price: Price;
settledAt?: Datetime;
closedAt?: Datetime;
}; };
type IState = 'unsettled' | 'settled' | 'closed'; type IState = 'unsettled' | 'settled' | 'closed';
@ -36,6 +38,8 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
order: '订单', order: '订单',
price: '结算金额', price: '结算金额',
iState: '结算计划状态', iState: '结算计划状态',
settledAt: '结算时间',
closedAt: '关闭时间'
}, },
action: { action: {
settle: '结算', settle: '结算',

View File

@ -76,7 +76,7 @@ const triggers: Trigger<EntityDict, 'settlePlan', BRC>[] = [
asRoot: true, asRoot: true,
priority: 99, priority: 99,
fn: async ({ operation }, context, option) => { fn: async ({ operation }, context, option) => {
const { filter } = operation; const { filter, data } = operation;
const settlePlans = await context.select('settlePlan', { const settlePlans = await context.select('settlePlan', {
data: { data: {
id: 1, id: 1,
@ -126,6 +126,14 @@ const triggers: Trigger<EntityDict, 'settlePlan', BRC>[] = [
}, option); }, option);
} }
} }
//为settlePlan赋上settledAt
if (data instanceof Array) {
for (const d of data) {
d.settledAt = now;
}
} else {
data.settledAt = now;
}
return settlePlans.length; return settlePlans.length;
}, },
}, },
@ -185,7 +193,7 @@ const triggers: Trigger<EntityDict, 'settlePlan', BRC>[] = [
asRoot: true, asRoot: true,
priority: 99, priority: 99,
fn: async ({ operation }, context, option) => { fn: async ({ operation }, context, option) => {
const { filter } = operation; const { filter, data } = operation;
const settlePlans = await context.select('settlePlan', { const settlePlans = await context.select('settlePlan', {
data: { data: {
id: 1, id: 1,
@ -224,6 +232,14 @@ const triggers: Trigger<EntityDict, 'settlePlan', BRC>[] = [
} }
}, option); }, option);
} }
//为settlePlan赋上closedAt
if (data instanceof Array) {
for (const d of data) {
d.closedAt = now;
}
} else {
data.closedAt = now;
}
return settlePlans.length; return settlePlans.length;
}, },
}, },

View File

@ -0,0 +1,3 @@
-- settlePlan --
ALTER TABLE `settlePlan` ADD COLUMN `settledAt` bigint NULL DEFAULT NULL;
ALTER TABLE `settlePlan` ADD COLUMN `closedAt` bigint NULL DEFAULT NULL;