Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjh5
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
gjjh5
Commits
3b31375e
Commit
3b31375e
authored
Mar 07, 2019
by
姜登
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增appKey配置
parent
d897fdaa
Pipeline
#4112
passed with stage
in 58 seconds
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
58 additions
and
39 deletions
+58
-39
order.js
app/controller/order.js
+12
-0
router.js
app/router.js
+0
-1
appKey.js
app/schedule/appKey.js
+0
-23
partner.js
app/service/partner.js
+37
-4
config.default.js
config/config.default.js
+1
-3
config.local.js
config/config.local.js
+5
-7
config.prod.js
config/config.prod.js
+3
-1
No files found.
app/controller/order.js
View file @
3b31375e
...
...
@@ -50,6 +50,10 @@ class OrderController extends Controller {
const
uuid
=
require
(
'node-uuid'
);
ctx
.
validate
(
this
.
createRule
);
let
{
appKey
,
userId
,
notifyUrl
,
backUrl
,
orderId
}
=
ctx
.
request
.
body
;
const
appKeyInfo
=
await
service
.
partner
.
fetchInfo
(
appKey
);
if
(
!
(
appKeyInfo
&&
appKeyInfo
.
valid
===
true
&&
appKeyInfo
.
enableHf
===
true
))
{
return
ctx
.
fail
(
'未开通此服务'
);
}
if
(
orderId
)
{
await
service
.
order
.
update
({
orderId
,
...
...
@@ -103,6 +107,10 @@ class OrderController extends Controller {
try
{
ctx
.
validate
(
this
.
showRule
);
const
{
appKey
,
orderId
}
=
ctx
.
request
.
body
.
params
;
const
appKeyInfo
=
await
service
.
partner
.
fetchInfo
(
appKey
);
if
(
!
(
appKeyInfo
&&
appKeyInfo
.
valid
===
true
&&
appKeyInfo
.
enableHfData
===
true
))
{
return
ctx
.
fail
(
'未开通此服务'
);
}
await
service
.
signature
.
signatureCheck
(
ctx
.
request
.
body
);
const
data
=
await
service
.
order
.
getOneByOrderId
(
orderId
);
if
(
data
)
{
...
...
@@ -132,6 +140,10 @@ class OrderController extends Controller {
async
orderShow
()
{
const
{
ctx
,
service
}
=
this
;
const
{
appKey
,
orderId
}
=
ctx
.
params
;
const
appKeyInfo
=
await
service
.
partner
.
fetchInfo
(
appKey
);
if
(
!
(
appKeyInfo
&&
appKeyInfo
.
valid
===
true
&&
appKeyInfo
.
enableHfView
===
true
))
{
return
ctx
.
fail
(
'未开通此服务'
);
}
const
data
=
await
service
.
order
.
getOneByOrderId
(
orderId
);
if
(
data
)
{
if
(
data
.
status
===
'success'
&&
(
data
.
appKey
===
appKey
))
{
...
...
app/router.js
View file @
3b31375e
...
...
@@ -24,7 +24,6 @@ module.exports = app => {
gjjRouter
.
get
(
'/params'
,
controller
.
script
.
fetchParamsInfo
);
// 获取登录参数字典
gjjRouter
.
post
(
'/tokens'
,
controller
.
token
.
create
);
// 创建token
gjjRouter
.
post
(
'/orders'
,
controller
.
order
.
create
);
// 创建订单号
// router.post('/orders/:orderId', controller.order.show); // 获取订单号详情
gjjRouter
.
get
(
'/hubs/:hubId/scripts'
,
controller
.
script
.
fetchHubSeripts
);
// 根据hubId 获取脚本数据(数组)
...
...
app/schedule/appKey.js
deleted
100644 → 0
View file @
d897fdaa
'use strict'
;
module
.
exports
=
{
schedule
:
{
interval
:
'5m'
,
// 5分钟间隔
type
:
'all'
,
// 所有woker
immediate
:
true
,
},
async
task
(
ctx
)
{
try
{
const
dbRes
=
await
ctx
.
cusPro
.
query
(
'SELECT app_key FROM customer_product WHERE goods_sn = 102 AND state = 1'
,
{
type
:
'SELECT'
,
});
const
arr
=
[];
for
(
const
item
of
dbRes
)
{
arr
.
push
(
item
.
app_key
);
}
ctx
.
app
.
appKeyArr
=
arr
;
}
catch
(
e
)
{
ctx
.
logger
.
error
(
'【schedule/flash_cus_pro】catch error:'
,
JSON
.
stringify
(
e
));
}
}
};
app/service/partner.js
View file @
3b31375e
...
...
@@ -22,17 +22,50 @@ class PartnerService extends Service {
}
}
}
const
ret
=
await
ctx
.
curl
(
`
${
host
+
fetchTheme
}
/
${
appKey
}
/theme
`
,
{
const
ret
=
await
ctx
.
curl
(
`
${
host
+
fetchTheme
}
`
,
{
charset
:
'utf-8'
,
timeout
:
[
'30s'
,
'30s'
],
dataType
:
'json'
,
method
:
'GET'
,
data
:
{
appKey
,
subject
:
'hf'
}
});
ctx
.
logger
.
info
(
`【Partner】 fetchTheme
${
host
+
fetchTheme
}
/
${
appKey
}
`
,
ret
.
data
);
if
(
ret
.
status
===
200
&&
ret
.
data
&&
ret
.
data
.
appKey
===
appKey
)
{
await
this
.
app
.
redis
.
set
(
redisThemePrefix
+
appKey
,
JSON
.
stringify
(
ret
.
data
),
'EX'
,
300
);
if
(
ret
.
status
===
200
&&
ret
.
data
&&
ret
.
data
.
length
>
0
&&
ret
.
data
[
0
].
appKey
===
appKey
)
{
await
this
.
app
.
redis
.
set
(
redisThemePrefix
+
appKey
,
JSON
.
stringify
(
ret
.
data
[
0
]
),
'EX'
,
300
);
}
return
ret
.
data
;
return
ret
.
data
[
0
];
}
async
fetchInfo
(
appKey
){
const
{
ctx
,
partnerAPI
:
{
fetchInfo
,
host
,
redisInfoPrefix
}
}
=
this
;
if
(
appKey
)
{
const
data
=
await
this
.
app
.
redis
.
get
(
redisInfoPrefix
+
appKey
);
if
(
data
)
{
try
{
return
JSON
.
parse
(
data
);
}
catch
(
err
)
{
ctx
.
logger
.
error
(
'【Scripts】fetchInfo'
,
redisInfoPrefix
+
appKey
,
'result:'
,
data
,
err
);
await
this
.
app
.
redis
.
del
(
redisInfoPrefix
+
appKey
);
}
}
}
const
ret
=
await
ctx
.
curl
(
`
${
host
+
fetchInfo
}
`
,
{
charset
:
'utf-8'
,
timeout
:
[
'30s'
,
'30s'
],
dataType
:
'json'
,
method
:
'GET'
,
data
:
{
appKey
}
});
ctx
.
logger
.
info
(
`【Partner】 fetchTheme
${
host
+
fetchInfo
}
?appKey=
${
appKey
}
`
,
ret
.
data
);
if
(
ret
.
status
===
200
&&
ret
.
data
&&
ret
.
data
.
length
>
0
&&
ret
.
data
[
0
].
appKey
===
appKey
)
{
await
this
.
app
.
redis
.
set
(
redisInfoPrefix
+
appKey
,
JSON
.
stringify
(
ret
.
data
[
0
]),
'EX'
,
300
);
}
return
ret
.
data
[
0
];
}
async
fetchScripts
(
appKey
)
{
...
...
config/config.default.js
View file @
3b31375e
...
...
@@ -13,9 +13,7 @@ module.exports = appInfo => {
maxDays
:
5
,
}
// config.verifyAppKey = {
// match: '/orders',
// }
// 是否启用csrf安全
config
.
security
=
{
...
...
config/config.local.js
View file @
3b31375e
...
...
@@ -25,12 +25,14 @@ module.exports = () => {
config
.
partnerAPI
=
{
host
:
'https://uat-nginx.jianbing.com/zeus-api/v1'
,
fetchTheme
:
'/chaos/
hf/partners
'
,
fetchTheme
:
'/chaos/
theme
'
,
fetchScripts
:
'/chaos/partners/scripts'
,
fetchAgreements
:
'/chaos/agreements'
,
redisThemePrefix
:
'URANUS.HF.PARNTERS.THEME'
,
redisScriptsPrefix
:
'URANUS.HF.PARNTERS.SCRIPTS'
,
redisAgreementsPrefix
:
'URANUS.HF.PARNTERS.Agreements'
,
fetchInfo
:
'/chaos/partner'
,
redisInfoPrefix
:
'URANUS.HF.PARNTERS.Info'
,
};
config
.
scriptsAPI
=
{
...
...
@@ -45,7 +47,7 @@ module.exports = () => {
fetchScriptByCityNameUrl
:
'/chaos/hf/city_scripts'
,
redisScriptsKey
:
'URANUS.HF.SCRIPTS'
,
redisParamsKey
:
'URANUS.HF.PARAMS'
,
redisScriptListKey
:
'URANUS.HF.SCRIPTLIST'
,
redisScriptListKey
:
'URANUS.HF.SCRIPTLIST'
,
};
config
.
storageAPI
=
{
...
...
@@ -68,7 +70,7 @@ module.exports = () => {
signatureUrl
:
'/Access/SignValidityCheck'
,
fetchParnterUrl
:
''
,
signatureType
:
'gjj'
,
customerUrl
:
'/customer/query'
,
customerUrl
:
'/customer/query'
,
};
config
.
lockKeys
=
{
...
...
@@ -105,10 +107,6 @@ module.exports = () => {
}],
};
config
.
GJJ_OpenAPI
=
{
appKey
:
'60670203E411FD62BA9E953CFB73F881'
,
appSecret
:
'0BDD1ECC147503C477563E5C1438C366D70E4F80'
,
};
config
.
callbackUrl
=
'https://dev-nginx.jianbing.com/gjjh5/callback'
;
...
...
config/config.prod.js
View file @
3b31375e
...
...
@@ -66,12 +66,14 @@ module.exports = () => {
config
.
partnerAPI
=
{
host
:
process
.
env
.
PARTNERAPI_HOST
||
'https://uat-nginx.jianbing.com/zeus-api/v1'
,
fetchTheme
:
'/chaos/
hf/partners
'
,
fetchTheme
:
'/chaos/
theme
'
,
fetchScripts
:
'/chaos/partners/scripts'
,
fetchAgreements
:
'/chaos/agreements'
,
redisThemePrefix
:
'URANUS.HF.PARNTERS.THEME'
,
redisScriptsPrefix
:
'URANUS.HF.PARNTERS.SCRIPTS'
,
redisAgreementsPrefix
:
'URANUS.HF.PARNTERS.Agreements'
,
fetchInfo
:
'/chaos/partner'
,
redisInfoPrefix
:
'URANUS.HF.PARNTERS.Info'
,
};
config
.
lockKeys
=
{
...
...
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