Commit 0d62adfd authored by 周尚's avatar 周尚

完善门店日统计 - 支付方式

parent 96335ba7
...@@ -258,64 +258,74 @@ local function sdt_sql(tk_biz, tk_control) ...@@ -258,64 +258,74 @@ local function sdt_sql(tk_biz, tk_control)
tostring(shop['shop_map_id'])) tostring(shop['shop_map_id']))
-- -- GET charge summary -- GET charge summary
-- local sql_rchg = string.format( sql = sql..string.format(
-- [[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]].. [[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]]..
-- [[FROM node_rchg ]].. [[FROM node_rchg ]]..
-- [[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND shop_map_id = %s]], [[AND shop_map_id = %s]],
-- os.date("%Y%m%d", os.time()-24*60*60), os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
-- -- GET cash summary -- GET cash summary
-- local sql_cash = string.format( sql = sql..string.format(
-- [[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]].. [[SELECT IFNULL(COUNT(*), 0) pay_cash_cnt, IFNULL(SUM(pay_amt), 0) pay_cash_amt ]]..
-- [[FROM node_payment ]].. [[FROM node_payment ]]..
-- [[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 1 ]].. -- paytype [[AND pay_type_id = 1 ]].. -- paytype
-- [[AND shop_map_id = %s;]], [[AND shop_map_id = %s;]],
-- os.date("%Y%m%d", os.time()-24*60*60), os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
-- -- GET bank summary -- GET WeiXin summary
-- local sql_cash = string.format( sql = sql..string.format(
-- [[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]].. [[SELECT IFNULL(COUNT(*), 0) pay_wx_cnt, IFNULL(SUM(pay_amt), 0) pay_wx_amt ]]..
-- [[FROM node_payment ]].. [[FROM node_payment ]]..
-- [[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 2 ]].. -- paytype [[AND pay_type_id = 2 ]].. -- paytype
-- [[AND shop_map_id = %s]], [[AND shop_map_id = %s;]],
-- os.date("%Y%m%d", os.time()-24*60*60), os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
-- -- GET cash summary -- GET AliPay summary
-- local sql_cash = string.format( sql = sql..string.format(
-- [[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]].. [[SELECT IFNULL(COUNT(*), 0) pay_alipay_cnt, IFNULL(SUM(pay_amt), 0) pay_alipay_amt ]]..
-- [[FROM node_payment ]].. [[FROM node_payment ]]..
-- [[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 1 ]].. -- paytype [[AND pay_type_id = 3 ]].. -- paytype
-- [[AND shop_map_id = %s]], [[AND shop_map_id = %s;]],
-- os.date("%Y%m%d", os.time()-24*60*60), os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
-- -- GET cash summary -- GET bank summary
-- local sql_cash = string.format( sql = sql..string.format(
-- [[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]].. [[SELECT IFNULL(COUNT(*), 0) pay_bank_cnt, IFNULL(SUM(pay_amt), 0) pay_bank_amt ]]..
-- [[FROM node_payment ]].. [[FROM node_payment ]]..
-- [[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 1 ]].. -- paytype [[AND pay_type_id = 4 ]].. -- paytype
-- [[AND shop_map_id = %s]], [[AND shop_map_id = %s;]],
-- os.date("%Y%m%d", os.time()-24*60*60), os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
-- -- GET cash summary -- GET vipcard summary
-- local sql_cash = string.format( sql = sql..string.format(
-- [[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]].. [[SELECT IFNULL(COUNT(*), 0) pay_vipcard_cnt, IFNULL(SUM(pay_amt), 0) pay_vipcard_amt ]]..
-- [[FROM node_payment ]].. [[FROM node_payment ]]..
-- [[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 1 ]].. -- paytype [[AND (pay_type_id = 5 OR pay_type_id = 6) ]].. -- paytype
-- [[AND shop_map_id = %s]], [[AND shop_map_id = %s;]],
-- os.date("%Y%m%d", os.time()-24*60*60), os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
-- GET othpay summary
sql = sql..string.format(
[[SELECT IFNULL(COUNT(*), 0) pay_othpay_cnt, IFNULL(SUM(pay_amt), 0) pay_vipcard_amt ]]..
[[FROM node_payment ]]..
[[WHERE DATE(create_time) = DATE('%s') ]]..
[[AND pay_type_id = 9 ]].. -- paytype
[[AND shop_map_id = %s;]],
os.date("%Y%m%d", os.time()-24*60*60),
tostring(shop.shop_map_id))
res, err, errcode, sqlstate = db_biz:query(sql) res, err, errcode, sqlstate = db_biz:query(sql)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment