Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
57c68b17
Commit
57c68b17
authored
Mar 18, 2020
by
王栋源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wdy
parent
b12c37cc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
257 additions
and
5 deletions
+257
-5
igirl-channel-gateway/app/base/service/app.base.js
+102
-0
igirl-channel-gateway/app/base/service/impl/common/oplogSve.js
+8
-3
igirl-channel-gateway/app/base/service/impl/utilsSve/utilsNeedSve.js
+50
-0
igirl-channel-gateway/app/config/routes/api.js
+95
-0
igirl-channel-gateway/app/config/settings.js
+2
-2
No files found.
igirl-channel-gateway/app/base/service/app.base.js
0 → 100644
View file @
57c68b17
const
system
=
require
(
"../system"
);
const
moment
=
require
(
'moment'
)
const
settings
=
require
(
"../../config/settings"
);
const
md5
=
require
(
"MD5"
);
class
AppServiceBase
{
constructor
()
{
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async
verifySign
(
params
,
app_key
)
{
if
(
!
params
)
{
return
system
.
getResult
(
null
,
"请求参数为空"
);
}
if
(
!
params
.
sign
)
{
return
system
.
getResult
(
null
,
"请求参数sign为空"
);
}
var
signArr
=
[];
var
keys
=
Object
.
keys
(
params
).
sort
();
if
(
keys
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"请求参数信息为空"
);
}
for
(
let
k
=
0
;
k
<
keys
.
length
;
k
++
)
{
const
tKey
=
keys
[
k
];
if
(
tKey
!=
"sign"
&&
params
[
tKey
]
&&
!
(
params
[
tKey
]
instanceof
Array
))
{
signArr
.
push
(
tKey
+
"="
+
params
[
tKey
]);
}
}
if
(
signArr
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"请求参数组装签名参数信息为空"
);
}
var
resultSignStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
app_key
;
var
resultTmpSign
=
md5
(
resultSignStr
).
toUpperCase
();
if
(
params
.
sign
!=
resultTmpSign
)
{
return
system
.
getResult
(
null
,
"返回值签名验证失败"
);
}
return
system
.
getResultSuccess
();
}
async
restPostUrl
(
pobj
,
url
)
{
var
rtn
=
await
this
.
restClient
.
execPost
(
pobj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"restPost data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
async
execPostUrl
(
pobj
,
url
)
{
var
rtn
=
await
this
.
execClient
.
execPost
(
pobj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async
getBusUid
(
prefix
)
{
prefix
=
(
prefix
||
""
);
if
(
prefix
)
{
prefix
=
prefix
.
toUpperCase
();
}
var
prefixlength
=
prefix
.
length
;
var
subLen
=
8
-
prefixlength
;
var
uidStr
=
""
;
if
(
subLen
>
0
)
{
uidStr
=
await
this
.
getUidInfo
(
subLen
,
60
);
}
var
timStr
=
moment
().
format
(
"YYYYMMDDHHmm"
);
return
prefix
+
timStr
+
uidStr
;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async
getUidInfo
(
len
,
radix
)
{
var
chars
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
.
split
(
''
);
//长度62,到yz长度为长36
var
uuid
=
[],
i
;
radix
=
radix
||
chars
.
length
;
if
(
len
)
{
for
(
i
=
0
;
i
<
len
;
i
++
)
uuid
[
i
]
=
chars
[
0
|
Math
.
random
()
*
radix
];
}
else
{
var
r
;
uuid
[
8
]
=
uuid
[
13
]
=
uuid
[
18
]
=
uuid
[
23
]
=
'-'
;
uuid
[
14
]
=
'4'
;
for
(
i
=
0
;
i
<
36
;
i
++
)
{
if
(
!
uuid
[
i
])
{
r
=
0
|
Math
.
random
()
*
16
;
uuid
[
i
]
=
chars
[(
i
==
19
)
?
(
r
&
0x3
)
|
0x8
:
r
];
}
}
}
return
uuid
.
join
(
''
);
}
}
module
.
exports
=
AppServiceBase
;
igirl-channel-gateway/app/base/service/impl/common/oplogSve.js
View file @
57c68b17
...
@@ -4,13 +4,19 @@ var settings = require("../../../../config/settings");
...
@@ -4,13 +4,19 @@ var settings = require("../../../../config/settings");
class
OplogService
extends
ServiceBase
{
class
OplogService
extends
ServiceBase
{
constructor
()
{
constructor
()
{
super
(
"common"
,
ServiceBase
.
getDaoName
(
OplogService
));
super
(
"common"
,
ServiceBase
.
getDaoName
(
OplogService
));
//this.appDao=system.getObject("db.appDao");
this
.
opLogUrl
=
settings
.
apiconfig
.
opLogUrl
();
this
.
opLogUrl
=
settings
.
apiconfig
.
opLogUrl
();
this
.
opLogEsIsAdd
=
settings
.
apiconfig
.
opLogEsIsAdd
();
this
.
opLogEsIsAdd
=
settings
.
apiconfig
.
opLogEsIsAdd
();
}
}
async
error
(
qobj
)
{
this
.
create
(
qobj
);
}
async
info
(
qobj
)
{
this
.
create
(
qobj
);
}
async
create
(
qobj
)
{
async
create
(
qobj
)
{
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"oplogCtl"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
...
@@ -48,7 +54,6 @@ class OplogService extends ServiceBase {
...
@@ -48,7 +54,6 @@ class OplogService extends ServiceBase {
async
createDb
(
qobj
)
{
async
createDb
(
qobj
)
{
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
if
(
!
qobj
||
!
qobj
.
op
||
qobj
.
op
.
indexOf
(
"metaCtl/getUiConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"userCtl/checkLogin"
)
>=
0
||
qobj
.
op
.
indexOf
(
"oplogCtl"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getDicConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRouteConfig"
)
>=
0
||
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
qobj
.
op
.
indexOf
(
"getRsConfig"
)
>=
0
)
{
...
@@ -58,7 +63,7 @@ class OplogService extends ServiceBase {
...
@@ -58,7 +63,7 @@ class OplogService extends ServiceBase {
qobj
.
optitle
=
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
":"
+
qobj
.
optitle
;
qobj
.
optitle
=
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
":"
+
qobj
.
optitle
;
//解决日志大于4000写入的问题
//解决日志大于4000写入的问题
if
(
qobj
.
content
.
length
>
4980
)
{
if
(
qobj
.
content
.
length
>
4980
)
{
qobj
.
content
=
qobj
.
content
.
substring
(
0
,
4980
);
qobj
.
content
=
qobj
.
content
.
substring
(
0
,
4980
);
}
}
this
.
dao
.
create
(
qobj
);
this
.
dao
.
create
(
qobj
);
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
igirl-channel-gateway/app/base/service/impl/utilsSve/utilsNeedSve.js
0 → 100644
View file @
57c68b17
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
AppServiceBase
=
require
(
"../../app.base"
);
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
//商标查询操作
class
UtilsNeedSve
extends
AppServiceBase
{
constructor
()
{
super
();
this
.
execlient
=
system
.
getObject
(
"util.execClient"
);
this
.
channelApiUrl
=
settings
.
channelApiUrl
();
this
.
appInfo
=
{
aliyuntmtransfer
:
{
appkey
:
settings
.
appKey
,
secret
:
settings
.
secret
}
};
}
async
getToken
()
{
var
self
=
this
;
var
reqTokenUrl
=
this
.
channelApiUrl
+
"/auth/accessAuth/getToken"
;
var
reqParam
=
self
.
appInfo
[
"aliyuntmtransfer"
];
if
(
!
reqParam
.
appkey
||
!
reqParam
.
secret
)
{
return
system
.
getResult
(
null
,
"reqType类型有误,请求失败"
);
}
var
rtn
=
await
this
.
execlient
.
execPost
(
reqParam
,
reqTokenUrl
);
if
(
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"获取token失败"
);
}
var
tokenResult
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
tokenResult
.
status
==
0
)
{
tokenResult
.
data
.
secret
=
reqParam
.
secret
;
}
return
tokenResult
;
}
async
reqcenterchannel
(
pobj
)
{
var
sobj
=
{
"actionProcess"
:
"ali"
,
"actionType"
:
pobj
.
action_type
,
"isUser"
:
"yes"
,
"actionBody"
:
pobj
}
var
tokenInfo
=
await
this
.
getToken
();
var
url
=
settings
.
centerChannelUrl
()
+
"web/opreceive/need/springBoard"
;
var
rtn
=
await
this
.
execlient
.
execPostTK
(
sobj
,
url
,
tokenInfo
.
data
.
token
);
return
rtn
;
}
}
module
.
exports
=
UtilsNeedSve
;
igirl-channel-gateway/app/config/routes/api.js
View file @
57c68b17
var
url
=
require
(
"url"
);
var
url
=
require
(
"url"
);
var
system
=
require
(
"../../base/system"
);
var
system
=
require
(
"../../base/system"
);
// var userSve = system.getObject("service.auth.userSve");
// var userSve = system.getObject("service.auth.userSve");
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
const
utilsNeedSve
=
system
.
getObject
(
"service.utilsSve.utilsNeedSve"
);
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
// app.get("/auth", async function (req, res) {
// app.get("/auth", async function (req, res) {
// if (!req.query.opencode) {
// if (!req.query.opencode) {
...
@@ -8,6 +11,98 @@ module.exports = function (app) {
...
@@ -8,6 +11,98 @@ module.exports = function (app) {
// }
// }
// return await userSve.authByCode(opencode);
// return await userSve.authByCode(opencode);
// });
// });
// case "submitSolution"://提交需求
// opResult = await this.needinfoSve.createicneedinfo(pobj);
// break;
// case "paySuccess"://支付成功回调
// opResult = await this.orderinfoSve.createsolutionOrder(pobj);
// break;
// case "solutionClose"://需求关闭
// opResult = await this.needinfoSve.solutionClose(pobj);
app
.
use
(
'/api/ali/esp/intention/submit'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
req
.
body
.
action_type
=
"submitSolution"
;
var
result
=
await
utilsNeedSve
.
reqcenterchannel
(
req
.
body
,
client_ip
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"回调处理订单结果:,method="
+
req
.
body
.
trxcode
,
op
:
"api/ali/esp/intention/submit"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调处理订单结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
res
.
end
(
JSON
.
stringify
(
result
));
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果异常:,method="
+
req
.
body
.
trxcode
,
op
:
"/api/ali/esp/intention/submit"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
app
.
use
(
'/api/ali/esp/intention/solution/feedback'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
req
.
body
.
action_type
=
"receiveFeedback"
;
var
result
=
await
utilsNeedSve
.
opBackNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"回调处理订单结果:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/opBackNotify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调处理订单结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
res
.
end
(
JSON
.
stringify
(
result
));
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果异常:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/opBackNotify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
app
.
use
(
'/api/ali/ic/paySuccess'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
req
.
body
.
action_type
=
"paySuccess"
;
var
result
=
await
utilsNeedSve
.
opBackNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"回调处理订单结果:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/opBackNotify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调处理订单结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
res
.
end
(
JSON
.
stringify
(
result
));
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果异常:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/opBackNotify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
app
.
use
(
'/api/ali/esp/intention/close'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
req
.
body
.
action_type
=
"solutionClose"
;
var
result
=
await
utilsNeedSve
.
opBackNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"回调处理订单结果:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/opBackNotify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调处理订单结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
res
.
end
(
JSON
.
stringify
(
result
));
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果异常:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/opBackNotify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
app
.
get
(
'/api/:gname/:qname/:method'
,
function
(
req
,
res
)
{
app
.
get
(
'/api/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
methodName
=
req
.
params
[
"method"
];
...
...
igirl-channel-gateway/app/config/settings.js
View file @
57c68b17
...
@@ -33,7 +33,7 @@ var settings = {
...
@@ -33,7 +33,7 @@ var settings = {
},
},
channelApiUrl
:
function
()
{
channelApiUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
if
(
this
.
env
==
"dev"
)
{
return
"http://
192.168.18.34
:4003"
;
return
"http://
gsb.qifu.gongsibao.com
:4003"
;
}
else
{
}
else
{
return
"http://zc-channel-service"
;
return
"http://zc-channel-service"
;
}
}
...
@@ -48,7 +48,7 @@ var settings = {
...
@@ -48,7 +48,7 @@ var settings = {
apiconfig
:
{
apiconfig
:
{
opLogUrl
:
function
()
{
opLogUrl
:
function
()
{
return
settings
.
reqEsAddr
()
+
"
bigdata_zc
_op_log/_doc?pretty"
;
return
settings
.
reqEsAddr
()
+
"
center_gateway
_op_log/_doc?pretty"
;
},
},
opLogEsIsAdd
:
function
()
{
opLogEsIsAdd
:
function
()
{
return
1
;
return
1
;
...
...
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