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
2573a983
Commit
2573a983
authored
Jul 27, 2020
by
孙亚楠
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
294ec89a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
341 additions
and
26 deletions
+341
-26
bpo-web/app/base/api/impl/bpoSDPJApi.js
+156
-26
bpo-web/app/base/db/impl/ccashinfoDao.js
+9
-0
bpo-web/app/base/db/models/ccashinfo.js
+111
-0
bpo-web/app/base/service/impl/ccashinfoSve.js
+65
-0
No files found.
bpo-web/app/base/api/impl/bpoSDPJApi.js
View file @
2573a983
var
system
=
require
(
"../../system"
)
const
md5
=
require
(
"md5"
);
class
Bp
WXSign
Api
{
class
Bp
oSDPJ
Api
{
constructor
()
{
this
.
cwxsignapiSve
=
system
.
getObject
(
"service.cwxsignapiSve"
);
...
...
@@ -20,6 +20,21 @@ class BpWXSignApi {
this
.
dkcontractSve
=
system
.
getObject
(
"service.dkcontractSve"
);
this
.
EXCEPT_KEYS
=
[
'sign'
];
this
.
ccashinfoSve
=
system
.
getObject
(
"service.ccashinfoSve"
);
this
.
ecompanybusiSve
=
system
.
getObject
(
"service.ecompanybusiSve"
);
this
.
qrClient
=
system
.
getObject
(
"util.qrClient"
);
let
resultMap
=
{
0
:
"操作成功"
,
1
:
"操作失败"
,
1001001
:
"签名失败"
,
1002001
:
"参数错误"
,
500
:
"接口异常"
,
}
}
trim
(
o
)
{
if
(
!
o
)
{
...
...
@@ -36,34 +51,115 @@ class BpWXSignApi {
*/
async
cashQRCode
(
obj
,
req
)
{
// 验证合法性
let
p
=
{
appId
:
this
.
trim
(
obj
.
appId
),
nonceStr
:
this
.
trim
(
obj
.
nonceStr
),
ecid
:
Number
(
obj
.
ecid
||
0
),
idNo
:
this
.
trim
(
obj
.
idNo
),
};
let
keys
=
Object
.
keys
(
p
).
sort
();
let
signArr
=
[];
for
(
let
k
=
0
;
k
<
keys
.
length
;
k
++
)
{
let
tKey
=
keys
[
k
];
if
(
this
.
EXCEPT_KEYS
.
indexOf
(
tKey
)
==
-
1
&&
p
[
tKey
])
{
signArr
.
push
(
tKey
+
"="
+
p
[
tKey
]);
// let p = {
// appId: this.trim(obj.appId),
// nonceStr: this.trim(obj.nonceStr),
// ecid: Number(obj.ecid || 0),
// idNo: this.trim(obj.idNo),
// };
//
// let keys = Object.keys(p).sort();
// let signArr = [];
// for (let k = 0; k < keys.length; k++) {
// let tKey = keys[k];
// if (this.EXCEPT_KEYS.indexOf(tKey) == -1 && p[tKey]) {
// signArr.push(tKey + "=" + p[tKey]);
// }
// }
// let signStr = signArr.join("&") + "&key=" + api.app_secret;
// let sign = md5(signStr).toUpperCase();
// console.log(obj.sign, signStr, sign);
//
// if (sign != obj.sign) {
// return {
// code: 1001001,
// msg: "签名失败"
// };
// }
try
{
if
(
!
obj
||
!
obj
.
outTradeNo
||
!
obj
.
mchtId
){
return
this
.
getResult
(
1002001
,
null
);
}
}
let
signStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
api
.
app_secret
;
let
sign
=
md5
(
signStr
).
toUpperCase
();
console
.
log
(
obj
.
sign
,
signStr
,
sign
);
if
(
sign
!=
obj
.
sign
)
{
return
{
code
:
1001001
,
msg
:
"签名失败"
//1.mchtId & ecid 进行联合查询 如果存在直接返回
let
_cCashInfo
=
await
this
.
ccashinfoSve
.
getBean
(
obj
);
console
.
log
(
`bpoSDPJApi.js -> cashQRCode -> mchtId & ecid 进行联合查询 :参数=`
+
JSON
.
stringify
(
obj
)
+
" _cCashInfo = "
+
JSON
.
stringify
(
_cCashInfo
));
if
(
_cCashInfo
){
return
this
.
getResult
(
1002001
,
null
);
}
//2.检验所有参数是否完整 如果出现非法参数直接返回
if
(
!
obj
.
ecid
||
!
obj
.
appId
||!
obj
.
idNo
||
!
obj
.
idName
||
!
obj
.
amt
){
return
this
.
getResult
(
1002001
,
null
);
}
//3.获取签约类型
let
_ecompanybusi
=
await
this
.
ecompanybusiSve
.
findOneByAppidMchtId
({
app_id
:
this
.
trim
(
obj
.
appId
),
mchtId
:
this
.
trim
(
obj
.
mchtId
)
});
console
.
log
(
"查看签约类型 _ecompanybusi="
+
JSON
.
stringify
(
_ecompanybusi
));
if
(
!
_ecompanybusi
||
!
_ecompanybusi
.
hasOwnProperty
(
"app_type"
)){
return
this
.
getResult
(
500
,
null
);
}
let
_ccashinfoProperty
=
{};
_ccashinfoProperty
.
app_type
=
_ecompanybusi
.
app_type
;
_ccashinfoProperty
.
outTradeNo
=
obj
.
outTradeNo
;
_ccashinfoProperty
.
mchtId
=
obj
.
mchtId
;
_ccashinfoProperty
.
ecid
=
_ecompanybusobj
;
_ccashinfoProperty
.
app_id
=
obj
.
appId
;
_ccashinfoProperty
.
amt
=
Number
(
obj
.
amt
||
0
);
_ccashinfoProperty
.
idName
=
this
.
trim
(
obj
.
idName
)
||
""
;
_ccashinfoProperty
.
idNo
=
this
.
trim
(
obj
.
idNo
)
||
""
;
//4.保存签约数据
_cCashInfo
=
await
this
.
ccashinfoSve
.
save
(
_ccashinfoProperty
);
if
(
!
_cCashInfo
){
return
this
.
getResult
(
500
,
null
);
}
//5. 拼接h5 http连接 http//xxx?mchtId=xxx&ecid=xxx&no=id
let
_no
=
await
this
.
setNo
(
_cCashInfo
.
id
);
let
custormUrl
=
`http://bpohhr.gongsibao.com?no=
${
_no
}
&outTradeNo=
${
_cCashInfo
.
outTradeNo
}
&mchtId=
${
_cCashInfo
.
mchtId
}
`
;
//6.生成二维码
let
url
=
await
this
.
qrClient
.
generateQR
(
custormUrl
);
return
this
.
getResult
(
0
,{
"qrcode"
:
url
||
""
});
}
catch
(
e
)
{
let
result
=
{
code
:
500
,
msg
:
"接口异常"
};
console
.
log
(
e
.
stack
);
return
result
;
}
}
async
setNo
(
no
){
return
no
;
}
async
getNo
(
no
)
{
return
no
;
}
/**
* fn:验证商户是否可用
* @returns {Promise<void>}
*/
async
verificationMtchOutTradeNo
(
obj
,
req
){
if
(
!
obj
||
!
obj
.
outTradeNo
||
!
obj
.
mchtId
||
!
obj
.
no
){
return
this
.
getResult
(
1002001
,
null
);
}
let
no
=
await
this
.
getNo
(
obj
.
no
);
try
{
return
{
code
:
0
,
msg
:
"暂未提供,工程师正在紧急加班开发"
};
}
catch
(
e
)
{
let
_cCashInfo
=
await
this
.
ccashinfoSve
.
getBean
({
id
:
no
,
outTradeNo
:
this
.
trim
(
obj
.
outTradeNo
),
mchtId
:
this
.
trim
(
obj
.
mchtId
),
});
return
this
.
getResult
(
0
,{
id_name
:
_cCashInfo
.
id_name
,
id_no
:
_cCashInfo
.
id_no
})
}
catch
(
e
)
{
console
.
log
(
e
);
let
result
=
{
code
:
500
,
msg
:
"接口异常"
...
...
@@ -73,7 +169,41 @@ class BpWXSignApi {
}
}
/**
* fn:个人要素认证
* @returns {Promise<void>}
*/
async
authentication
(
obj
,
req
){
if
(
!
obj
||
!
obj
.
id_name
||
!
obj
.
id_no
){
return
this
.
getResult
(
1002001
,
null
);
}
try
{
}
catch
(
e
)
{
console
.
log
(
e
);
let
result
=
{
code
:
500
,
msg
:
"接口异常"
};
console
.
log
(
e
.
stack
);
return
result
;
}
}
getResult
(
code
,
data
=
{},
other
=
{}){
let
res
=
{
"code"
:
code
,
"msg"
:
this
.
resultMap
[
code
]
||
""
,
"data"
:
data
}
for
(
let
ele
in
other
)
{
res
[
ele
]
=
other
[
ele
];
}
return
res
;
}
}
module
.
exports
=
Bp
WXSign
Api
;
module
.
exports
=
Bp
oSDPJ
Api
;
bpo-web/app/base/db/impl/ccashinfoDao.js
0 → 100644
View file @
2573a983
const
system
=
require
(
"../../system"
);
const
Dao
=
require
(
"../dao.base"
);
class
CcashinfoDao
extends
Dao
{
constructor
(){
super
(
Dao
.
getModelName
(
CcashinfoDao
));
}
}
module
.
exports
=
CcashinfoDao
;
bpo-web/app/base/db/models/ccashinfo.js
0 → 100644
View file @
2573a983
const
system
=
require
(
"../../system"
);
const
settings
=
require
(
"../../../config/settings"
);
const
uiconfig
=
system
.
getUiConfig2
(
settings
.
wxconfig
.
appId
);
module
.
exports
=
(
db
,
DataTypes
)
=>
{
return
db
.
define
(
"ccashinfo"
,
{
app_id
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
},
app_type
:
{
type
:
DataTypes
.
BIGINT
,
allowNull
:
false
,
},
//需要在后台补充
mchtId
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
//需要在后台补充
ecid
:
{
type
:
DataTypes
.
BIGINT
,
allowNull
:
true
,
},
//需要在后台补充
outTradeNo
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
//需要在后台补充
amt
:
{
type
:
DataTypes
.
BIGINT
,
allowNull
:
true
,
},
sign_url
:{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
qrcode
:{
//用途类型
type
:
DataTypes
.
STRING
,
allowNull
:
true
},
qrcode_status
:{
type
:
DataTypes
.
BIGINT
,
allowNull
:
true
,
},
openId
:{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
id_name
:{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
id_no
:{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
trade_status
:{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
flow_status
:{
type
:
DataTypes
.
BIGINT
,
allowNull
:
true
,
},
contract_id
:{
type
:
DataTypes
.
BIGINT
,
allowNull
:
true
,
},
notify_api
:{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
}
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
version
:
true
,
freezeTableName
:
true
,
//freezeTableName: true,
// define the table's name
tableName
:
'c_cash_info'
,
validate
:
{},
indexes
:
[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
bpo-web/app/base/service/impl/ccashinfoSve.js
0 → 100644
View file @
2573a983
const
system
=
require
(
"../../system"
);
const
ServiceBase
=
require
(
"../sve.base"
);
class
CcashinfoSve
extends
ServiceBase
{
constructor
()
{
super
(
ServiceBase
.
getDaoName
(
CcashinfoSve
));
}
/**
* fn:根据条件获取对象
* @param params
* @returns {Promise<null>}
*
* 条件:mchtId ecid
*
*/
async
getBean
(
params
)
{
try
{
let
where
=
{};
if
(
params
.
mchtId
){
where
.
mchtId
=
params
.
mchtId
;
}
if
(
params
.
outTradeNo
){
where
.
outTradeNo
=
params
.
outTradeNo
;
}
if
(
params
.
id
){
where
.
id
=
params
.
id
;
}
let
bean
=
this
.
dao
.
model
.
findOne
({
where
:
where
});
return
bean
||
null
;
}
catch
(
e
)
{
console
.
log
(
e
);
return
system
.
getResult
(
null
,
`系统错误 错误信息:`
+
JSON
.
stringify
(
e
))
}
return
null
;
}
/**
* fn:保存
* @param params
* @returns {Promise<void>}
*/
async
save
(
params
){
if
(
!
params
){
return
null
;
}
try
{
await
this
.
dao
.
create
(
params
);
let
res
=
await
this
.
getBean
({
mchtId
:
params
.
mchtId
,
outTradeNo
:
params
.
outTradeNo
})
return
res
;
}
catch
(
e
)
{
console
.
log
(
e
);
}
}
}
module
.
exports
=
CcashinfoSve
;
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