Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tax_api
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
tax_api
Commits
d07e239d
Commit
d07e239d
authored
May 09, 2019
by
何娜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
taxapi 限制appKey查询次数
parent
ea5f3f25
Pipeline
#7259
passed with stage
in 9 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
16 deletions
+133
-16
order.js
app/controller/order.js
+16
-15
nodeLimit.js
app/model/nodeLimit.js
+70
-0
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 @
d07e239d
...
...
@@ -49,15 +49,16 @@ class OrderController extends Controller {
//拉取数据接口
async
partnerShow
()
{
const
{
ctx
,
service
}
=
this
;
const
{
ctx
,
service
}
=
this
;
try
{
ctx
.
validate
(
this
.
showRule
);
const
{
appKey
,
orderSn
}
=
ctx
.
request
.
body
.
params
;
const
{
appKey
,
orderSn
}
=
ctx
.
request
.
body
.
params
;
await
service
.
signature
.
signatureCheck
(
ctx
.
request
.
body
);
let
data
=
await
service
.
cache
.
get
({
key
:
orderSn
});
let
data
=
await
service
.
cache
.
get
({
key
:
orderSn
});
let
result
=
'任务还在执行或未输入'
;
if
(
data
)
{
if
(
data
.
status
===
'success'
)
{
await
service
.
partner
.
appKeyLimit
(
appKey
);
const
result
=
await
service
.
storage
.
read
(
orderSn
,
appKey
);
ctx
.
body
=
{
code
:
0
,
...
...
@@ -74,18 +75,18 @@ class OrderController extends Controller {
ctx
.
logger
.
error
(
'partnerShow'
,
err
);
ctx
.
status
=
200
;
if
(
err
.
code
==
'invalid_param'
)
{
return
ctx
.
body
=
{
code
:
-
1
,
msg
:
err
.
message
||
''
};
return
ctx
.
body
=
{
code
:
-
1
,
msg
:
err
.
message
||
''
};
}
return
ctx
.
body
=
{
code
:
err
.
code
||
-
1
,
msg
:
err
.
message
||
''
};
return
ctx
.
body
=
{
code
:
err
.
code
||
-
1
,
msg
:
err
.
message
||
''
};
}
}
//创建订单号接口
async
fetchOrderId
()
{
const
{
ctx
,
service
}
=
this
;
const
{
ctx
,
service
}
=
this
;
try
{
ctx
.
validate
(
this
.
fetchOrderIdRule
,
ctx
.
query
);
const
{
appKey
,
cityId
}
=
ctx
.
query
;
const
{
appKey
,
cityId
}
=
ctx
.
query
;
// const appKeyInfo = await service.partner.fetchInfo(appKey);
// ctx.logger.info(appKey, ',appKeyInfo,', appKeyInfo);
// if (!(appKeyInfo && appKeyInfo.valid === true && appKeyInfo.enableIt === true)) {
...
...
@@ -112,21 +113,21 @@ class OrderController extends Controller {
ctx
.
logger
.
error
(
'fetchOrderId'
,
err
);
ctx
.
status
=
200
;
if
(
err
.
code
==
'invalid_param'
)
{
return
ctx
.
body
=
{
code
:
-
1
,
msg
:
err
.
message
||
''
};
return
ctx
.
body
=
{
code
:
-
1
,
msg
:
err
.
message
||
''
};
}
return
ctx
.
body
=
{
code
:
err
.
code
||
-
1
,
msg
:
err
.
message
||
''
};
return
ctx
.
body
=
{
code
:
err
.
code
||
-
1
,
msg
:
err
.
message
||
''
};
}
}
//获取帮助配置接口
async
help
()
{
const
{
ctx
,
service
}
=
this
;
const
{
cityId
}
=
ctx
.
query
;
async
help
()
{
const
{
ctx
,
service
}
=
this
;
const
{
cityId
}
=
ctx
.
query
;
const
cityName
=
await
await
service
.
scripts
.
fetchScriptName
(
cityId
);
const
helpData
=
await
service
.
scripts
.
fetchHelp
(
cityId
);
if
(
helpData
&&
helpData
.
length
>
0
)
{
if
(
helpData
&&
helpData
.
length
>
0
)
{
let
helpInfo
=
[];
for
(
let
item
of
helpData
[
0
].
help_list
)
{
for
(
let
item
of
helpData
[
0
].
help_list
)
{
helpInfo
.
push
({
desc
:
item
.
content
,
link
:
{
...
...
@@ -143,7 +144,7 @@ class OrderController extends Controller {
help
:
helpInfo
}
});
}
else
{
}
else
{
return
ctx
.
body
=
{
code
:
"-1"
,
msg
:
"未查询到此地区帮助信息"
...
...
app/model/nodeLimit.js
0 → 100644
View file @
d07e239d
'use strict'
;
module
.
exports
=
app
=>
{
const
{
DataTypes
}
=
app
.
Sequelize
;
const
nodeLimit
=
app
.
model
.
define
(
'nodeLimit'
,
{
id
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
false
,
autoIncrement
:
true
,
primaryKey
:
true
,
field
:
'id'
,
},
companyName
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
true
,
field
:
'companyName'
,
},
appKey
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
false
,
field
:
'appKey'
,
},
type
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
true
,
field
:
'type'
,
},
currentCount
:
{
type
:
DataTypes
.
INTEGER
(
20
),
allowNull
:
true
,
defaultValue
:
0
,
field
:
'currentCount'
,
},
limitCount
:
{
type
:
DataTypes
.
INTEGER
(
20
),
allowNull
:
true
,
defaultValue
:
0
,
field
:
'limitCount'
,
},
createTime
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
,
defaultValue
:
app
.
Sequelize
.
literal
(
'CURRENT_TIMESTAMP'
),
field
:
'createTime'
,
},
updateTime
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
true
,
defaultValue
:
app
.
Sequelize
.
literal
(
'CURRENT_TIMESTAMP'
),
field
:
'updateTime'
,
},
text
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
true
,
field
:
'text1'
,
},
text2
:
{
type
:
DataTypes
.
STRING
(
255
),
allowNull
:
true
,
field
:
'text2'
,
},
},
{
tableName
:
'node_limit'
,
timestamps
:
false
,
});
return
nodeLimit
;
};
app/schedule/notifyUrl.js
View file @
d07e239d
...
...
@@ -25,8 +25,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 @
d07e239d
...
...
@@ -61,6 +61,50 @@ class PartnerService extends Service {
}
return
;
}
async
appKeyLimit
(
appKey
)
{
const
{
ctx
,
partnerAPI
:
{
redisappKeyLimitPrefix
}
}
=
this
;
let
data
=
await
this
.
app
.
redis
.
get
(
redisappKeyLimitPrefix
);
if
(
data
)
{
data
=
JSON
.
parse
(
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
:
'tax'
},
});
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 @
d07e239d
...
...
@@ -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 @
d07e239d
...
...
@@ -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