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
e9a9c211
Commit
e9a9c211
authored
Sep 25, 2018
by
周尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix paytype bug
parent
9ed7a0f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
33 deletions
+48
-33
nginx/lua/luabiz/tk_sdt.lua
nginx/lua/luabiz/tk_sdt.lua
+48
-33
No files found.
nginx/lua/luabiz/tk_sdt.lua
View file @
e9a9c211
...
...
@@ -108,8 +108,8 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- CHECK if exists
local
sql_check
=
string.format
(
[[SELECT * FROM tk_sdt WHERE DATE(total_date) = DATE('%s') ]]
..
[[AND shop_map_id = %s]]
,
os.date
(
'%Y%m%d'
,
os.time
()
),
[[AND shop_map_id = %s
]]
,
os.date
(
'%Y%m%d'
,
total_time
),
tostring
(
shop
.
shop_map_id
))
res
,
err
,
errcode
,
sqlstate
=
db_biz
:
query
(
sql_check
)
if
not
res
then
...
...
@@ -325,11 +325,13 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET cash summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(*), 0) pay_cash_cnt, IFNULL(SUM(pay_amt), 0) pay_cash_amt ]]
..
[[FROM node_payment ]]
..
[[WHERE DATE(create_time) = DATE('%s') ]]
..
[[AND pay_type_id = 1 ]]
..
-- paytype
[[AND shop_map_id = %s;]]
,
[[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
))
)
...
...
@@ -337,23 +339,28 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET WeiXin summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(*), 0) pay_wx_cnt, IFNULL(SUM(pay_amt), 0) pay_wx_amt ]]
..
[[FROM node_payment ]]
..
[[WHERE DATE(create_time) = DATE('%s') ]]
..
[[AND pay_type_id = 2 ]]
..
-- paytype
[[AND shop_map_id = %s;]]
,
[[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
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(*), 0) pay_alipay_cnt, IFNULL(SUM(pay_amt), 0) pay_alipay_amt ]]
..
[[FROM node_payment ]]
..
[[WHERE DATE(create_time) = DATE('%s') ]]
..
[[AND pay_type_id = 3 ]]
..
-- paytype
[[AND shop_map_id = %s;]]
,
[[SELECT IFNULL(COUNT(p.order_no), 0) pay_alipay_cnt, IFNULL(SUM(p.pay_amt), 0) pay_alipay_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 = 3 ]]
..
-- 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
))
)
...
...
@@ -361,11 +368,13 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET bank summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(*), 0) pay_bank_cnt, IFNULL(SUM(pay_amt), 0) pay_bank_amt ]]
..
[[FROM node_payment ]]
..
[[WHERE DATE(create_time) = DATE('%s') ]]
..
[[AND pay_type_id = 4 ]]
..
-- paytype
[[AND shop_map_id = %s;]]
,
[[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
))
)
...
...
@@ -373,11 +382,13 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET vipcard summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(*), 0) pay_vipcard_cnt, IFNULL(SUM(pay_amt), 0) pay_vipcard_amt ]]
..
[[FROM node_payment ]]
..
[[WHERE DATE(create_time) = DATE('%s') ]]
..
[[AND (pay_type_id = 5 OR pay_type_id = 6) ]]
..
-- paytype
[[AND shop_map_id = %s;]]
,
[[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
))
)
...
...
@@ -385,17 +396,21 @@ local function sdt_sql(tk_biz, tk_control, total_time)
-- GET othpay summary
table.insert
(
sql
,
string.format
(
[[SELECT IFNULL(COUNT(*), 0) pay_othpay_cnt, IFNULL(SUM(pay_amt), 0) pay_othpay_amt ]]
..
[[FROM node_payment ]]
..
[[WHERE DATE(create_time) = DATE('%s') ]]
..
[[AND pay_type_id = 9 ]]
..
-- paytype
[[AND shop_map_id = %s;]]
,
[[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
])
if
not
res
then
log_lua
:
log
(
log_lua
:
__FILE__
()
..
":"
..
log_lua
:
__LINE__
(),
"ERR: "
..
"failed to query:"
,
json
.
encode
(
tk_biz
),
":"
,
err
,
":"
,
errcode
,
":"
,
sqlstate
,
"."
)
return
...
...
@@ -413,8 +428,8 @@ local function sdt_sql(tk_biz, tk_control, total_time)
while
err
==
"again"
do
-- repeat
res
,
err
,
errcode
,
sqlstate
=
db_biz
:
read_result
()
log_lua
:
log
(
log_lua
:
__FILE__
()
..
":"
..
log_lua
:
__LINE__
(),
"NOTICE: "
,
sql
[
j
])
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
,
"."
)
return
ngx
.
exit
(
500
)
end
...
...
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