Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openresty
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tangku7
openresty
Commits
50b2bd82
Commit
50b2bd82
authored
Jul 18, 2018
by
周尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化TK_SDT批处理部分
parent
2aa571ea
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
823 additions
and
232 deletions
+823
-232
README.org
README.org
+4
-2
nginx/conf/nginx.conf
nginx/conf/nginx.conf
+58
-2
nginx/lua/async.lua
nginx/lua/async.lua
+4
-4
nginx/lua/base.lua
nginx/lua/base.lua
+38
-3
nginx/lua/settle/node_asb.lua
nginx/lua/settle/node_asb.lua
+11
-13
nginx/lua/settle/node_asbdetail.lua
nginx/lua/settle/node_asbdetail.lua
+10
-13
nginx/lua/settle/node_card.lua
nginx/lua/settle/node_card.lua
+14
-15
nginx/lua/settle/node_chgrule.lua
nginx/lua/settle/node_chgrule.lua
+8
-9
nginx/lua/settle/node_cs.lua
nginx/lua/settle/node_cs.lua
+14
-14
nginx/lua/settle/node_csdetail.lua
nginx/lua/settle/node_csdetail.lua
+10
-11
nginx/lua/settle/node_ms.lua
nginx/lua/settle/node_ms.lua
+9
-12
nginx/lua/settle/node_payment.lua
nginx/lua/settle/node_payment.lua
+10
-11
nginx/lua/settle/node_psb.lua
nginx/lua/settle/node_psb.lua
+6
-6
nginx/lua/settle/node_psbdetail.lua
nginx/lua/settle/node_psbdetail.lua
+6
-6
nginx/lua/settle/node_rchg.lua
nginx/lua/settle/node_rchg.lua
+11
-11
nginx/lua/settle/node_rchgdetail.lua
nginx/lua/settle/node_rchgdetail.lua
+10
-12
nginx/lua/settle/node_saledetail.lua
nginx/lua/settle/node_saledetail.lua
+10
-11
nginx/lua/settle/node_saleorder.lua
nginx/lua/settle/node_saleorder.lua
+14
-15
nginx/lua/settle/node_shift.lua
nginx/lua/settle/node_shift.lua
+10
-11
nginx/lua/settle/node_sku.lua
nginx/lua/settle/node_sku.lua
+8
-9
nginx/lua/settle/node_sms.lua
nginx/lua/settle/node_sms.lua
+10
-11
nginx/lua/settle/node_smsvip.lua
nginx/lua/settle/node_smsvip.lua
+10
-11
nginx/lua/settle/node_ticket.lua
nginx/lua/settle/node_ticket.lua
+8
-8
nginx/lua/settle/node_vipacct.lua
nginx/lua/settle/node_vipacct.lua
+4
-4
nginx/lua/settle/settle.lua
nginx/lua/settle/settle.lua
+45
-8
nginx/lua/settle/tk_sdt.lua
nginx/lua/settle/tk_sdt.lua
+481
-0
No files found.
README.org
View file @
50b2bd82
...
...
@@ -39,6 +39,8 @@
10. [X] 门店盘库明细
11. [X] 短信流水
12. [X] 交班记录
5. [
] 统计汇总
1. [
] 门店日统计
5. [
-
] 统计汇总
1. [
X
] 门店日统计
2. [ ] 会员日统计
3. [ ] 调度服务
1. [ ]
nginx/conf/nginx.conf
View file @
50b2bd82
...
...
@@ -63,6 +63,62 @@ http {
index
index.html
index.htm
;
}
location
/mysq
{
content_by_lua_block
{
local
cjson
=
require
"cjson"
local
mysql
=
require
"resty.mysql"
local
db
=
mysql:new()
local
ok,
err,
errcode,
sqlstate
=
db:connect(
{
host
=
"127.0.0.1",
port
=
3306
,
database
=
"test",
user
=
"root",
password
=
""
}
)
if
not
ok
then
ngx.log(ngx.ERR,
"failed
to
connect:
",
err,
":
",
errcode,
"
",
sqlstate)
return
ngx.exit(500)
end
res,
err,
errcode,
sqlstate
=
db:query("select
1
;
select
2
;
select
3
;
"
)
if
not
res
then
ngx.log(ngx.ERR,
"bad
result
#1: ", err, ": ", errcode, ": ", sqlstate, ".")
return
ngx.exit(500)
end
ngx.say("result
#1: ", cjson.encode(res))
local
i
=
2
while
err
==
"again"
do
res,
err,
errcode,
sqlstate
=
db:read_result()
if
not
res
then
ngx.log(ngx.ERR,
"bad
result
#", i, ": ", err, ": ", errcode, ": ", sqlstate, ".")
return
ngx.exit(500)
end
ngx.say("result
#", i, ": ", cjson.encode(res))
i
=
i
+
1
end
local
ok,
err
=
db:set_keepalive(10000,
50
)
if
not
ok
then
ngx.log(ngx.ERR,
"failed
to
set
keepalive:
",
err)
ngx.exit(500)
end
}
}
location
/test
{
content_by_lua_block
{
package.path
=
package.path.."
;
/users/zhoush/openresty/nginx/lua/?.lua
;
;
"
package.path
=
package.path.."
;
/users/zhoush/openresty/nginx/lua/settle/?.lua
;
;
"
tk_sdt
=
require
("tk_sdt")
tk_sdt:run()
}
}
location
/echo
{
content_by_lua_block
{
...
...
nginx/lua/async.lua
View file @
50b2bd82
...
...
@@ -27,7 +27,7 @@ local function async_sql_ins()
reqs
[
'out_transaction_no'
],
reqs
[
'out_trade_no'
],
reqs
[
'transaction_no'
],
pay_type
,
reqs
[
'total_amount'
]
*
100
,
reqs
[
'time_start'
],
"0"
,
reqs
[
'currency'
],
rate
)
base
:
print_
log
(
"ASYNC_SQL"
,
ins_sql
)
base
:
log
(
"ASYNC_SQL"
,
ins_sql
)
return
ins_sql
end
...
...
@@ -35,7 +35,7 @@ local function async_db(ins_sql)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"ASYNC_DB"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"ASYNC_DB"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -52,13 +52,13 @@ local function async_db(ins_sql)
}
if
not
ok
then
base
:
print_
log
(
"ASYNC_DB"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"ASYNC_DB"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
ins_sql
)
if
not
res
then
base
:
print_
log
(
"ASYNC_DB"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"ASYNC_DB"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
return
end
...
...
nginx/lua/base.lua
View file @
50b2bd82
...
...
@@ -2,7 +2,11 @@ local _BASE = {}
local
json
=
require
(
'cjson'
)
function
_BASE
.
print_log
(
self
,
fname
,
...
)
function
_BASE
.
__FILE__
()
return
debug.getinfo
(
2
,
'S'
).
source
end
function
_BASE
.
__LINE__
()
return
debug.getinfo
(
2
,
'l'
).
currentline
end
function
_BASE
.
log
(
self
,
fname
,
...
)
local
fpath
=
string.format
(
"/Users/zhoush/openresty/nginx/logs/%s_%s.log"
,
tostring
(
fname
),
os.date
(
"%Y%m%d"
))
local
f
=
io.open
(
fpath
,
"a+"
)
local
str
=
""
...
...
@@ -10,7 +14,9 @@ function _BASE.print_log(self, fname, ...)
local
tmp
=
tostring
(
select
(
i
,
...
))
str
=
string.format
(
"%s %s"
,
str
,
tmp
)
end
f
:
write
(
os.date
(
"<%Y-%m-%d %H:%M:%S> "
)
..
str
)
f
:
write
(
os.date
(
"<%Y-%m-%d %H:%M:%S> "
))
-- f:write(...)
f
:
write
(
str
)
f
:
write
(
"
\n
"
)
f
:
close
()
end
...
...
@@ -30,7 +36,36 @@ function _BASE.close_db(self, db)
local
ok
,
err
=
db
:
close
()
if
not
ok
then
_BASE
.
print_log
(
"failed to close:"
,
err
)
_BASE
.
log
(
"failed to close:"
,
err
)
end
return
end
function
_BASE
.
sql_concate
(
self
,
operate
,
tb_name
,
tb_data
)
local
str
=
""
if
string.lower
(
string.sub
(
operate
,
0
,
6
))
==
'insert'
then
str
=
"INSERT INTO "
..
tb_name
..
" SET "
elseif
string.lower
(
string.sub
(
operate
,
0
,
6
))
==
'update'
then
str
=
"UPDATE "
..
tb_name
..
" SET "
end
for
k
,
v
in
pairs
(
tb_data
)
do
if
type
(
v
)
==
"number"
then
str
=
str
..
string.format
(
"%s = %d, "
,
k
,
v
)
elseif
type
(
v
)
==
"string"
then
str
=
str
..
string.format
(
"%s = '%s', "
,
k
,
v
)
end
end
str
=
string.sub
(
str
,
0
,
string.len
(
str
)
-
1
)
..
" "
return
str
end
function
_BASE
.
tonumber
(
self
,
str
)
if
str
==
nil
then
return
0
else
return
tonumber
(
str
)
end
end
...
...
nginx/lua/settle/node_asb.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,10 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
asb_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +17,7 @@ local function asb_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[ASB]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[ASB]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +33,7 @@ local function asb_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_ASB]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_ASB]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +44,8 @@ local function asb_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_ASB]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_ASB"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_ASB]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_ASB
"
,
sql_update
)
return
end
...
...
@@ -57,8 +57,8 @@ local function asb_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_ASB]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_ASB"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_ASB]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_ASB
"
,
sql_delete
)
return
end
end
...
...
@@ -95,8 +95,6 @@ local function dispatch()
end
function
_ASB
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_asbdetail.lua
View file @
50b2bd82
...
...
@@ -5,11 +5,10 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
tasks
=
{}
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
function
asbdetail_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +16,7 @@ local function asbdetail_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[ASBDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[ASBDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +32,7 @@ local function asbdetail_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_ASBDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_ASBDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +43,8 @@ local function asbdetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_ASBDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_ASBDETAIL"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_ASBDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_ASBDETAIL
"
,
sql_update
)
return
end
...
...
@@ -57,8 +56,8 @@ local function asbdetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_ASBDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_ASBDETAIL"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_ASBDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_ASBDETAIL
"
,
sql_delete
)
return
end
end
...
...
@@ -95,8 +94,6 @@ local function dispatch()
end
function
_ASBDETAIL
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_card.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,11 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
card_sql
(
db_st
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +18,7 @@ local function card_sql(db_st)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[CARD]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[CARD]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +34,7 @@ local function card_sql(db_st)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_CARD]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_CARD]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -42,8 +43,8 @@ local function card_sql(db_st)
local
sql_update
=
[[UPDATE node_card SET card_status = 8 WHERE now() > card_exp]]
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_CARD]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_CARD"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_CARD]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_CARD
"
,
sql_update
)
return
end
...
...
@@ -51,8 +52,8 @@ local function card_sql(db_st)
local
sql_update
=
[[UPDATE node_card SET card_lbal_amt = card_cbal_amt, card_lbal_count = card_cbal_count]]
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_CARD]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_CARD"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_CARD]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_CARD
"
,
sql_update
)
return
end
...
...
@@ -60,8 +61,8 @@ local function card_sql(db_st)
local
sql_insert
=
string.format
(
[[INSERT INTO node_card_his SELECT * FROM node_card WHERE DATE(`create_time`) < DATE('%s')]]
,
os.date
(
"%Y%m%d%H%M%S"
))
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_insert
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_CARD]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_CARD"
,
"<SQL>
"
,
sql_insert
)
base
:
log
(
"S"
,
"[NODE_CARD]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_CARD
"
,
sql_insert
)
return
end
...
...
@@ -70,8 +71,8 @@ local function card_sql(db_st)
local
sql_delete
=
string.format
(
[[DELETE FROM node_card WHERE DATE(`create_time`) < DATE('%s')]]
,
os.date
(
"%Y%m%d%H%M%S"
))
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_CARD]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_CARD"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_CARD]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_CARD
"
,
sql_delete
)
return
end
end
...
...
@@ -108,8 +109,6 @@ local function dispatch()
end
function
_NC
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
for
i
=
1
,
#
dbs_st
.
tk_biz
do
async
(
dbs_st
.
tk_biz
[
i
])
...
...
nginx/lua/settle/node_chgrule.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,11 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
chgrule_sql
(
db_st
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +18,7 @@ local function chgrule_sql(db_st)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[CHGRULE]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[CHGRULE]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +34,7 @@ local function chgrule_sql(db_st)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_CHGRULE]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_CHGRULE]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -42,8 +43,8 @@ local function chgrule_sql(db_st)
local
sql_update
=
[[UPDATE node_chgrule SET rule_status = 1 WHERE now() > `DATE_end`]]
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_CHGRULE]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_CHGRULE"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_CHGRULE]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_CHGRULE
"
,
sql_update
)
return
end
end
...
...
@@ -80,8 +81,6 @@ local function dispatch()
end
function
_CR
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
for
i
=
1
,
#
dbs_st
.
tk_biz
do
async
(
dbs_st
.
tk_biz
[
i
])
...
...
nginx/lua/settle/node_cs.lua
View file @
50b2bd82
...
...
@@ -5,19 +5,18 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
base
=
require
(
'base'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
cs_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
local
ERR
=
ngx
.
ERR
base
:
log
(
MODULE
,
"-----------------------> START[node_cs]"
)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[CS]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[CS]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +32,7 @@ local function cs_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_CS]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_CS]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,23 +43,26 @@ local function cs_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_CS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_CS"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_CS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_CS
"
,
sql_update
)
return
end
-- DELETE current tables record
local
sql_delete
=
string.format
(
[[DELETE FROM node_cs ]]
..
local
sql_delete
=
string.format
(
[[DELETE FROM node_cs ]]
..
[[WHERE EXTRACT(YEAR_MONTH FROM `create_time`) < EXTRACT(YEAR_MONTH FROM DATE_SUB('%s', interval %s month))]]
,
os.date
(
'%Y%m%d'
),
tostring
(
interval
))
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_CS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_CS"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_CS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_CS
"
,
sql_delete
)
return
end
base
:
log
(
MODULE
,
"[NODE_SALEORDER]"
,
"-----------------------> END[node_cs]"
)
end
...
...
@@ -95,8 +97,6 @@ local function dispatch()
end
function
_CS
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_csdetail.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,11 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
csdetail_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +18,7 @@ local function csdetail_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[CSDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[CSDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +34,7 @@ local function csdetail_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_CSDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_CSDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +45,8 @@ local function csdetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_CSDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_CSDETAIL"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_CSDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_CSDETAIL
"
,
sql_update
)
return
end
...
...
@@ -57,8 +58,8 @@ local function csdetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_CSDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_CSDETAIL"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_CSDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_CSDETAIL
"
,
sql_delete
)
return
end
end
...
...
@@ -95,8 +96,6 @@ local function dispatch()
end
function
_CSDETAIL
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_ms.lua
View file @
50b2bd82
...
...
@@ -2,14 +2,13 @@ local _MS = {}
package.path
=
package.path
..
";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
ms_sql
(
db_st
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +16,7 @@ local function ms_sql(db_st)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[MS]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[MS]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,17 +32,17 @@ local function ms_sql(db_st)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_MS]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_MS]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
--
DELE
TE invalid rows
--
UPDA
TE invalid rows
-- local sql_delete = [[DELETE FROM node_MS WHERE (card_status != 0 AND card_status !=1) or now() > card_exp]]
local
sql_update
=
[[UPDATE node_ms SET ms_status = 1 WHERE now() > `ms_date_end`]]
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_MS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_MS"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_MS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_MS
"
,
sql_update
)
return
end
end
...
...
@@ -80,8 +79,6 @@ local function dispatch()
end
function
_MS
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
for
i
=
1
,
#
dbs_st
.
tk_biz
do
async
(
dbs_st
.
tk_biz
[
i
])
...
...
nginx/lua/settle/node_payment.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,11 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
payment_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +18,7 @@ local function payment_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[PAYMENT]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[PAYMENT]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +34,7 @@ local function payment_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_PAYMENT]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_PAYMENT]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +45,8 @@ local function payment_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_PAYMENT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_PAYMENT"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_PAYMENT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_PAYMENT
"
,
sql_update
)
return
end
...
...
@@ -57,8 +58,8 @@ local function payment_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_PAYMENT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_PAYMENT"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_PAYMENT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_PAYMENT
"
,
sql_delete
)
return
end
end
...
...
@@ -95,8 +96,6 @@ local function dispatch()
end
function
_PAYMENT
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_psb.lua
View file @
50b2bd82
...
...
@@ -17,7 +17,7 @@ local function psb_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[PSB]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[PSB]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +33,7 @@ local function psb_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_PSB]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_PSB]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +44,8 @@ local function psb_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_PSB]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_PSB"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_PSB]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_PSB
"
,
sql_update
)
return
end
...
...
@@ -57,8 +57,8 @@ local function psb_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_PSB]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_PSB"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_PSB]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_PSB
"
,
sql_delete
)
return
end
end
...
...
nginx/lua/settle/node_psbdetail.lua
View file @
50b2bd82
...
...
@@ -17,7 +17,7 @@ local function psbdetail_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[PSBDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[PSBDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +33,7 @@ local function psbdetail_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_PSBDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_PSBDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +44,8 @@ local function psbdetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_PSBDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_PSBDETAIL"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_PSBDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_PSBDETAIL
"
,
sql_update
)
return
end
...
...
@@ -57,8 +57,8 @@ local function psbdetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_PSBDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_PSBDETAIL"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_PSBDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_PSBDETAIL
"
,
sql_delete
)
return
end
end
...
...
nginx/lua/settle/node_rchg.lua
View file @
50b2bd82
...
...
@@ -6,16 +6,18 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
tasks
=
{}
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
function
rchg_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
local
ERR
=
ngx
.
ERR
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[RCHG]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[RCHG]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -31,7 +33,7 @@ local function rchg_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_RCHG]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_RCHG]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -41,8 +43,8 @@ local function rchg_sql(db_st, interval)
os.date
(
"%Y%m%d"
),
tostring
(
interval
))
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_RCHG]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_RCHG"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_RCHG]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_RCHG
"
,
sql_update
)
return
end
...
...
@@ -53,8 +55,8 @@ local function rchg_sql(db_st, interval)
os.date
(
'%Y%m%d'
),
tostring
(
interval
))
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_RCHG]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_RCHG"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_RCHG]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_RCHG
"
,
sql_delete
)
return
end
end
...
...
@@ -90,8 +92,6 @@ local function dispatch()
end
function
_RCHG
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
...
...
nginx/lua/settle/node_rchgdetail.lua
View file @
50b2bd82
...
...
@@ -6,18 +6,18 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
rchgdetail_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
local
ERR
=
ngx
.
ERR
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[RCHGDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[RCHGDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +33,7 @@ local function rchgdetail_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_RCHGDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_RCHGDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +44,8 @@ local function rchgdetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_RCHGDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_RCHGDETAIL"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_RCHGDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_RCHGDETAIL
"
,
sql_update
)
return
end
...
...
@@ -57,8 +57,8 @@ local function rchgdetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_RCHGDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_RCHGDETAIL"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_RCHGDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_RCHGDETAIL
"
,
sql_delete
)
return
end
end
...
...
@@ -95,8 +95,6 @@ local function dispatch()
end
function
_RCHGDETAIL
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_saledetail.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,11 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
saledetail_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +18,7 @@ local function saledetail_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[SALEDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[SALEDETAIL]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +34,7 @@ local function saledetail_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_SALEDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_SALEDETAIL]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +45,8 @@ local function saledetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_SALEDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SALEDETAIL"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_SALEDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_SALEDETAIL
"
,
sql_update
)
return
end
...
...
@@ -57,8 +58,8 @@ local function saledetail_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_SALEDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SALEDETAIL"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_SALEDETAIL]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_SALEDETAIL
"
,
sql_delete
)
return
end
end
...
...
@@ -95,8 +96,6 @@ local function dispatch()
end
function
_SALEDETAIL
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_saleorder.lua
View file @
50b2bd82
local
_SALEORDER
=
{}
package.path
=
package.path
..
";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
MODULE
=
"NODE"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
saleorder_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
local
ERR
=
ngx
.
ERR
base
:
log
(
MODULE
,
"-----------------------> START[node_saleorder]"
)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_log
(
"S"
,
"[SALEORDER]:
"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
MODULE
,
"[SALEORDER]
"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +32,7 @@ local function saleorder_sql(db_st, interval)
}
if
not
ok
then
base
:
print_log
(
"S"
,
"[NODE_SALEORDER]:
"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
MODULE
,
"[NODE_SALEORDER]
"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,23 +43,25 @@ local function saleorder_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_log
(
"S"
,
"[NODE_SALEORDER]:
"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SALEORDER"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
MODULE
,
"[NODE_SALEORDER]
"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
MODULE
,
"[NODE_SALEORDER]
"
,
sql_update
)
return
end
-- DELETE current tables record
local
sql_delete
=
string.format
(
[[DELETE FROM node_saleorder ]]
..
local
sql_delete
=
string.format
(
[[DELETE FROM node_saleorder ]]
..
[[WHERE EXTRACT(YEAR_MONTH FROM `create_time`) < EXTRACT(YEAR_MONTH FROM DATE_SUB('%s', interval %s month))]]
,
os.date
(
'%Y%m%d'
),
tostring
(
interval
))
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_log
(
"S"
,
"[NODE_SALEORDER]:
"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SALEORDER"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
MODULE
,
"[NODE_SALEORDER]
"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
MODULE
,
"[NODE_SALEORDER]
"
,
sql_delete
)
return
end
base
:
log
(
MODULE
,
"[NODE_SALEORDER]"
,
"-----------------------> END[node_saleorder]"
)
end
...
...
@@ -95,8 +96,6 @@ local function dispatch()
end
function
_SALEORDER
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_shift.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,11 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
shift_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +18,7 @@ local function shift_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[SHIFT]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[SHIFT]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +34,7 @@ local function shift_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_SHIFT]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_SHIFT]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +45,8 @@ local function shift_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_SHIFT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SHIFT"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_SHIFT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_SHIFT
"
,
sql_update
)
return
end
...
...
@@ -57,8 +58,8 @@ local function shift_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_SHIFT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SHIFT"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_SHIFT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_SHIFT
"
,
sql_delete
)
return
end
end
...
...
@@ -95,8 +96,6 @@ local function dispatch()
end
function
_SHIFT
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_sku.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,11 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
sku_sql
(
db_st
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +18,7 @@ local function sku_sql(db_st)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[SKU]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[SKU]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +34,7 @@ local function sku_sql(db_st)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_SKU]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_SKU]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -41,8 +42,8 @@ local function sku_sql(db_st)
local
sql_update
=
[[DELETE FROM node_sku WHERE sku_exp_flag = 9]]
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_SKU]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SKU"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_SKU]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_SKU
"
,
sql_update
)
return
end
...
...
@@ -81,8 +82,6 @@ local function dispatch()
end
function
_SKU
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
for
i
=
1
,
#
dbs_st
.
tk_biz
do
async
(
dbs_st
.
tk_biz
[
i
])
...
...
nginx/lua/settle/node_sms.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,11 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
sms_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +18,7 @@ local function sms_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[SMS]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[SMS]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +34,7 @@ local function sms_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_SMS]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_SMS]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +45,8 @@ local function sms_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_SMS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SMS"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_SMS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_SMS
"
,
sql_update
)
return
end
...
...
@@ -57,8 +58,8 @@ local function sms_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_SMS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SMS"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_SMS]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_SMS
"
,
sql_delete
)
return
end
end
...
...
@@ -95,8 +96,6 @@ local function dispatch()
end
function
_SMS
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_smsvip.lua
View file @
50b2bd82
...
...
@@ -6,10 +6,11 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
smsvip_sql
(
db_st
,
interval
)
local
log
=
ngx
.
log
...
...
@@ -17,7 +18,7 @@ local function smsvip_sql(db_st, interval)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[SMSVIP]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[SMSVIP]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +34,7 @@ local function smsvip_sql(db_st, interval)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_SMSVIP]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_SMSVIP]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -44,8 +45,8 @@ local function smsvip_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_SMSVIP]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SMSVIP"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_SMSVIP]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_SMSVIP
"
,
sql_update
)
return
end
...
...
@@ -57,8 +58,8 @@ local function smsvip_sql(db_st, interval)
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_SMSVIP]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_SMSVIP"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_SMSVIP]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_SMSVIP
"
,
sql_delete
)
return
end
end
...
...
@@ -95,8 +96,6 @@ local function dispatch()
end
function
_SMSVIP
.
run
()
local
base
=
require
(
'base'
)
local
json
=
require
(
'cjson'
)
local
dbs_st
=
base
:
db_read
(
db_conf
)
local
interval
=
3
-- the month interval
for
i
=
1
,
#
dbs_st
.
tk_biz
do
...
...
nginx/lua/settle/node_ticket.lua
View file @
50b2bd82
...
...
@@ -17,7 +17,7 @@ local function ticket_sql(db_st)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[TICKET]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[TICKET]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +33,7 @@ local function ticket_sql(db_st)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_TICKET]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_TICKET]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -42,8 +42,8 @@ local function ticket_sql(db_st)
local
sql_update
=
[[UPDATE node_ticket SET ticket_status = 8 WHERE now() > ticket_exp]]
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_TICKET]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_TICKET"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_TICKET]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_TICKET
"
,
sql_update
)
return
end
...
...
@@ -51,8 +51,8 @@ local function ticket_sql(db_st)
local
sql_insert
=
string.format
(
[[INSERT INTO node_ticket_his SELECT * FROM node_ticket WHERE DATE(`create_time`) < DATE('%s')]]
,
os.date
(
"%Y%m%d%H%M%S"
))
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_insert
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_TICKET]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_TICKET"
,
"<SQL>
"
,
sql_insert
)
base
:
log
(
"S"
,
"[NODE_TICKET]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_TICKET
"
,
sql_insert
)
return
end
...
...
@@ -61,8 +61,8 @@ local function ticket_sql(db_st)
local
sql_delete
=
string.format
(
[[DELETE FROM node_ticket WHERE DATE(`create_time`) < DATE('%s')]]
,
os.date
(
"%Y%m%d%H%M%S"
))
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_delete
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_TICKET]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_TICKET"
,
"<SQL>
"
,
sql_delete
)
base
:
log
(
"S"
,
"[NODE_TICKET]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_TICKET
"
,
sql_delete
)
return
end
end
...
...
nginx/lua/settle/node_vipacct.lua
View file @
50b2bd82
...
...
@@ -17,7 +17,7 @@ local function vipacct_sql(db_st)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_
log
(
"S"
,
"[VIPACCT]:"
,
"failed to instantiate mysql: "
,
err
)
base
:
log
(
"S"
,
"[VIPACCT]:"
,
"failed to instantiate mysql: "
,
err
)
return
false
end
...
...
@@ -33,7 +33,7 @@ local function vipacct_sql(db_st)
}
if
not
ok
then
base
:
print_
log
(
"S"
,
"[NODE_VIPACCT]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
base
:
log
(
"S"
,
"[NODE_VIPACCT]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
...
...
@@ -42,8 +42,8 @@ local function vipacct_sql(db_st)
[[`acct_lbal` = `acct_cbal`, `count_lbal` = `count_cbal`]]
local
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_update
)
if
not
res
then
base
:
print_
log
(
"S"
,
"[NODE_VIPACCT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
print_log
(
"NODE_VIPACCT"
,
"<SQL>
"
,
sql_update
)
base
:
log
(
"S"
,
"[NODE_VIPACCT]:"
,
"bad result: "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
base
:
log
(
"NODE_VIPACCT
"
,
sql_update
)
return
end
...
...
nginx/lua/settle/settle.lua
View file @
50b2bd82
...
...
@@ -5,10 +5,29 @@ package.path = package.path..";/Users/zhoush/openresty/nginx/lua/settle/?.lua;;"
local
base
=
require
(
'base'
)
-- Settle modules
local
NC
=
require
(
'node_card'
)
local
NT
=
require
(
'node_ticket'
)
local
CR
=
require
(
'node_chgrule'
)
local
MS
=
require
(
'node_ms'
)
local
node_asb
=
require
(
'node_asb'
)
local
node_asbdetail
=
require
(
'node_asbdetail'
)
local
node_card
=
require
(
'node_card'
)
local
node_chgrule
=
require
(
'node_chgrule'
)
local
node_cs
=
require
(
'node_cs'
)
local
node_csdetail
=
require
(
'node_csdetail'
)
local
node_ms
=
require
(
'node_ms'
)
local
node_payment
=
require
(
'node_payment'
)
local
node_psb
=
require
(
'node_psb'
)
local
node_psbdetail
=
require
(
'node_psbdetail'
)
local
node_rchg
=
require
(
'node_rchg'
)
local
node_rchgdetail
=
require
(
'node_rchgdetail'
)
local
node_saledetail
=
require
(
'node_saledetail'
)
local
node_saleorder
=
require
(
'node_saleorder'
)
local
node_shift
=
require
(
'node_shift'
)
local
node_sku
=
require
(
'node_sku'
)
local
node_sms
=
require
(
'node_sms'
)
local
node_smsvip
=
require
(
'node_smsvip'
)
local
node_ticket
=
require
(
'node_ticket'
)
local
node_vipacct
=
require
(
'node_vipacct'
)
local
tk_sdt
=
require
(
'tk_sdt'
)
...
...
@@ -19,11 +38,29 @@ handler = function(premature, interval_time)
if
not
premature
then
local
nowtime
=
os.date
(
"%H%M"
)
if
nowtime
==
interval_time
then
-- settle features start
NC
:
run
()
NT
:
run
()
CR
:
run
()
MS
:
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
interval_time
=
tostring
(
tonumber
(
interval_time
)
-
1
)
...
...
nginx/lua/settle/tk_sdt.lua
0 → 100644
View file @
50b2bd82
local
_SDT
=
{}
package.path
=
package.path
..
";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
MODULE
=
"S"
-- Settle
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
json
=
require
(
'cjson'
)
local
db_conf
=
"tk7_dbs.json"
local
tasks
=
{}
local
__LINE__
=
base
.
__LINE__
local
__FILE__
=
base
.
__FILE__
local
function
sdt_sql
(
db_st
)
base
:
log
(
MODULE
,
"-----------------------> START[TK_SDT]"
)
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
log
(
MODULE
,
__FILE__
()
..
":"
..
__LINE__
(),
"failed to instantiate mysql: "
,
err
)
return
false
end
db
:
set_timeout
(
1000
)
-- 1 sec
local
ok
,
err
,
errcode
,
sqlstate
=
db
:
connect
{
host
=
db_st
[
'host'
],
port
=
db_st
[
'port'
],
database
=
db_st
[
'database'
],
user
=
db_st
[
'user'
],
password
=
db_st
[
'password'
],
timeout
=
db_st
[
'timeout'
],
}
if
not
ok
then
base
:
log
(
MODULE
,
__FILE__
()
..
":"
..
__LINE__
(),
"failed to connect:"
,
json
.
encode
(
db_st
),
":"
,
errcode
,
sqlstate
)
return
end
-- GET shop_map_id list
local
shops
local
sql_select
=
'SELECT DISTINCT shop_map_id FROM node_saleorder UNION SELECT DISTINCT shop_map_id FROM node_rchg'
shops
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql_select
)
if
not
shops
then
base
:
log
(
"S"
,
"[TK_SDT]"
,
"failed to connect:"
,
json
.
encode
(
db_st
),
":"
,
err
,
":"
,
errcode
,
":"
,
sqlstate
,
"."
)
base
:
log
(
"S"
,
"[TK_SDT]"
,
sql_select
)
return
end
for
i
=
1
,
#
shops
do
local
shop
=
shops
[
i
]
local
res
-- CHECK if exists
local
sql
=
string.format
(
[[SELECT * FROM tk_sdt WHERE DATE(total_date) = DATE('%s') ]]
..
[[AND shop_map_id = %s]]
,
os.date
(
'%Y%m%d'
,
os.time
()),
tostring
(
shop
.
shop_map_id
))
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql
)
if
not
res
then
base
:
log
(
"S"
,
"[TK_SDT]"
,
"failed to connect:"
,
json
.
encode
(
db_st
),
":"
,
err
,
":"
,
errcode
,
":"
,
sqlstate
,
"."
)
base
:
log
(
"S"
,
"[TK_SDT]"
,
sql
)
return
end
if
#
res
~=
0
then
ngx
.
say
(
json
.
encode
({
cnt
=#
res
,
res
=
res
}))
base
:
log
(
"S"
,
"[TK_SDT]"
,
"checked already"
)
return
end
-- GET summary
sql
=
string.format
(
[[SELECT op_map_id, mer_map_id, shop_map_id, city_county_id, ]]
..
[[IFNULL(COUNT(*), 0) t_order_cnt, ]]
..
[[IFNULL(SUM(amt_pay), 0) t_order_amt, ]]
..
[[IFNULL(SUM(amt_profit), 0) t_order_profit, ]]
..
[[IFNULL(SUM(amt_point_num), 0) t_point_use_cnt, ]]
..
[[IFNULL(SUM(amt_point), 0) t_point_use_amt, ]]
..
[[IFNULL(SUM(amt_ticket_num), 0) t_ticket_use_cnt, ]]
..
[[IFNULL(SUM(amt_ticket), 0) t_ticket_use_amt ]]
..
[[FROM node_saleorder ]]
..
[[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'
,
tostring
(
shop
.
shop_map_id
))
-- GET online records
sql
=
sql
..
string.format
(
[[SELECT IFNULL(COUNT(*), 0) t_order_on_cnt, IFNULL(SUM(amt_pay), 0) t_order_on_amt ]]
..
[[FROM node_saleorder ]]
..
[[WHERE date(`create_time`) = date('%s') ]]
..
[[AND shop_map_id = %s ]]
..
[[AND order_source > 0 ]]
..
[[GROUP BY op_map_id, mer_map_id, shop_map_id, city_county_id;]]
,
'20180716'
,
tostring
(
shop
.
shop_map_id
))
-- GET VIP/NOVIP records
sql
=
sql
..
string.format
(
[[SELECT IFNULL(COUNT(*), 0) t_order_vip_cnt, IFNULL(SUM(amt_pay), 0) t_order_vip_amt ]]
..
[[FROM node_saleorder ]]
..
[[WHERE date(`create_time`) = date('%s') ]]
..
[[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'
,
tostring
(
shop
.
shop_map_id
))
-- GET MS records
sql
=
sql
..
string.format
(
[[SELECT IFNULL(COUNT(*), 0) t_order_ms_cnt ]]
..
[[FROM node_saleorder ]]
..
[[WHERE date(`create_time`) = date('%s') ]]
..
[[AND shop_map_id = %s ]]
..
[[AND AMT_PROMOTE != 0 ]]
..
[[GROUP BY op_map_id, mer_map_id, shop_map_id, city_county_id;]]
,
'20180716'
,
tostring
(
shop
.
shop_map_id
))
-- GET 0000-0900 order
sql
=
sql
..
string.format
(
[[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' ;]]
,
tostring
(
shop
.
shop_map_id
),
os.date
(
'%Y%m%d000000'
,
os.time
()),
os.date
(
'%Y%m%d090000'
,
os.time
()))
-- GET 0900-1100 order
sql
=
sql
..
string.format
(
[[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' ;]]
,
tostring
(
shop
.
shop_map_id
),
os.date
(
'%Y%m%d090000'
,
os.time
()),
os.date
(
'%Y%m%d110000'
,
os.time
()))
-- GET 1100-1300 order
sql
=
sql
..
string.format
(
[[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' ;]]
,
tostring
(
shop
.
shop_map_id
),
os.date
(
'%Y%m%d110000'
,
os.time
()),
os.date
(
'%Y%m%d130000'
,
os.time
()))
-- GET 1300-1500 order
sql
=
sql
..
string.format
(
[[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' ;]]
,
tostring
(
shop
.
shop_map_id
),
os.date
(
'%Y%m%d130000'
,
os.time
()),
os.date
(
'%Y%m%d150000'
,
os.time
()))
-- GET 1500-1700 order
sql
=
sql
..
string.format
(
[[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' ;]]
,
tostring
(
shop
.
shop_map_id
),
os.date
(
'%Y%m%d150000'
,
os.time
()),
os.date
(
'%Y%m%d170000'
,
os.time
()))
-- GET 1700-1900 order
sql
=
sql
..
string.format
(
[[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' ;]]
,
tostring
(
shop
.
shop_map_id
),
os.date
(
'%Y%m%d170000'
,
os.time
()),
os.date
(
'%Y%m%d190000'
,
os.time
()))
-- GET 1900-2100 order
sql
=
sql
..
string.format
(
[[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' ;]]
,
tostring
(
shop
.
shop_map_id
),
os.date
(
'%Y%m%d190000'
,
os.time
()),
os.date
(
'%Y%m%d210000'
,
os.time
()))
-- GET 2100-2400 order
sql
=
sql
..
string.format
(
[[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' ;]]
,
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
(
[[SELECT IFNULL(COUNT(vip_map_id), 0) t_vip_cnt ]]
..
[[FROM node_vipacct ]]
..
[[WHERE shop_map_id IN ]]
..
[[(SELECT shop_map_id FROM tk_shop ]]
..
[[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)));]]
,
tostring
(
shop
[
'shop_map_id'
]))
-- GET VIP new cnt
local
sql_vip_newcnt
=
string.format
(
[[SELECT IFNULL(COUNT(vip_map_id), 0) t_vip_newcnt ]]
..
[[FROM node_vipacct ]]
..
[[WHERE DATE(create_time) = DATE('%s') ]]
..
[[AND shop_map_id IN ]]
..
[[(SELECT shop_map_id FROM tk_shop ]]
..
[[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'
,
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 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 bank 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 = 2 ]].. -- 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]],
-- '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]],
-- '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]],
-- '20180716',
-- tostring(shop.shop_map_id))
res
,
err
,
errcode
,
sqlstate
=
db
:
query
(
sql
)
base
:
log
(
"S"
,
"[TK_SDT]"
,
sql
)
if
not
res
then
base
:
log
(
"S"
,
"[TK_SDT]"
,
"failed to connect:"
,
json
.
encode
(
db_st
),
":"
,
err
,
":"
,
errcode
,
":"
,
sqlstate
,
"."
)
return
end
if
#
res
~=
0
then
for
k
,
v
in
pairs
(
res
[
1
])
do
shop
[
k
]
=
v
end
end
while
err
==
"again"
do
res
,
err
,
errcode
,
sqlstate
=
db
:
read_result
()
if
not
res
then
base
:
log
(
MODULE
,
"[TK_SDT]"
,
"bad result #"
,
i
,
": "
,
err
,
": "
,
errcode
,
": "
,
sqlstate
,
"."
)
return
ngx
.
exit
(
500
)
end
if
#
res
~=
0
then
for
k
,
v
in
pairs
(
res
[
1
])
do
shop
[
k
]
=
v
end
i
=
i
+
1
end
end
-- SET total_date
shop
[
'total_date'
]
=
base
:
tonumber
(
os.date
(
'%Y%m%d'
,
os.time
()))
-- Convert type
shop
[
'op_map_id'
]
=
base
:
tonumber
(
shop
[
'op_map_id'
])
shop
[
'mer_map_id'
]
=
base
:
tonumber
(
shop
[
'mer_map_id'
])
shop
[
'shop_map_id'
]
=
base
:
tonumber
(
shop
[
'shop_map_id'
])
shop
[
'total_date'
]
=
base
:
tonumber
(
shop
[
'total_date'
])
shop
[
'city_county_id'
]
=
base
:
tonumber
(
shop
[
'city_county_id'
])
shop
[
't_order_cnt'
]
=
base
:
tonumber
(
shop
[
't_order_cnt'
])
shop
[
't_order_amt'
]
=
base
:
tonumber
(
shop
[
't_order_amt'
])
shop
[
't_order_on_cnt'
]
=
base
:
tonumber
(
shop
[
't_order_on_cnt'
])
shop
[
't_order_on_amt'
]
=
base
:
tonumber
(
shop
[
't_order_on_amt'
])
shop
[
't_order_off_cnt'
]
=
base
:
tonumber
(
shop
[
't_order_off_cnt'
])
shop
[
't_order_off_amt'
]
=
base
:
tonumber
(
shop
[
't_order_off_amt'
])
shop
[
't_order_vip_cnt'
]
=
base
:
tonumber
(
shop
[
't_order_vip_cnt'
])
shop
[
't_order_vip_amt'
]
=
base
:
tonumber
(
shop
[
't_order_vip_amt'
])
shop
[
't_order_novip_cnt'
]
=
base
:
tonumber
(
shop
[
't_order_novip_cnt'
])
shop
[
't_order_novip_amt'
]
=
base
:
tonumber
(
shop
[
't_order_novip_amt'
])
shop
[
't_order_ms_cnt'
]
=
base
:
tonumber
(
shop
[
't_order_ms_cnt'
])
shop
[
't_order_avg_price'
]
=
base
:
tonumber
(
shop
[
't_order_avg_price'
])
shop
[
't_order_profit'
]
=
base
:
tonumber
(
shop
[
't_order_profit'
])
shop
[
't_order_profit_per'
]
=
base
:
tonumber
(
shop
[
't_order_profit_per'
])
shop
[
't_vip_cnt'
]
=
base
:
tonumber
(
shop
[
't_vip_cnt'
])
shop
[
't_vip_newcnt'
]
=
base
:
tonumber
(
shop
[
't_vip_newcnt'
])
shop
[
't_charge_cnt'
]
=
base
:
tonumber
(
shop
[
't_charge_cnt'
])
shop
[
't_charge_amt'
]
=
base
:
tonumber
(
shop
[
't_charge_amt'
])
shop
[
't_point_use_cnt'
]
=
base
:
tonumber
(
shop
[
't_point_use_cnt'
])
shop
[
't_point_use_amt'
]
=
base
:
tonumber
(
shop
[
't_point_use_amt'
])
shop
[
't_ticket_use_cnt'
]
=
base
:
tonumber
(
shop
[
't_ticket_use_cnt'
])
shop
[
't_ticket_use_amt'
]
=
base
:
tonumber
(
shop
[
't_ticket_use_amt'
])
shop
[
't_point_send_cnt'
]
=
base
:
tonumber
(
shop
[
't_point_send_cnt'
])
shop
[
't_point_send_amt'
]
=
base
:
tonumber
(
shop
[
't_point_send_amt'
])
shop
[
't_ticket_send_cnt'
]
=
base
:
tonumber
(
shop
[
't_ticket_send_cnt'
])
shop
[
't_ticket_send_amt'
]
=
base
:
tonumber
(
shop
[
't_ticket_send_amt'
])
shop
[
'pay_cash_cnt'
]
=
base
:
tonumber
(
shop
[
'pay_cash_cnt'
])
shop
[
'pay_cash_amt'
]
=
base
:
tonumber
(
shop
[
'pay_cash_amt'
])
shop
[
'pay_bank_cnt'
]
=
base
:
tonumber
(
shop
[
'pay_bank_cnt'
])
shop
[
'pay_bank_amt'
]
=
base
:
tonumber
(
shop
[
'pay_bank_amt'
])
shop
[
'pay_vipcard_cnt'
]
=
base
:
tonumber
(
shop
[
'pay_vipcard_cnt'
])
shop
[
'pay_vipcard_amt'
]
=
base
:
tonumber
(
shop
[
'pay_vipcard_amt'
])
shop
[
'pay_wx_cnt'
]
=
base
:
tonumber
(
shop
[
'pay_wx_cnt'
])
shop
[
'pay_wx_amt'
]
=
base
:
tonumber
(
shop
[
'pay_wx_amt'
])
shop
[
'pay_alipay_cnt'
]
=
base
:
tonumber
(
shop
[
'pay_alipay_cnt'
])
shop
[
'pay_alipay_amt'
]
=
base
:
tonumber
(
shop
[
'pay_alipay_amt'
])
shop
[
'pay_othpay_cnt'
]
=
base
:
tonumber
(
shop
[
'pay_othpay_cnt'
])
shop
[
'pay_othpay_amt'
]
=
base
:
tonumber
(
shop
[
'pay_othpay_amt'
])
shop
[
'time_cnt_0009'
]
=
base
:
tonumber
(
shop
[
'time_cnt_0009'
])
shop
[
'time_amt_0009'
]
=
base
:
tonumber
(
shop
[
'time_amt_0009'
])
shop
[
'time_avg_price_0009'
]
=
base
:
tonumber
(
shop
[
'time_avg_price_0009'
])
shop
[
'time_profit_0009'
]
=
base
:
tonumber
(
shop
[
'time_profit_0009'
])
shop
[
'time_profit_per_0009'
]
=
base
:
tonumber
(
shop
[
'time_profit_per_0009'
])
shop
[
'time_cnt_0911'
]
=
base
:
tonumber
(
shop
[
'time_cnt_0911'
])
shop
[
'time_amt_0911'
]
=
base
:
tonumber
(
shop
[
'time_amt_0911'
])
shop
[
'time_avg_price_0911'
]
=
base
:
tonumber
(
shop
[
'time_avg_price_0911'
])
shop
[
'time_profit_0911'
]
=
base
:
tonumber
(
shop
[
'time_profit_0911'
])
shop
[
'time_profit_per_0911'
]
=
base
:
tonumber
(
shop
[
'time_profit_per_0911'
])
shop
[
'time_cnt_1113'
]
=
base
:
tonumber
(
shop
[
'time_cnt_1113'
])
shop
[
'time_amt_1113'
]
=
base
:
tonumber
(
shop
[
'time_amt_1113'
])
shop
[
'time_avg_price_1113'
]
=
base
:
tonumber
(
shop
[
'time_avg_price_1113'
])
shop
[
'time_profit_1113'
]
=
base
:
tonumber
(
shop
[
'time_profit_1113'
])
shop
[
'time_profit_per_1113'
]
=
base
:
tonumber
(
shop
[
'time_profit_per_1113'
])
shop
[
'time_cnt_1315'
]
=
base
:
tonumber
(
shop
[
'time_cnt_1315'
])
shop
[
'time_amt_1315'
]
=
base
:
tonumber
(
shop
[
'time_amt_1315'
])
shop
[
'time_avg_price_1315'
]
=
base
:
tonumber
(
shop
[
'time_avg_price_1315'
])
shop
[
'time_profit_1315'
]
=
base
:
tonumber
(
shop
[
'time_profit_1315'
])
shop
[
'time_profit_per_1315'
]
=
base
:
tonumber
(
shop
[
'time_profit_per_1315'
])
shop
[
'time_cnt_1517'
]
=
base
:
tonumber
(
shop
[
'time_cnt_1517'
])
shop
[
'time_amt_1517'
]
=
base
:
tonumber
(
shop
[
'time_amt_1517'
])
shop
[
'time_avg_price_1517'
]
=
base
:
tonumber
(
shop
[
'time_avg_price_1517'
])
shop
[
'time_profit_1517'
]
=
base
:
tonumber
(
shop
[
'time_profit_1517'
])
shop
[
'time_profit_per_1517'
]
=
base
:
tonumber
(
shop
[
'time_profit_per_1517'
])
shop
[
'time_cnt_1719'
]
=
base
:
tonumber
(
shop
[
'time_cnt_1719'
])
shop
[
'time_amt_1719'
]
=
base
:
tonumber
(
shop
[
'time_amt_1719'
])
shop
[
'time_avg_price_1719'
]
=
base
:
tonumber
(
shop
[
'time_avg_price_1719'
])
shop
[
'time_profit_1719'
]
=
base
:
tonumber
(
shop
[
'time_profit_1719'
])
shop
[
'time_profit_per_1719'
]
=
base
:
tonumber
(
shop
[
'time_profit_per_1719'
])
shop
[
'time_cnt_1921'
]
=
base
:
tonumber
(
shop
[
'time_cnt_1921'
])
shop
[
'time_amt_1921'
]
=
base
:
tonumber
(
shop
[
'time_amt_1921'
])
shop
[
'time_avg_price_1921'
]
=
base
:
tonumber
(
shop
[
'time_avg_price_1921'
])
shop
[
'time_profit_1921'
]
=
base
:
tonumber
(
shop
[
'time_profit_1921'
])
shop
[
'time_profit_per_1921'
]
=
base
:
tonumber
(
shop
[
'time_profit_per_1921'
])
shop
[
'time_cnt_2124'
]
=
base
:
tonumber
(
shop
[
'time_cnt_2124'
])
shop
[
'time_amt_2124'
]
=
base
:
tonumber
(
shop
[
'time_amt_2124'
])
shop
[
'time_avg_price_2124'
]
=
base
:
tonumber
(
shop
[
'time_avg_price_2124'
])
shop
[
'time_profit_2124'
]
=
base
:
tonumber
(
shop
[
'time_profit_2124'
])
shop
[
'time_profit_per_2124'
]
=
base
:
tonumber
(
shop
[
'time_profit_per_2124'
])
-- Calculate
shop
[
't_order_off_amt'
]
=
shop
[
't_order_amt'
]
-
shop
[
't_order_on_amt'
]
shop
[
't_order_off_cnt'
]
=
shop
[
't_order_cnt'
]
-
shop
[
't_order_on_cnt'
]
shop
[
't_order_novip_amt'
]
=
shop
[
't_order_amt'
]
-
shop
[
't_order_vip_amt'
]
shop
[
't_order_novip_cnt'
]
=
shop
[
't_order_cnt'
]
-
shop
[
't_order_vip_cnt'
]
if
shop
[
't_order_amt'
]
==
0
or
shop
[
't_order_cnt'
]
==
0
then
shop
[
't_order_avg_price'
]
=
0
else
shop
[
't_order_avg_price'
]
=
shop
[
't_order_amt'
]
/
shop
[
't_order_cnt'
]
shop
[
't_order_profit_per'
]
=
shop
[
't_order_profit'
]
/
shop
[
't_order_amt'
]
*
10000
end
-- INSERT INTO tk_sdt
local
str
=
base
:
sql_concate
(
'insert into'
,
'tk_sdt'
,
shop
)
base
:
log
(
MODULE
,
str
)
ngx
.
say
(
json
.
encode
(
shop
))
table.insert
(
shops
,
shop
)
end
ngx
.
say
(
json
.
encode
({
shops
=
shops
}))
base
:
log
(
MODULE
,
"-----------------------> END[TK_SDT]"
)
end
local
function
async
(
i
)
local
co
=
coroutine.wrap
(
function
()
sdt_sql
(
i
)
end
)
table.insert
(
tasks
,
co
)
end
local
function
dispatch
()
local
i
=
1
while
true
do
if
tasks
[
i
]
==
nil
then
if
tasks
[
1
]
==
nil
then
break
end
i
=
1
end
local
res
=
tasks
[
i
]()
if
not
res
then
table.remove
(
tasks
,
i
)
else
i
=
i
+
1
end
end
end
function
_SDT
.
run
()
local
dbs_st
=
base
:
db_read
(
db_conf
)
for
i
=
1
,
#
dbs_st
.
tk_biz
do
async
(
dbs_st
.
tk_biz
[
i
])
end
dispatch
()
end
return
_SDT
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment