Commit 8c9b52c0 by 王昆

gsb

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