Commit daf2234b by 王昆

gsb

parent 684e610d
......@@ -29,7 +29,8 @@ class BpoSDPJApi {
this.idcardClient = system.getObject("util.idcardClient");
this.esettleSve = system.getObject("service.esettleSve");
this.tdevApi = require("./tdevApi");
let resultMap = {
this.redisLock = system.getObject("util.redisLock");
this.resultMap = {
0:"操作成功",
1:"操作失败",
1001001:"签名失败",
......@@ -79,17 +80,17 @@ class BpoSDPJApi {
// }
try {
if(!obj || !obj.outTradeNo || !obj.mchtId){
return this.getResult(1002001,null);
return this.getCodeResult(1002001,null);
}
//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);
return this.getCodeResult(1002001,null);
}
//2.检验所有参数是否完整 如果出现非法参数直接返回
if(!obj.ecid || !obj.appId ||!obj.idNo || !obj.idName || !obj.amt){
return this.getResult(1002001,null);
return this.getCodeResult(1002001,null);
}
//3.获取签约类型
let _ecompanybusi = await this.ecompanybusiSve.findOneByAppidMchtId({
......@@ -98,7 +99,7 @@ class BpoSDPJApi {
});
console.log("查看签约类型 _ecompanybusi=" + JSON.stringify(_ecompanybusi));
if(!_ecompanybusi || !_ecompanybusi.hasOwnProperty("app_type")){
return this.getResult(500,null);
return this.getCodeResult(500,null);
}
let _ccashinfoProperty = {};
......@@ -114,14 +115,14 @@ class BpoSDPJApi {
//4.保存签约数据
_cCashInfo = await this.ccashinfoSve.save(_ccashinfoProperty);
if(!_cCashInfo){
return this.getResult(500,null);
return this.getCodeResult(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 || ""});
return this.getCodeResult(0,{"qrcode": url || ""});
} catch (e) {
let result = {
code: 500,
......@@ -146,7 +147,7 @@ class BpoSDPJApi {
*/
async verificationMtchOutTradeNo(obj, req){
if(!obj || !obj.outTradeNo || !obj.mchtId || !obj.no){
return this.getResult(1002001,null);
return this.getCodeResult(1002001,null);
}
let no = await this.getNo(obj.no);
try {
......@@ -155,7 +156,7 @@ class BpoSDPJApi {
outTradeNo: this.trim(obj.outTradeNo),
mchtId: this.trim(obj.mchtId),
});
return this.getResult(0,{
return this.getCodeResult(0,{
id_name:_cCashInfo.id_name,
id_no:_cCashInfo.id_no,
app_id: _cCashInfo.app_id,
......@@ -178,7 +179,7 @@ class BpoSDPJApi {
*/
async authentication(obj, req){
if(!obj || !obj.id_name || !obj.id_no || !obj.mchtId || !obj.app_id|| !obj.id){
return this.getResult(1002001,null);
return this.getCodeResult(1002001,null);
}
try{
if (!await this.idcardClient.checkIDCard(obj.id_no)) {
......@@ -249,13 +250,13 @@ class BpoSDPJApi {
}
async doAuth(params, api) {
async doAuth(cashInfo) {
let res;
// 姓名二要素
res = await this.bankthreelogSve.personTwo({
appId: "sdpj_sign_" + api.app_id,
userName: params.idName,
userIdNo: params.idNo
appId: "sdpj_sign_" + cashInfo.app_id,
userName: cashInfo.id_name,
userIdNo: cashInfo.id_no
});
return res;
}
......@@ -290,7 +291,7 @@ class BpoSDPJApi {
"note": "提现",
"idType": "00",
"idName": cashInfo.id_name,
"seqNo": cashInfo.id,
"seqNo": "1000",
"accNo": cashInfo.openId,
"amt": cashInfo.amt,
"accType": "00",
......@@ -299,7 +300,7 @@ class BpoSDPJApi {
let nonceStr = await this.getUidStr(32, 36);
let tradeTime = moment().format('YYYYMMDDHHmmss');
var param = {
"appId": cashInfo.appId,
"appId": cashInfo.app_id,
"currency": "CNY",
"mchtId": cashInfo.mchtId,
"nonceStr": nonceStr,
......@@ -331,11 +332,10 @@ class BpoSDPJApi {
data: param,
});
if (rs.data.code === 0) {
trade.trade_status = "00";
return system.getResult2("提现成功");
return this.getSuccessResult("提现成功");
}
console.log(rs.data);
return system.getErrResult2(rs.data.msg);
return this.getCodeResult(rs.data.msg);
} catch (error) {
console.log(error);
// 发起失败,删除trade
......@@ -363,17 +363,24 @@ class BpoSDPJApi {
return uuid.join('');
}
getResult(code,data={},other={}){
getSuccessResult(msg = "success", data = {}) {
return this.getBaseResult(0, msg, data);
}
getCodeResult(code, data={}){
return this.getBaseResult(code, this.resultMap[code], data);
}
getErrResult(msg){
return this.getBaseResult(1, msg);
}
getBaseResult(code = 0, msg = "", data = {}) {
let res = {
"code": code,
"msg": this.resultMap[code] || "",
"msg": msg,
"data": data
}
for (let ele in other) {
res[ele] = other[ele];
}
return res;
}
}
module.exports = BpoSDPJApi;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment