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
2aa571ea
Commit
2aa571ea
authored
Jul 12, 2018
by
周尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
门店库存 [完成]
parent
211056b9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
198 additions
and
4 deletions
+198
-4
.gitmodules
.gitmodules
+3
-0
README.org
README.org
+6
-4
nginx/lua/settle/node_sku.lua
nginx/lua/settle/node_sku.lua
+93
-0
nginx/lua/settle/node_vipacct.lua
nginx/lua/settle/node_vipacct.lua
+95
-0
openresty.wiki
openresty.wiki
+1
-0
No files found.
.gitmodules
0 → 100644
View file @
2aa571ea
[submodule "openresty.wiki"]
path = openresty.wiki
url = 192.168.254.154:tangku7/openresty.wiki.git
README.org
View file @
2aa571ea
...
...
@@ -15,10 +15,12 @@
1. [ ] 异步推送
2. [-] 业务批处理
1. [ ] 库存信息类
1. [ ] 门店库存
2. [ ] 会员管理类
1. [ ] 会员账户
1. [X] 库存信息类
1. [X] 门店库存
2. [-] 会员管理类
1. [-] 会员账户
1. [X] 设置余额
2. [ ] 会员等级更新
3. [X] 营销工具
1. [X] 卡账户
2. [X] 券账户
...
...
nginx/lua/settle/node_sku.lua
0 → 100644
View file @
2aa571ea
local
_SKU
=
{}
package.path
=
package.path
..
";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
sku_sql
(
db_st
)
local
log
=
ngx
.
log
local
ERR
=
ngx
.
ERR
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_log
(
"S"
,
"[SKU]:"
,
"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
:
print_log
(
"S"
,
"[NODE_SKU]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
-- DELETE invalid sku records
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
)
return
end
end
local
function
async
(
i
)
local
co
=
coroutine.wrap
(
function
()
sku_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
_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
])
end
dispatch
()
end
return
_SKU
nginx/lua/settle/node_vipacct.lua
0 → 100644
View file @
2aa571ea
local
_VIPACCT
=
{}
package.path
=
package.path
..
";/Users/zhoush/openresty/nginx/lua/?.lua;;"
local
mysql
=
require
(
"resty.mysql"
)
local
base
=
require
(
"base"
)
local
tasks
=
{}
local
db_conf
=
"tk7_dbs.json"
local
function
vipacct_sql
(
db_st
)
local
log
=
ngx
.
log
local
ERR
=
ngx
.
ERR
local
db
,
err
=
mysql
:
new
()
if
not
db
then
base
:
print_log
(
"S"
,
"[VIPACCT]:"
,
"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
:
print_log
(
"S"
,
"[NODE_VIPACCT]:"
,
"failed to connect: "
,
err
,
": "
,
errcode
,
" "
,
sqlstate
)
return
end
-- SET yesterday's balance
local
sql_update
=
[[UPDATE node_vipacct SET `point_lbal` = `point_cbal`, `acct_lbal` = `acct_cbal`, ]]
..
[[`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
)
return
end
-- SET VIPACCT's level
end
local
function
async
(
i
)
local
co
=
coroutine.wrap
(
function
()
vipacct_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
_VIPACCT
.
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
])
end
dispatch
()
end
return
_VIPACCT
openresty.wiki
@
74d78be5
Subproject commit 74d78be5d737131f68f7432fb139908c9de1c333
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