pay实体增加autoStart决定是否自动开始支付

This commit is contained in:
lxy 2025-02-13 17:36:33 +08:00
parent 58f01d86f7
commit e2be5c11fc
23 changed files with 118 additions and 101 deletions

View File

@ -32,6 +32,7 @@ export interface Schema extends EntityShape {
phantom3?: Int<4>;
phantom4?: Int<8>;
opers: AccountOper[];
autoStart?: Boolean;
}
type IAction = 'startPaying' | 'succeedPaying' | 'close' | 'startRefunding' | 'refundAll' | 'refundPartially' | 'stopRefunding';
type IState = 'unpaid' | 'paying' | 'paid' | 'closed' | 'refunding' | 'partiallyRefunded' | 'refunded';

View File

@ -86,6 +86,7 @@ export const entityDesc = {
phantom2: '索引项二',
phantom3: '索引项三',
phantom4: '索引项四',
autoStart: '自动开始支付',
},
action: {
startPaying: '开始支付',

View File

@ -85,7 +85,7 @@ export type OpSchema = EntityShape & {
style?: Style | null;
dangerousVersions: Versions;
warningVersions: Versions;
soaVersion: String<32>;
soaVersion: String<12>;
domainId?: ForeignKey<"domain"> | null;
} & {
[A in ExpressionKey]?: any;

View File

@ -95,6 +95,9 @@ export const desc = {
signed: true
}
},
autoStart: {
type: "boolean"
},
iState: {
type: "enum",
enumeration: ["unpaid", "paying", "paid", "closed", "refunding", "partiallyRefunded", "refunded"]

View File

@ -23,6 +23,7 @@ export type OpSchema = EntityShape & {
phantom2?: String<32> | null;
phantom3?: Int<4> | null;
phantom4?: Int<8> | null;
autoStart?: Boolean | null;
iState?: IState | null;
} & {
[A in ExpressionKey]?: any;
@ -52,6 +53,7 @@ export type OpFilter = {
phantom2: Q_StringValue;
phantom3: Q_NumberValue;
phantom4: Q_NumberValue;
autoStart: Q_BooleanValue;
iState: Q_EnumValue<IState>;
} & ExprOp<OpAttr | string>;
export type OpProjection = {
@ -80,6 +82,7 @@ export type OpProjection = {
phantom2?: number;
phantom3?: number;
phantom4?: number;
autoStart?: number;
iState?: number;
} & Partial<ExprOp<OpAttr | string>>;
export type OpSortAttr = Partial<{
@ -101,6 +104,7 @@ export type OpSortAttr = Partial<{
phantom2: number;
phantom3: number;
phantom4: number;
autoStart: number;
iState: number;
[k: string]: any;
} | ExprOp<OpAttr | string>>;

View File

@ -21,7 +21,8 @@
"phantom1": "索引项一",
"phantom2": "索引项二",
"phantom3": "索引项三",
"phantom4": "索引项四"
"phantom4": "索引项四",
"autoStart": "自动开始支付"
},
"action": {
"startPaying": "开始支付",

View File

@ -1,5 +1,5 @@
import aoTriggers from './accountOper';
import payTriggers, { optionalTriggers as optionalPayTriggers } from './pay';
import payTriggers from './pay';
import userSystemTriggers from './userSystem';
import accountTriggers from './account';
import refundTriggers from './refund';
@ -30,5 +30,5 @@ const triggers = [
];
export default triggers;
export const optionalTriggers = [
...optionalPayTriggers,
// ...optionalPayTriggers,
];

View File

@ -3,4 +3,3 @@ import { EntityDict } from '../oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
declare const triggers: Trigger<EntityDict, 'pay', BRC>[];
export default triggers;
export declare const optionalTriggers: Trigger<EntityDict, 'pay', BRC>[];

View File

@ -265,29 +265,27 @@ const triggers = [
return 1;
},
} as CreateTriggerInTxn<EntityDict, 'pay', BRC>, */
/**
{
name: '当生成pay后自动开始支付流程',
name: '当生成autoStart的pay后自动开始支付流程',
entity: 'pay',
action: 'create',
when: 'commit',
asRoot: true,
check: (operation) => !!operation.data.autoStart,
fn: async ({ ids }, context, option) => {
assert(ids.length === 1);
const [id] = ids;
await context.operate('pay', {
id: await generateNewIdAsync(),
action: 'startPaying',
data: {
},
data: {},
filter: {
id,
}
}, option);
return;
},
},*/
},
{
name: '当pay的状态发生变化时修改相应的order的状态或者deposit的状态同时尝试向订阅者推送',
entity: 'pay',
@ -701,25 +699,26 @@ const triggers = [
} as SelectTriggerAfter<EntityDict, 'pay', BRC>, */
];
export default triggers;
export const optionalTriggers = [
{
name: '当生成pay后自动开始支付流程',
entity: 'pay',
action: 'create',
when: 'commit',
asRoot: true,
fn: async ({ ids }, context, option) => {
assert(ids.length === 1);
const [id] = ids;
await context.operate('pay', {
id: await generateNewIdAsync(),
action: 'startPaying',
data: {},
filter: {
id,
}
}, option);
return;
},
}
];
// export const optionalTriggers: Trigger<EntityDict, 'pay', BRC>[] = [
// {
// name: '当生成pay后自动开始支付流程',
// entity: 'pay',
// action: 'create',
// when: 'commit',
// asRoot: true,
// fn: async ({ ids }, context, option) => {
// assert(ids.length === 1);
// const [id] = ids;
// await context.operate('pay', {
// id: await generateNewIdAsync(),
// action: 'startPaying',
// data: {
// },
// filter: {
// id,
// }
// }, option);
// return;
// },
// }
// ]

View File

@ -32,6 +32,7 @@ export interface Schema extends EntityShape {
phantom3?: Int<4>;
phantom4?: Int<8>;
opers: AccountOper[];
autoStart?: Boolean;
}
type IAction = 'startPaying' | 'succeedPaying' | 'close' | 'startRefunding' | 'refundAll' | 'refundPartially' | 'stopRefunding';
type IState = 'unpaid' | 'paying' | 'paid' | 'closed' | 'refunding' | 'partiallyRefunded' | 'refunded';

View File

@ -89,6 +89,7 @@ exports.entityDesc = {
phantom2: '索引项二',
phantom3: '索引项三',
phantom4: '索引项四',
autoStart: '自动开始支付',
},
action: {
startPaying: '开始支付',

View File

@ -85,7 +85,7 @@ export type OpSchema = EntityShape & {
style?: Style | null;
dangerousVersions: Versions;
warningVersions: Versions;
soaVersion: String<32>;
soaVersion: String<12>;
domainId?: ForeignKey<"domain"> | null;
} & {
[A in ExpressionKey]?: any;

View File

@ -98,6 +98,9 @@ exports.desc = {
signed: true
}
},
autoStart: {
type: "boolean"
},
iState: {
type: "enum",
enumeration: ["unpaid", "paying", "paid", "closed", "refunding", "partiallyRefunded", "refunded"]

View File

@ -23,6 +23,7 @@ export type OpSchema = EntityShape & {
phantom2?: String<32> | null;
phantom3?: Int<4> | null;
phantom4?: Int<8> | null;
autoStart?: Boolean | null;
iState?: IState | null;
} & {
[A in ExpressionKey]?: any;
@ -52,6 +53,7 @@ export type OpFilter = {
phantom2: Q_StringValue;
phantom3: Q_NumberValue;
phantom4: Q_NumberValue;
autoStart: Q_BooleanValue;
iState: Q_EnumValue<IState>;
} & ExprOp<OpAttr | string>;
export type OpProjection = {
@ -80,6 +82,7 @@ export type OpProjection = {
phantom2?: number;
phantom3?: number;
phantom4?: number;
autoStart?: number;
iState?: number;
} & Partial<ExprOp<OpAttr | string>>;
export type OpSortAttr = Partial<{
@ -101,6 +104,7 @@ export type OpSortAttr = Partial<{
phantom2: number;
phantom3: number;
phantom4: number;
autoStart: number;
iState: number;
[k: string]: any;
} | ExprOp<OpAttr | string>>;

View File

@ -21,7 +21,8 @@
"phantom1": "索引项一",
"phantom2": "索引项二",
"phantom3": "索引项三",
"phantom4": "索引项四"
"phantom4": "索引项四",
"autoStart": "自动开始支付"
},
"action": {
"startPaying": "开始支付",

View File

@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.optionalTriggers = void 0;
const tslib_1 = require("tslib");
const accountOper_1 = tslib_1.__importDefault(require("./accountOper"));
const pay_1 = tslib_1.__importStar(require("./pay"));
const pay_1 = tslib_1.__importDefault(require("./pay"));
const userSystem_1 = tslib_1.__importDefault(require("./userSystem"));
const account_1 = tslib_1.__importDefault(require("./account"));
const refund_1 = tslib_1.__importDefault(require("./refund"));
@ -34,5 +34,5 @@ const triggers = [
];
exports.default = triggers;
exports.optionalTriggers = [
...pay_1.optionalTriggers,
// ...optionalPayTriggers,
];

View File

@ -3,4 +3,3 @@ import { EntityDict } from '../oak-app-domain';
import { BRC } from '../types/RuntimeCxt';
declare const triggers: Trigger<EntityDict, 'pay', BRC>[];
export default triggers;
export declare const optionalTriggers: Trigger<EntityDict, 'pay', BRC>[];

View File

@ -1,6 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.optionalTriggers = void 0;
const tslib_1 = require("tslib");
const uuid_1 = require("oak-domain/lib/utils/uuid");
const assert_1 = tslib_1.__importDefault(require("assert"));
@ -269,29 +268,27 @@ const triggers = [
return 1;
},
} as CreateTriggerInTxn<EntityDict, 'pay', BRC>, */
/**
{
name: '当生成pay后自动开始支付流程',
name: '当生成autoStart的pay后自动开始支付流程',
entity: 'pay',
action: 'create',
when: 'commit',
asRoot: true,
check: (operation) => !!operation.data.autoStart,
fn: async ({ ids }, context, option) => {
assert(ids.length === 1);
(0, assert_1.default)(ids.length === 1);
const [id] = ids;
await context.operate('pay', {
id: await generateNewIdAsync(),
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'startPaying',
data: {
},
data: {},
filter: {
id,
}
}, option);
return;
},
},*/
},
{
name: '当pay的状态发生变化时修改相应的order的状态或者deposit的状态同时尝试向订阅者推送',
entity: 'pay',
@ -705,25 +702,26 @@ const triggers = [
} as SelectTriggerAfter<EntityDict, 'pay', BRC>, */
];
exports.default = triggers;
exports.optionalTriggers = [
{
name: '当生成pay后自动开始支付流程',
entity: 'pay',
action: 'create',
when: 'commit',
asRoot: true,
fn: async ({ ids }, context, option) => {
(0, assert_1.default)(ids.length === 1);
const [id] = ids;
await context.operate('pay', {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'startPaying',
data: {},
filter: {
id,
}
}, option);
return;
},
}
];
// export const optionalTriggers: Trigger<EntityDict, 'pay', BRC>[] = [
// {
// name: '当生成pay后自动开始支付流程',
// entity: 'pay',
// action: 'create',
// when: 'commit',
// asRoot: true,
// fn: async ({ ids }, context, option) => {
// assert(ids.length === 1);
// const [id] = ids;
// await context.operate('pay', {
// id: await generateNewIdAsync(),
// action: 'startPaying',
// data: {
// },
// filter: {
// id,
// }
// }, option);
// return;
// },
// }
// ]

View File

@ -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<EntityDict, 'withdraw', BRC>[];
export default triggers;

View File

@ -162,7 +162,7 @@ export default OakComponent({
);
const { mode } = this.props;
const succeedable =data["#oakLegalActions"].includes('succeedPaying');
const succeedable =data["#oakLegalActions"]?.includes('succeedPaying');
const payChannels = this.features.pay.getPayChannels();
const offlines = this.features.cache.get('offlineAccount', {

View File

@ -41,6 +41,7 @@ export interface Schema extends EntityShape {
phantom3?: Int<4>;
phantom4?: Int<8>;
opers: AccountOper[];
autoStart?: Boolean;
};
type IAction = 'startPaying' | 'succeedPaying' | 'close' | 'startRefunding' | 'refundAll' | 'refundPartially' | 'stopRefunding';
@ -128,7 +129,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
timeoutAt: '过期时间',
successAt: '完成时间',
forbidRefundAt: '停止退款时间',
refundable: '是否可退款',
refundable: '是否可退款',
meta: '支付metadata',
externalId: '外部订单Id',
opers: '被关联帐户操作',
@ -138,6 +139,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
phantom2: '索引项二',
phantom3: '索引项三',
phantom4: '索引项四',
autoStart: '自动开始支付',
},
action: {
startPaying: '开始支付',
@ -153,7 +155,7 @@ export const entityDesc: EntityDesc<Schema, Action, '', {
v: {
iState: {
unpaid: '待付款',
paying: '支付中',
paying: '支付中',
paid: '已付款',
closed: '已关闭',
refunding: '退款中',

View File

@ -2,7 +2,7 @@ import { EntityDict } from '@oak-app-domain';
import { Trigger } from 'oak-domain/lib/types';
import { BRC } from '../types/RuntimeCxt';
import aoTriggers from './accountOper';
import payTriggers, { optionalTriggers as optionalPayTriggers } from './pay';
import payTriggers from './pay';
import userSystemTriggers from './userSystem';
import accountTriggers from './account';
import refundTriggers from './refund';
@ -36,5 +36,5 @@ const triggers = [
export default triggers;
export const optionalTriggers = [
...optionalPayTriggers,
// ...optionalPayTriggers,
] as Trigger<EntityDict, keyof EntityDict, BRC>[];

View File

@ -288,13 +288,13 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
return 1;
},
} as CreateTriggerInTxn<EntityDict, 'pay', BRC>, */
/**
{
name: '当生成pay后自动开始支付流程',
name: '当生成autoStart的pay后自动开始支付流程',
entity: 'pay',
action: 'create',
when: 'commit',
asRoot: true,
check: (operation: EntityDict['pay']['Create']) => !!(operation as EntityDict['pay']['CreateSingle']).data.autoStart,
fn: async ({ ids }, context, option) => {
assert(ids.length === 1);
const [id] = ids;
@ -310,7 +310,7 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
return;
},
},*/
},
{
name: '当pay的状态发生变化时修改相应的order的状态或者deposit的状态同时尝试向订阅者推送',
entity: 'pay',
@ -763,27 +763,27 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
export default triggers;
export const optionalTriggers: Trigger<EntityDict, 'pay', BRC>[] = [
{
name: '当生成pay后自动开始支付流程',
entity: 'pay',
action: 'create',
when: 'commit',
asRoot: true,
fn: async ({ ids }, context, option) => {
assert(ids.length === 1);
const [id] = ids;
await context.operate('pay', {
id: await generateNewIdAsync(),
action: 'startPaying',
data: {
},
filter: {
id,
}
}, option);
// export const optionalTriggers: Trigger<EntityDict, 'pay', BRC>[] = [
// {
// name: '当生成pay后自动开始支付流程',
// entity: 'pay',
// action: 'create',
// when: 'commit',
// asRoot: true,
// fn: async ({ ids }, context, option) => {
// assert(ids.length === 1);
// const [id] = ids;
// await context.operate('pay', {
// id: await generateNewIdAsync(),
// action: 'startPaying',
// data: {
// },
// filter: {
// id,
// }
// }, option);
return;
},
}
]
// return;
// },
// }
// ]