Commit 8c9b52c0 by 王昆

gsb

parent fc42b43a
......@@ -233,8 +233,8 @@ class BpoSDPJApi {
};
//判断用户是否提现过 交易状态 00 成功 01 待处理 02 失败
if(!_cCashInfo.trade_status){
resData.redirectCode=1; //跳转到认证
}else{
resData.redirect_code = 1; //跳转到认证
} else{
resData.redirect_code = 2;//跳转到领取结果
resData.trade_status = _cCashInfo.trade_status;
if(resData.trade_status=="00"){
......@@ -271,10 +271,10 @@ class BpoSDPJApi {
id: id
});
if(!ccashinfo){
this.getErrResult("信息不存在");
return this.getErrResult("提现申请不存在");
}
if (!await this.idcardClient.checkIDCard(obj.id_no)) {
return this.returnjson(-1, "身份证格式不正确");
return this.getErrResult("身份证格式不正确");
}
let num = await this.esettleSve.isValidAge([obj.mchtId]);
......@@ -282,30 +282,31 @@ class BpoSDPJApi {
let card = await this.idcardClient.cardInfo(obj.id_no);
let age = card.age || 0;
if(!age) {
return this.returnjson(-1, "身份证号格式错误, 只支持18位身份证号码");
return this.getErrResult("身份证号格式错误, 只支持18位身份证号码");
}
if(card.sex == 'male') {
if (age < 18 || age > 60) {
return this.returnjson(-1, "签约失败,男限制18-60岁之间")
return this.getErrResult("签约失败,男限制18-60岁之间")
}
} else {
if (age < 18 || age > 55) {
return this.returnjson(-1, "签约失败,女限制18-55岁之间")
return this.getErrResult("签约失败,女限制18-55岁之间")
}
}
}
/**
* 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});
// if (doAuthRes.status !== 0) {
// return this.getBaseResult(1, doAuthRes.msg || "姓名或身份证错误");
// }
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) {
return this.getBaseResult(1, doAuthRes.msg || "姓名或身份证错误");
}
ccashinfo.id_name = this.trim(obj.id_name);
ccashinfo.id_no = this.trim(obj.id_no);
ccashinfo.openId = this.trim(obj.openId);
await ccashinfo.save();
// console.log("调用二要素 (兰伯望) 接口返回:"+JSON.stringify(doAuthRes));
// this.doSign3(ccashinfo);
this.doSign3(ccashinfo);
return { code:0, msg:"认证成功", data:{amt:system.f2y(ccashinfo.amt),mchtId:ccashinfo.mchtId}};
}catch (e) {
console.log(e);
......@@ -326,16 +327,15 @@ class BpoSDPJApi {
if(!obj.no){
return this.getBaseResult(1, 'ID不能为空');
}
let ccashinfo =await this.ccashinfoSve.getBean({
id:this.getNo(obj.no)
});
let id = this.getNo(obj.no);
let ccashinfo = await this.ccashinfoSve.getBean({
id: id
}) || {};
let key = `SDPJ_CASH_${ccashinfo.id}`;
let _lock = uuidv1();
try {
let ccashinfo = await this.ccashinfoSve.getBean({
id: this.getNo(obj.no)
});
if(!ccashinfo){
if (!ccashinfo) {
return this.getErrResult("信息不存在");
}
......@@ -347,8 +347,14 @@ class BpoSDPJApi {
return this.getErrResult("已提现,不要重复提现");
}
let api = await this.ecompanybusiSve.findOne({
appId: ccashinfo.app_id,
etemplate_id: ccashinfo.ecid,
mchtId: ccashinfo.mchtId,
});
await this.redisLock.lock(key, _lock, 20);
let result = await this.cashOut(ccashinfo);
let result = await this.cashOut(ccashinfo, api);
return result;
} catch (e) {
console.log(e);
......@@ -363,7 +369,6 @@ class BpoSDPJApi {
}
}
async doAuth(cashInfo) {
let res;
// 姓名二要素
......@@ -375,7 +380,7 @@ class BpoSDPJApi {
return res;
}
async doSign3(cashInfo, params) {
async doSign3(cashInfo) {
let result;
// 专票签(三方签)
let signParam = {
......@@ -389,7 +394,7 @@ class BpoSDPJApi {
let key = `${cashInfo.mcthId}_${cashInfo.outTradeNo}`;
let id = uuidv1();
await this.redisLock.lock(key, id, 20);
let result = await this.econtractSve.autoSignBankTwo(params);
let result = await this.econtractSve.autoSignBankTwo(signParam);
await this.redisLock.unLock(key, id);
if (result.data && result.data.contractId) {
......@@ -403,7 +408,7 @@ class BpoSDPJApi {
}
}
async cashOut(cashInfo) {
async cashOut(cashInfo, api) {
// 发起交易
let bizContent = [];
bizContent.push({
......@@ -413,22 +418,22 @@ class BpoSDPJApi {
"seqNo": "1000",
"accNo": cashInfo.openId,
"amt": cashInfo.amt,
"accType": "00",
"accType": "02",
"idNo": cashInfo.id_no
});
let nonceStr = await this.getUidStr(32, 36);
let tradeTime = moment().format('YYYYMMDDHHmmss');
var param = {
let param = {
"appId": cashInfo.app_id,
"currency": "CNY",
"mchtId": cashInfo.mchtId,
"nonceStr": nonceStr,
"notityUrl": "https://bpohhr.gongsibao.com/api/econtractApi/transferNotify",
"outTradeNo": cashInfo.outTradeNo,
"outTradeNo": cashInfo.outTradeNo + "abcd1234a2",
"signType": "MD5",
"tradeTime": tradeTime,
"bizContent": bizContent,
}
};
// now
let signArr = [];
......@@ -440,18 +445,26 @@ class BpoSDPJApi {
signArr.push("outTradeNo=" + param.outTradeNo);
signArr.push("signType=" + param.signType);
signArr.push("tradeTime=" + param.tradeTime);
signArr.push("key=" + mcht.secret);
signArr.push("key=" + api.key);
param.sign = md5(signArr.join("&")).toUpperCase();
console.log(JSON.stringify(param));
try {
let rs = await axios({
method: 'post',
url: settings.payDomain() + "/merchant/order/transfer",
url: settings.apiconfig.payDomain() + "/merchant/order/transfer",
data: param,
});
if (rs.data.code === 0) {
return this.getSuccessResult("提现成功");
cashInfo.trade_status = "01";
cashInfo.trade_desc = "提现申请成功";
await cashInfo.save();
return this.getSuccessResult("提现成功", {amt: system.f2y(cashInfo.amt)});
} else {
cashInfo.trade_status = "02";
cashInfo.trade_desc = rs.data.msg || "提现申请失败";
await cashInfo.save();
return this.getBaseResult(1, cashInfo.trade_desc);
}
console.log(rs.data);
return this.getCodeResult(rs.data.msg);
......
......@@ -66,6 +66,10 @@ module.exports = (db, DataTypes) => {
notify_api:{
type:DataTypes.STRING,
allowNull: true,
},
trade_desc:{
type:DataTypes.STRING,
allowNull: true,
}
}, {
paranoid: true,//假的删除
......
......@@ -51,6 +51,7 @@ module.exports = function (app) {
}
//params.push(req.query);
params.push(req.body);
console.log(req.body);
var p = null;
var invokeObj = System.getObject("api." + classPath);
if (invokeObj[methodName]) {
......
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