Commit e9a9c211 authored by 周尚's avatar 周尚

fix paytype bug

parent 9ed7a0f8
...@@ -108,8 +108,8 @@ local function sdt_sql(tk_biz, tk_control, total_time) ...@@ -108,8 +108,8 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- CHECK if exists -- CHECK if exists
local sql_check = string.format( local sql_check = string.format(
[[SELECT * FROM tk_sdt WHERE DATE(total_date) = DATE('%s') ]].. [[SELECT * FROM tk_sdt WHERE DATE(total_date) = DATE('%s') ]]..
[[AND shop_map_id = %s]], [[AND shop_map_id = %s ]],
os.date('%Y%m%d',os.time()), os.date('%Y%m%d',total_time),
tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
res, err, errcode, sqlstate = db_biz:query(sql_check) res, err, errcode, sqlstate = db_biz:query(sql_check)
if not res then if not res then
...@@ -325,11 +325,13 @@ local function sdt_sql(tk_biz, tk_control, total_time) ...@@ -325,11 +325,13 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET cash summary -- GET cash summary
table.insert(sql, string.format( table.insert(sql, string.format(
[[SELECT IFNULL(COUNT(*), 0) pay_cash_cnt, IFNULL(SUM(pay_amt), 0) pay_cash_amt ]].. [[SELECT IFNULL(COUNT(p.order_no), 0) pay_cash_cnt, IFNULL(SUM(p.pay_amt), 0) pay_cash_amt ]]..
[[FROM node_payment ]].. [[FROM node_payment p, node_saleorder s ]]..
[[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE p.order_no = s.order_no ]]..
[[AND pay_type_id = 1 ]].. -- paytype [[AND DATE(p.create_time) = DATE('%s') ]]..
[[AND shop_map_id = %s;]], [[AND p.pay_type_id = 1 ]].. -- paytype
[[AND p.shop_map_id = %s ]]..
[[AND s.order_status = 0;]],
os.date("%Y%m%d", total_time-24*60*60), os.date("%Y%m%d", total_time-24*60*60),
tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
) )
...@@ -337,23 +339,28 @@ local function sdt_sql(tk_biz, tk_control, total_time) ...@@ -337,23 +339,28 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET WeiXin summary -- GET WeiXin summary
table.insert(sql, string.format( table.insert(sql, string.format(
[[SELECT IFNULL(COUNT(*), 0) pay_wx_cnt, IFNULL(SUM(pay_amt), 0) pay_wx_amt ]].. [[SELECT IFNULL(COUNT(p.order_no), 0) pay_wx_cnt, IFNULL(SUM(p.pay_amt), 0) pay_wx_amt ]]..
[[FROM node_payment ]].. [[FROM node_payment p, node_saleorder s ]]..
[[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE p.order_no = s.order_no ]]..
[[AND pay_type_id = 2 ]].. -- paytype [[AND DATE(p.create_time) = DATE('%s') ]]..
[[AND shop_map_id = %s;]], [[AND p.pay_type_id = 2 ]].. -- paytype
[[AND p.shop_map_id = %s ]]..
[[AND s.order_status = 0;]],
os.date("%Y%m%d", total_time-24*60*60), os.date("%Y%m%d", total_time-24*60*60),
tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
) )
-- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[17]) -- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[17])
-- GET AliPay summary -- GET AliPay summary
table.insert(sql, string.format( table.insert(sql, string.format(
[[SELECT IFNULL(COUNT(*), 0) pay_alipay_cnt, IFNULL(SUM(pay_amt), 0) pay_alipay_amt ]].. [[SELECT IFNULL(COUNT(p.order_no), 0) pay_alipay_cnt, IFNULL(SUM(p.pay_amt), 0) pay_alipay_amt ]]..
[[FROM node_payment ]].. [[FROM node_payment p, node_saleorder s ]]..
[[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE p.order_no = s.order_no ]]..
[[AND pay_type_id = 3 ]].. -- paytype [[AND DATE(p.create_time) = DATE('%s') ]]..
[[AND shop_map_id = %s;]], [[AND p.pay_type_id = 3 ]].. -- paytype
[[AND p.shop_map_id = %s ]]..
[[AND s.order_status = 0;]],
os.date("%Y%m%d", total_time-24*60*60), os.date("%Y%m%d", total_time-24*60*60),
tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
) )
...@@ -361,11 +368,13 @@ local function sdt_sql(tk_biz, tk_control, total_time) ...@@ -361,11 +368,13 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET bank summary -- GET bank summary
table.insert(sql, string.format( table.insert(sql, string.format(
[[SELECT IFNULL(COUNT(*), 0) pay_bank_cnt, IFNULL(SUM(pay_amt), 0) pay_bank_amt ]].. [[SELECT IFNULL(COUNT(p.order_no), 0) pay_bank_cnt, IFNULL(SUM(p.pay_amt), 0) pay_bank_amt ]]..
[[FROM node_payment ]].. [[FROM node_payment p, node_saleorder s ]]..
[[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE p.order_no = s.order_no ]]..
[[AND pay_type_id = 4 ]].. -- paytype [[AND DATE(p.create_time) = DATE('%s') ]]..
[[AND shop_map_id = %s;]], [[AND p.pay_type_id = 4 ]].. -- paytype
[[AND p.shop_map_id = %s ]]..
[[AND s.order_status = 0;]],
os.date("%Y%m%d", total_time-24*60*60), os.date("%Y%m%d", total_time-24*60*60),
tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
) )
...@@ -373,11 +382,13 @@ local function sdt_sql(tk_biz, tk_control, total_time) ...@@ -373,11 +382,13 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET vipcard summary -- GET vipcard summary
table.insert(sql, string.format( table.insert(sql, string.format(
[[SELECT IFNULL(COUNT(*), 0) pay_vipcard_cnt, IFNULL(SUM(pay_amt), 0) pay_vipcard_amt ]].. [[SELECT IFNULL(COUNT(p.order_no), 0) pay_vipcard_cnt, IFNULL(SUM(p.pay_amt), 0) pay_vipcard_amt ]]..
[[FROM node_payment ]].. [[FROM node_payment p, node_saleorder s ]]..
[[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE p.order_no = s.order_no ]]..
[[AND (pay_type_id = 5 OR pay_type_id = 6) ]].. -- paytype [[AND DATE(p.create_time) = DATE('%s') ]]..
[[AND shop_map_id = %s;]], [[AND (p.pay_type_id = 5 OR p.pay_type_id = 6) ]].. -- paytype
[[AND p.shop_map_id = %s ]]..
[[AND s.order_status = 0;]],
os.date("%Y%m%d", total_time-24*60*60), os.date("%Y%m%d", total_time-24*60*60),
tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
) )
...@@ -385,17 +396,21 @@ local function sdt_sql(tk_biz, tk_control, total_time) ...@@ -385,17 +396,21 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET othpay summary -- GET othpay summary
table.insert(sql, string.format( table.insert(sql, string.format(
[[SELECT IFNULL(COUNT(*), 0) pay_othpay_cnt, IFNULL(SUM(pay_amt), 0) pay_othpay_amt ]].. [[SELECT IFNULL(COUNT(p.order_no), 0) pay_othpay_cnt, IFNULL(SUM(p.pay_amt), 0) pay_othpay_amt ]]..
[[FROM node_payment ]].. [[FROM node_payment p, node_saleorder s ]]..
[[WHERE DATE(create_time) = DATE('%s') ]].. [[WHERE p.order_no = s.order_no ]]..
[[AND pay_type_id = 9 ]].. -- paytype [[AND DATE(p.create_time) = DATE('%s') ]]..
[[AND shop_map_id = %s;]], [[AND p.pay_type_id = 9 ]].. -- paytype
[[AND p.shop_map_id = %s ]]..
[[AND s.order_status = 0;]],
os.date("%Y%m%d", total_time-24*60*60), os.date("%Y%m%d", total_time-24*60*60),
tostring(shop.shop_map_id)) tostring(shop.shop_map_id))
) )
-- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[21]) -- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[21])
res, err, errcode, sqlstate = db_biz:query(table.concat(sql)) res, err, errcode, sqlstate = db_biz:query(table.concat(sql))
log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: ", sql[1])
if not res then if not res then
log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "ERR: " .. "failed to query:", json.encode(tk_biz), ":", err, ":", errcode, ":", sqlstate, ".") log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "ERR: " .. "failed to query:", json.encode(tk_biz), ":", err, ":", errcode, ":", sqlstate, ".")
return return
...@@ -413,8 +428,8 @@ local function sdt_sql(tk_biz, tk_control, total_time) ...@@ -413,8 +428,8 @@ local function sdt_sql(tk_biz, tk_control, total_time)
while err == "again" do while err == "again" do
-- repeat -- repeat
res, err, errcode, sqlstate = db_biz:read_result() res, err, errcode, sqlstate = db_biz:read_result()
log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: ", sql[j])
if not res then if not res then
log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "ERR: " .. "bad sql: ", sql[j])
log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "ERR: " .. "bad result #", j, ": ", err, ": ", errcode, ": ", sqlstate, ".") log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "ERR: " .. "bad result #", j, ": ", err, ": ", errcode, ": ", sqlstate, ".")
return ngx.exit(500) return ngx.exit(500)
end end
......
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