Commit 98166452 by 王昆

Merge branch 'bpo-web' of gitlab.gongsibao.com:jiangyong/zhichan into bpo-web

parents b3271f05 5502b1f6
...@@ -2,7 +2,7 @@ var system = require("../../system") ...@@ -2,7 +2,7 @@ var system = require("../../system")
const md5 = require("md5"); const md5 = require("md5");
const moment = require("moment"); const moment = require("moment");
const axios = require("axios"); const axios = require("axios");
const uuidv1 = require('uuid/v1');
class BpoSDPJApi { class BpoSDPJApi {
constructor() { constructor() {
...@@ -158,11 +158,15 @@ class BpoSDPJApi { ...@@ -158,11 +158,15 @@ class BpoSDPJApi {
} }
} }
async setNo(no){ setNo(no){
return system.encryption(no); return system.encryption(no);
} }
async getNo(no) { async setNoTest(params){
return system.encryption(params.no);
}
getNo(no) {
return system.decryption(no); return system.decryption(no);
} }
...@@ -232,12 +236,23 @@ class BpoSDPJApi { ...@@ -232,12 +236,23 @@ class BpoSDPJApi {
outTradeNo: this.trim(obj.outTradeNo), outTradeNo: this.trim(obj.outTradeNo),
mchtId: this.trim(obj.mchtId), mchtId: this.trim(obj.mchtId),
}); });
return this.getCodeResult(0,{ let resData = {
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, };
no:this.setNo(_cCashInfo.id) //判断用户是否提现过 交易状态 00 成功 01 待处理 02 失败
}) if(!_cCashInfo.trade_status){
resData.redirectCode=1; //跳转到认证
}else{
resData.redirect_code = 2;//跳转到领取结果
resData.trade_status = _cCashInfo.trade_status;
if(resData.trade_status=="00"){
_cCashInfo.amt = system.f2y(_cCashInfo.amt);
}else if(resData.trade_status=="02"){
_cCashInfo.failReason = "";
}
}
return this.getCodeResult(0, resData);
}catch (e) { }catch (e) {
console.log(e); console.log(e);
let result = { let result = {
...@@ -289,16 +304,16 @@ class BpoSDPJApi { ...@@ -289,16 +304,16 @@ class BpoSDPJApi {
/** /**
* TODO:需要线上测试 * TODO:需要线上测试
*/ */
let doAuthRes =await this.doAuth({id_name:this.trim(obj.id_name),id_no:this.trim(obj.id_no), app_id:obj.app_id}); // let doAuthRes =await this.doAuth({id_name:this.trim(obj.id_name),id_no:this.trim(obj.id_no), app_id:obj.app_id});
if (doAuthRes.status !== 0) { // if (doAuthRes.status !== 0) {
return this.getBaseResult(1, doAuthRes.msg || "姓名或身份证错误"); // return this.getBaseResult(1, doAuthRes.msg || "姓名或身份证错误");
} // }
ccashinfo.id_name = this.trim(obj.id_name); ccashinfo.id_name = this.trim(obj.id_name);
ccashinfo.id_no = this.trim(obj.id_no); ccashinfo.id_no = this.trim(obj.id_no);
await ccashinfo.save(); await ccashinfo.save();
console.log("调用二要素 (兰伯望) 接口返回:"+JSON.stringify(doAuthRes)); // console.log("调用二要素 (兰伯望) 接口返回:"+JSON.stringify(doAuthRes));
this.doSign3(ccashinfo); // this.doSign3(ccashinfo);
return this.getBaseResult( 0, msg = "认证成功", data = {no:this.setNo(ccashinfo.id),amt:system.f2y(ccashinfo.amt),mchtId:ccashinfo.mchtId}); return { code:0, msg:"认证成功", data:{amt:system.f2y(ccashinfo.amt),mchtId:ccashinfo.mchtId}};
}catch (e) { }catch (e) {
console.log(e); console.log(e);
let result = { let result = {
...@@ -318,6 +333,9 @@ class BpoSDPJApi { ...@@ -318,6 +333,9 @@ class BpoSDPJApi {
if(!obj.no){ if(!obj.no){
return this.getBaseResult(1, 'ID不能为空'); return this.getBaseResult(1, 'ID不能为空');
} }
let ccashinfo =await this.ccashinfoSve.getBean({
id:this.getNo(obj.no)
});
let key = `SDPJ_CASH_${ccashinfo.id}`; let key = `SDPJ_CASH_${ccashinfo.id}`;
let _lock = uuidv1(); let _lock = uuidv1();
try { try {
...@@ -332,12 +350,13 @@ class BpoSDPJApi { ...@@ -332,12 +350,13 @@ class BpoSDPJApi {
return this.getErrResult("二维码已作废,禁止提现"); return this.getErrResult("二维码已作废,禁止提现");
} }
if (ccashinfo.trade_status != "00") { if (ccashinfo.trade_status) {
return this.getErrResult("已提现,不要重复提现"); return this.getErrResult("已提现,不要重复提现");
} }
await this.redisLock.lock(key, _lock, 20); await this.redisLock.lock(key, _lock, 20);
let result = await this.cashOut(ccashinfo); let result = await this.cashOut(ccashinfo);
return result;
} catch (e) { } catch (e) {
console.log(e); console.log(e);
let result = { let result = {
...@@ -482,7 +501,7 @@ class BpoSDPJApi { ...@@ -482,7 +501,7 @@ class BpoSDPJApi {
return this.getBaseResult(1, msg); return this.getBaseResult(1, msg);
} }
getBaseResult(code = 0, msg = "", data = {}) { getBaseResult(code, msg, data) {
let res = { let res = {
"code": code, "code": code,
"msg": msg, "msg": msg,
......
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