settlement实体增加settledAt和closedAt字段
This commit is contained in:
parent
c4021ff42c
commit
52e95b487b
|
|
@ -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<IAction, IState>;
|
||||
type Action = IAction | 'refund' | 'refundFailure';
|
||||
type Action = IAction;
|
||||
export declare const entityDesc: EntityDesc<Schema, Action, '', {
|
||||
iState: IState;
|
||||
}>;
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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<IAction, IState>;
|
||||
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: {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -15,6 +15,12 @@ export const desc = {
|
|||
notNull: true,
|
||||
type: "money"
|
||||
},
|
||||
settledAt: {
|
||||
type: "datetime"
|
||||
},
|
||||
closedAt: {
|
||||
type: "datetime"
|
||||
},
|
||||
iState: {
|
||||
type: "enum",
|
||||
enumeration: ["unsettled", "settled", "closed"]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
export const style = {
|
||||
icon: {
|
||||
settle: '',
|
||||
refund: '',
|
||||
refundFailure: '',
|
||||
close: '',
|
||||
},
|
||||
color: {
|
||||
iState: {
|
||||
|
|
|
|||
|
|
@ -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<IState>;
|
||||
} & ExprOp<OpAttr | string>;
|
||||
export type OpProjection = {
|
||||
|
|
@ -32,6 +36,8 @@ export type OpProjection = {
|
|||
accountId?: number;
|
||||
planId?: number;
|
||||
price?: number;
|
||||
settledAt?: number;
|
||||
closedAt?: number;
|
||||
iState?: number;
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
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<OpAttr | string>>;
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
"plan": "结算计划",
|
||||
"price": "变化金额",
|
||||
"iState": "结算状态",
|
||||
"opers": "相关帐户操作"
|
||||
"opers": "相关帐户操作",
|
||||
"settledAt": "结算时间",
|
||||
"closedAt": "关闭时间"
|
||||
},
|
||||
"action": {
|
||||
"settle": "结算",
|
||||
"close": "关闭",
|
||||
"refund": "退款",
|
||||
"refundFailure": "退款失败"
|
||||
"close": "关闭"
|
||||
},
|
||||
"v": {
|
||||
"iState": {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<IAction, IState>;
|
||||
type Action = IAction | 'refund' | 'refundFailure';
|
||||
type Action = IAction;
|
||||
export declare const entityDesc: EntityDesc<Schema, Action, '', {
|
||||
iState: IState;
|
||||
}>;
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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<IAction, IState>;
|
||||
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: {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ exports.desc = {
|
|||
notNull: true,
|
||||
type: "money"
|
||||
},
|
||||
settledAt: {
|
||||
type: "datetime"
|
||||
},
|
||||
closedAt: {
|
||||
type: "datetime"
|
||||
},
|
||||
iState: {
|
||||
type: "enum",
|
||||
enumeration: ["unsettled", "settled", "closed"]
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ exports.style = void 0;
|
|||
exports.style = {
|
||||
icon: {
|
||||
settle: '',
|
||||
refund: '',
|
||||
refundFailure: '',
|
||||
close: '',
|
||||
},
|
||||
color: {
|
||||
iState: {
|
||||
|
|
|
|||
|
|
@ -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<IState>;
|
||||
} & ExprOp<OpAttr | string>;
|
||||
export type OpProjection = {
|
||||
|
|
@ -32,6 +36,8 @@ export type OpProjection = {
|
|||
accountId?: number;
|
||||
planId?: number;
|
||||
price?: number;
|
||||
settledAt?: number;
|
||||
closedAt?: number;
|
||||
iState?: number;
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
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<OpAttr | string>>;
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
"plan": "结算计划",
|
||||
"price": "变化金额",
|
||||
"iState": "结算状态",
|
||||
"opers": "相关帐户操作"
|
||||
"opers": "相关帐户操作",
|
||||
"settledAt": "结算时间",
|
||||
"closedAt": "关闭时间"
|
||||
},
|
||||
"action": {
|
||||
"settle": "结算",
|
||||
"close": "关闭",
|
||||
"refund": "退款",
|
||||
"refundFailure": "退款失败"
|
||||
"close": "关闭"
|
||||
},
|
||||
"v": {
|
||||
"iState": {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<IAction, IState> = {
|
|||
is: 'unsettled',
|
||||
};
|
||||
|
||||
type Action = IAction | 'refund' | 'refundFailure';
|
||||
type Action = IAction;
|
||||
|
||||
export const entityDesc: EntityDesc<Schema, Action, '', {
|
||||
iState: IState,
|
||||
|
|
@ -39,12 +42,12 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
|
|||
price: '变化金额',
|
||||
iState: '结算状态',
|
||||
opers: '相关帐户操作',
|
||||
settledAt: '结算时间',
|
||||
closedAt: '关闭时间'
|
||||
},
|
||||
action: {
|
||||
settle: '结算',
|
||||
close: '关闭',
|
||||
refund: '退款',
|
||||
refundFailure: '退款失败',
|
||||
},
|
||||
v: {
|
||||
iState: {
|
||||
|
|
@ -58,8 +61,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
|
|||
style: {
|
||||
icon: {
|
||||
settle: '',
|
||||
refund: '',
|
||||
refundFailure: '',
|
||||
close: '',
|
||||
},
|
||||
color: {
|
||||
iState: {
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ const triggers: Trigger<EntityDict, 'settlePlan', BRC>[] = [
|
|||
},
|
||||
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<EntityDict, 'settlePlan', BRC>[] = [
|
|||
id: await generateNewIdAsync(),
|
||||
action: 'settle',
|
||||
data: {
|
||||
settledAt: now,
|
||||
accountOper$entity: [{
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'create',
|
||||
|
|
@ -163,6 +165,7 @@ const triggers: Trigger<EntityDict, 'settlePlan', BRC>[] = [
|
|||
},
|
||||
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<EntityDict, 'settlePlan', BRC>[] = [
|
|||
await context.operate('settlement', {
|
||||
id: await generateNewIdAsync(),
|
||||
action: 'close',
|
||||
data: {},
|
||||
data: {
|
||||
closedAt: now,
|
||||
},
|
||||
filter: {
|
||||
id: settlementId,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue