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
3a86566a
Commit
3a86566a
authored
Nov 18, 2020
by
wangyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: (auth/settings) 磐农项目 易代账API地址修改
parent
f4265bd7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
68 deletions
+65
-68
icp-deliver/app/base/controller/impl/agriculture/messageCtl.js
+37
-27
icp-deliver/app/base/controller/impl/auth/authCtl.js
+4
-1
icp-deliver/app/base/service/impl/agriculture/messageSve.js
+12
-35
icp-deliver/app/config/settings.js
+12
-5
No files found.
icp-deliver/app/base/controller/impl/agriculture/messageCtl.js
View file @
3a86566a
var
system
=
require
(
"../../../system"
);
var
system
=
require
(
"../../../system"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
const
CtlBase
=
require
(
"../../ctl.base"
);
const
CryptoJS
=
require
(
"crypto-js"
);
const
crypto
=
require
(
"crypto"
);
var
crypto
=
require
(
'crypto'
);
const
settings
=
require
(
"./../../../../config/settings"
);
const
settings
=
require
(
"./../../../../config/settings"
);
/**
/**
* @module agriculture
* @module agriculture
* @class
servicelist
Ctl
* @class
message
Ctl
*
服务单
ctl
*
消息
ctl
*/
*/
class
messageCtl
extends
CtlBase
{
class
messageCtl
extends
CtlBase
{
...
@@ -16,33 +15,43 @@ class messageCtl extends CtlBase {
...
@@ -16,33 +15,43 @@ class messageCtl extends CtlBase {
this
.
servicebillCtl
=
system
.
getObject
(
"service.agriculture.servicebillCtl"
);
this
.
servicebillCtl
=
system
.
getObject
(
"service.agriculture.servicebillCtl"
);
}
}
async
message
(
meg
)
{
async
message
(
msg
)
{
console
.
log
(
'-----------------------------message--------------------'
);
const
key
=
settings
.
ydzKey
().
msgSecret
;
console
.
log
(
meg
)
const
plaintextMsg
=
this
.
decryptMessage
(
key
,
msg
.
encryptMsg
);
const
res
=
{};
console
.
log
(
'-----------------------msg--------------------'
);
switch
(
meg
.
type
)
{
console
.
log
(
plaintextMsg
);
case
"CREATE_ACCOUNTING"
:
switch
(
plaintextMsg
.
msgType
)
{
res
=
await
this
.
servicebillCtl
.
create
(
meg
);
case
"CREATE_ACCOUNTING"
:
//新建会计
await
this
.
servicebillCtl
.
create
(
plaintextMsg
);
break
;
break
;
case
"APP_TICKET"
:
case
"APP_TICKET"
:
// 应用票据
res
=
await
this
.
service
.
ticketProcessing
(
me
g
);
await
this
.
service
.
tempMsgProcessing
(
plaintextMsg
.
msgType
,
plaintextMs
g
);
break
;
break
;
case
"TEMP_AUTH_CODE"
:
//企业临时授权码
await
this
.
service
.
tempMsgProcessing
(
plaintextMsg
.
msgType
,
plaintextMsg
);
}
}
return
{
"result"
:
"success"
};
return
{
"result"
:
"success"
};
}
};
zeropad
(
inputData
,
length
=
8
)
{
/**
inputData
=
Buffer
.
from
(
inputData
,
"utf8"
).
toString
(
"hex"
);
* 解密消息内容
const
bitLength
=
inputData
.
length
*
length
;
* @param {string} key 16位密钥
if
(
bitLength
<
256
)
{
* @param {string} msgContent 加密串儿
for
(
i
=
bitLength
;
i
<
256
;
i
+=
length
)
{
* @return {object} decryptMessage
inputData
+=
0
;
*/
}
decryptMessage
(
key
,
msgContent
)
{
}
else
if
(
bitLength
>
256
)
{
var
iv
=
""
;
while
((
inputData
.
length
*
length
)
%
256
!=
0
)
{
var
clearEncoding
=
'utf8'
;
inputData
+=
0
;
var
cipherEncoding
=
'base64'
;
}
var
cipherChunks
=
[];
}
return
Buffer
.
from
(
inputData
,
"hex"
).
toString
(
"utf8"
);
var
decipher
=
crypto
.
createDecipheriv
(
'aes-128-ecb'
,
key
,
iv
);
decipher
.
setAutoPadding
(
true
);
cipherChunks
.
push
(
decipher
.
update
(
msgContent
,
cipherEncoding
,
clearEncoding
));
cipherChunks
.
push
(
decipher
.
final
(
clearEncoding
));
const
decryptMessage
=
JSON
.
parse
(
cipherChunks
.
join
(
''
));
return
decryptMessage
;
}
}
}
}
module
.
exports
=
messageCtl
;
module
.
exports
=
messageCtl
;
\ No newline at end of file
icp-deliver/app/base/controller/impl/auth/authCtl.js
View file @
3a86566a
...
@@ -25,7 +25,7 @@ class AuthCtl extends CtlBase {
...
@@ -25,7 +25,7 @@ class AuthCtl extends CtlBase {
/**
/**
* 易代账获取初始化token
* 易代账获取初始化token
* @param {*} code
* @param {*} code
企业授权码
*/
*/
async
getOpenToken
(
body
)
{
async
getOpenToken
(
body
)
{
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/getToken`
const
url
=
`
${
settings
.
ydzUrl
()}
/auth/getToken`
...
@@ -59,6 +59,9 @@ class AuthCtl extends CtlBase {
...
@@ -59,6 +59,9 @@ class AuthCtl extends CtlBase {
}
}
const
addRedisResult
=
await
this
.
redisClient
.
setWithEx
(
'ydzToken'
,
JSON
.
stringify
(
ydzToken
),
Number
(
deTokenExp
-
timestamp
));
const
addRedisResult
=
await
this
.
redisClient
.
setWithEx
(
'ydzToken'
,
JSON
.
stringify
(
ydzToken
),
Number
(
deTokenExp
-
timestamp
));
// const getRedisResult = await this.redisClient.get('ydzToken');
// const getRedisResult = await this.redisClient.get('ydzToken');
console
.
log
(
'------------------------------addRedisResult-----------------------'
);
console
.
log
(
ydzToken
)
console
.
log
(
addRedisResult
);
return
system
.
getResult
(
addRedisResult
);
return
system
.
getResult
(
addRedisResult
);
}
else
{
}
else
{
return
system
.
getResultFail
(
201
,
res
.
data
.
message
);
return
system
.
getResultFail
(
201
,
res
.
data
.
message
);
...
...
icp-deliver/app/base/service/impl/agriculture/messageSve.js
View file @
3a86566a
const
ServiceBase
=
require
(
"../../sve.base"
);
const
ServiceBase
=
require
(
"../../sve.base"
);
const
redisClient
=
system
.
getObject
(
"util.redisClient"
);
const
settings
=
require
(
"./../../../../config/settings"
);
const
settings
=
require
(
"./../../../../config/settings"
);
const
System
=
require
(
"../../../system"
);
const
redisClient
=
System
.
getObject
(
"util.redisClient"
);
class
m
essageService
extends
ServiceBase
{
class
M
essageService
extends
ServiceBase
{
constructor
()
{
constructor
()
{
super
(
"agriculture"
,
ServiceBase
.
getDaoName
(
m
essageService
));
super
(
"agriculture"
,
ServiceBase
.
getDaoName
(
M
essageService
));
}
}
async
ticketProcessing
(
meg
)
{
async
tempMsgProcessing
(
key
,
msgContent
)
{
const
messageSecret
=
settings
.
ydzKey
().
messageSecret
;
// 密钥 16 位
//临时存储30分钟
const
iv
=
messageSecret
;
// 初始向量 initial vector 16 位, messageSecret 和 iv 可以一致
//APP_TICKET: 每十分钟刷新一次,有效期30分钟
//const data = CryptoJS.enc.Utf8.parse(meg.encryptMsg);
//TEMP_AUTH_CODE: 企业临时授权码
// console.log('-----------------data-------------------');
const
addRedisResult
=
await
redisClient
.
setWithEx
(
key
,
JSON
.
stringify
(
msgContent
),
30
*
60
);
// console.log(meg.encryptMsg);
return
addRedisResult
;
// var decrypted = CryptoJS.AES.decrypt(data, messageSecret, {
// iv: iv,
// mode: CryptoJS.mode.CBC,
// padding: CryptoJS.pad.Pkcs7
// });
// // 转换为 utf8 字符串
// console.log('---------------------------before -------------');
// console.log(decrypted);
// decrypted = CryptoJS.enc.Utf8.stringify(decrypted);
// console.log('------------------------decrypted--------------------')
// console.log(decrypted)
// console.log(iv.length);
// var clearEncoding = 'utf8'
// var cipherEncoding = 'base64'
// var cipherChunks = []
// var decipher = crypto.createCipheriv('aes-128-ecb', messageSecret, iv)
// decipher.setAutoPadding(false)
// cipherChunks.push(decipher.update(this.zeropad(meg.encryptMsg, 8), clearEncoding, cipherEncoding))
// cipherChunks.push(decipher.final(cipherEncoding))
// console.log(cipherChunks.join('').toUpperCase());
// return cipherChunks.join('').toUpperCase();
// const addRedisResult = await this.redisClient.setWithEx('APP_TICKET', JSON.stringify(obj), 2 * 60 * 60); //俩小时
// return addRedisResult;
}
}
}
}
module
.
exports
=
messageService
;
module
.
exports
=
MessageService
;
\ No newline at end of file
\ No newline at end of file
icp-deliver/app/config/settings.js
View file @
3a86566a
...
@@ -60,28 +60,35 @@ var settings = {
...
@@ -60,28 +60,35 @@ var settings = {
return
"http://sytxpublic-msgq-service.chaolai/api/queueAction/producer/springBoard"
;
return
"http://sytxpublic-msgq-service.chaolai/api/queueAction/producer/springBoard"
;
}
}
},
},
ydzUrl
:
function
()
{
//
TODO:
易代账URL
ydzUrl
:
function
()
{
// 易代账URL
if
(
this
.
env
==
"dev"
)
{
//集测环境
if
(
this
.
env
==
"dev"
)
{
//集测环境
return
"https://inte-openapi.chanjet.com"
;
return
"https://inte-openapi.chanjet.com"
;
}
else
{
}
else
{
return
"https://
market
.chanjet.com"
;
return
"https://
openapi
.chanjet.com"
;
}
}
},
},
ydzKey
:
function
()
{
//
TODO:
易代账Key
ydzKey
:
function
()
{
// 易代账Key
if
(
this
.
env
==
"dev"
)
{
if
(
this
.
env
==
"dev"
)
{
return
{
return
{
"appKey"
:
"qP2tgcfw"
,
"appKey"
:
"qP2tgcfw"
,
"appSecret"
:
"D25E0435ACFB4844DB75E7E0F87B9F71"
,
"appSecret"
:
"D25E0435ACFB4844DB75E7E0F87B9F71"
,
"m
essage
Secret"
:
"1234567890123456"
"m
sg
Secret"
:
"1234567890123456"
};
};
}
else
{
}
else
{
return
{
return
{
"appKey"
:
"cXqZIzIl"
,
"appKey"
:
"cXqZIzIl"
,
"appSecret"
:
"B5AE885F55652CE9A4686F96A4CD90D8"
,
"appSecret"
:
"B5AE885F55652CE9A4686F96A4CD90D8"
,
"m
essageSecret"
:
"
"
"m
sgSecret"
:
"WzeZ6EwkIAzUsa56
"
};
};
}
}
},
},
javaUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
""
;
}
else
{
return
""
;
}
},
pmappid
:
1
,
pmappid
:
1
,
pmcompanyid
:
1
,
pmcompanyid
:
1
,
pmroleid
:
{
"ta"
:
1
,
"pr"
:
2
},
pmroleid
:
{
"ta"
:
1
,
"pr"
:
2
},
...
...
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