Commit 447c8003 authored by 周尚's avatar 周尚

修复一些错误, 注释所有业务以检查, 仅保留门店统计部分

parent 98266078
......@@ -56,7 +56,7 @@ function _BASE.sql_concate(self, operate, tb_name, tb_data)
end
end
str = string.sub(str, 0, string.len(str)-1).." "
str = string.sub(str, 0, string.len(str)-2).." "
return str
end
......
local _CS = {}
local NODE_CS = {}
package.path = package.path..";openresty/luabiz/?.lua;;"
......@@ -37,7 +37,7 @@ local function cs_sql(db_st, interval)
end
-- INSERT INTO history table
local sql_update = string.format([[INSERT INTO node_cstail_his SELECT * FROM node_payment ]] ..
local sql_update = string.format([[INSERT INTO node_cs_his SELECT * FROM node_payment ]] ..
[[WHERE EXTRACT(YEAR_MONTH FROM `create_time`) < EXTRACT(YEAR_MONTH FROM DATE_SUB('%s', interval %s month) )]],
os.date("%Y%m%d"), tostring(interval))
......@@ -105,4 +105,4 @@ function _CS.run()
dispatch()
end
return _CS
return NODE_CS
......@@ -40,26 +40,26 @@ handler = function(premature, interval_time)
if nowtime == interval_time then
-- settle features start
node_asb: run()
node_asbdetail: run()
node_card: run()
node_chgrule: run()
node_cs: run()
node_csdetail: run()
node_ms: run()
node_payment: run()
node_psb: run()
node_psbdetail: run()
node_rchg: run()
node_rchgdetail: run()
node_saledetail: run()
node_saleorder: run()
node_shift: run()
node_sku: run()
node_sms: run()
node_smsvip: run()
node_ticket: run()
node_vipacct: run()
-- node_asb: run()
-- node_asbdetail: run()
-- node_card: run()
-- node_chgrule: run()
-- node_cs: run()
-- node_csdetail: run()
-- node_ms: run()
-- node_payment: run()
-- node_psb: run()
-- node_psbdetail: run()
-- node_rchg: run()
-- node_rchgdetail: run()
-- node_saledetail: run()
-- node_saleorder: run()
-- node_shift: run()
-- node_sku: run()
-- node_sms: run()
-- node_smsvip: run()
-- node_ticket: run()
-- node_vipacct: run()
tk_sdt: run()
-- reset interval_time
......
......@@ -17,6 +17,7 @@ local tasks = {}
local __LINE__ = base.__LINE__
local __FILE__ = base.__FILE__
local function sdt_sql(db_st)
base:log(MODULE, "-----------------------> START[TK_SDT]")
......@@ -70,7 +71,7 @@ local function sdt_sql(db_st)
end
if #res ~= 0 then
ngx.say(json.encode({cnt=#res, res=res}))
base:log("S", "[TK_SDT]", "checked already")
base:log("S", "[TK_SDT]", "finished already")
return
end
......@@ -89,7 +90,7 @@ local function sdt_sql(db_st)
[[WHERE date(`create_time`) = date('%s') ]]..
[[AND shop_map_id = %s ]]..
[[GROUP BY op_map_id, mer_map_id, shop_map_id, city_county_id;]],
'20180716',
os.date("%Y%m%d", os.time()-24*60*60),
tostring(shop.shop_map_id))
-- GET online records
......@@ -100,7 +101,7 @@ local function sdt_sql(db_st)
[[AND shop_map_id = %s ]]..
[[AND order_source > 0 ]]..
[[GROUP BY op_map_id, mer_map_id, shop_map_id, city_county_id;]],
'20180716',
os.date("%Y%m%d", os.time()-24*60*60),
tostring(shop.shop_map_id))
......@@ -112,7 +113,7 @@ local function sdt_sql(db_st)
[[AND shop_map_id = %s ]]..
[[AND vip_map_id != 0 ]]..
[[GROUP BY op_map_id, mer_map_id, shop_map_id, city_county_id;]],
'20180716',
os.date("%Y%m%d", os.time()-24*60*60),
tostring(shop.shop_map_id))
-- GET MS records
......@@ -123,7 +124,7 @@ local function sdt_sql(db_st)
[[AND shop_map_id = %s ]]..
[[AND AMT_PROMOTE != 0 ]]..
[[GROUP BY op_map_id, mer_map_id, shop_map_id, city_county_id;]],
'20180716',
os.date("%Y%m%d", os.time()-24*60*60),
tostring(shop.shop_map_id))
-- GET 0000-0900 order
......@@ -131,7 +132,7 @@ local function sdt_sql(db_st)
[[SELECT IFNULL(count (*), 0) time_cnt_0009, IFNULL(SUM(amt_pay), 0) time_amt_0009 ]]..
[[FROM node_saleorder ]]..
[[WHERE shop_map_id = %s ]]..
[[AND `create_time` > '%s' AND `create_time` < '%s' ;]],
[[AND `create_time` > '%s' AND `create_time` < '%s'; ]],
tostring(shop.shop_map_id),
os.date('%Y%m%d000000', os.time()),
os.date('%Y%m%d090000', os.time()))
......@@ -141,7 +142,7 @@ local function sdt_sql(db_st)
[[SELECT IFNULL(count (*), 0) time_cnt_0911, IFNULL(SUM(amt_pay), 0) time_amt_0911 ]]..
[[FROM node_saleorder ]]..
[[WHERE shop_map_id = %s ]]..
[[AND `create_time` > '%s' AND `create_time` < '%s' ;]],
[[AND `create_time` > '%s' AND `create_time` < '%s'; ]],
tostring(shop.shop_map_id),
os.date('%Y%m%d090000', os.time()),
os.date('%Y%m%d110000', os.time()))
......@@ -151,7 +152,7 @@ local function sdt_sql(db_st)
[[SELECT IFNULL(count (*), 0) time_cnt_1113, IFNULL(SUM(amt_pay), 0) time_amt_1113 ]]..
[[FROM node_saleorder ]]..
[[WHERE shop_map_id = %s ]]..
[[AND `create_time` > '%s' AND `create_time` < '%s' ;]],
[[AND `create_time` > '%s' AND `create_time` < '%s'; ]],
tostring(shop.shop_map_id),
os.date('%Y%m%d110000', os.time()),
os.date('%Y%m%d130000', os.time()))
......@@ -161,7 +162,7 @@ local function sdt_sql(db_st)
[[SELECT IFNULL(count (*), 0) time_cnt_1315, IFNULL(SUM(amt_pay), 0) time_amt_1315 ]]..
[[FROM node_saleorder ]]..
[[WHERE shop_map_id = %s ]]..
[[AND `create_time` > '%s' AND `create_time` < '%s' ;]],
[[AND `create_time` > '%s' AND `create_time` < '%s'; ]],
tostring(shop.shop_map_id),
os.date('%Y%m%d130000', os.time()),
os.date('%Y%m%d150000', os.time()))
......@@ -171,7 +172,7 @@ local function sdt_sql(db_st)
[[SELECT IFNULL(count (*), 0) time_cnt_1517, IFNULL(SUM(amt_pay), 0) time_amt_1517 ]]..
[[FROM node_saleorder ]]..
[[WHERE shop_map_id = %s ]]..
[[AND `create_time` > '%s' AND `create_time` < '%s' ;]],
[[AND `create_time` > '%s' AND `create_time` < '%s'; ]],
tostring(shop.shop_map_id),
os.date('%Y%m%d150000', os.time()),
os.date('%Y%m%d170000', os.time()))
......@@ -181,7 +182,7 @@ local function sdt_sql(db_st)
[[SELECT IFNULL(count (*), 0) time_cnt_1719, IFNULL(SUM(amt_pay), 0) time_amt_1719 ]]..
[[FROM node_saleorder ]]..
[[WHERE shop_map_id = %s ]]..
[[AND `create_time` > '%s' AND `create_time` < '%s' ;]],
[[AND `create_time` > '%s' AND `create_time` < '%s'; ]],
tostring(shop.shop_map_id),
os.date('%Y%m%d170000', os.time()),
os.date('%Y%m%d190000', os.time()))
......@@ -191,7 +192,7 @@ local function sdt_sql(db_st)
[[SELECT IFNULL(count (*), 0) time_cnt_1921, IFNULL(SUM(amt_pay), 0) time_amt_1921 ]]..
[[FROM node_saleorder ]]..
[[WHERE shop_map_id = %s ]]..
[[AND `create_time` > '%s' AND `create_time` < '%s' ;]],
[[AND `create_time` > '%s' AND `create_time` < '%s'; ]],
tostring(shop.shop_map_id),
os.date('%Y%m%d190000', os.time()),
os.date('%Y%m%d210000', os.time()))
......@@ -201,13 +202,13 @@ local function sdt_sql(db_st)
[[SELECT IFNULL(count (*), 0) time_cnt_2124, IFNULL(SUM(amt_pay), 0) time_amt_2124 ]]..
[[FROM node_saleorder ]]..
[[WHERE shop_map_id = %s ]]..
[[AND `create_time` > '%s' AND `create_time` < '%s' ;]],
[[AND `create_time` > '%s' AND `create_time` < '%s'; ]],
tostring(shop.shop_map_id),
os.date('%Y%m%d210000', os.time()),
os.date('%Y%m%d235959', os.time()))
-- GET VIP cnt
local sql_vip_cnt = string.format(
sql = sql..string.format(
[[SELECT IFNULL(COUNT(vip_map_id), 0) t_vip_cnt ]]..
[[FROM node_vipacct ]]..
[[WHERE shop_map_id IN ]]..
......@@ -218,7 +219,7 @@ local function sdt_sql(db_st)
tostring(shop['shop_map_id']))
-- GET VIP new cnt
local sql_vip_newcnt = string.format(
sql = sql..string.format(
[[SELECT IFNULL(COUNT(vip_map_id), 0) t_vip_newcnt ]]..
[[FROM node_vipacct ]]..
[[WHERE DATE(create_time) = DATE('%s') ]]..
......@@ -227,28 +228,28 @@ local function sdt_sql(db_st)
[[WHERE shop_grp_id = ]]..
[[(SELECT shop_grp_id FROM node_shopgrp ]]..
[[WHERE mer_map_id = (SELECT mer_map_id FROM tk_shop WHERE shop_map_id = %s)));]],
'20180716',
os.date("%Y%m%d", os.time()-24*60*60),
tostring(shop['shop_map_id']))
-- GET charge summary
local sql_rchg = string.format(
[[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]]..
[[FROM node_rchg ]]..
[[WHERE DATE(create_time) = DATE('%s') ]]..
[[AND shop_map_id = %s]],
'20180716',
tostring(shop.shop_map_id))
-- -- GET charge summary
-- local sql_rchg = string.format(
-- [[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]]..
-- [[FROM node_rchg ]]..
-- [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND shop_map_id = %s]],
-- os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id))
-- GET cash summary
local sql_cash = string.format(
[[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]]..
[[FROM node_payment ]]..
[[WHERE DATE(create_time) = DATE('%s') ]]..
[[AND pay_type_id = 1 ]].. -- paytype
[[AND shop_map_id = %s;]],
'20180716',
tostring(shop.shop_map_id))
-- -- GET cash summary
-- local sql_cash = string.format(
-- [[SELECT IFNULL(COUNT(*), 0) t_charge_cnt, IFNULL(SUM(pay_amt), 0) t_charge_amt ]]..
-- [[FROM node_payment ]]..
-- [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 1 ]].. -- paytype
-- [[AND shop_map_id = %s;]],
-- os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id))
-- -- GET bank summary
-- local sql_cash = string.format(
......@@ -257,7 +258,7 @@ local function sdt_sql(db_st)
-- [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 2 ]].. -- paytype
-- [[AND shop_map_id = %s]],
-- '20180716',
-- os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id))
-- -- GET cash summary
......@@ -267,7 +268,7 @@ local function sdt_sql(db_st)
-- [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 1 ]].. -- paytype
-- [[AND shop_map_id = %s]],
-- '20180716',
-- os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id))
-- -- GET cash summary
......@@ -277,7 +278,7 @@ local function sdt_sql(db_st)
-- [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 1 ]].. -- paytype
-- [[AND shop_map_id = %s]],
-- '20180716',
-- os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id))
-- -- GET cash summary
......@@ -287,7 +288,7 @@ local function sdt_sql(db_st)
-- [[WHERE DATE(create_time) = DATE('%s') ]]..
-- [[AND pay_type_id = 1 ]].. -- paytype
-- [[AND shop_map_id = %s]],
-- '20180716',
-- os.date("%Y%m%d", os.time()-24*60*60),
-- tostring(shop.shop_map_id))
......
......@@ -63,7 +63,7 @@ http {
index index.html index.htm;
}
location /mysq {
location /mysql {
content_by_lua_block {
local cjson = require "cjson"
local mysql = require "resty.mysql"
......
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