feat: suspension trigger
This commit is contained in:
parent
118852a433
commit
e0581fc39b
4 changed files with 31 additions and 6 deletions
|
|
@ -64,15 +64,18 @@ function cancel (txId) {
|
|||
})
|
||||
}
|
||||
|
||||
function customerHistory (customerId) {
|
||||
function customerHistory (customerId, thresholdDays) {
|
||||
const sql = ` select txIn.id, txIn.created, txIn.fiat, 'cashIn' as direction from cash_in_txs txIn
|
||||
where txIn.customer_id = $1
|
||||
and txIn.created > now() - interval $2
|
||||
union
|
||||
select txOut.id, txOut.created, txOut.fiat, 'cashOut' as direction from cash_out_txs txOut
|
||||
where txOut.customer_id = $1
|
||||
and txOut.created > now() - interval $2
|
||||
order by created;`
|
||||
|
||||
return db.any(sql, [customerId])
|
||||
const days = _.isNil(thresholdDays) ? 0 : thresholdDays
|
||||
return db.any(sql, [customerId, `${days} days`])
|
||||
}
|
||||
|
||||
module.exports = {post, cancel, customerHistory}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue