Commit 2caaa803 by 宋毅

tj

parent dcce743d
...@@ -5,58 +5,43 @@ class PaymentAPI extends APIBase { ...@@ -5,58 +5,43 @@ class PaymentAPI extends APIBase {
super(); super();
this.utilstlbankSve = system.getObject("service.utilsSve.utilstlbankSve"); this.utilstlbankSve = system.getObject("service.utilsSve.utilstlbankSve");
} }
async test(pobj, query, req) { /**
// var tmp = await this.orderSve.createLicense(pobj.action_body); * 接口跳转-POST请求
return system.getResultSuccess({req:"ok"}); * action_process 执行的流程
} * action_type 执行的类型
async h5payment(p,o,r){ * action_body 执行的参数
var a=await this.utilstlbankSve.getH5Url(o.app_id,o.order_num,o.total_fee,null,o.body_desc,null,o.opType); */
return a; async springBoard(pobj, qobj, req) {
} if (!pobj.actionType) {
async getQrCode(pobj,o,r){ return system.getResult(null, "actionType参数不能为空");
var rtn=await this.utilstlbankSve.getQrCode(pobj.actionBody.uapp_id,pobj.actionBody.order_num,pobj.actionBody.total_fee,pobj.actionBody.body_desc,pobj.actionBody.opType); }
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getH5PayUrl":
opResult = await this.utilstlbankSve.getH5PayUrl(pobj, pobj.actionBody);
break;
case "getQrCode":
case "getOrderQrCode":
opResult = await this.utilstlbankSve.getQrCode(pobj.appInfo.uapp_id, pobj.actionBody.order_num, pobj.actionBody.total_fee, pobj.actionBody.body_desc, pobj.actionBody.op_type);
break;
case "queryOrder":
case "queryOrderStatus":
opResult = await this.utilstlbankSve.queryOrder(pobj.appInfo.uapp_id, pobj.actionBody.trxid);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
//支付成功后通知
async receiveCallBackNotify(pobj, query, req) {
var rtn = await this.utilstlbankSve.receiveCallBackNotify(pobj.actionBody.parmas, pobj.client_ip);
return rtn; return rtn;
} }
async queryOrder(pobj,o,r){
var rtn=await this.utilstlbankSve.queryOrder(pobj.actionBody.uapp_id,pobj.actionBody.trxid);
return rtn;
}
async receiveCallBackNotify(pobj,o,r){
var rtn=await this.utilstlbankSve.receiveCallBackNotify(pobj.actionBody.parmas, pobj.client_ip);
return rtn;
}
exam() {
return "";
}
classDesc() {
return {
groupName: "",
groupDesc: "",
name: "",
desc: "",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: "",
methodName: "",
paramdescs: [
{
paramDesc: "",
paramName: "",
paramType: "",
defaultValue: "",
}
],
rtnTypeDesc: "",
rtnType: ""
}
];
}
} }
module.exports = PaymentAPI; module.exports = PaymentAPI;
\ No newline at end of file
...@@ -48,28 +48,27 @@ class utilsTlBankSve { ...@@ -48,28 +48,27 @@ class utilsTlBankSve {
* @param {*} order_no 订单号 * @param {*} order_no 订单号
* @param {*} returl 支付成功后返回的url * @param {*} returl 支付成功后返回的url
*/ */
async getH5Url(app_id, pay_title, total_sum, order_no, returl) { async getH5PayUrl(pobj, actionBody) {
// appid:00000003,商户号(mch_id):990440148166000,md5key(pay_key):a0ea3fa20dbd7bb4d5abf1d59d63bae8 // pobj.actionBody.body_desc, pobj.actionBody.total_fee, pobj.actionBody.order_num, pobj.actionBody.returl
// var payParam = await this.companypayparamDao.getOneByCompanyId(company_id, 1); var payParam = await this.getpaymentinfo(pobj.appInfo.uapp_id);
var payParam = await this.getpaymentinfo(app_id);
if (!payParam) { if (!payParam) {
return { status: -210, msg: "公司没有对应的支付凭证" } return { status: -210, msg: "应用没有对应的支付凭证" }
} }
var timestamp = Date.now(); var timestamp = Date.now();
var jsonObj = { var jsonObj = {
appid: payParam.pay_appid, appid: payParam.pay_appid,
cusid: payParam.mch_id, cusid: payParam.mch_id,
version: 12, version: 12,
trxamt: total_sum,//单位为分 trxamt: pobj.actionBody.total_fee,//单位为分
reqsn: order_no,//order_num + "_" + company_id.toString(), reqsn: pobj.actionBody.order_num,// "qft" + order_num + "_" + uapp_id.toString(),
charset: "UTF-8", charset: "UTF-8",
returl: returl, returl: pobj.actionBody.returl,
notify_url: this.notifyUrl, notify_url: pobj.actionBody.returl,
body: pay_title, body: pobj.actionBody.body_desc,
remark: "h5paypagesywdy", remark: "h5paypagesywdy",
randomstr: timestamp.toString()//随机字符串,不长于32位 randomstr: timestamp.toString()//随机字符串,不长于32位
} }
var param_result = await this.getReqBeforeParam(jsonObj, "1352105537612345789"); var param_result = await this.getReqBeforeParam(jsonObj, payParam.pay_key);
if (param_result.status != 0) { if (param_result.status != 0) {
return param_result; return param_result;
} }
...@@ -96,7 +95,7 @@ class utilsTlBankSve { ...@@ -96,7 +95,7 @@ class utilsTlBankSve {
opType:操作类型,1微信、2支付宝 opType:操作类型,1微信、2支付宝
返回错误码:成功为1 返回错误码:成功为1
返回错误码:成功为1 返回错误码:成功为1
-210:公司没有对应的支付凭证 -210:应用没有对应的支付凭证
-230:请求参数信息为空 -230:请求参数信息为空
-250:请求组装签名参数信息为空 -250:请求组装签名参数信息为空
-280:请求结算接口返回失败 -280:请求结算接口返回失败
...@@ -113,7 +112,7 @@ class utilsTlBankSve { ...@@ -113,7 +112,7 @@ class utilsTlBankSve {
// var payParam = await this.companypayparamDao.getOneByCompanyId(company_id, 1); // var payParam = await this.companypayparamDao.getOneByCompanyId(company_id, 1);
var payParam = await this.getpaymentinfo(app_id); var payParam = await this.getpaymentinfo(app_id);
if (!payParam) { if (!payParam) {
return { status: -210, msg: "公司没有对应的支付凭证" } return { status: -210, msg: "应用没有对应的支付凭证" }
} }
var reqMethod = this.wxMethod; var reqMethod = this.wxMethod;
if (opType == "alipay") { if (opType == "alipay") {
...@@ -256,7 +255,7 @@ class utilsTlBankSve { ...@@ -256,7 +255,7 @@ class utilsTlBankSve {
order_num:订单号、 order_num:订单号、
opType:操作类型,1微信、2支付宝 opType:操作类型,1微信、2支付宝
返回错误码:成功为1 返回错误码:成功为1
-210:公司没有对应的支付凭证 -210:应用没有对应的支付凭证
-230:请求参数信息为空 -230:请求参数信息为空
-250:请求组装签名参数信息为空 -250:请求组装签名参数信息为空
-280:请求结算接口返回失败 -280:请求结算接口返回失败
...@@ -272,7 +271,7 @@ class utilsTlBankSve { ...@@ -272,7 +271,7 @@ class utilsTlBankSve {
async queryOrder(uapp_id, trxid) {//查询订单支付状态 async queryOrder(uapp_id, trxid) {//查询订单支付状态
var payParam = await this.getpaymentinfo(uapp_id); var payParam = await this.getpaymentinfo(uapp_id);
if (!payParam) { if (!payParam) {
return { status: -210, msg: "公司没有对应的支付凭证" } return { status: -210, msg: "应用没有对应的支付凭证" }
} }
var timestamp = Date.now(); var timestamp = Date.now();
var jsonObj = { var jsonObj = {
...@@ -316,7 +315,7 @@ class utilsTlBankSve { ...@@ -316,7 +315,7 @@ class utilsTlBankSve {
async receiveCallBackNotify(parmas, client_ip) {//收到通联回调通知---post请求 async receiveCallBackNotify(parmas, client_ip) {//收到通联回调通知---post请求
var result = {status:-1,msg:""}; var result = { status: -1, msg: "" };
try { try {
if (!parmas) { if (!parmas) {
result.msg = "回调parmas中参数信息为空"; result.msg = "回调parmas中参数信息为空";
...@@ -342,12 +341,12 @@ class utilsTlBankSve { ...@@ -342,12 +341,12 @@ class utilsTlBankSve {
var payParam = await this.getpaymentinfo(uappid); var payParam = await this.getpaymentinfo(uappid);
if (!payParam) { if (!payParam) {
result.msg = "回调公司没有对应的支付凭证"; result.msg = "回调应用没有对应的支付凭证";
return result; return result;
} }
var appinfo = await this.getappinfo(uappid); var appinfo = await this.getappinfo(uappid);
if (!appinfo) { if (!appinfo) {
result.msg = "回调公司没有对应的支付凭证"; result.msg = "回调应用没有对应的支付凭证";
return result; return result;
} }
var signResult = await this.resultSign(parmas, payParam.pay_key); var signResult = await this.resultSign(parmas, payParam.pay_key);
...@@ -355,18 +354,18 @@ class utilsTlBankSve { ...@@ -355,18 +354,18 @@ class utilsTlBankSve {
result.msg = signResult.msg; result.msg = signResult.msg;
return result; return result;
} }
//解析支付参数 //解析支付参数
parmas.out_trade_no = attachList[0].substr(3); parmas.out_trade_no = attachList[0].substr(3);
parmas.uappid = attachList.length == 2 ? attachList[1] : attachList[2]; parmas.uappid = attachList.length == 2 ? attachList[1] : attachList[2];
//重写新签名 //重写新签名
var newparmas = await this.getReqBeforeParam(parmas, appinfo.uapp_secret); var newparmas = await this.getReqBeforeParam(parmas, appinfo.uapp_secret);
var backResult = await this.execReqInfo(null,payParam.notify_url,newparmas.req_param); var backResult = await this.execReqInfo(null, payParam.notify_url, newparmas.req_param);
if (backResult.status != 0) { if (backResult.status != 0) {
result.msg = backResult.msg; result.msg = backResult.msg;
return result; return result;
} }
result.status=0; result.status = 0;
return result; return result;
} catch (e) { } catch (e) {
result.msg = "回调业务处理---error异常"; result.msg = "回调业务处理---error异常";
...@@ -390,7 +389,7 @@ class utilsTlBankSve { ...@@ -390,7 +389,7 @@ class utilsTlBankSve {
return ""; return "";
} }
async opBackNotify(getParams, opDesc) {//操作回调业务逻辑 async opBackNotify(getParams, opDesc) {//操作回调业务逻辑__暂时没有用到
try { try {
//日志记录 //日志记录
logCtl.info({ logCtl.info({
......
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