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
20809075
Commit
20809075
authored
Nov 19, 2020
by
wangyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: (accounting) 磐农项目 回传会计信息调整
parent
7d23c34f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
67 deletions
+83
-67
icp-deliver/app/base/controller/impl/auth/authCtl.js
+42
-33
icp-deliver/app/base/service/impl/agriculture/messageSve.js
+3
-1
icp-deliver/app/base/service/impl/agriculture/servicebillSve.js
+10
-3
icp-deliver/app/base/utils/toQft/baseClient.js
+28
-30
No files found.
icp-deliver/app/base/controller/impl/auth/authCtl.js
View file @
20809075
...
@@ -7,6 +7,7 @@ const CtlBase = require("../../ctl.base");
...
@@ -7,6 +7,7 @@ const CtlBase = require("../../ctl.base");
const
axios
=
require
(
"axios"
);
const
axios
=
require
(
"axios"
);
const
jwt
=
require
(
"jsonwebtoken"
);
const
jwt
=
require
(
"jsonwebtoken"
);
const
{
appKey
,
appSecret
}
=
settings
.
ydzKey
();
const
{
appKey
,
appSecret
}
=
settings
.
ydzKey
();
const
ydz_prefix
=
"ydz:"
;
class
AuthCtl
extends
CtlBase
{
class
AuthCtl
extends
CtlBase
{
constructor
()
{
constructor
()
{
...
@@ -29,13 +30,15 @@ class AuthCtl extends CtlBase {
...
@@ -29,13 +30,15 @@ class AuthCtl extends CtlBase {
*/
*/
async
getAppCredentials
()
{
async
getAppCredentials
()
{
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/appAuth/getAppAccessToken`
;
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/appAuth/getAppAccessToken`
;
const
{
appTicket
}
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
'APP_TICKET'
)).
bizContent
;
const
{
appTicket
}
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
`
${
ydz_prefix
}
APP_TICKET`
)).
bizContent
;
const
headers
=
{
const
headers
=
{
"Content-Type"
:
"application/json"
,
"Content-Type"
:
"application/json"
,
appKey
,
appKey
,
appSecret
appSecret
};
};
return
await
this
.
postRequest
(
url
,
{
appTicket
},
headers
);
const
creRes
=
await
this
.
postRequest
(
url
,
{
appTicket
},
headers
);
const
addRedisResult
=
await
this
.
redisClient
.
setWithEx
(
`
${
ydz_prefix
}
appAccessToken`
,
JSON
.
stringify
(
creRes
.
result
));
return
creRes
.
result
;
};
};
/**
/**
...
@@ -43,11 +46,11 @@ class AuthCtl extends CtlBase {
...
@@ -43,11 +46,11 @@ class AuthCtl extends CtlBase {
*/
*/
async
getPermanentAuthCode
()
{
async
getPermanentAuthCode
()
{
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/orgAuth/getPermanentAuthCode`
;
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/orgAuth/getPermanentAuthCode`
;
const
{
result
}
=
await
this
.
getAppCredentials
(
);
//获取应用凭证
const
{
appAccessToken
}
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
`
${
ydz_prefix
}
appAccessToken`
)
);
//获取应用凭证
const
{
tempAuthCode
}
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
'TEMP_AUTH_CODE'
)).
bizContent
;
//
const
{
tempAuthCode
}
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
`
${
ydz_prefix
}
TEMP_AUTH_CODE`
)).
bizContent
;
//获取企业临时授权码
const
params
=
{
const
params
=
{
appAccessToken
:
result
.
appAccessToken
,
//应用凭证
appAccessToken
,
//应用凭证
tempAuthCode
tempAuthCode
//企业临时授权码
}
}
const
headers
=
{
const
headers
=
{
"Content-Type"
:
"application/json"
,
"Content-Type"
:
"application/json"
,
...
@@ -56,9 +59,10 @@ class AuthCtl extends CtlBase {
...
@@ -56,9 +59,10 @@ class AuthCtl extends CtlBase {
};
};
const
perResult
=
await
this
.
postRequest
(
url
,
params
,
headers
);
const
perResult
=
await
this
.
postRequest
(
url
,
params
,
headers
);
if
(
perResult
.
code
==
200
)
{
if
(
perResult
.
code
==
200
)
{
// const addRedisResult = await this.redisClient.setWithEx('PERMANENT_AUTH_CODE', JSON.stringify(perResult.result));
return
perResult
.
result
;
return
perResult
.
result
;
}
else
{
}
else
{
console
.
log
(
'--------------getPermanentAuthCode-----ERROR-----------------'
);
console
.
log
(
perResult
)
return
system
.
getResultFail
(
perResult
);
return
system
.
getResultFail
(
perResult
);
}
}
}
}
...
@@ -68,13 +72,10 @@ class AuthCtl extends CtlBase {
...
@@ -68,13 +72,10 @@ class AuthCtl extends CtlBase {
*/
*/
async
getOrgAccessToken
()
{
async
getOrgAccessToken
()
{
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/orgAuth/getOrgAccessToken`
;
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/orgAuth/getOrgAccessToken`
;
const
{
result
}
=
await
this
.
getAppCredentials
();
//获取应用凭证
const
{
appAccessToken
}
=
await
this
.
getAppCredentials
();
//获取应用凭证
const
permanentAuthCode
=
(
await
this
.
getPermanentAuthCode
()).
permanentAuthCode
;
const
permanentAuthCode
=
(
await
this
.
getPermanentAuthCode
()).
permanentAuthCode
;
//获取企业永久授权码
console
.
log
(
'[[-----------'
)
console
.
log
(
permanentAuthCode
);
// const { permanentAuthCode } = JSON.parse(await this.redisClient.get('PERMANENT_AUTH_CODE')); //
const
params
=
{
const
params
=
{
appAccessToken
:
result
.
appAccessToken
,
//应用凭证
appAccessToken
,
//应用凭证
permanentAuthCode
//企业永久授权码
permanentAuthCode
//企业永久授权码
}
}
const
headers
=
{
const
headers
=
{
...
@@ -83,6 +84,7 @@ class AuthCtl extends CtlBase {
...
@@ -83,6 +84,7 @@ class AuthCtl extends CtlBase {
appSecret
appSecret
};
};
const
OrgResult
=
await
this
.
postRequest
(
url
,
params
,
headers
);
const
OrgResult
=
await
this
.
postRequest
(
url
,
params
,
headers
);
const
addRedisResult
=
await
this
.
redisClient
.
setWithEx
(
`
${
ydz_prefix
}
orgAccessToken`
,
JSON
.
stringify
(
OrgResult
.
result
),
OrgResult
.
result
.
expireTime
);
return
OrgResult
.
result
;
return
OrgResult
.
result
;
}
}
...
@@ -95,11 +97,13 @@ class AuthCtl extends CtlBase {
...
@@ -95,11 +97,13 @@ class AuthCtl extends CtlBase {
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/getToken`
;
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/getToken`
;
return
await
this
.
publicTokenFun
(
url
,
"authorization_code"
,
appKey
,
body
.
code
,
"code"
);
return
await
this
.
publicTokenFun
(
url
,
"authorization_code"
,
appKey
,
body
.
code
,
"code"
);
}
else
{
//用户永久授权码
}
else
{
//用户永久授权码
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/token/getTokenByPermanentCode`
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/token/getTokenByPermanentCode`
;
console
.
log
(
'---------------------------co---------------'
);
const
{
user_auth_permanent_code
}
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
`
${
ydz_prefix
}
ydzToken`
));
//用户永久授权码
const
{
user_auth_permanent_code
}
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
'ydzToken'
));
console
.
log
(
user_auth_permanent_code
);
console
.
log
(
user_auth_permanent_code
);
const
{
orgAccessToken
}
=
await
this
.
getOrgAccessToken
();
//获取企业凭证
const
{
orgAccessToken
}
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
`
${
ydz_prefix
}
orgAccessToken`
));
if
(
!
orgAccessToken
)
{
orgAccessToken
=
(
await
this
.
getOrgAccessToken
()).
orgAccessToken
;
//获取企业凭证
}
const
params
=
{
const
params
=
{
orgAccessToken
,
//企业凭证
orgAccessToken
,
//企业凭证
userAuthPermanentCode
:
user_auth_permanent_code
//企业永久授权码
userAuthPermanentCode
:
user_auth_permanent_code
//企业永久授权码
...
@@ -111,8 +115,8 @@ class AuthCtl extends CtlBase {
...
@@ -111,8 +115,8 @@ class AuthCtl extends CtlBase {
};
};
const
perToTokenResult
=
await
this
.
postRequest
(
url
,
params
,
headers
);
const
perToTokenResult
=
await
this
.
postRequest
(
url
,
params
,
headers
);
if
(
perToTokenResult
.
code
==
200
)
{
if
(
perToTokenResult
.
code
==
200
)
{
cons
ole
.
log
(
'------------------------ssfdfdfdfdf---------'
);
cons
t
addRedisResult
=
await
this
.
setRedisValue
(
`
${
ydz_prefix
}
ydzToken`
,
perToTokenResult
.
result
);
console
.
log
(
perToTokenResult
);
return
system
.
getResultSuccess
(
perToTokenResult
)
}
else
{
}
else
{
return
system
.
getResultFail
(
perToTokenResult
);
return
system
.
getResultFail
(
perToTokenResult
);
}
}
...
@@ -125,7 +129,7 @@ class AuthCtl extends CtlBase {
...
@@ -125,7 +129,7 @@ class AuthCtl extends CtlBase {
*/
*/
async
refreshToken
()
{
async
refreshToken
()
{
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/refreshToken`
;
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/refreshToken`
;
const
getRedisResult
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
'ydzToken'
)).
refresh_token
;
const
getRedisResult
=
JSON
.
parse
(
await
this
.
redisClient
.
get
(
`
${
ydz_prefix
}
ydzToken`
)).
refresh_token
;
return
await
this
.
publicTokenFun
(
url
,
"refresh_token"
,
appKey
,
getRedisResult
,
"refreshToken"
)
return
await
this
.
publicTokenFun
(
url
,
"refresh_token"
,
appKey
,
getRedisResult
,
"refreshToken"
)
};
};
...
@@ -137,24 +141,29 @@ class AuthCtl extends CtlBase {
...
@@ -137,24 +141,29 @@ class AuthCtl extends CtlBase {
params
[
specialKey
]
=
data
;
params
[
specialKey
]
=
data
;
const
res
=
await
this
.
getRequest
(
url
,
params
);
const
res
=
await
this
.
getRequest
(
url
,
params
);
if
(
res
.
data
.
code
==
200
)
{
if
(
res
.
data
.
code
==
200
)
{
const
ydzToken
=
{
const
addRedisResult
=
await
this
.
setRedisValue
(
`
${
ydz_prefix
}
ydzToken`
,
res
.
data
.
result
);
access_token
:
res
.
data
.
result
.
access_token
,
return
system
.
getResultSuccess
(
res
);
refresh_token
:
res
.
data
.
result
.
refresh_token
,
user_auth_permanent_code
:
res
.
data
.
result
.
user_auth_permanent_code
}
const
deTokenExp
=
Number
((
jwt
.
decode
(
res
.
data
.
result
.
access_token
).
exp
));
const
timestamp
=
Math
.
round
(
new
Date
()
/
1000
);
const
addRedisResult
=
await
this
.
redisClient
.
setWithEx
(
'ydzToken'
,
JSON
.
stringify
(
ydzToken
),
Number
(
deTokenExp
-
timestamp
));
// const getRedisResult = await this.redisClient.get('ydzToken');
console
.
log
(
'------------------------------addRedisResult-----------------------'
);
console
.
log
(
`Request:
${
JSON
.
stringify
(
res
.
data
)}
`
);
console
.
log
(
`addRedisResult:
${
addRedisResult
}
`
);
return
system
.
getResult
(
addRedisResult
);
}
else
{
}
else
{
return
system
.
getResultFail
(
201
,
res
.
data
.
message
);
return
system
.
getResultFail
(
201
,
res
.
data
.
message
);
}
}
};
};
async
setRedisValue
(
key
,
data
)
{
const
ydzToken
=
{
access_token
:
data
.
access_token
,
refresh_token
:
data
.
refresh_token
,
user_auth_permanent_code
:
data
.
user_auth_permanent_code
}
const
deTokenExp
=
Number
((
jwt
.
decode
(
data
.
access_token
).
exp
));
const
timestamp
=
Math
.
round
(
new
Date
()
/
1000
);
const
addRedisResult
=
await
this
.
redisClient
.
setWithEx
(
key
,
JSON
.
stringify
(
ydzToken
),
Number
(
deTokenExp
-
timestamp
));
// const getRedisResult = await this.redisClient.get('ydzToken');
console
.
log
(
'------------------------------addRedisResult-----------------------'
);
console
.
log
(
`Request:
${
JSON
.
stringify
(
data
)}
`
);
console
.
log
(
`addRedisResult:
${
addRedisResult
}
`
);
return
addRedisResult
;
}
/**
/**
* 公用get请求
* 公用get请求
* @param {*} url
* @param {*} url
...
...
icp-deliver/app/base/service/impl/agriculture/messageSve.js
View file @
20809075
...
@@ -2,6 +2,7 @@ const ServiceBase = require("../../sve.base");
...
@@ -2,6 +2,7 @@ const ServiceBase = require("../../sve.base");
const
settings
=
require
(
"./../../../../config/settings"
);
const
settings
=
require
(
"./../../../../config/settings"
);
const
System
=
require
(
"../../../system"
);
const
System
=
require
(
"../../../system"
);
const
redisClient
=
System
.
getObject
(
"util.redisClient"
);
const
redisClient
=
System
.
getObject
(
"util.redisClient"
);
const
ydz_prefix
=
"ydz:"
;
class
MessageService
extends
ServiceBase
{
class
MessageService
extends
ServiceBase
{
constructor
()
{
constructor
()
{
...
@@ -11,7 +12,8 @@ class MessageService extends ServiceBase {
...
@@ -11,7 +12,8 @@ class MessageService extends ServiceBase {
async
tempMsgProcessing
(
key
,
msgContent
,
time
)
{
async
tempMsgProcessing
(
key
,
msgContent
,
time
)
{
//APP_TICKET: 每十分钟刷新一次,有效期30分钟
//APP_TICKET: 每十分钟刷新一次,有效期30分钟
//TEMP_AUTH_CODE: 企业临时授权码
//TEMP_AUTH_CODE: 企业临时授权码
const
addRedisResult
=
await
redisClient
.
setWithEx
(
key
,
JSON
.
stringify
(
msgContent
),
time
);
const
perKey
=
ydz_prefix
+
key
;
const
addRedisResult
=
await
redisClient
.
setWithEx
(
perKey
,
JSON
.
stringify
(
msgContent
),
time
);
return
addRedisResult
;
return
addRedisResult
;
}
}
}
}
...
...
icp-deliver/app/base/service/impl/agriculture/servicebillSve.js
View file @
20809075
...
@@ -69,9 +69,16 @@ class ServicebillService extends ServiceBase {
...
@@ -69,9 +69,16 @@ class ServicebillService extends ServiceBase {
backData
.
note
=
findOne
.
feedback_notes
;
backData
.
note
=
findOne
.
feedback_notes
;
}
}
//推送企服通
//推送企服通
await
TOQFT
.
getClientByType
(
"pannong"
).
pushQiFuTong
(
obj
.
username
,
{
"actionType"
:
"feedback"
,
"actionBody"
:
backData
});
const
result
=
await
TOQFT
.
getClientByType
(
"pannong"
).
pushQiFuTong
(
obj
.
username
,
{
"actionType"
:
"feedback"
,
"actionBody"
:
backData
});
if
(
result
.
code
==
200
)
{
return
result
;
}
else
{
console
.
log
(
result
);
throw
new
Error
(
result
);
}
}
else
{
}
else
{
console
.
log
(
'查无此单:'
+
obj
.
bizId
);
console
.
log
(
'未查询到此服务单'
+
obj
.
bizId
);
throw
new
Error
(
'未查询到此服务单'
+
obj
.
bizId
);
}
}
}
}
mappingQiFuTong
(
findService
,
findAccount
)
{
mappingQiFuTong
(
findService
,
findAccount
)
{
...
@@ -81,7 +88,7 @@ class ServicebillService extends ServiceBase {
...
@@ -81,7 +88,7 @@ class ServicebillService extends ServiceBase {
accCode
:
findAccount
.
accCode
,
accCode
:
findAccount
.
accCode
,
accName
:
findAccount
.
accName
,
accName
:
findAccount
.
accName
,
accaddress
:
findAccount
.
accaddress
,
accaddress
:
findAccount
.
accaddress
,
workingYears
:
findAccount
.
workingYears
,
//
workingYears: findAccount.workingYears,
accCredentials
:
findAccount
.
accCredentials
,
accCredentials
:
findAccount
.
accCredentials
,
accAccount
:
findAccount
.
accAccount
,
accAccount
:
findAccount
.
accAccount
,
accountingName
:
findAccount
.
name
,
accountingName
:
findAccount
.
name
,
...
...
icp-deliver/app/base/utils/toQft/baseClient.js
View file @
20809075
...
@@ -12,31 +12,30 @@ const qifutongUrl = settings.qifutongUrl();
...
@@ -12,31 +12,30 @@ const qifutongUrl = settings.qifutongUrl();
*/
*/
class
BaseClient
{
class
BaseClient
{
constructor
(
appKey
,
secret
,
url
)
{
constructor
(
appKey
,
secret
,
url
)
{
this
.
appKey
=
appKey
;
this
.
appKey
=
appKey
;
this
.
secret
=
secret
;
this
.
secret
=
secret
;
this
.
url
=
url
this
.
url
=
url
}
}
/**
/**
* 推送到 启服通
* 推送到 启服通
* @param {*} user
* @param {*} user
* @param {*} data
* @param {*} data
*/
*/
async
pushQiFuTong
(
user
,
data
)
{
async
pushQiFuTong
(
user
,
data
)
{
const
header
=
await
this
.
getLoginByUserName
(
user
);
const
header
=
await
this
.
getLoginByUserName
(
user
);
await
this
.
postRequest
(
`
${
qifutongUrl
}${
this
.
url
}
`
,
data
,
header
);
return
await
this
.
postRequest
(
`
${
qifutongUrl
}${
this
.
url
}
`
,
data
,
header
);
}
}
async
getLoginByUserName
(
user
)
{
async
getLoginByUserName
(
user
)
{
const
token
=
await
this
.
getAppTokenByAppKey
(
this
.
appKey
,
this
.
secret
);
const
token
=
await
this
.
getAppTokenByAppKey
(
this
.
appKey
,
this
.
secret
);
const
data
=
await
this
.
postRequest
(
`
${
centerChannelUrl
}
/api/opreceive/accessAuth/springBoard`
,
const
data
=
await
this
.
postRequest
(
`
${
centerChannelUrl
}
/api/opreceive/accessAuth/springBoard`
,
{
{
"actionType"
:
"getLoginByUserName"
,
"actionType"
:
"getLoginByUserName"
,
"actionBody"
:
{
"actionBody"
:
{
"channelUserId"
:
user
,
"channelUserId"
:
user
,
" user"
:
user
,
" user"
:
user
,
"userName"
:
user
"userName"
:
user
}
}
},
{
},
{
token
token
});
});
return
{
return
{
...
@@ -46,14 +45,13 @@ class BaseClient {
...
@@ -46,14 +45,13 @@ class BaseClient {
}
}
async
getAppTokenByAppKey
(
appKey
,
secret
)
{
async
getAppTokenByAppKey
(
appKey
,
secret
)
{
const
data
=
await
this
.
postRequest
(
`
${
centerChannelUrl
}
/api/opreceive/accessAuth/getAppTokenByAppKey`
,
const
data
=
await
this
.
postRequest
(
`
${
centerChannelUrl
}
/api/opreceive/accessAuth/getAppTokenByAppKey`
,
{
{
"actionType"
:
"getAppTokenByAppKey"
,
"actionType"
:
"getAppTokenByAppKey"
,
"actionBody"
:
{
"actionBody"
:
{
"appkey"
:
appKey
,
"appkey"
:
appKey
,
"secret"
:
secret
"secret"
:
secret
}
}
});
});
return
data
.
token
return
data
.
token
}
}
...
@@ -72,8 +70,7 @@ class BaseClient {
...
@@ -72,8 +70,7 @@ class BaseClient {
console
.
log
(
`
${
url
}
: 返回信息 ------- `
);
console
.
log
(
`
${
url
}
: 返回信息 ------- `
);
console
.
log
(
result
);
console
.
log
(
result
);
system
.
execLogs
(
system
.
execLogs
(
`请求启服通`
,
`请求启服通`
,
{
{
url
,
url
,
data
,
data
,
headers
headers
...
@@ -96,4 +93,4 @@ class BaseClient {
...
@@ -96,4 +93,4 @@ class BaseClient {
}
}
}
}
}
}
module
.
exports
=
BaseClient
;
module
.
exports
=
BaseClient
;
\ 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