From 9ce747ea8fa1211647694faeec98f66b85130450 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 23 Aug 2018 23:21:49 +0800 Subject: [PATCH] modify get donate bar api --- route/api/twitch/index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/route/api/twitch/index.js b/route/api/twitch/index.js index b5707a8..1fdd90a 100644 --- a/route/api/twitch/index.js +++ b/route/api/twitch/index.js @@ -159,6 +159,26 @@ r.get('/channel/:chid/opay/bar', async (c, n) => { if (result.rowCount === 0) setting = {} setting = result.rows[0] + if (result.rowCount > 0) { + text = `select sum(list.price) as total from "public"."opay_donate_list" list + left join "public"."twitch" tw + on tw.opayid = list.opayid + where + tw.opayid != '' + and tw.id = $1 + and ctime >= $2 + group by list.opayid` + values = [chid, setting.start_date] + let priceResult = await c.db.query({ + text, values + }) + if (priceResult.rowCount > 0) { + setting.total = priceResult.row[0].price + } else { + setting.total = 0 + } + } + c.obj = resObject('Success', {setting}) })