trigger的进一步修正
This commit is contained in:
parent
5c6c180c0a
commit
96991b9ef0
|
|
@ -267,8 +267,7 @@ const triggers = [
|
|||
priority: 99,
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { data, filter, action, id } = operation;
|
||||
assert(typeof filter.id === 'string');
|
||||
const [pay] = await context.select('pay', {
|
||||
const pays = await context.select('pay', {
|
||||
data: {
|
||||
id: 1,
|
||||
orderId: 1,
|
||||
|
|
@ -288,11 +287,14 @@ const triggers = [
|
|||
},
|
||||
filter,
|
||||
}, { dontCollect: true });
|
||||
const { orderId, depositId, iState, deposit, application } = pay;
|
||||
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter.id}`);
|
||||
if (orderId) {
|
||||
return await changeOrderStateByPay({ id: orderId }, context, option);
|
||||
for (const pay of pays) {
|
||||
const { orderId, depositId, iState, deposit, application } = pay;
|
||||
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter.id}`);
|
||||
if (orderId) {
|
||||
await changeOrderStateByPay({ id: orderId }, context, option);
|
||||
}
|
||||
}
|
||||
return pays.length;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -270,8 +270,7 @@ const triggers = [
|
|||
priority: 99,
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { data, filter, action, id } = operation;
|
||||
(0, assert_1.default)(typeof filter.id === 'string');
|
||||
const [pay] = await context.select('pay', {
|
||||
const pays = await context.select('pay', {
|
||||
data: {
|
||||
id: 1,
|
||||
orderId: 1,
|
||||
|
|
@ -291,11 +290,14 @@ const triggers = [
|
|||
},
|
||||
filter,
|
||||
}, { dontCollect: true });
|
||||
const { orderId, depositId, iState, deposit, application } = pay;
|
||||
context.saveOperationToEvent(id, `${constants_1.DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter.id}`);
|
||||
if (orderId) {
|
||||
return await changeOrderStateByPay({ id: orderId }, context, option);
|
||||
for (const pay of pays) {
|
||||
const { orderId, depositId, iState, deposit, application } = pay;
|
||||
context.saveOperationToEvent(id, `${constants_1.DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter.id}`);
|
||||
if (orderId) {
|
||||
await changeOrderStateByPay({ id: orderId }, context, option);
|
||||
}
|
||||
}
|
||||
return pays.length;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -292,9 +292,8 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
|
|||
priority: 99,
|
||||
fn: async ({ operation }, context, option) => {
|
||||
const { data, filter, action, id } = operation as EntityDict['pay']['Update'];
|
||||
assert(typeof filter!.id === 'string');
|
||||
|
||||
const [pay] = await context.select('pay', {
|
||||
|
||||
const pays = await context.select('pay', {
|
||||
data: {
|
||||
id: 1,
|
||||
orderId: 1,
|
||||
|
|
@ -314,12 +313,17 @@ const triggers: Trigger<EntityDict, 'pay', BRC>[] = [
|
|||
},
|
||||
filter,
|
||||
}, { dontCollect: true });
|
||||
const { orderId, depositId, iState, deposit, application } = pay;
|
||||
|
||||
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter!.id!}`);
|
||||
if (orderId) {
|
||||
return await changeOrderStateByPay({ id: orderId }, context, option);
|
||||
|
||||
for (const pay of pays) {
|
||||
const { orderId, depositId, iState, deposit, application } = pay;
|
||||
|
||||
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.payStateChanged}-${filter!.id!}`);
|
||||
if (orderId) {
|
||||
await changeOrderStateByPay({ id: orderId }, context, option);
|
||||
}
|
||||
}
|
||||
|
||||
return pays.length;
|
||||
},
|
||||
} as UpdateTriggerInTxn<EntityDict, 'pay', BRC>,
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue