oak-pay-business/es/triggers/acount.js

21 lines
793 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { DATA_SUBSCRIBER_KEYS } from '../config/constants';
import assert from 'assert';
const triggers = [
{
name: '当account帐户的值发生变化时向订阅者推送',
entity: 'account',
action: ['deposit', 'withdraw', 'withdrawBack', 'consume', 'loan', 'repay'],
check(operation) {
return operation.data.hasOwnProperty('total') || operation.data.hasOwnProperty('avail');
},
when: 'after',
fn: async ({ operation }, context, option) => {
const { id, filter } = operation;
assert(typeof filter?.id === 'string');
context.saveOperationToEvent(id, `${DATA_SUBSCRIBER_KEYS.accountNumberChanged}-${filter.id}`);
return 1;
},
},
];
export default triggers;