Commit daf2234b by 王昆

gsb

parent 684e610d
...@@ -29,7 +29,8 @@ class BpoSDPJApi { ...@@ -29,7 +29,8 @@ class BpoSDPJApi {
this.idcardClient = system.getObject("util.idcardClient"); this.idcardClient = system.getObject("util.idcardClient");
this.esettleSve = system.getObject("service.esettleSve"); this.esettleSve = system.getObject("service.esettleSve");
this.tdevApi = require("./tdevApi"); this.tdevApi = require("./tdevApi");
let resultMap = { this.redisLock = system.getObject("util.redisLock");
this.resultMap = {
0:"操作成功", 0:"操作成功",
1:"操作失败", 1:"操作失败",
1001001:"签名失败", 1001001:"签名失败",
...@@ -79,17 +80,17 @@ class BpoSDPJApi { ...@@ -79,17 +80,17 @@ class BpoSDPJApi {
// } // }
try { try {
if(!obj || !obj.outTradeNo || !obj.mchtId){ if(!obj || !obj.outTradeNo || !obj.mchtId){
return this.getResult(1002001,null); return this.getCodeResult(1002001,null);
} }
//1.mchtId & ecid 进行联合查询 如果存在直接返回 //1.mchtId & ecid 进行联合查询 如果存在直接返回
let _cCashInfo = await this.ccashinfoSve.getBean(obj); let _cCashInfo = await this.ccashinfoSve.getBean(obj);
console.log(`bpoSDPJApi.js -> cashQRCode -> mchtId & ecid 进行联合查询 :参数=` + JSON.stringify(obj) + " _cCashInfo = " + JSON.stringify(_cCashInfo)); console.log(`bpoSDPJApi.js -> cashQRCode -> mchtId & ecid 进行联合查询 :参数=` + JSON.stringify(obj) + " _cCashInfo = " + JSON.stringify(_cCashInfo));
if(_cCashInfo){ if(_cCashInfo){
return this.getResult(1002001,null); return this.getCodeResult(1002001,null);
} }
//2.检验所有参数是否完整 如果出现非法参数直接返回 //2.检验所有参数是否完整 如果出现非法参数直接返回
if(!obj.ecid || !obj.appId ||!obj.idNo || !obj.idName || !obj.amt){ if(!obj.ecid || !obj.appId ||!obj.idNo || !obj.idName || !obj.amt){
return this.getResult(1002001,null); return this.getCodeResult(1002001,null);
} }
//3.获取签约类型 //3.获取签约类型
let _ecompanybusi = await this.ecompanybusiSve.findOneByAppidMchtId({ let _ecompanybusi = await this.ecompanybusiSve.findOneByAppidMchtId({
...@@ -98,7 +99,7 @@ class BpoSDPJApi { ...@@ -98,7 +99,7 @@ class BpoSDPJApi {
}); });
console.log("查看签约类型 _ecompanybusi=" + JSON.stringify(_ecompanybusi)); console.log("查看签约类型 _ecompanybusi=" + JSON.stringify(_ecompanybusi));
if(!_ecompanybusi || !_ecompanybusi.hasOwnProperty("app_type")){ if(!_ecompanybusi || !_ecompanybusi.hasOwnProperty("app_type")){
return this.getResult(500,null); return this.getCodeResult(500,null);
} }
let _ccashinfoProperty = {}; let _ccashinfoProperty = {};
...@@ -114,14 +115,14 @@ class BpoSDPJApi { ...@@ -114,14 +115,14 @@ class BpoSDPJApi {
//4.保存签约数据 //4.保存签约数据
_cCashInfo = await this.ccashinfoSve.save(_ccashinfoProperty); _cCashInfo = await this.ccashinfoSve.save(_ccashinfoProperty);
if(!_cCashInfo){ if(!_cCashInfo){
return this.getResult(500,null); return this.getCodeResult(500,null);
} }
//5. 拼接h5 http连接 http//xxx?mchtId=xxx&ecid=xxx&no=id //5. 拼接h5 http连接 http//xxx?mchtId=xxx&ecid=xxx&no=id
let _no = await this.setNo(_cCashInfo.id); let _no = await this.setNo(_cCashInfo.id);
let custormUrl = `http://bpohhr.gongsibao.com?no=${_no}&outTradeNo=${_cCashInfo.outTradeNo}&mchtId=${_cCashInfo.mchtId}`; let custormUrl = `http://bpohhr.gongsibao.com?no=${_no}&outTradeNo=${_cCashInfo.outTradeNo}&mchtId=${_cCashInfo.mchtId}`;
//6.生成二维码 //6.生成二维码
let url =await this.qrClient.generateQR(custormUrl); let url =await this.qrClient.generateQR(custormUrl);
return this.getResult(0,{"qrcode": url || ""}); return this.getCodeResult(0,{"qrcode": url || ""});
} catch (e) { } catch (e) {
let result = { let result = {
code: 500, code: 500,
...@@ -146,7 +147,7 @@ class BpoSDPJApi { ...@@ -146,7 +147,7 @@ class BpoSDPJApi {
*/ */
async verificationMtchOutTradeNo(obj, req){ async verificationMtchOutTradeNo(obj, req){
if(!obj || !obj.outTradeNo || !obj.mchtId || !obj.no){ 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); let no = await this.getNo(obj.no);
try { try {
...@@ -155,7 +156,7 @@ class BpoSDPJApi { ...@@ -155,7 +156,7 @@ class BpoSDPJApi {
outTradeNo: this.trim(obj.outTradeNo), outTradeNo: this.trim(obj.outTradeNo),
mchtId: this.trim(obj.mchtId), mchtId: this.trim(obj.mchtId),
}); });
return this.getResult(0,{ return this.getCodeResult(0,{
id_name:_cCashInfo.id_name, id_name:_cCashInfo.id_name,
id_no:_cCashInfo.id_no, id_no:_cCashInfo.id_no,
app_id: _cCashInfo.app_id, app_id: _cCashInfo.app_id,
...@@ -178,7 +179,7 @@ class BpoSDPJApi { ...@@ -178,7 +179,7 @@ class BpoSDPJApi {
*/ */
async authentication(obj, req){ async authentication(obj, req){
if(!obj || !obj.id_name || !obj.id_no || !obj.mchtId || !obj.app_id|| !obj.id){ 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{ try{
if (!await this.idcardClient.checkIDCard(obj.id_no)) { if (!await this.idcardClient.checkIDCard(obj.id_no)) {
...@@ -249,13 +250,13 @@ class BpoSDPJApi { ...@@ -249,13 +250,13 @@ class BpoSDPJApi {
} }
async doAuth(params, api) { async doAuth(cashInfo) {
let res; let res;
// 姓名二要素 // 姓名二要素
res = await this.bankthreelogSve.personTwo({ res = await this.bankthreelogSve.personTwo({
appId: "sdpj_sign_" + api.app_id, appId: "sdpj_sign_" + cashInfo.app_id,
userName: params.idName, userName: cashInfo.id_name,
userIdNo: params.idNo userIdNo: cashInfo.id_no
}); });
return res; return res;
} }
...@@ -290,7 +291,7 @@ class BpoSDPJApi { ...@@ -290,7 +291,7 @@ class BpoSDPJApi {
"note": "提现", "note": "提现",
"idType": "00", "idType": "00",
"idName": cashInfo.id_name, "idName": cashInfo.id_name,
"seqNo": cashInfo.id, "seqNo": "1000",
"accNo": cashInfo.openId, "accNo": cashInfo.openId,
"amt": cashInfo.amt, "amt": cashInfo.amt,
"accType": "00", "accType": "00",
...@@ -299,7 +300,7 @@ class BpoSDPJApi { ...@@ -299,7 +300,7 @@ class BpoSDPJApi {
let nonceStr = await this.getUidStr(32, 36); let nonceStr = await this.getUidStr(32, 36);
let tradeTime = moment().format('YYYYMMDDHHmmss'); let tradeTime = moment().format('YYYYMMDDHHmmss');
var param = { var param = {
"appId": cashInfo.appId, "appId": cashInfo.app_id,
"currency": "CNY", "currency": "CNY",
"mchtId": cashInfo.mchtId, "mchtId": cashInfo.mchtId,
"nonceStr": nonceStr, "nonceStr": nonceStr,
...@@ -331,11 +332,10 @@ class BpoSDPJApi { ...@@ -331,11 +332,10 @@ class BpoSDPJApi {
data: param, data: param,
}); });
if (rs.data.code === 0) { if (rs.data.code === 0) {
trade.trade_status = "00"; return this.getSuccessResult("提现成功");
return system.getResult2("提现成功");
} }
console.log(rs.data); console.log(rs.data);
return system.getErrResult2(rs.data.msg); return this.getCodeResult(rs.data.msg);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
// 发起失败,删除trade // 发起失败,删除trade
...@@ -363,17 +363,24 @@ class BpoSDPJApi { ...@@ -363,17 +363,24 @@ class BpoSDPJApi {
return uuid.join(''); 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 = { let res = {
"code": code, "code": code,
"msg": this.resultMap[code] || "", "msg": msg,
"data": data "data": data
} }
for (let ele in other) {
res[ele] = other[ele];
}
return res;
} }
} }
module.exports = BpoSDPJApi; 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