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
0c6c7cfc
Commit
0c6c7cfc
authored
Jul 01, 2020
by
linboxuan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'center-channel' of
http://gitlab.gongsibao.com/jiangyong/zhichan
into center-channel
parents
6eca1879
d54106be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
126 additions
and
128 deletions
+126
-128
center-channel/app/config/routes/api.js
+126
-128
No files found.
center-channel/app/config/routes/api.js
View file @
0c6c7cfc
var
url
=
require
(
"url"
);
var
url
=
require
(
"url"
);
var
system
=
require
(
"../../base/system"
);
var
system
=
require
(
"../../base/system"
);
const
utilsAuthSve
=
system
.
getObject
(
"service.utilsSve.utilsAuthSve"
);
const
utilsAuthSve
=
system
.
getObject
(
"service.utilsSve.utilsAuthSve"
);
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
const
utilsOrderSve
=
system
.
getObject
(
"service.utilsSve.utilsOrderSve"
);
const
utilsOrderSve
=
system
.
getObject
(
"service.utilsSve.utilsOrderSve"
);
const
utilsFeishuSve
=
system
.
getObject
(
"service.utilsSve.utilsFeishuSve"
);
const
utilsFeishuSve
=
system
.
getObject
(
"service.utilsSve.utilsFeishuSve"
);
var
axios
=
require
(
'axios'
);
var
md5
=
require
(
'md5'
);
var
md5
=
require
(
'md5'
);
var
xml2js
=
require
(
'xml2js'
);
var
xml2js
=
require
(
'xml2js'
);
...
@@ -77,6 +76,130 @@ module.exports = function (app) {
...
@@ -77,6 +76,130 @@ module.exports = function (app) {
});
});
}
}
});
});
//----------------------飞书小程序---------------------------------------------开始
//飞书通知
app
.
use
(
'/feishu/notify'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsFeishuSve
.
notify
(
req
.
body
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
var
returnObj
=
JSON
.
stringify
(
result
);
return
res
.
end
(
returnObj
);
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常:,method=notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
app
.
use
(
'/feishu/login'
,
async
function
(
req
,
res
)
{
try
{
var
result
=
system
.
getResult
(
null
,
"login fail"
);
// console.log(req,"/feishu/login++++++++++++++++++++++++++++++++++++++");
var
client_ip
=
system
.
get_client_ip
(
req
);
var
pobj
=
req
.
query
;
var
token
=
pobj
.
state
||
""
;
if
(
!
token
)
{
result
.
msg
=
"req headers token can not be empty"
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
var
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
var
result
=
await
cacheManager
[
"AppTokenByHostsCache"
].
getCache
(
token
,
system
.
exTime
);
if
(
result
.
status
!=
0
)
{
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
pobj
.
appInfo
=
result
.
data
;
result
=
await
utilsFeishuSve
.
checkAndLogin
(
pobj
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=login"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
pobj
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
var
returnObj
=
JSON
.
stringify
(
result
);
return
res
.
end
(
returnObj
);
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常:,method=login"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
query
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
//----------------------飞书小程序---------------------------------------------结束
// app-ali支付回调通知
app
.
use
(
'/orderNotify/aliPayNotify'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsOrderSve
.
aliPayNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录支付宝回调处理结果 api层"
,
op
:
"center-channel/orderNotify/aliPayNotify"
,
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"FAIL"
);
}
return
res
.
end
(
"success"
);
}
catch
(
e
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"支付宝回调处理异常 api层"
,
op
:
"center-channel/orderNotify/aliPayNotify"
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
// app-wx支付回调
app
.
use
(
'/orderNotify/wxPayNotify'
,
async
function
(
req
,
res
)
{
try
{
var
body
=
""
;
req
.
on
(
'data'
,
function
(
data
)
{
body
+=
data
;
});
req
.
on
(
'end'
,
async
function
()
{
xml2js
.
parseString
(
body
,
{
trim
:
true
,
explicitArray
:
false
,
explicitRoot
:
false
},
async
function
(
err
,
json
)
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsOrderSve
.
wxPayNotify
(
json
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录微信支付回调处理结果"
,
op
:
"center-channel/orderNotify/wxPayNotify"
,
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"FAIL"
);
}
return
res
.
end
(
"success"
);
})
})
}
catch
(
e
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"微信回调处理异常"
,
op
:
"center-channel/orderNotify/wxPayNotify"
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
app
.
all
(
"/web/*"
,
async
function
(
req
,
res
,
next
)
{
app
.
all
(
"/web/*"
,
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"
)
{
...
@@ -329,71 +452,6 @@ module.exports = function (app) {
...
@@ -329,71 +452,6 @@ module.exports = function (app) {
//-----------------------新的模式---------api---------结束
//-----------------------新的模式---------api---------结束
//----------------------飞书小程序---------------------------------------------开始
//飞书通知
app
.
use
(
'/feishu/notify'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsFeishuSve
.
notify
(
req
.
body
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
var
returnObj
=
JSON
.
stringify
(
result
);
return
res
.
end
(
returnObj
);
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常:,method=notify"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
body
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
app
.
use
(
'/feishu/login'
,
async
function
(
req
,
res
)
{
try
{
var
result
=
system
.
getResult
(
null
,
"login fail"
);
// console.log(req,"/feishu/login++++++++++++++++++++++++++++++++++++++");
var
client_ip
=
system
.
get_client_ip
(
req
);
var
pobj
=
req
.
query
;
var
token
=
pobj
.
state
||
""
;
if
(
!
token
)
{
result
.
msg
=
"req headers token can not be empty"
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
var
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
var
result
=
await
cacheManager
[
"AppTokenByHostsCache"
].
getCache
(
token
,
system
.
exTime
);
if
(
result
.
status
!=
0
)
{
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
pobj
.
appInfo
=
result
.
data
;
result
=
await
utilsFeishuSve
.
checkAndLogin
(
pobj
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果,method=login"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
pobj
)
+
"回调结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
var
returnObj
=
JSON
.
stringify
(
result
);
return
res
.
end
(
returnObj
);
}
catch
(
error
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"飞书小程序记录回调处理结果异常:,method=login"
,
op
:
"app/config/routes/api.js/feishu/notify"
,
content
:
"回调参数:"
+
JSON
.
stringify
(
req
.
query
)
+
"error:"
+
error
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
//----------------------飞书小程序---------------------------------------------结束
//--------------------------起名宝------------------------------------//
//--------------------------起名宝------------------------------------//
app
.
post
(
'/name/:gname/:qname/:method'
,
function
(
req
,
res
)
{
app
.
post
(
'/name/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
classPath
=
req
.
params
[
"qname"
];
...
@@ -409,7 +467,7 @@ module.exports = function (app) {
...
@@ -409,7 +467,7 @@ module.exports = function (app) {
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
;
...
@@ -421,63 +479,4 @@ module.exports = function (app) {
...
@@ -421,63 +479,4 @@ module.exports = function (app) {
res
.
end
(
JSON
.
stringify
(
r
));
res
.
end
(
JSON
.
stringify
(
r
));
});
});
});
});
// 支付回调通知
app
.
use
(
'/orderNotify/aliPayNotify'
,
async
function
(
req
,
res
)
{
try
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsOrderSve
.
aliPayNotify
(
req
.
body
,
client_ip
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录支付宝回调处理结果 api层"
,
op
:
"center-channel/orderNotify/aliPayNotify"
,
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"FAIL"
);
}
return
res
.
end
(
"success"
);
}
catch
(
e
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"支付宝回调处理异常 api层"
,
op
:
"center-channel/orderNotify/aliPayNotify"
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
// wx支付回调
app
.
use
(
'/orderNotify/wxPayNotify'
,
async
function
(
req
,
res
)
{
try
{
var
body
=
""
;
req
.
on
(
'data'
,
function
(
data
)
{
body
+=
data
;
});
req
.
on
(
'end'
,
async
function
()
{
xml2js
.
parseString
(
body
,
{
trim
:
true
,
explicitArray
:
false
,
explicitRoot
:
false
},
async
function
(
err
,
json
)
{
var
client_ip
=
system
.
get_client_ip
(
req
);
var
result
=
await
utilsOrderSve
.
wxPayNotify
(
json
);
logCtl
.
info
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"记录微信支付回调处理结果"
,
op
:
"center-channel/orderNotify/wxPayNotify"
,
content
:
"支付回调处理结果:"
+
JSON
.
stringify
(
result
),
clientIp
:
client_ip
||
""
});
if
(
result
.
status
!=
0
)
{
return
res
.
end
(
"FAIL"
);
}
return
res
.
end
(
"success"
);
})
})
}
catch
(
e
)
{
logCtl
.
error
({
optitle
:
(
new
Date
()).
Format
(
"yyyy-MM-dd hh:mm:ss"
)
+
"微信回调处理异常"
,
op
:
"center-channel/orderNotify/wxPayNotify"
,
content
:
"回调参数:req="
+
JSON
.
stringify
(
req
)
+
"error:"
+
e
.
stack
,
clientIp
:
client_ip
||
""
});
}
});
};
};
\ 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