1. fix opay api struct
This commit is contained in:
parent
55283ccf45
commit
1e834612cb
@ -265,6 +265,7 @@ const checkDonate = async (loginName = null, opayid = null) => {
|
|||||||
let url = `https://payment.opay.tw/Broadcaster/CheckDonate/${opayid}`
|
let url = `https://payment.opay.tw/Broadcaster/CheckDonate/${opayid}`
|
||||||
let db = await DB.connect()
|
let db = await DB.connect()
|
||||||
|
|
||||||
|
// console.log('check donate :::: ', loginName, opayid)
|
||||||
// donate response format
|
// donate response format
|
||||||
// {
|
// {
|
||||||
// "donateid": "10821396",
|
// "donateid": "10821396",
|
||||||
@ -276,16 +277,22 @@ const checkDonate = async (loginName = null, opayid = null) => {
|
|||||||
try {
|
try {
|
||||||
let result = await axios({
|
let result = await axios({
|
||||||
url,
|
url,
|
||||||
|
data: {},
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
method: 'post'
|
method: 'post'
|
||||||
})
|
})
|
||||||
if ('data' in result && Array.isArray(result.data) && result.data.length > 0) {
|
console.log(loginName, 'http response :::: ', JSON.stringify(result.data))
|
||||||
let ids = result.data.map(t => t.donateid)
|
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 inparams = ids.map((t, idx) => `$${(idx + 1)}`)
|
||||||
let dbres = await db.query({
|
let dbres = await db.query({
|
||||||
text: `select * from "public"."donate_list" where "donate_id" in (${inparams.join(',')})`,
|
text: `select * from "public"."donate_list" where "donate_id" in (${inparams.join(',')})`,
|
||||||
values: [...ids]
|
values: [...ids]
|
||||||
})
|
})
|
||||||
let list = result.data.filter(t => {
|
let list = result.data.lstDonate.filter(t => {
|
||||||
for (let i of dbres.rows) {
|
for (let i of dbres.rows) {
|
||||||
if (i.donate_id === t.donateid) return false
|
if (i.donate_id === t.donateid) return false
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ r.post('/youtube/webhook', getRaw, async (c, n) => {
|
|||||||
resolve(res)
|
resolve(res)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// console.log(JSON.stringify(data, null, 2))
|
console.log(JSON.stringify(data, null, 2))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let ytid = data.feed.entry[0].id[0]
|
let ytid = data.feed.entry[0].id[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user