let update = async function () {
wallet.getTran(token, start, now).then((res) => {
//console.log(JSON.stringify(res))
//console.log(res['data']['activities']);
res['data']['activities'].forEach((tran) => {
if (tran['originalType'] == 'transfer' && tran['originalAction'] == 'creditor') {
let id = tran['reportID']
wallet.CheckTran(token, id).then((res) => {
//console.log(JSON.stringify(res))
let hash = md5(id)
let phone = res['data']['ref1']
let name = res['data']['section2']['column1']['cell2']['value']
let amount = res['data']['amount']
let message = res['data']['personalMessage']['value'];
let tranID = res['data']['section4']['column2']['cell1']['value']
let tranDate = res['data']['section4']['column1']['cell1']['value']
let datetime = moment().tz("Asia/Bangkok").format('YYYY-MM-DD HH:mm:ss')
sql = `SELECT * FROM user_data WHERE transaction_id = ${tranID}`;
con.query(sql, (err, res) => {
if (err) throw err
if (res.length == 0) {
con.query(`INSERT INTO user_data (transaction_id, transfer_date, transfer_phone, transfer_amount, hash, time_create, message, donator, streamer, alerts) VALUES ("${tranID}", "${tranDate}", "${phone}", "${amount}", "${hash}", "${datetime}", "${message}", "${name}", "${streamer}", "0")`, (err, res) => {
if (err) throw err
console.log(`${tranDate} - ${name} โดเนทจาก :${phone} ข้อตวาม :${message} จำนวนเงิน:${amount} หมายเลขอ้างอิง: ${tranID}`);
})
}
})
}).catch()
}
})
})
}
Wallet.prototype.getTran = async function (token, start, end){
let uri = `${api_gettran}${token}/?startDate=${start}&endDate=${end}&limit=20`
let headers = {
"Host": "ขอไม่แสดง url host"
}
return await wallet_request(headers, uri, false)
}