Commit 7418d586 by 宋毅

tj

parent 017783ae
......@@ -121,7 +121,7 @@ class APIBase {
async doexec(gname, methodname, pobj, query, req) {
req.requestId = this.getUUID();
try {
if (["getTokenByHosts", "receiveCallBackNotify"].indexOf(methodname) < 0) {
if (["getTokenByHosts", "receiveCallBackNotify", "getAppInfo"].indexOf(methodname) < 0) {
if (!pobj.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !");
}
......@@ -163,7 +163,7 @@ class APIBase {
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId,
op: pobj.classname + "/" + methodname,
op: req.classname + "/" + methodname,
content: e.stack,
clientIp: pobj.clientIp,
agent: req.uagent,
......
......@@ -29,7 +29,7 @@ class PaymentAPI extends APIBase {
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":
case "queryOrderStatus": this.logCtl = system.getObject("service.common.oplogSve");
opResult = await this.utilstlbankSve.queryOrder(pobj.appInfo.uapp_id, pobj.actionBody.trxid);
break;
default:
......@@ -43,5 +43,12 @@ class PaymentAPI extends APIBase {
var rtn = await this.utilstlbankSve.receiveCallBackNotify(pobj.actionBody.parmas, pobj.client_ip);
return rtn;
}
async getPayParamInfo(pobj, qobj, req) {
return await this.utilstlbankSve.getPayParamItem(pobj.uappId);
}
async getAppInfo(pobj, qobj, req) {
return await this.utilstlbankSve.getAppItem(pobj.uappId);
}
}
module.exports = PaymentAPI;
\ No newline at end of file
......@@ -9,18 +9,6 @@ class AppDao extends Dao {
where: {
app_hosts: app_hosts
},
attributes: ["id",
"app_hosts",
"app_code",
"app_name",
"uapp_id",
"uapp_key",
"uapp_secret",
"contact_name",
"contact_mobile",
"contact_email",
"is_enabled",
"is_sign"],
raw: true
});
}
......@@ -30,18 +18,14 @@ class AppDao extends Dao {
uapp_key: uapp_key,
uapp_secret: uapp_secret
},
attributes: ["id",
"app_hosts",
"app_code",
"app_name",
"uapp_id",
"uapp_key",
"uapp_secret",
"contact_name",
"contact_mobile",
"contact_email",
"is_enabled",
"is_sign"],
raw: true
});
}
async getItemByUAppId(uapp_id) {
return this.model.findOne({
where: {
uapp_id: uapp_id
},
raw: true
});
}
......
......@@ -4,5 +4,13 @@ class AppPayparamDao extends Dao {
constructor() {
super(Dao.getModelName(AppPayparamDao));
}
async getItemByUAppId(uapp_id) {
return this.model.findOne({
where: {
uapp_id: uapp_id
},
raw: true
});
}
}
module.exports = AppPayparamDao;
......@@ -4,35 +4,24 @@ const querystring = require('querystring');
const md5 = require("MD5");
class utilsTlBankSve {
constructor() {
this.logCtl = system.getObject("service.common.oplogSve");
this.wxMethod = "W01";//微信订单支付
this.aliMethod = "A01";//阿里订单支付
this.notifyUrl = "https://igirl.gongsibao.com/api/tl/zxNotify";
this.restClient = system.getObject("util.restClient");
this.oplogDao = system.getObject("db.common.oplogDao");
this.appDao = system.getObject("db.dbapp.appDao");
this.apppayparamDao = system.getObject("db.dbapp.apppayparamDao");
}
async getpaymentinfo(appid) {
var sql = "select * from p_app_payparam where uapp_id=" + appid;
var appinfo = await this.oplogDao.customQuery(sql);
if (appinfo) {
console.log(appinfo);
return appinfo[0];
} else {
return null
}
async getPayParamItem(uappId) {
var item = await this.apppayparamDao.getItemByUAppId(uappId);
return system.getResultSuccess(item);
}
async getappinfo(appid) {
var sql = "select * from p_app where uapp_id=" + appid;
var appinfo = await this.oplogDao.customQuery(sql);
if (appinfo) {
console.log(appinfo);
return appinfo[0];
} else {
return null
}
async getAppItem(uappId) {
var item = await this.appDao.getItemByUAppId(uappId);
return system.getResultSuccess(item);
}
//-------------------------------------------h5支付-----------------开始
......@@ -46,7 +35,7 @@ class utilsTlBankSve {
*/
async getH5PayUrl(pobj, actionBody) {
// pobj.actionBody.body_desc, pobj.actionBody.total_fee, pobj.actionBody.order_num, pobj.actionBody.returl
var payParam = await this.getpaymentinfo(pobj.appInfo.uapp_id);
var payParam = await this.apppayparamDao.getItemByUAppId(pobj.appInfo.uapp_id);
if (!payParam) {
return { status: -210, msg: "应用没有对应的支付凭证" }
}
......@@ -106,7 +95,7 @@ class utilsTlBankSve {
*/
async getQrCode(app_id, order_num, total_fee, body_desc, op_type) {//获取微信支付二维码
// var payParam = await this.companypayparamDao.getOneByCompanyId(company_id, 1);
var payParam = await this.getpaymentinfo(app_id);
var payParam = await this.apppayparamDao.getItemByUAppId(app_id);
if (!payParam) {
var rtn = await this.restClient.execPost2(req_param, reqUrl);
return { status: -210, msg: "应用没有对应的支付凭证" }
......@@ -266,7 +255,7 @@ class utilsTlBankSve {
-410:请求结算接口返回空
*/
async queryOrder(uapp_id, trxid) {//查询订单支付状态
var payParam = await this.getpaymentinfo(uapp_id);
var payParam = await this.apppayparamDao.getItemByUAppId(uapp_id);
if (!payParam) {
return { status: -210, msg: "应用没有对应的支付凭证" }
}
......@@ -316,6 +305,13 @@ class utilsTlBankSve {
if (!parmas) {
return system.getResult(null, "回调parmas中参数信息为空");
}
//日志记录
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":,method=" + parmas.trxcode,
op: "center-app/app/base/service/impl/utilsSve/utilstlbankSve.js/receiveCallBackNotify",
content: JSON.stringify(parmas),
clientIp: client_ip || ""
});
var isVerify = await this.verifyCallBackParams(parmas);
if (isVerify) {
result.msg = isVerify;
......@@ -333,14 +329,14 @@ class utilsTlBankSve {
}
var uappid = attachList.length == 2 ? attachList[1] : attachList[2];
var payParam = await this.getpaymentinfo(uappid);
var payParam = await this.apppayparamDao.getItemByUAppId(uappid);
if (!payParam) {
return system.getResult(null, "app_pay_param回调应用没有对应的支付凭证");
}
if (!payParam.notify_url) {
return system.getResult(null, "app_pay_param回调应用没有对应的支付成功通知url配置");
}
var appinfo = await this.getappinfo(uappid);
var appinfo =await this.appDao.getItemByUAppId(uappid);
if (!appinfo) {
return system.getResult(null, "app回调应用没有对应的支付凭证");
}
......@@ -359,7 +355,12 @@ class utilsTlBankSve {
}
return system.getResultSuccess();
} catch (e) {
//TODO:异常日志记录
logCtl.error({
optitle: "回调业务处理---error异常",
op: "center-app/app/base/service/impl/utilsSve/utilstlbankSve.js/receiveCallBackNotify",
content: "参数=" + JSON.stringify(parmas),
clientIp: client_ip || ""
});
return system.getResult(null, "回调业务处理---error异常");
}
}
......@@ -382,13 +383,13 @@ class utilsTlBankSve {
async opBackNotify(getParams, opDesc) {//操作回调业务逻辑__暂时没有用到
try {
//日志记录
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":支付回调信息=====" + opDesc + ",method=" + getParams.trxcode,
op: "base/service/impl/utilszxbankSve.js/opBackNotify",
content: JSON.stringify(getParams),
clientIp: getParams.client_ip || ""
});
// //日志记录
// logCtl.info({
// optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":支付回调信息=====" + opDesc + ",method=" + getParams.trxcode,
// op: "base/service/impl/utilszxbankSve.js/opBackNotify",
// content: JSON.stringify(getParams),
// clientIp: getParams.client_ip || ""
// });
//获取充值业务锁
var locker = await cacheManager["ZxPayLocker"].enter(getParams.trxid);
if (locker && locker == "1") {
......@@ -404,12 +405,12 @@ class utilsTlBankSve {
}
else {
// await cacheManager["ZxPayLocker"].release(getParams.trxid);//---测试时放开
logCtl.info({
optitle: "通联回调操作频繁---太频繁了,太频繁了",
op: "/app/config/routes/api.js",
content: "参数=" + JSON.stringify(getParams),
clientIp: getParams.client_ip || ""
});
// logCtl.info({
// optitle: "通联回调操作频繁---太频繁了,太频繁了",
// op: "/app/config/routes/api.js",
// content: "参数=" + JSON.stringify(getParams),
// clientIp: getParams.client_ip || ""
// });
return { status: -510, msg: "中信回调操作频繁---太频繁了,太频繁了" };
}
} catch (e) {
......
......@@ -58,7 +58,7 @@ var settings = {
},
apiconfig: {
opLogUrl: function () {
return settings.reqEsAddr() + "bigdata_zc_op_log/_doc?pretty";
return settings.reqEsAddr() + "center_app_log/_doc?pretty";
},
opLogEsIsAdd: function () {
return 1;
......
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