1. fix opay api struct

This commit is contained in:
Jay 2018-08-11 12:58:34 +08:00
parent 55283ccf45
commit 1e834612cb
2 changed files with 11 additions and 4 deletions

View File

@ -265,6 +265,7 @@ const checkDonate = async (loginName = null, opayid = null) => {
let url = `https://payment.opay.tw/Broadcaster/CheckDonate/${opayid}`
let db = await DB.connect()
// console.log('check donate :::: ', loginName, opayid)
// donate response format
// {
// "donateid": "10821396",
@ -276,16 +277,22 @@ const checkDonate = async (loginName = null, opayid = null) => {
try {
let result = await axios({
url,
data: {},
headers: {
'Content-Type': 'application/json'
},
method: 'post'
})
if ('data' in result && Array.isArray(result.data) && result.data.length > 0) {
let ids = result.data.map(t => t.donateid)
console.log(loginName, 'http response :::: ', JSON.stringify(result.data))
if ('data' in result && 'lstDonate' in result.data && Array.isArray(result.data.lstDonate) && result.data.lstDonate.length > 0) {
console.log(`${loginName} donate :::: ${JSON.stringify(result.data)}`)
let ids = result.data.lstDonate.map(t => t.donateid)
let inparams = ids.map((t, idx) => `$${(idx + 1)}`)
let dbres = await db.query({
text: `select * from "public"."donate_list" where "donate_id" in (${inparams.join(',')})`,
values: [...ids]
})
let list = result.data.filter(t => {
let list = result.data.lstDonate.filter(t => {
for (let i of dbres.rows) {
if (i.donate_id === t.donateid) return false
}

View File

@ -48,7 +48,7 @@ r.post('/youtube/webhook', getRaw, async (c, n) => {
resolve(res)
})
})
// console.log(JSON.stringify(data, null, 2))
console.log(JSON.stringify(data, null, 2))
try {
let ytid = data.feed.entry[0].id[0]