From 52e95b487b1f9cf5eb239e41a2650448d81d4845 Mon Sep 17 00:00:00 2001 From: lxy Date: Mon, 21 Jul 2025 17:26:32 +0800 Subject: [PATCH] =?UTF-8?q?settlement=E5=AE=9E=E4=BD=93=E5=A2=9E=E5=8A=A0s?= =?UTF-8?q?ettledAt=E5=92=8CclosedAt=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/entities/Settlement.d.ts | 6 ++++-- es/entities/Settlement.js | 7 +++---- es/oak-app-domain/Settlement/Action.d.ts | 2 +- es/oak-app-domain/Settlement/Action.js | 2 +- es/oak-app-domain/Settlement/Storage.js | 6 ++++++ es/oak-app-domain/Settlement/Style.js | 3 +-- es/oak-app-domain/Settlement/_baseSchema.d.ts | 10 +++++++++- es/oak-app-domain/Settlement/locales/zh_CN.json | 8 ++++---- es/triggers/settlePlan.js | 7 ++++++- lib/entities/Settlement.d.ts | 6 ++++-- lib/entities/Settlement.js | 7 +++---- lib/oak-app-domain/Settlement/Action.d.ts | 2 +- lib/oak-app-domain/Settlement/Action.js | 2 +- lib/oak-app-domain/Settlement/Storage.js | 6 ++++++ lib/oak-app-domain/Settlement/Style.js | 3 +-- lib/oak-app-domain/Settlement/_baseSchema.d.ts | 10 +++++++++- lib/oak-app-domain/Settlement/locales/zh_CN.json | 8 ++++---- lib/triggers/settlePlan.js | 7 ++++++- src/entities/Settlement.ts | 12 +++++++----- src/triggers/settlePlan.ts | 7 ++++++- 20 files changed, 83 insertions(+), 38 deletions(-) diff --git a/es/entities/Settlement.d.ts b/es/entities/Settlement.d.ts index fa87139e..b121bf5b 100644 --- a/es/entities/Settlement.d.ts +++ b/es/entities/Settlement.d.ts @@ -1,4 +1,4 @@ -import { Price } from 'oak-domain/lib/types/DataType'; +import { Price, Datetime } from 'oak-domain/lib/types/DataType'; import { EntityShape } from 'oak-domain/lib/types/Entity'; import { EntityDesc, ActionDef } from 'oak-domain/lib/types'; import { Schema as Account } from './Account'; @@ -9,11 +9,13 @@ export interface Schema extends EntityShape { plan: SettlePlan; price: Price; opers?: AccountOper[]; + settledAt?: Datetime; + closedAt?: Datetime; } type IState = 'unsettled' | 'settled' | 'closed'; type IAction = 'settle' | 'close'; export declare const IActionDef: ActionDef; -type Action = IAction | 'refund' | 'refundFailure'; +type Action = IAction; export declare const entityDesc: EntityDesc; diff --git a/es/entities/Settlement.js b/es/entities/Settlement.js index 17c589b5..aa256ef6 100644 --- a/es/entities/Settlement.js +++ b/es/entities/Settlement.js @@ -16,12 +16,12 @@ export const entityDesc = { price: '变化金额', iState: '结算状态', opers: '相关帐户操作', + settledAt: '结算时间', + closedAt: '关闭时间' }, action: { settle: '结算', close: '关闭', - refund: '退款', - refundFailure: '退款失败', }, v: { iState: { @@ -35,8 +35,7 @@ export const entityDesc = { style: { icon: { settle: '', - refund: '', - refundFailure: '', + close: '', }, color: { iState: { diff --git a/es/oak-app-domain/Settlement/Action.d.ts b/es/oak-app-domain/Settlement/Action.d.ts index 37ea2182..bbf45ba9 100644 --- a/es/oak-app-domain/Settlement/Action.d.ts +++ b/es/oak-app-domain/Settlement/Action.d.ts @@ -3,7 +3,7 @@ import { GenericAction } from "oak-domain/lib/actions/action"; export type IState = 'unsettled' | 'settled' | 'closed' | string; export type IAction = 'settle' | 'close' | string; export declare const IActionDef: ActionDef; -export type ParticularAction = IAction | 'refund' | 'refundFailure'; +export type ParticularAction = IAction; export declare const actions: string[]; export type Action = GenericAction | ParticularAction | string; export declare const actionDefDict: { diff --git a/es/oak-app-domain/Settlement/Action.js b/es/oak-app-domain/Settlement/Action.js index 114caf3d..bf0a1719 100644 --- a/es/oak-app-domain/Settlement/Action.js +++ b/es/oak-app-domain/Settlement/Action.js @@ -5,7 +5,7 @@ export const IActionDef = { }, is: 'unsettled', }; -export const actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "settle", "close", "refund", "refundFailure"]; +export const actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "settle", "close"]; export const actionDefDict = { iState: IActionDef }; diff --git a/es/oak-app-domain/Settlement/Storage.js b/es/oak-app-domain/Settlement/Storage.js index f1a43c6c..3676d6fa 100644 --- a/es/oak-app-domain/Settlement/Storage.js +++ b/es/oak-app-domain/Settlement/Storage.js @@ -15,6 +15,12 @@ export const desc = { notNull: true, type: "money" }, + settledAt: { + type: "datetime" + }, + closedAt: { + type: "datetime" + }, iState: { type: "enum", enumeration: ["unsettled", "settled", "closed"] diff --git a/es/oak-app-domain/Settlement/Style.js b/es/oak-app-domain/Settlement/Style.js index ffdff23d..a8e4e5c6 100644 --- a/es/oak-app-domain/Settlement/Style.js +++ b/es/oak-app-domain/Settlement/Style.js @@ -1,8 +1,7 @@ export const style = { icon: { settle: '', - refund: '', - refundFailure: '', + close: '', }, color: { iState: { diff --git a/es/oak-app-domain/Settlement/_baseSchema.d.ts b/es/oak-app-domain/Settlement/_baseSchema.d.ts index 8baa31fd..40ca3d5b 100644 --- a/es/oak-app-domain/Settlement/_baseSchema.d.ts +++ b/es/oak-app-domain/Settlement/_baseSchema.d.ts @@ -2,11 +2,13 @@ import { ForeignKey } from "oak-domain/lib/types/DataType"; import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { Action, ParticularAction, IState } from "./Action"; -import { Price } from "oak-domain/lib/types/DataType"; +import { Price, Datetime } from "oak-domain/lib/types/DataType"; export type OpSchema = EntityShape & { accountId: ForeignKey<"account">; planId: ForeignKey<"settlePlan">; price: Price; + settledAt?: Datetime | null; + closedAt?: Datetime | null; iState?: IState | null; } & { [A in ExpressionKey]?: any; @@ -20,6 +22,8 @@ export type OpFilter = { accountId: Q_StringValue; planId: Q_StringValue; price: Q_NumberValue; + settledAt: Q_DateValue; + closedAt: Q_DateValue; iState: Q_EnumValue; } & ExprOp; export type OpProjection = { @@ -32,6 +36,8 @@ export type OpProjection = { accountId?: number; planId?: number; price?: number; + settledAt?: number; + closedAt?: number; iState?: number; } & Partial>; export type OpSortAttr = Partial<{ @@ -42,6 +48,8 @@ export type OpSortAttr = Partial<{ accountId: number; planId: number; price: number; + settledAt: number; + closedAt: number; iState: number; [k: string]: any; } | ExprOp>; diff --git a/es/oak-app-domain/Settlement/locales/zh_CN.json b/es/oak-app-domain/Settlement/locales/zh_CN.json index 428bb293..db93a035 100644 --- a/es/oak-app-domain/Settlement/locales/zh_CN.json +++ b/es/oak-app-domain/Settlement/locales/zh_CN.json @@ -5,13 +5,13 @@ "plan": "结算计划", "price": "变化金额", "iState": "结算状态", - "opers": "相关帐户操作" + "opers": "相关帐户操作", + "settledAt": "结算时间", + "closedAt": "关闭时间" }, "action": { "settle": "结算", - "close": "关闭", - "refund": "退款", - "refundFailure": "退款失败" + "close": "关闭" }, "v": { "iState": { diff --git a/es/triggers/settlePlan.js b/es/triggers/settlePlan.js index 43db409c..5ee09c29 100644 --- a/es/triggers/settlePlan.js +++ b/es/triggers/settlePlan.js @@ -84,6 +84,7 @@ const triggers = [ }, filter, }, { forUpdate: true }); + const now = Date.now(); for (const settlePlan of settlePlans) { const { id, price: planPrice, settlement$plan: settlements, orderId, order } = settlePlan; assert(settlements && settlements.length > 0); @@ -94,6 +95,7 @@ const triggers = [ id: await generateNewIdAsync(), action: 'settle', data: { + settledAt: now, accountOper$entity: [{ id: await generateNewIdAsync(), action: 'create', @@ -160,6 +162,7 @@ const triggers = [ }, filter, }, { forUpdate: true }); + const now = Date.now(); for (const settlePlan of settlePlans) { const { id, price: planPrice, settlement$plan: settlements, orderId, order } = settlePlan || {}; assert(settlements && settlements.length > 0); @@ -169,7 +172,9 @@ const triggers = [ await context.operate('settlement', { id: await generateNewIdAsync(), action: 'close', - data: {}, + data: { + closedAt: now, + }, filter: { id: settlementId, } diff --git a/lib/entities/Settlement.d.ts b/lib/entities/Settlement.d.ts index fa87139e..b121bf5b 100644 --- a/lib/entities/Settlement.d.ts +++ b/lib/entities/Settlement.d.ts @@ -1,4 +1,4 @@ -import { Price } from 'oak-domain/lib/types/DataType'; +import { Price, Datetime } from 'oak-domain/lib/types/DataType'; import { EntityShape } from 'oak-domain/lib/types/Entity'; import { EntityDesc, ActionDef } from 'oak-domain/lib/types'; import { Schema as Account } from './Account'; @@ -9,11 +9,13 @@ export interface Schema extends EntityShape { plan: SettlePlan; price: Price; opers?: AccountOper[]; + settledAt?: Datetime; + closedAt?: Datetime; } type IState = 'unsettled' | 'settled' | 'closed'; type IAction = 'settle' | 'close'; export declare const IActionDef: ActionDef; -type Action = IAction | 'refund' | 'refundFailure'; +type Action = IAction; export declare const entityDesc: EntityDesc; diff --git a/lib/entities/Settlement.js b/lib/entities/Settlement.js index c7dda4ab..2a299422 100644 --- a/lib/entities/Settlement.js +++ b/lib/entities/Settlement.js @@ -19,12 +19,12 @@ exports.entityDesc = { price: '变化金额', iState: '结算状态', opers: '相关帐户操作', + settledAt: '结算时间', + closedAt: '关闭时间' }, action: { settle: '结算', close: '关闭', - refund: '退款', - refundFailure: '退款失败', }, v: { iState: { @@ -38,8 +38,7 @@ exports.entityDesc = { style: { icon: { settle: '', - refund: '', - refundFailure: '', + close: '', }, color: { iState: { diff --git a/lib/oak-app-domain/Settlement/Action.d.ts b/lib/oak-app-domain/Settlement/Action.d.ts index 37ea2182..bbf45ba9 100644 --- a/lib/oak-app-domain/Settlement/Action.d.ts +++ b/lib/oak-app-domain/Settlement/Action.d.ts @@ -3,7 +3,7 @@ import { GenericAction } from "oak-domain/lib/actions/action"; export type IState = 'unsettled' | 'settled' | 'closed' | string; export type IAction = 'settle' | 'close' | string; export declare const IActionDef: ActionDef; -export type ParticularAction = IAction | 'refund' | 'refundFailure'; +export type ParticularAction = IAction; export declare const actions: string[]; export type Action = GenericAction | ParticularAction | string; export declare const actionDefDict: { diff --git a/lib/oak-app-domain/Settlement/Action.js b/lib/oak-app-domain/Settlement/Action.js index 9b9ad24a..9364f599 100644 --- a/lib/oak-app-domain/Settlement/Action.js +++ b/lib/oak-app-domain/Settlement/Action.js @@ -8,7 +8,7 @@ exports.IActionDef = { }, is: 'unsettled', }; -exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "settle", "close", "refund", "refundFailure"]; +exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "settle", "close"]; exports.actionDefDict = { iState: exports.IActionDef }; diff --git a/lib/oak-app-domain/Settlement/Storage.js b/lib/oak-app-domain/Settlement/Storage.js index 447e56ee..a78f0ff7 100644 --- a/lib/oak-app-domain/Settlement/Storage.js +++ b/lib/oak-app-domain/Settlement/Storage.js @@ -18,6 +18,12 @@ exports.desc = { notNull: true, type: "money" }, + settledAt: { + type: "datetime" + }, + closedAt: { + type: "datetime" + }, iState: { type: "enum", enumeration: ["unsettled", "settled", "closed"] diff --git a/lib/oak-app-domain/Settlement/Style.js b/lib/oak-app-domain/Settlement/Style.js index 4066ace0..48a78fd0 100644 --- a/lib/oak-app-domain/Settlement/Style.js +++ b/lib/oak-app-domain/Settlement/Style.js @@ -4,8 +4,7 @@ exports.style = void 0; exports.style = { icon: { settle: '', - refund: '', - refundFailure: '', + close: '', }, color: { iState: { diff --git a/lib/oak-app-domain/Settlement/_baseSchema.d.ts b/lib/oak-app-domain/Settlement/_baseSchema.d.ts index 8baa31fd..40ca3d5b 100644 --- a/lib/oak-app-domain/Settlement/_baseSchema.d.ts +++ b/lib/oak-app-domain/Settlement/_baseSchema.d.ts @@ -2,11 +2,13 @@ import { ForeignKey } from "oak-domain/lib/types/DataType"; import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, ExprOp, ExpressionKey } from "oak-domain/lib/types/Demand"; import { MakeAction as OakMakeAction, EntityShape } from "oak-domain/lib/types/Entity"; import { Action, ParticularAction, IState } from "./Action"; -import { Price } from "oak-domain/lib/types/DataType"; +import { Price, Datetime } from "oak-domain/lib/types/DataType"; export type OpSchema = EntityShape & { accountId: ForeignKey<"account">; planId: ForeignKey<"settlePlan">; price: Price; + settledAt?: Datetime | null; + closedAt?: Datetime | null; iState?: IState | null; } & { [A in ExpressionKey]?: any; @@ -20,6 +22,8 @@ export type OpFilter = { accountId: Q_StringValue; planId: Q_StringValue; price: Q_NumberValue; + settledAt: Q_DateValue; + closedAt: Q_DateValue; iState: Q_EnumValue; } & ExprOp; export type OpProjection = { @@ -32,6 +36,8 @@ export type OpProjection = { accountId?: number; planId?: number; price?: number; + settledAt?: number; + closedAt?: number; iState?: number; } & Partial>; export type OpSortAttr = Partial<{ @@ -42,6 +48,8 @@ export type OpSortAttr = Partial<{ accountId: number; planId: number; price: number; + settledAt: number; + closedAt: number; iState: number; [k: string]: any; } | ExprOp>; diff --git a/lib/oak-app-domain/Settlement/locales/zh_CN.json b/lib/oak-app-domain/Settlement/locales/zh_CN.json index 428bb293..db93a035 100644 --- a/lib/oak-app-domain/Settlement/locales/zh_CN.json +++ b/lib/oak-app-domain/Settlement/locales/zh_CN.json @@ -5,13 +5,13 @@ "plan": "结算计划", "price": "变化金额", "iState": "结算状态", - "opers": "相关帐户操作" + "opers": "相关帐户操作", + "settledAt": "结算时间", + "closedAt": "关闭时间" }, "action": { "settle": "结算", - "close": "关闭", - "refund": "退款", - "refundFailure": "退款失败" + "close": "关闭" }, "v": { "iState": { diff --git a/lib/triggers/settlePlan.js b/lib/triggers/settlePlan.js index e8e45e0e..c323b2f6 100644 --- a/lib/triggers/settlePlan.js +++ b/lib/triggers/settlePlan.js @@ -87,6 +87,7 @@ const triggers = [ }, filter, }, { forUpdate: true }); + const now = Date.now(); for (const settlePlan of settlePlans) { const { id, price: planPrice, settlement$plan: settlements, orderId, order } = settlePlan; (0, assert_1.default)(settlements && settlements.length > 0); @@ -97,6 +98,7 @@ const triggers = [ id: await (0, uuid_1.generateNewIdAsync)(), action: 'settle', data: { + settledAt: now, accountOper$entity: [{ id: await (0, uuid_1.generateNewIdAsync)(), action: 'create', @@ -163,6 +165,7 @@ const triggers = [ }, filter, }, { forUpdate: true }); + const now = Date.now(); for (const settlePlan of settlePlans) { const { id, price: planPrice, settlement$plan: settlements, orderId, order } = settlePlan || {}; (0, assert_1.default)(settlements && settlements.length > 0); @@ -172,7 +175,9 @@ const triggers = [ await context.operate('settlement', { id: await (0, uuid_1.generateNewIdAsync)(), action: 'close', - data: {}, + data: { + closedAt: now, + }, filter: { id: settlementId, } diff --git a/src/entities/Settlement.ts b/src/entities/Settlement.ts index e082bbb7..d4381b27 100644 --- a/src/entities/Settlement.ts +++ b/src/entities/Settlement.ts @@ -1,5 +1,6 @@ import { Price, + Datetime, } from 'oak-domain/lib/types/DataType'; import { EntityShape } from 'oak-domain/lib/types/Entity'; import { EntityDesc, ActionDef } from 'oak-domain/lib/types'; @@ -12,6 +13,8 @@ export interface Schema extends EntityShape { plan: SettlePlan; price: Price; opers?: AccountOper[]; + settledAt?: Datetime; + closedAt?: Datetime; }; type IState = 'unsettled' | 'settled' | 'closed'; @@ -25,7 +28,7 @@ export const IActionDef: ActionDef = { is: 'unsettled', }; -type Action = IAction | 'refund' | 'refundFailure'; +type Action = IAction; export const entityDesc: EntityDesc[] = [ }, filter, }, { forUpdate: true }); + const now = Date.now(); for (const settlePlan of settlePlans) { const { id, price: planPrice, settlement$plan: settlements, orderId, order } = settlePlan; assert(settlements && settlements.length > 0); @@ -97,6 +98,7 @@ const triggers: Trigger[] = [ id: await generateNewIdAsync(), action: 'settle', data: { + settledAt: now, accountOper$entity: [{ id: await generateNewIdAsync(), action: 'create', @@ -163,6 +165,7 @@ const triggers: Trigger[] = [ }, filter, }, { forUpdate: true }); + const now = Date.now(); for (const settlePlan of settlePlans) { const { id, price: planPrice, settlement$plan: settlements, orderId, order } = settlePlan || {}; assert(settlements && settlements.length > 0); @@ -172,7 +175,9 @@ const triggers: Trigger[] = [ await context.operate('settlement', { id: await generateNewIdAsync(), action: 'close', - data: {}, + data: { + closedAt: now, + }, filter: { id: settlementId, }