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
64aa3750
Commit
64aa3750
authored
Oct 12, 2018
by
周尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize tk_sdt pay_type SQL
parent
e05d23d6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
82 deletions
+41
-82
nginx/conf/nginx.conf
nginx/conf/nginx.conf
+1
-1
nginx/lua/luabiz/tk_sdt.lua
nginx/lua/luabiz/tk_sdt.lua
+38
-79
nginx/lua/luainit/mods.lua
nginx/lua/luainit/mods.lua
+2
-2
No files found.
nginx/conf/nginx.conf
View file @
64aa3750
...
...
@@ -108,7 +108,7 @@ http {
location
/settle
{
content_by_lua_block
{
--
local
settle
=
loadmod("
settle")
local
settle
=
loadmod("luabiz.
settle")
settle:run()
}
}
...
...
nginx/lua/luabiz/tk_sdt.lua
View file @
64aa3750
...
...
@@ -122,6 +122,7 @@ local function sdt_sql(tk_biz, tk_control, total_time)
break
end
-- GET summary
table.insert
(
sql
,
string.format
(
[[SELECT op_map_id, city_county_id, ]]
..
...
...
@@ -321,91 +322,18 @@ local function sdt_sql(tk_biz, tk_control, total_time)
)
-- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[15])
-- GET cash summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(p.order_no), 0) pay_cash_cnt, IFNULL(SUM(p.pay_amt), 0) pay_cash_amt ]]
..
[[FROM node_payment p, node_saleorder s ]]
..
[[WHERE p.order_no = s.order_no ]]
..
[[AND DATE(p.create_time) = DATE('%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
),
tostring
(
shop
.
shop_map_id
))
)
-- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[16])
-- GET WeiXin summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(p.order_no), 0) pay_wx_cnt, IFNULL(SUM(p.pay_amt), 0) pay_wx_amt ]]
..
[[FROM node_payment p, node_saleorder s ]]
..
[[WHERE p.order_no = s.order_no ]]
..
[[AND DATE(p.create_time) = DATE('%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
),
tostring
(
shop
.
shop_map_id
))
)
-- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[17])
-- GET AliPay summary
-- GET PAY_TYPEs summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(p.order_no), 0) pay_
alipay_cnt, IFNULL(SUM(p.pay_amt), 0) pay_alipay_amt
]]
..
[[SELECT IFNULL(COUNT(p.order_no), 0) pay_
tmp_cnt, IFNULL(SUM(p.pay_amt), 0) pay_tmp_amt, p.pay_type_id pay_type_id
]]
..
[[FROM node_payment p, node_saleorder s ]]
..
[[WHERE p.order_no = s.order_no ]]
..
[[AND DATE(p.create_time) = DATE('%s') ]]
..
[[AND p.pay_type_id = 3 ]]
..
-- paytype
[[AND p.shop_map_id = %s ]]
..
[[AND s.order_status = 0;]]
,
[[AND s.order_status = 0 ]]
..
[[GROUP BY p.pay_type_id]]
,
os.date
(
"%Y%m%d"
,
total_time
-
24
*
60
*
60
),
tostring
(
shop
.
shop_map_id
))
)
-- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[18])
-- GET bank summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(p.order_no), 0) pay_bank_cnt, IFNULL(SUM(p.pay_amt), 0) pay_bank_amt ]]
..
[[FROM node_payment p, node_saleorder s ]]
..
[[WHERE p.order_no = s.order_no ]]
..
[[AND DATE(p.create_time) = DATE('%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
),
tostring
(
shop
.
shop_map_id
))
)
-- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[19])
-- GET vipcard summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(p.order_no), 0) pay_vipcard_cnt, IFNULL(SUM(p.pay_amt), 0) pay_vipcard_amt ]]
..
[[FROM node_payment p, node_saleorder s ]]
..
[[WHERE p.order_no = s.order_no ]]
..
[[AND DATE(p.create_time) = DATE('%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
),
tostring
(
shop
.
shop_map_id
))
)
-- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[20])
-- GET othpay summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(p.order_no), 0) pay_othpay_cnt, IFNULL(SUM(p.pay_amt), 0) pay_othpay_amt ]]
..
[[FROM node_payment p, node_saleorder s ]]
..
[[WHERE p.order_no = s.order_no ]]
..
[[AND DATE(p.create_time) = DATE('%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
),
tostring
(
shop
.
shop_map_id
))
)
-- log_lua:log(log_lua:__FILE__() .. ":" .. log_lua:__LINE__(), "NOTICE: " .. sql[21])
res
,
err
,
errcode
,
sqlstate
=
db_biz
:
query
(
table.concat
(
sql
))
log_lua
:
log
(
log_lua
:
__FILE__
()
..
":"
..
log_lua
:
__LINE__
(),
"NOTICE: "
,
sql
[
1
])
...
...
@@ -433,13 +361,45 @@ local function sdt_sql(tk_biz, tk_control, total_time)
end
if
#
res
~=
0
then
-- GET different paytype summary
if
res
[
1
][
"pay_type_id"
]
then
local
pay_tmp_amt
=
res
[
1
][
"pay_tmp_amt"
]
local
pay_tmp_cnt
=
res
[
1
][
"pay_tmp_cnt"
]
local
paytype
=
res
[
1
][
"pay_type_id"
]
if
paytype
==
1
then
shop
[
"pay_cash_amt"
]
=
pay_tmp_amt
shop
[
"pay_cash_cnt"
]
=
pay_tmp_cnt
elseif
paytype
==
2
then
shop
[
"pay_wx_amt"
]
=
pay_tmp_amt
shop
[
"pay_wx_cnt"
]
=
pay_tmp_cnt
elseif
paytype
==
3
then
shop
[
"pay_alipay_amt"
]
=
pay_tmp_amt
shop
[
"pay_alipay_cnt"
]
=
pay_tmp_cnt
elseif
paytype
==
4
then
shop
[
"pay_bank_amt"
]
=
pay_tmp_amt
shop
[
"pay_bank_cnt"
]
=
pay_tmp_cnt
elseif
paytype
==
5
or
paytype
==
6
then
shop
[
"pay_vipcard_amt"
]
=
pay_tmp_amt
shop
[
"pay_vipcard_cnt"
]
=
pay_tmp_cnt
elseif
paytype
==
9
then
shop
[
"pay_othpay_amt"
]
=
pay_tmp_amt
shop
[
"pay_othpay_cnt"
]
=
pay_tmp_cnt
end
end
for
k
,
v
in
pairs
(
res
[
1
])
do
if
k
~=
"pay_tmp_amt"
and
k
~=
"pay_tmp_cnt"
and
k
~=
"pay_type_id"
then
shop
[
k
]
=
v
end
end
j
=
j
+
1
end
-- until(err ~= "again")
end
-- DETAIL data
log_lua
:
log
(
log_lua
:
__FILE__
()
..
":"
..
log_lua
:
__LINE__
(),
"NOTICE: "
..
string.format
(
"================ TK_SDT [%s - %s] =========="
,
tostring
(
shop
[
'shop_map_id'
]),
...
...
@@ -588,7 +548,6 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- return
end
-- table.insert(shops, shop)
break
end
...
...
nginx/lua/luainit/mods.lua
View file @
64aa3750
...
...
@@ -4,8 +4,8 @@ require ('luainit.db_conf')
-- custom base module
_G
.
zx_base
=
_G
.
zx_base
or
require
(
'luabiz.zx_base'
)
-- settle module
_G
.
settle
=
_G
.
settle
or
require
(
'luabiz.settle'
)
--
--
settle module
--
_G.settle = _G.settle or require('luabiz.settle')
-- settle detail
_G
.
tk_sync
=
_G
.
tk_sync
or
require
(
'luabiz.tk_sync'
)
...
...
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