fix redeem bugs
This commit is contained in:
parent
91e1077daa
commit
dd7d06f38b
4 changed files with 17 additions and 6 deletions
|
|
@ -28,7 +28,7 @@ function stateChange (deviceId, deviceTime, rec) {
|
|||
return dbm.machineEvent(event)
|
||||
}
|
||||
|
||||
function toObj (row) {
|
||||
function toCashOutTx (row) {
|
||||
if (!row) return null
|
||||
|
||||
const keys = _.keys(row)
|
||||
|
|
@ -44,7 +44,7 @@ function toObj (row) {
|
|||
newObj[objKey] = row[key]
|
||||
})
|
||||
|
||||
return newObj
|
||||
return _.set('direction', 'cashOut', newObj)
|
||||
}
|
||||
|
||||
function fetchPhoneTx (phone) {
|
||||
|
|
@ -55,7 +55,7 @@ function fetchPhoneTx (phone) {
|
|||
const values = [phone, false, TRANSACTION_EXPIRATION]
|
||||
|
||||
return db.any(sql, values)
|
||||
.then(_.map(toObj))
|
||||
.then(_.map(toCashOutTx))
|
||||
.then(txs => {
|
||||
const confirmedTxs = txs.filter(tx => R.contains(tx.status, ['instant', 'confirmed']))
|
||||
if (confirmedTxs.length > 0) {
|
||||
|
|
@ -75,7 +75,7 @@ function fetchStatusTx (txId, status) {
|
|||
const sql = 'select * from cash_out_txs where id=$1'
|
||||
|
||||
return db.oneOrNone(sql, [txId])
|
||||
.then(toObj)
|
||||
.then(toCashOutTx)
|
||||
.then(tx => {
|
||||
if (!tx) throw httpError('No transaction', 404)
|
||||
if (tx.status === status) throw httpError('Not Modified', 304)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue