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
b149c3a1
Commit
b149c3a1
authored
May 07, 2021
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加路由
parent
027370fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
696 additions
and
667 deletions
+696
-667
center-channel/app/config/businessConfig.js
+4
-0
center-channel/app/config/routes/api.js
+692
-667
No files found.
center-channel/app/config/businessConfig.js
View file @
b149c3a1
...
@@ -58,6 +58,10 @@ module.exports = {
...
@@ -58,6 +58,10 @@ module.exports = {
"/api/tm/status/notify"
,
"/api/tm/status/notify"
,
"/api/tm/tmcase/nbtzreceiveAssistTmData"
,
"/api/tm/tmcase/nbtzreceiveAssistTmData"
,
"/api/tm/tmcase/nbtzreceiveEditAssistTmData"
"/api/tm/tmcase/nbtzreceiveEditAssistTmData"
],
apiAliSendKeyPathList
:
[
"/api/opreceive/pushAliInfo/tmNote"
,
"/api/opreceive/pushAliInfo/icNote"
,
]
]
},
},
AREACOMM
:
{
AREACOMM
:
{
...
...
center-channel/app/config/routes/api.js
View file @
b149c3a1
...
@@ -6,700 +6,724 @@ const utilsFeishuSve = system.getObject("service.utilsSve.utilsFeishuSve");
...
@@ -6,700 +6,724 @@ const utilsFeishuSve = system.getObject("service.utilsSve.utilsFeishuSve");
const
signSve
=
system
.
getObject
(
"service.common.signSve"
);
const
signSve
=
system
.
getObject
(
"service.common.signSve"
);
const
xml2js
=
require
(
'xml2js'
);
const
xml2js
=
require
(
'xml2js'
);
const
jwt
=
require
(
'jsonwebtoken'
);
const
jwt
=
require
(
'jsonwebtoken'
);
const
{
PDICT
}
=
require
(
"../../config/businessConfig"
);
const
{
PDICT
}
=
require
(
"../../config/businessConfig"
);
const
settings
=
require
(
"../../config/settings"
);
const
settings
=
require
(
"../../config/settings"
);
module
.
exports
=
function
(
app
)
{
module
.
exports
=
function
(
app
)
{
//-----------------------新的模式---------web---------开始
//-----------------------新的模式---------web---------开始
app
.
use
(
'/tlpay/aliPayNotify'
,
async
function
(
req
,
res
)
{
//钉钉接入的搁浅
app
.
use
(
'/tlpay/aliPayNotify'
,
async
function
(
req
,
res
)
{
//钉钉接入的搁浅
try
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsOrderSve
.
opH5AliDingPayBackNotify
(
req
.
body
,
client_ip
);
var
result
=
await
utilsOrderSve
.
opH5AliDingPayBackNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录阿里钉钉支付回调处理结果"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录阿里钉钉支付回调处理结果"
,
op
:
"center-channel/tlpay/aliPayNotify"
,
op
:
"center-channel/tlpay/aliPayNotify"
,
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
if
(
result
.
status
!=
0
)
{
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"FAIL"
);
return
res
.
end
(
"FAIL"
);
}
}
return
res
.
end
(
"success"
);
return
res
.
end
(
"success"
);
}
catch
(
error
)
{
}
catch
(
error
)
{
logCtl
.
error
({
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"阿里钉钉支付回调处理异常"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"阿里钉钉支付回调处理异常"
,
op
:
"center-channel/tlpay/aliPayNotify"
,
op
:
"center-channel/tlpay/aliPayNotify"
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
error
.
stack
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
}
}
});
});
app
.
use
(
'/tlpay/notify'
,
async
function
(
req
,
res
)
{
app
.
use
(
'/tlpay/notify'
,
async
function
(
req
,
res
)
{
try
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsOrderSve
.
receiveCallBackNotify
(
req
.
body
,
client_ip
);
var
result
=
await
utilsOrderSve
.
receiveCallBackNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果:,method="
+
req
.
body
.
trxcode
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/notify"
,
op
:
"center-channel/tlpay/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
if
(
result
.
status
!=
0
)
{
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"FAIL"
);
return
res
.
end
(
"FAIL"
);
}
}
return
res
.
end
(
"success"
);
return
res
.
end
(
"success"
);
}
catch
(
error
)
{
}
catch
(
error
)
{
logCtl
.
error
({
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果异常:,method="
+
req
.
body
.
trxcode
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果异常:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/notify"
,
op
:
"center-channel/tlpay/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
}
}
});
});
app
.
use
(
'/tlpay/opBackNotify'
,
async
function
(
req
,
res
)
{
app
.
use
(
'/tlpay/opBackNotify'
,
async
function
(
req
,
res
)
{
try
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsOrderSve
.
opBackNotify
(
req
.
body
,
client_ip
);
var
result
=
await
utilsOrderSve
.
opBackNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"回调处理订单结果:,method="
+
req
.
body
.
trxcode
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"回调处理订单结果:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/opBackNotify"
,
op
:
"center-channel/tlpay/opBackNotify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调处理订单结果:"
+
JSON
.
stringify
(
result
),
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调处理订单结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
}
catch
(
error
)
{
}
catch
(
error
)
{
logCtl
.
error
({
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果异常:,method="
+
req
.
body
.
trxcode
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录回调处理结果异常:,method="
+
req
.
body
.
trxcode
,
op
:
"center-channel/tlpay/opBackNotify"
,
op
:
"center-channel/tlpay/opBackNotify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
}
}
});
});
//----------------------飞书小程序---------------------------------------------开始
//----------------------飞书小程序---------------------------------------------开始
//飞书通知
//飞书通知
app
.
use
(
'/feishu/notify'
,
async
function
(
req
,
res
)
{
app
.
use
(
'/feishu/notify'
,
async
function
(
req
,
res
)
{
try
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsFeishuSve
.
notify
(
req
.
body
);
var
result
=
await
utilsFeishuSve
.
notify
(
req
.
body
);
logCtl
.
info
({
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=notify"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
var
returnObj
=
JSON
.
stringify
(
result
);
var
returnObj
=
JSON
.
stringify
(
result
);
return
res
.
end
(
returnObj
);
return
res
.
end
(
returnObj
);
}
catch
(
error
)
{
}
catch
(
error
)
{
logCtl
.
error
({
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常:,method=notify"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常:,method=notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
}
}
});
});
app
.
use
(
'/feishu/login'
,
async
function
(
req
,
res
)
{
app
.
use
(
'/feishu/login'
,
async
function
(
req
,
res
)
{
try
{
try
{
var
result
=
system
.
getResult
(
null
,
"login fail"
);
var
result
=
system
.
getResult
(
null
,
"login fail"
);
// console.log(req,"/feishu/login++++++++++++++++++++++++++++++++++++++");
// console.log(req,"/feishu/login++++++++++++++++++++++++++++++++++++++");
var
client_ip
=
system
.
get_client_ip
(
req
);
var
client_ip
=
system
.
get_client_ip
(
req
);
var
pobj
=
req
.
query
;
var
pobj
=
req
.
query
;
var
token
=
pobj
.
state
||
""
;
var
token
=
pobj
.
state
||
""
;
if
(
!
token
)
{
if
(
!
token
)
{
result
.
msg
=
"req headers token can not be empty"
;
result
.
msg
=
"req headers token can not be empty"
;
result
.
data
=
null
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
var
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
var
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
var
result
=
await
cacheManager
[
"AppTokenByHostsCache"
].
getCache
(
token
,
system
.
exTime
);
var
result
=
await
cacheManager
[
"AppTokenByHostsCache"
].
getCache
(
token
,
system
.
exTime
);
if
(
result
.
status
!=
0
)
{
if
(
result
.
status
!=
0
)
{
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
pobj
.
appInfo
=
result
.
data
;
pobj
.
appInfo
=
result
.
data
;
result
=
await
utilsFeishuSve
.
checkAndLogin
(
req
,
pobj
);
result
=
await
utilsFeishuSve
.
checkAndLogin
(
req
,
pobj
);
logCtl
.
info
({
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=login"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=login"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
pobj
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
content
:
"回调参数:"
+
JSON
.
stringify
(
pobj
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
var
returnObj
=
JSON
.
stringify
(
result
);
var
returnObj
=
JSON
.
stringify
(
result
);
return
res
.
end
(
returnObj
);
return
res
.
end
(
returnObj
);
}
catch
(
error
)
{
}
catch
(
error
)
{
logCtl
.
error
({
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常:,method=login"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常:,method=login"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
query
)
+
"error:"
+
error
.
stack
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
query
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
}
}
});
});
//----------------------飞书小程序---------------------------------------------结束
//----------------------飞书小程序---------------------------------------------结束
// app-ali支付回调通知
// app-ali支付回调通知
app
.
use
(
'/orderNotify/aliPayNotify'
,
async
function
(
req
,
res
)
{
app
.
use
(
'/orderNotify/aliPayNotify'
,
async
function
(
req
,
res
)
{
try
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsOrderSve
.
aliPayNotify
(
req
.
body
,
client_ip
);
var
result
=
await
utilsOrderSve
.
aliPayNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录支付宝回调处理结果 api层"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录支付宝回调处理结果 api层"
,
op
:
"center-channel/orderNotify/aliPayNotify"
,
op
:
"center-channel/orderNotify/aliPayNotify"
,
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
if
(
result
.
status
!=
0
)
{
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"FAIL"
);
return
res
.
end
(
"FAIL"
);
}
}
return
res
.
end
(
"success"
);
return
res
.
end
(
"success"
);
}
catch
(
e
)
{
}
catch
(
e
)
{
logCtl
.
error
({
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"支付宝回调处理异常 api层"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"支付宝回调处理异常 api层"
,
op
:
"center-channel/orderNotify/aliPayNotify"
,
op
:
"center-channel/orderNotify/aliPayNotify"
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
}
}
});
});
// app-wx支付回调
// app-wx支付回调
app
.
use
(
'/orderNotify/wxPayNotify'
,
async
function
(
req
,
res
)
{
app
.
use
(
'/orderNotify/wxPayNotify'
,
async
function
(
req
,
res
)
{
try
{
try
{
var
body
=
""
;
var
body
=
""
;
req
.
on
(
'data'
,
function
(
data
)
{
req
.
on
(
'data'
,
function
(
data
)
{
body
+=
data
;
body
+=
data
;
});
});
req
.
on
(
'end'
,
async
function
()
{
req
.
on
(
'end'
,
async
function
()
{
xml2js
.
parseString
(
body
,
{
trim
:
true
,
explicitArray
:
false
,
explicitRoot
:
false
},
async
function
(
err
,
json
)
{
xml2js
.
parseString
(
body
,
{
var
client_ip
=
system
.
get_client_ip
(
req
);
trim
:
true
,
var
result
=
await
utilsOrderSve
.
wxPayNotify
(
json
);
explicitArray
:
false
,
logCtl
.
info
({
explicitRoot
:
false
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录微信支付回调处理结果"
,
},
async
function
(
err
,
json
)
{
op
:
"center-channel/orderNotify/wxPayNotify"
,
var
client_ip
=
system
.
get_client_ip
(
req
);
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
var
result
=
await
utilsOrderSve
.
wxPayNotify
(
json
);
clientIp
:
client_ip
||
""
logCtl
.
info
({
});
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录微信支付回调处理结果"
,
if
(
result
.
status
!=
0
)
{
op
:
"center-channel/orderNotify/wxPayNotify"
,
return
res
.
end
(
"FAIL"
);
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
}
clientIp
:
client_ip
||
""
return
res
.
end
(
"success"
);
});
})
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"FAIL"
);
}
return
res
.
end
(
"success"
);
})
})
})
}
catch
(
e
)
{
}
catch
(
e
)
{
logCtl
.
error
({
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"微信回调处理异常"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"微信回调处理异常"
,
op
:
"center-channel/orderNotify/wxPayNotify"
,
op
:
"center-channel/orderNotify/wxPayNotify"
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
}
}
});
});
app
.
use
(
'/orderNotify/channelPayNotify'
,
async
function
(
req
,
res
)
{
app
.
use
(
'/orderNotify/channelPayNotify'
,
async
function
(
req
,
res
)
{
try
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
client_ip
=
system
.
get_client_ip
(
req
);
let
result
=
{};
let
result
=
{};
result
=
await
utilsOrderSve
.
channelPayNotify
(
req
.
body
,
client_ip
);
result
=
await
utilsOrderSve
.
channelPayNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"渠道支付订单通知 api层"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"渠道支付订单通知 api层"
,
op
:
"center-channel/orderNotify/channelPayNotify"
,
op
:
"center-channel/orderNotify/channelPayNotify"
,
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
var
returnObj
=
JSON
.
stringify
(
result
);
var
returnObj
=
JSON
.
stringify
(
result
);
return
res
.
end
(
returnObj
);
return
res
.
end
(
returnObj
);
}
catch
(
e
)
{
}
catch
(
e
)
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
client_ip
=
system
.
get_client_ip
(
req
);
logCtl
.
error
({
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"渠道订单支付通知处理异常"
,
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"渠道订单支付通知处理异常"
,
op
:
"center-channel/orderNotify/channelPayNotify"
,
op
:
"center-channel/orderNotify/channelPayNotify"
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
clientIp
:
client_ip
||
""
clientIp
:
client_ip
||
""
});
});
}
}
});
});
app
.
all
(
"/web/*"
,
async
function
(
req
,
res
,
next
)
{
app
.
all
(
"/web/*"
,
async
function
(
req
,
res
,
next
)
{
const
self
=
this
;
const
self
=
this
;
var
result
=
system
.
getResult
(
null
,
"req method must is post"
);
var
result
=
system
.
getResult
(
null
,
"req method must is post"
);
if
(
req
.
method
!=
"POST"
)
{
if
(
req
.
method
!=
"POST"
)
{
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
if
(
!
req
.
body
.
actionType
)
{
if
(
!
req
.
body
.
actionType
)
{
result
.
msg
=
"actionType can not be empty"
;
result
.
msg
=
"actionType can not be empty"
;
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
// 2020 0812 lin 只去掉了check,因为要记录智能诊断的返回值,其他接口暂时未去掉
// 2020 0812 lin 只去掉了check,因为要记录智能诊断的返回值,其他接口暂时未去掉
if
([
"getAppTokenByHosts"
,
"getAppTokenByAppKey"
,
"test"
,
"getIndustries"
,
"getSecondIndustries"
,
"getQualificationByIndustry"
,
"counselling"
,
"queryTradeProduceList"
].
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
if
([
"getAppTokenByHosts"
,
"getAppTokenByAppKey"
,
"test"
,
"getIndustries"
,
"getSecondIndustries"
,
"getQualificationByIndustry"
,
"counselling"
,
"queryTradeProduceList"
].
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
req
.
body
.
actionBody
.
appHosts
=
req
.
host
;
req
.
body
.
actionBody
.
appHosts
=
req
.
host
;
next
();
next
();
return
;
return
;
}
}
if
(
req
.
body
.
actionType
==
"receiveCallBackNotify"
)
{
if
(
req
.
body
.
actionType
==
"receiveCallBackNotify"
)
{
req
.
body
.
actionBody
.
app_hosts
=
req
.
host
;
req
.
body
.
actionBody
.
app_hosts
=
req
.
host
;
next
();
next
();
return
;
return
;
}
}
var
token
=
req
.
headers
[
"token"
]
||
""
;
var
token
=
req
.
headers
[
"token"
]
||
""
;
if
(
!
token
)
{
if
(
!
token
)
{
result
.
msg
=
"req headers token can not be empty"
;
result
.
msg
=
"req headers token can not be empty"
;
result
.
data
=
null
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
//校验jwt产生的token
//校验jwt产生的token
const
tokenSecret
=
settings
.
env
==
"localhost"
||
settings
.
env
==
"dev"
?
PDICT
.
token_secret_dev
:
PDICT
.
token_secret_prod
;
const
tokenSecret
=
settings
.
env
==
"localhost"
||
settings
.
env
==
"dev"
?
PDICT
.
token_secret_dev
:
PDICT
.
token_secret_prod
;
let
token_secret_str
=
null
;
let
token_secret_str
=
null
;
jwt
.
verify
(
token
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
jwt
.
verify
(
token
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
if
(
err
)
{
//如果token过期则会执行err的代码块
if
(
err
)
{
//如果token过期则会执行err的代码块
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,error:"
+
err
));
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,error:"
+
err
));
}
else
{
}
else
{
token_secret_str
=
decoded
.
token_secret
;
token_secret_str
=
decoded
.
token_secret
;
}
}
});
});
let
decryptResult
=
await
utilsAuthSve
.
decryptInfo
(
token_secret_str
);
let
decryptResult
=
await
utilsAuthSve
.
decryptInfo
(
token_secret_str
);
if
(
decryptResult
.
status
!=
0
)
{
if
(
decryptResult
.
status
!=
0
)
{
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,fail:"
+
decryptResult
.
msg
));
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,fail:"
+
decryptResult
.
msg
));
}
}
let
tmpAppInfo
=
JSON
.
parse
(
decryptResult
.
data
);
let
tmpAppInfo
=
JSON
.
parse
(
decryptResult
.
data
);
req
.
body
.
appInfo
=
tmpAppInfo
;
req
.
body
.
appInfo
=
tmpAppInfo
;
req
.
body
.
actionProcess
=
tmpAppInfo
.
app_code
;
req
.
body
.
actionProcess
=
tmpAppInfo
.
app_code
;
//去除缓存,改用jwt模式
//去除缓存,改用jwt模式
// var cacheManager = system.getObject("db.common.cacheManager");
// var cacheManager = system.getObject("db.common.cacheManager");
// var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
// var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
// if (result.status != 0) {
// if (result.status != 0) {
// res.end(JSON.stringify(result));
// res.end(JSON.stringify(result));
// return;
// return;
// }
// }
// req.body.appInfo = result.data;
// req.body.appInfo = result.data;
// req.body.actionProcess = result.data.app_code;
// req.body.actionProcess = result.data.app_code;
if
(
PDICT
.
webMustUserpinList
.
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
if
(
PDICT
.
webMustUserpinList
.
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
var
userpin
=
req
.
headers
[
"userpin"
]
||
""
;
var
userpin
=
req
.
headers
[
"userpin"
]
||
""
;
if
(
!
userpin
)
{
if
(
!
userpin
)
{
result
.
status
=
system
.
noLogin
;
result
.
status
=
system
.
noLogin
;
result
.
msg
=
"req headers userpin can not be empty"
;
result
.
msg
=
"req headers userpin can not be empty"
;
result
.
data
=
null
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
let
userpin_secret_str
=
null
;
let
userpin_secret_str
=
null
;
jwt
.
verify
(
userpin
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
jwt
.
verify
(
userpin
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
if
(
err
)
{
//如果token过期则会执行err的代码块
if
(
err
)
{
//如果token过期则会执行err的代码块
return
res
.
send
(
system
.
getResultFail
(
system
.
noLogin
,
"Failed to authenticate userpin,error:"
+
err
));
return
res
.
send
(
system
.
getResultFail
(
system
.
noLogin
,
"Failed to authenticate userpin,error:"
+
err
));
}
else
{
}
else
{
userpin_secret_str
=
decoded
.
userpin_secret
;
userpin_secret_str
=
decoded
.
userpin_secret
;
}
}
});
});
let
userDecryptResult
=
await
utilsAuthSve
.
decryptInfo
(
userpin_secret_str
);
let
userDecryptResult
=
await
utilsAuthSve
.
decryptInfo
(
userpin_secret_str
);
if
(
userDecryptResult
.
status
!=
0
)
{
if
(
userDecryptResult
.
status
!=
0
)
{
return
res
.
send
(
system
.
getResultFail
(
system
.
noLogin
,
"Failed to authenticate userpin,fail:"
+
userDecryptResult
.
msg
));
return
res
.
send
(
system
.
getResultFail
(
system
.
noLogin
,
"Failed to authenticate userpin,fail:"
+
userDecryptResult
.
msg
));
}
}
let
tmpUserInfo
=
JSON
.
parse
(
userDecryptResult
.
data
);
let
tmpUserInfo
=
JSON
.
parse
(
userDecryptResult
.
data
);
req
.
body
.
userInfo
=
tmpUserInfo
;
req
.
body
.
userInfo
=
tmpUserInfo
;
if
(
req
.
body
.
actionType
===
"getLoginInfo"
)
{
if
(
req
.
body
.
actionType
===
"getLoginInfo"
)
{
result
=
system
.
getResultSuccess
(
tmpUserInfo
);
result
=
system
.
getResultSuccess
(
tmpUserInfo
);
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
// var params = {
// var params = {
// "appInfo": req.body.appInfo,
// "appInfo": req.body.appInfo,
// "actionType": "getLoginInfo",
// "actionType": "getLoginInfo",
// "actionBody": {
// "actionBody": {
// "userpin": userpin
// "userpin": userpin
// }
// }
// }
// }
// result = await utilsAuthSve.getLoginInfo(params, params.actionBody);
// result = await utilsAuthSve.getLoginInfo(params, params.actionBody);
// if (result.status != 0) {
// if (result.status != 0) {
// result.status = system.noLogin;
// result.status = system.noLogin;
// result.msg = "user login is invalidation";
// result.msg = "user login is invalidation";
// res.end(JSON.stringify(result));
// res.end(JSON.stringify(result));
// return;
// return;
// }
// }
// req.body.userInfo = result.data;
// req.body.userInfo = result.data;
}
//需要用户登录
}
//需要用户登录
next
();
next
();
});
});
app
.
get
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
app
.
get
(
'/web/: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"
];
var
gname
=
req
.
params
[
"gname"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
req
.
classname
=
classPath
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
classname
=
classPath
;
var
params
=
[];
var
params
=
[];
params
.
push
(
gname
);
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
);
var
p
=
null
;
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexecMethod"
])
{
if
(
invokeObj
[
"doexecMethod"
])
{
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
}
}
p
.
then
(
r
=>
{
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
res
.
end
(
JSON
.
stringify
(
r
));
});
});
});
});
app
.
post
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
app
.
post
(
'/web/: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"
];
var
gname
=
req
.
params
[
"gname"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
classname
=
classPath
;
req
.
classname
=
classPath
;
params
.
push
(
gname
);
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
);
var
p
=
null
;
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexecMethod"
])
{
if
(
invokeObj
[
"doexecMethod"
])
{
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
}
}
p
.
then
(
r
=>
{
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
res
.
end
(
JSON
.
stringify
(
r
));
});
});
});
});
//-----------------------新的模式---------web---------结束
//-----------------------新的模式---------web---------结束
//-----------------------新的模式---------api---------开始
//-----------------------新的模式---------api---------开始
//百度手动获取签名sign方法
//百度手动获取签名sign方法
// app.post("/baidu/creatSign", async function (req, res, next) {
// app.post("/baidu/creatSign", async function (req, res, next) {
// if (!req.body.key) {
// if (!req.body.key) {
// res.end({ code: -200, message: "缺少加签秘钥key参数" });
// res.end({ code: -200, message: "缺少加签秘钥key参数" });
// return;
// return;
// }
// }
// if (!req.body.obj) {
// if (!req.body.obj) {
// res.end({ code: -200, message: "缺少obj参数" });
// res.end({ code: -200, message: "缺少obj参数" });
// return;
// return;
// }
// }
// let obj = req.body.obj;
// let obj = req.body.obj;
// let key = req.body.key;
// let key = req.body.key;
// let result = await signSve.createSign(obj, key);
// let result = await signSve.createSign(obj, key);
// res.end(JSON.stringify(result));
// res.end(JSON.stringify(result));
// return;
// return;
// });
// });
app
.
all
(
"/api/*"
,
async
function
(
req
,
res
,
next
)
{
app
.
all
(
"/api/*"
,
async
function
(
req
,
res
,
next
)
{
var
result
=
system
.
getResult
(
null
,
"req method must is post"
);
var
result
=
system
.
getResult
(
null
,
"req method must is post"
);
if
(
req
.
method
!=
"POST"
)
{
if
(
req
.
method
!=
"POST"
)
{
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
if
(
PDICT
.
apiSecretPathList
.
indexOf
(
req
.
originalUrl
)
>=
0
)
{
if
(
PDICT
.
apiAliSendKeyPathList
.
indexOf
(
req
.
originalUrl
)
>=
0
)
{
//TODO:验证数据签名
//验证数据key
var
appkey
=
req
.
headers
[
"appkey"
]
||
""
;
var
appkey
=
req
.
headers
[
"appkey"
]
||
""
;
if
(
!
appkey
)
{
if
(
!
appkey
)
{
result
.
msg
=
"req headers appkey can not be empty"
;
result
.
msg
=
"req headers appkey can not be empty"
;
result
.
data
=
null
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
var
sign
=
req
.
headers
[
"sign"
]
||
""
;
if
(
appkey
!=
"201912031344"
)
{
if
(
!
sign
)
{
result
.
msg
=
"req appkey verify error"
;
result
.
msg
=
"req headers sign can not be empty"
;
result
.
data
=
null
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
next
();
//1.通过appkey 获取appInfo
return
;
var
appRes
=
await
signSve
.
getAppInfoByAppKey
(
appkey
);
}
if
(
!
appRes
||
appRes
.
status
!=
0
)
{
if
(
PDICT
.
apiSecretPathList
.
indexOf
(
req
.
originalUrl
)
>=
0
)
{
result
.
msg
=
"获取应用信息失败"
;
//验证数据签名
result
.
data
=
null
;
var
appkey
=
req
.
headers
[
"appkey"
]
||
""
;
res
.
end
(
JSON
.
stringify
(
result
));
if
(
!
appkey
)
{
return
;
result
.
msg
=
"req headers appkey can not be empty"
;
}
result
.
data
=
null
;
var
appInfo
=
appRes
.
data
;
res
.
end
(
JSON
.
stringify
(
result
));
//2.通过appsecret 验签
return
;
req
.
body
.
sign
=
sign
;
}
var
signParams
=
req
.
body
;
var
sign
=
req
.
headers
[
"sign"
]
||
""
;
var
verifyRes
=
await
signSve
.
verifySign
(
req
.
body
,
appInfo
.
uapp_secret
);
if
(
!
sign
)
{
if
(
verifyRes
&&
verifyRes
.
status
==
0
)
{
result
.
msg
=
"req headers sign can not be empty"
;
req
.
body
.
appInfo
=
appInfo
;
result
.
data
=
null
;
req
.
appInfo
=
appInfo
;
res
.
end
(
JSON
.
stringify
(
result
));
req
.
actionProcess
=
appInfo
.
app_code
;
return
;
next
();
}
return
;
//1.通过appkey 获取appInfo
}
else
{
var
appRes
=
await
signSve
.
getAppInfoByAppKey
(
appkey
);
res
.
end
(
JSON
.
stringify
(
verifyRes
));
if
(
!
appRes
||
appRes
.
status
!=
0
)
{
return
;
result
.
msg
=
"获取应用信息失败"
;
}
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
var
appInfo
=
appRes
.
data
;
//2.通过appsecret 验签
req
.
body
.
sign
=
sign
;
var
signParams
=
req
.
body
;
var
verifyRes
=
await
signSve
.
verifySign
(
req
.
body
,
appInfo
.
uapp_secret
);
if
(
verifyRes
&&
verifyRes
.
status
==
0
)
{
req
.
body
.
appInfo
=
appInfo
;
req
.
appInfo
=
appInfo
;
req
.
actionProcess
=
appInfo
.
app_code
;
next
();
return
;
}
else
{
res
.
end
(
JSON
.
stringify
(
verifyRes
));
return
;
}
}
}
if
([
"getAppTokenByHosts"
,
"getAppTokenByAppKey"
,
"getTmNclFilterSearch"
,
"feedback"
,
"accountingInfo"
,
"booksInfo"
].
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
if
([
"getAppTokenByHosts"
,
"getAppTokenByAppKey"
,
"getTmNclFilterSearch"
,
"feedback"
,
"accountingInfo"
,
"booksInfo"
].
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
req
.
body
.
actionBody
.
appHosts
=
req
.
host
;
req
.
body
.
actionBody
.
appHosts
=
req
.
host
;
next
();
next
();
return
;
return
;
}
}
if
(
req
.
path
.
indexOf
(
"/taskapi/"
)
>=
0
)
{
if
(
req
.
path
.
indexOf
(
"/taskapi/"
)
>=
0
)
{
next
();
next
();
return
;
return
;
}
}
if
(
!
req
.
body
.
actionType
)
{
if
(
!
req
.
body
.
actionType
)
{
result
.
msg
=
"actionType can not be empty"
;
result
.
msg
=
"actionType can not be empty"
;
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
var
token
=
req
.
headers
[
"token"
]
||
""
;
var
token
=
req
.
headers
[
"token"
]
||
""
;
if
(
!
token
)
{
if
(
!
token
)
{
result
.
msg
=
"req headers token can not be empty"
;
result
.
msg
=
"req headers token can not be empty"
;
result
.
data
=
null
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
//校验jwt产生的token
//校验jwt产生的token
const
tokenSecret
=
settings
.
env
==
"localhost"
||
settings
.
env
==
"dev"
?
PDICT
.
token_secret_dev
:
PDICT
.
token_secret_prod
;
const
tokenSecret
=
settings
.
env
==
"localhost"
||
settings
.
env
==
"dev"
?
PDICT
.
token_secret_dev
:
PDICT
.
token_secret_prod
;
let
token_secret_str
=
null
;
let
token_secret_str
=
null
;
jwt
.
verify
(
token
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
jwt
.
verify
(
token
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
if
(
err
)
{
//如果token过期则会执行err的代码块
if
(
err
)
{
//如果token过期则会执行err的代码块
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,error:"
+
err
));
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,error:"
+
err
));
}
else
{
}
else
{
token_secret_str
=
decoded
.
token_secret
;
token_secret_str
=
decoded
.
token_secret
;
}
}
});
});
let
decryptResult
=
await
utilsAuthSve
.
decryptInfo
(
token_secret_str
);
let
decryptResult
=
await
utilsAuthSve
.
decryptInfo
(
token_secret_str
);
if
(
decryptResult
.
status
!=
0
)
{
if
(
decryptResult
.
status
!=
0
)
{
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,fail:"
+
decryptResult
.
msg
));
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,fail:"
+
decryptResult
.
msg
));
}
}
let
tmpAppInfo
=
JSON
.
parse
(
decryptResult
.
data
);
let
tmpAppInfo
=
JSON
.
parse
(
decryptResult
.
data
);
req
.
body
.
appInfo
=
tmpAppInfo
;
req
.
body
.
appInfo
=
tmpAppInfo
;
req
.
body
.
actionProcess
=
tmpAppInfo
.
app_code
;
req
.
body
.
actionProcess
=
tmpAppInfo
.
app_code
;
// var cacheManager = system.getObject("db.common.cacheManager");
// var cacheManager = system.getObject("db.common.cacheManager");
// var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
// var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
// if (result.status != 0) {
// if (result.status != 0) {
// res.end(JSON.stringify(result));
// res.end(JSON.stringify(result));
// return;
// return;
// }
// }
// req.body.appInfo = result.data;
// req.body.appInfo = result.data;
// req.body.actionProcess = result.data.app_code;
// req.body.actionProcess = result.data.app_code;
if
(
PDICT
.
apiMustUserpinList
.
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
if
(
PDICT
.
apiMustUserpinList
.
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
var
userpin
=
req
.
headers
[
"userpin"
]
||
""
;
var
userpin
=
req
.
headers
[
"userpin"
]
||
""
;
if
(
!
userpin
)
{
if
(
!
userpin
)
{
result
.
status
=
system
.
noLogin
;
result
.
status
=
system
.
noLogin
;
result
.
msg
=
"req headers userpin can not be empty"
;
result
.
msg
=
"req headers userpin can not be empty"
;
result
.
data
=
null
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
// var params = {
// var params = {
// "appInfo": req.body.appInfo,
// "appInfo": req.body.appInfo,
// "actionType": "getLoginInfo",
// "actionType": "getLoginInfo",
// "actionBody": {
// "actionBody": {
// "userpin": userpin
// "userpin": userpin
// }
// }
// }
// }
// result = await utilsAuthSve.getLoginInfo(params, params.actionBody);
// result = await utilsAuthSve.getLoginInfo(params, params.actionBody);
// if (result.status != 0) {
// if (result.status != 0) {
// result.status = system.noLogin;
// result.status = system.noLogin;
// result.msg = "user login is invalidation";
// result.msg = "user login is invalidation";
// res.end(JSON.stringify(result));
// res.end(JSON.stringify(result));
// return;
// return;
// }
// }
let
userpin_secret_str
=
null
;
let
userpin_secret_str
=
null
;
jwt
.
verify
(
userpin
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
jwt
.
verify
(
userpin
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
if
(
err
)
{
//如果token过期则会执行err的代码块
if
(
err
)
{
//如果token过期则会执行err的代码块
return
res
.
send
(
system
.
getResultFail
(
system
.
noLogin
,
"Failed to authenticate userpin,error:"
+
err
));
return
res
.
send
(
system
.
getResultFail
(
system
.
noLogin
,
"Failed to authenticate userpin,error:"
+
err
));
}
else
{
}
else
{
userpin_secret_str
=
decoded
.
userpin_secret
;
userpin_secret_str
=
decoded
.
userpin_secret
;
}
}
});
});
let
userDecryptResult
=
await
utilsAuthSve
.
decryptInfo
(
userpin_secret_str
);
let
userDecryptResult
=
await
utilsAuthSve
.
decryptInfo
(
userpin_secret_str
);
if
(
userDecryptResult
.
status
!=
0
)
{
if
(
userDecryptResult
.
status
!=
0
)
{
return
res
.
send
(
system
.
getResultFail
(
system
.
noLogin
,
"Failed to authenticate userpin,fail:"
+
userDecryptResult
.
msg
));
return
res
.
send
(
system
.
getResultFail
(
system
.
noLogin
,
"Failed to authenticate userpin,fail:"
+
userDecryptResult
.
msg
));
}
}
let
tmpUserInfo
=
JSON
.
parse
(
userDecryptResult
.
data
);
let
tmpUserInfo
=
JSON
.
parse
(
userDecryptResult
.
data
);
req
.
body
.
userInfo
=
tmpUserInfo
;
req
.
body
.
userInfo
=
tmpUserInfo
;
if
(
req
.
body
.
actionType
===
"getLoginInfo"
)
{
if
(
req
.
body
.
actionType
===
"getLoginInfo"
)
{
result
=
system
.
getResultSuccess
(
tmpUserInfo
);
result
=
system
.
getResultSuccess
(
tmpUserInfo
);
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
}
//需要用户登录
}
//需要用户登录
next
();
next
();
});
});
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"
];
var
gname
=
req
.
params
[
"gname"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
req
.
classname
=
classPath
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
classname
=
classPath
;
var
params
=
[];
var
params
=
[];
params
.
push
(
gname
);
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
);
var
p
=
null
;
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexecMethod"
])
{
if
(
invokeObj
[
"doexecMethod"
])
{
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
}
}
p
.
then
(
r
=>
{
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
res
.
end
(
JSON
.
stringify
(
r
));
});
});
});
});
app
.
post
(
'/api/:gname/:qname/:method'
,
function
(
req
,
res
)
{
app
.
post
(
'/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"
];
var
gname
=
req
.
params
[
"gname"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
classname
=
classPath
;
req
.
classname
=
classPath
;
params
.
push
(
gname
);
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
);
var
p
=
null
;
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
var
invokeObj
=
system
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexecMethod"
])
{
if
(
invokeObj
[
"doexecMethod"
])
{
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
}
}
p
.
then
(
r
=>
{
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
res
.
end
(
JSON
.
stringify
(
r
));
});
});
});
});
//-----------------------新的模式---------api---------结束
//-----------------------新的模式---------api---------结束
//-----------------------新的模式---------ICP---------开始
//-----------------------新的模式---------ICP---------开始
app
.
all
(
"/icp/*"
,
async
function
(
req
,
res
,
next
)
{
app
.
all
(
"/icp/*"
,
async
function
(
req
,
res
,
next
)
{
var
result
=
system
.
getResult
(
null
,
"req method must is post"
);
var
result
=
system
.
getResult
(
null
,
"req method must is post"
);
if
(
req
.
method
!=
"POST"
)
{
if
(
req
.
method
!=
"POST"
)
{
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
// var token = req.headers["token"] || "";
// var token = req.headers["token"] || "";
// if (!token) {
// if (!token) {
// var resfail = {
// var resfail = {
// "success": false,
// "success": false,
// "errorMsg": "req headers token can not be empty",
// "errorMsg": "req headers token can not be empty",
// "errorCode": "ok"
// "errorCode": "ok"
// };
// };
// res.end(JSON.stringify(resfail));
// res.end(JSON.stringify(resfail));
// return;
// return;
// }
// }
// var cacheManager = system.getObject("db.common.cacheManager");
// var cacheManager = system.getObject("db.common.cacheManager");
// var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
// var result = await cacheManager["AppTokenByHostsCache"].getCache(token, system.exTime);
// if (result.status != 0) {
// if (result.status != 0) {
// var resfail = {
// var resfail = {
// "success": false,
// "success": false,
// "errorMsg": result.msg || "token error",
// "errorMsg": result.msg || "token error",
// "errorCode": "ok"
// "errorCode": "ok"
// };
// };
// res.end(JSON.stringify(resfail));
// res.end(JSON.stringify(resfail));
// // res.end(JSON.stringify(result));
// // res.end(JSON.stringify(result));
// return;
// return;
// }
// }
// req.appInfo = result.data;
// req.appInfo = result.data;
// req.body.appInfo = result.data;
// req.body.appInfo = result.data;
// req.actionProcess = result.data.app_code;
// req.actionProcess = result.data.app_code;
var
token
=
req
.
headers
[
"token"
]
||
""
;
var
token
=
req
.
headers
[
"token"
]
||
""
;
if
(
!
token
)
{
if
(
!
token
)
{
var
resfail
=
{
var
resfail
=
{
"success"
:
false
,
"success"
:
false
,
"errorMsg"
:
"req headers token can not be empty"
,
"errorMsg"
:
"req headers token can not be empty"
,
"errorCode"
:
"ok"
"errorCode"
:
"ok"
};
};
res
.
end
(
JSON
.
stringify
(
resfail
));
res
.
end
(
JSON
.
stringify
(
resfail
));
return
;
return
;
}
}
//校验jwt产生的token
//校验jwt产生的token
const
tokenSecret
=
settings
.
env
==
"localhost"
||
settings
.
env
==
"dev"
?
PDICT
.
token_secret_dev
:
PDICT
.
token_secret_prod
;
const
tokenSecret
=
settings
.
env
==
"localhost"
||
settings
.
env
==
"dev"
?
PDICT
.
token_secret_dev
:
PDICT
.
token_secret_prod
;
let
token_secret_str
=
null
;
let
token_secret_str
=
null
;
jwt
.
verify
(
token
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
jwt
.
verify
(
token
,
tokenSecret
,
function
(
err
,
decoded
)
{
// decoded:指的是token解码后用户信息
if
(
err
)
{
//如果token过期则会执行err的代码块
if
(
err
)
{
//如果token过期则会执行err的代码块
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,error:"
+
err
));
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,error:"
+
err
));
}
else
{
}
else
{
token_secret_str
=
decoded
.
token_secret
;
token_secret_str
=
decoded
.
token_secret
;
}
}
});
});
let
decryptResult
=
await
utilsAuthSve
.
decryptInfo
(
token_secret_str
);
let
decryptResult
=
await
utilsAuthSve
.
decryptInfo
(
token_secret_str
);
if
(
decryptResult
.
status
!=
0
)
{
if
(
decryptResult
.
status
!=
0
)
{
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,fail:"
+
decryptResult
.
msg
));
return
res
.
send
(
system
.
getResultFail
(
-
88
,
"Failed to authenticate token,fail:"
+
decryptResult
.
msg
));
}
}
let
tmpAppInfo
=
JSON
.
parse
(
decryptResult
.
data
);
let
tmpAppInfo
=
JSON
.
parse
(
decryptResult
.
data
);
req
.
body
.
appInfo
=
tmpAppInfo
;
req
.
body
.
appInfo
=
tmpAppInfo
;
req
.
appInfo
=
tmpAppInfo
;
req
.
appInfo
=
tmpAppInfo
;
req
.
actionProcess
=
tmpAppInfo
.
app_code
;
req
.
actionProcess
=
tmpAppInfo
.
app_code
;
next
();
next
();
});
});
//icp需求推送
//icp需求推送
app
.
post
(
'/icp/consultation/submit'
,
function
(
req
,
res
)
{
app
.
post
(
'/icp/consultation/submit'
,
function
(
req
,
res
)
{
var
p
=
null
;
var
p
=
null
;
var
params
=
[
"icpnotify"
,
"icpSubmitNeed"
,
req
.
body
,
req
.
query
,
req
];
var
params
=
[
"icpnotify"
,
"icpSubmitNeed"
,
req
.
body
,
req
.
query
,
req
];
// gname, methodname, pobj, query, req
// gname, methodname, pobj, query, req
var
invokeObj
=
system
.
getObject
(
"api.action.icpnotify"
);
var
invokeObj
=
system
.
getObject
(
"api.action.icpnotify"
);
if
(
invokeObj
[
"doexecMethod"
])
{
if
(
invokeObj
[
"doexecMethod"
])
{
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
}
}
p
.
then
(
r
=>
{
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
res
.
end
(
JSON
.
stringify
(
r
));
});
});
});
});
//⽤户反馈需求通知服务商
//⽤户反馈需求通知服务商
app
.
post
(
'/icp/feedback/submit'
,
function
(
req
,
res
)
{
app
.
post
(
'/icp/feedback/submit'
,
function
(
req
,
res
)
{
var
p
=
null
;
var
p
=
null
;
req
.
body
.
action_type
=
"icpFeedbackSubmit"
;
req
.
body
.
action_type
=
"icpFeedbackSubmit"
;
var
params
=
[
"icpnotify"
,
"icpFeedbackSubmit"
,
req
.
body
,
req
.
query
,
req
];
var
params
=
[
"icpnotify"
,
"icpFeedbackSubmit"
,
req
.
body
,
req
.
query
,
req
];
// gname, methodname, pobj, query, req
// gname, methodname, pobj, query, req
var
invokeObj
=
system
.
getObject
(
"api.action.icpnotify"
);
var
invokeObj
=
system
.
getObject
(
"api.action.icpnotify"
);
if
(
invokeObj
[
"doexecMethod"
])
{
if
(
invokeObj
[
"doexecMethod"
])
{
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
}
}
p
.
then
(
r
=>
{
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
res
.
end
(
JSON
.
stringify
(
r
));
});
});
});
});
//推送订单信息
//推送订单信息
app
.
post
(
'/icp/order/notify'
,
function
(
req
,
res
)
{
app
.
post
(
'/icp/order/notify'
,
function
(
req
,
res
)
{
var
p
=
null
;
var
p
=
null
;
req
.
body
.
action_type
=
"icpNotify"
;
req
.
body
.
action_type
=
"icpNotify"
;
var
params
=
[
"icpnotify"
,
"icpNotify"
,
req
.
body
,
req
.
query
,
req
];
var
params
=
[
"icpnotify"
,
"icpNotify"
,
req
.
body
,
req
.
query
,
req
];
// gname, methodname, pobj, query, req
// gname, methodname, pobj, query, req
var
invokeObj
=
system
.
getObject
(
"api.action.icpnotify"
);
var
invokeObj
=
system
.
getObject
(
"api.action.icpnotify"
);
if
(
invokeObj
[
"doexecMethod"
])
{
if
(
invokeObj
[
"doexecMethod"
])
{
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
p
=
invokeObj
[
"doexecMethod"
].
apply
(
invokeObj
,
params
);
}
}
p
.
then
(
r
=>
{
p
.
then
(
r
=>
{
res
.
end
(
JSON
.
stringify
(
r
));
res
.
end
(
JSON
.
stringify
(
r
));
});
});
});
});
//-----------------------新的模式---------ICP---------结束
//-----------------------新的模式---------ICP---------结束
};
};
\ No newline at end of file
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