Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
taxh5
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
data_server
taxh5
Commits
8e5a1516
Commit
8e5a1516
authored
May 08, 2019
by
何娜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
taxh5 限制appkey上限
parent
71d11922
Pipeline
#7165
passed with stage
in 2 seconds
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
17 deletions
+64
-17
order.js
app/controller/order.js
+17
-16
notifyUrl.js
app/schedule/notifyUrl.js
+1
-1
partner.js
app/service/partner.js
+44
-0
config.local.js
config/config.local.js
+1
-0
config.prod.js
config/config.prod.js
+1
-0
No files found.
app/controller/order.js
View file @
8e5a1516
...
...
@@ -46,9 +46,9 @@ class OrderController extends Controller {
}
async
create
()
{
const
{
ctx
,
service
}
=
this
;
const
{
ctx
,
service
}
=
this
;
ctx
.
validate
(
this
.
createRule
);
let
{
appKey
,
userId
,
notifyUrl
,
redirectUrl
,
orderId
}
=
ctx
.
request
.
body
;
let
{
appKey
,
userId
,
notifyUrl
,
redirectUrl
,
orderId
}
=
ctx
.
request
.
body
;
ctx
.
logger
.
info
(
'【orders】 appKey'
,
appKey
);
const
appKeyInfo
=
await
service
.
partner
.
fetchInfo
(
appKey
);
ctx
.
logger
.
info
(
appKey
,
',appKeyInfo,'
,
appKeyInfo
);
...
...
@@ -69,13 +69,13 @@ class OrderController extends Controller {
await
service
.
order
.
update
(
object
);
}
else
{
if
(
!
userId
)
{
ctx
.
throw
(
422
,
{
message
:
'请输入userId'
});
ctx
.
throw
(
422
,
{
message
:
'请输入userId'
});
return
;
}
}
object
.
orderId
=
ctx
.
helper
.
getUuid
();
await
service
.
order
.
create
(
object
);
}
ctx
.
success
({
orderId
:
object
.
orderId
});
ctx
.
success
({
orderId
:
object
.
orderId
});
}
async
partnerOrder
()
{
...
...
@@ -107,20 +107,21 @@ class OrderController extends Controller {
}
}
const
sign
=
await
service
.
signature
.
signatureCheck
(
ctx
.
request
.
body
);
if
(
sign
.
code
!=
0
)
{
if
(
sign
.
code
!=
0
)
{
return
ctx
.
body
=
{
code
:
-
1
,
mag
:
sign
.
msg
}
}
const
data
=
await
service
.
order
.
getOneByOrderId
({
orderId
,
status
:
'success'
});
const
data
=
await
service
.
order
.
getOneByOrderId
({
orderId
,
status
:
'success'
});
if
(
data
)
{
const
result
=
await
service
.
storage
.
read
(
orderId
,
appKey
);
ctx
.
body
=
{
code
:
0
,
data
:
result
};
return
;
await
service
.
partner
.
appKeyLimit
(
appKey
);
const
result
=
await
service
.
storage
.
read
(
orderId
,
appKey
);
ctx
.
body
=
{
code
:
0
,
data
:
result
};
return
;
}
ctx
.
body
=
{
code
:
-
1
,
...
...
@@ -129,13 +130,13 @@ class OrderController extends Controller {
}
async
orderShow
()
{
const
{
ctx
,
service
}
=
this
;
const
{
appKey
,
orderId
}
=
ctx
.
params
;
const
{
ctx
,
service
}
=
this
;
const
{
appKey
,
orderId
}
=
ctx
.
params
;
const
appKeyInfo
=
await
service
.
partner
.
fetchInfo
(
appKey
);
if
(
!
(
appKeyInfo
&&
appKeyInfo
.
valid
===
true
&&
appKeyInfo
.
enableItView
===
true
))
{
return
ctx
.
fail
(
'未开通此服务'
);
}
const
data
=
await
service
.
order
.
getOneByOrderId
({
orderId
,
status
:
'success'
});
const
data
=
await
service
.
order
.
getOneByOrderId
({
orderId
,
status
:
'success'
});
if
(
data
)
{
if
(
data
.
status
===
'success'
&&
(
data
.
appkey
===
appKey
))
{
const
result
=
await
service
.
storage
.
read
(
orderId
,
appKey
);
...
...
app/schedule/notifyUrl.js
View file @
8e5a1516
...
...
@@ -24,8 +24,8 @@ module.exports = {
notifyMap
.
set
(
customer
.
appKey
,
{
notifyUrl
:
customer
.
callBackUrl
});
}
});
ctx
.
app
.
notifyMap
=
notifyMap
;
}
ctx
.
app
.
notifyMap
=
notifyMap
;
}
catch
(
e
)
{
ctx
.
logger
.
error
(
'【schedule/notifyUrlTask】catch error:'
,
JSON
.
stringify
(
e
));
}
...
...
app/service/partner.js
View file @
8e5a1516
...
...
@@ -156,6 +156,50 @@ class PartnerService extends Service {
ctx
.
logger
.
info
(
'【Partner】 notice no send'
,
'orderId:'
,
orderId
);
}
}
async
appKeyLimit
(
appKey
)
{
const
{
ctx
,
partnerAPI
:
{
redisappKeyLimitPrefix
}
}
=
this
;
let
data
=
await
this
.
app
.
redis
.
get
(
redisappKeyLimitPrefix
);
data
=
JSON
.
parse
(
data
);
if
(
data
)
{
if
(
data
.
includes
(
appKey
))
{
let
limit
=
await
this
.
app
.
redis
.
get
(
redisappKeyLimitPrefix
+
appKey
);
if
(
limit
)
{
limit
=
JSON
.
parse
(
limit
);
if
(
limit
.
currentCount
>=
limit
.
limitCount
)
{
ctx
.
throw
(
422
,
{
message
:
'appKey查询数量超过限制,请联系技术人员'
});
}
else
{
// limit.currentCount++;
// await this.app.redis.set(redisappKeyLimitPrefix + appKey, JSON.stringify({ currentCount: limit.currentCount, limitCount: limit.limitCount }), 'EX', 300);
await
ctx
.
model
.
query
(
'UPDATE node_limit set currentCount = currentCount + 1 where appKey = ?'
,
{
type
:
'UPDATE'
,
replacements
:
[
appKey
],
});
}
}
}
}
else
{
const
dbRes
=
await
ctx
.
model
.
NodeLimit
.
findAll
({
attributes
:
[
'appKey'
,
'currentCount'
,
'limitCount'
],
where
:
{
type
:
'gjj'
},
});
if
(
dbRes
)
{
const
appKeyArray
=
[];
for
(
const
item
of
dbRes
)
{
const
{
appKey
,
currentCount
,
limitCount
}
=
item
;
appKeyArray
.
push
(
appKey
);
await
this
.
app
.
redis
.
set
(
redisappKeyLimitPrefix
+
appKey
,
JSON
.
stringify
({
currentCount
,
limitCount
}),
'EX'
,
300
);
}
await
this
.
app
.
redis
.
set
(
redisappKeyLimitPrefix
,
JSON
.
stringify
(
appKeyArray
),
'EX'
,
300
);
if
(
appKeyArray
.
includes
(
appKey
))
{
await
ctx
.
model
.
query
(
'UPDATE node_limit set currentCount = currentCount + 1 where appKey = ?'
,
{
type
:
'UPDATE'
,
replacements
:
[
appKey
],
});
}
}
}
}
}
module
.
exports
=
PartnerService
;
config/config.local.js
View file @
8e5a1516
...
...
@@ -34,6 +34,7 @@ module.exports = () => {
redisScriptsPrefix
:
'URANUS.IT.PARNTERS.SCRIPTS'
,
redisAgreementsPrefix
:
'URANUS.IT.PARNTERS.Agreements'
,
redisInfoPrefix
:
'URANUS.IT.PARNTERS.Info'
,
redisappKeyLimitPrefix
:
'URANUS.IT.PARNTERS.Limit'
,
};
config
.
scriptsAPI
=
{
...
...
config/config.prod.js
View file @
8e5a1516
...
...
@@ -37,6 +37,7 @@ module.exports = () => {
redisScriptsPrefix
:
'URANUS.IT.PARNTERS.SCRIPTS'
,
redisAgreementsPrefix
:
'URANUS.IT.PARNTERS.Agreements'
,
redisInfoPrefix
:
'URANUS.IT.PARNTERS.Info'
,
redisappKeyLimitPrefix
:
'URANUS.IT.PARNTERS.Limit'
,
};
config
.
scriptsAPI
=
{
...
...
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