Commit 48fccf23 by 王栋源

wdy

parent 6c9c0c42
var WEBBase = require("../../web.base");
var system = require("../../../system");
class AccessAuthAPI extends WEBBase {
constructor() {
super();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
this.gatewaypushlogSve = system.getObject("service.common.gatewaypushlogSve");
}
async taskAliIcapi(){
var rtn=await this.gatewaypushlogSve.taskAliIcapi();
return rtn;
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
......@@ -5,6 +5,7 @@ class Ic extends APIBase {
constructor() {
super();
this.centerorderSve = system.getObject("service.common.centerorderSve");
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
}
/**
......@@ -35,6 +36,9 @@ class Ic extends APIBase {
case "paySuccess"://支付回调
opResult = await this.centerorderSve.paySuccess(pobj);
break;
case "orderClose"://阿里退款
opResult = await this.utilsOrderSve.orderClose(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class GatewaypushlogDao extends Dao{
constructor(){
super(Dao.getModelName(GatewaypushlogDao));
}
}
module.exports=GatewaypushlogDao;
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("gatewaypushlog", {
requestId: DataTypes.STRING,
requestUrl: DataTypes.STRING, //请求地址
requestjson: DataTypes.STRING,//请求地址
pushUrl: DataTypes.STRING,//调用地址
pushActionType: DataTypes.STRING,//调用参数
pushtimes:DataTypes.INTEGER,//推送次数
pushStatus:DataTypes.STRING,//推送状态
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'gateway_pushlog',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
const uuidv4 = require('uuid/v4');
const getRawBody = require('raw-body');
class GatewaypushlogService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(GatewaypushlogService));
this.execClient = system.getObject("util.execClient");
}
async taskAliIcapi() {
try {
var sql = "select * from gateway_pushlog where pushStatus='wts' and pushtimes<4"
var icloginfos = await this.customQuery(sql);
if (icloginfos.length > 0) {
var count = 10;
if (icloginfos.length < count) {
count = icloginfos.length;
}
var self = this;
for (var i = 0; i < count; i++) {
var icloginfo = icloginfos[i];
var requestdata = null;
if (icloginfo && icloginfo.requestjson) {
requestdata = JSON.parse(icloginfo.requestjson);
}
var url = settings.gatewayUrl() + "action/intentionapi/springBoard";
var rtn = await self.execClient.execPost(requestdata, url);
var data = JSON.parse(rtn.stdout);
if (data.success) {
icloginfo.pushStatus = "yts";
} else {
icloginfo.pushtimes += 1;
}
await this.update(icloginfo);
}
}
return system.getResultSuccess();
} catch (error) {
return system.getResultFail(-1,error);
}
}
}
module.exports = GatewaypushlogService;
......@@ -462,5 +462,22 @@ class UtilsOrderService extends AppServiceBase {
return system.getResultFail(-200, e.stack);
}
}
async orderClose(pobj) {//阿里退款
if (!pobj.actionBody.orderNo) {
return system.getResult(null, "actionBody.prderNo can not be empty");
}
try {
pobj.actionType = "channeldelOrder";
await this.delOrder(pobj, pobj.actionBody);
pobj.actionType = "updateStausByRefundOrder";
var url = settings.centerOrderUrl() + "action/icapi/springBoard";
await this.execClient.execPost(pobj, url);
return system.getResultSuccess();
} catch (e) {
return system.getResultFail(-200, e.stack);
}
}
}
module.exports = UtilsOrderService;
......@@ -211,7 +211,7 @@ module.exports = function (app) {
next();
return;
}
if (req.path.indexOf("/taskapi/").indexOf >= 0) {
if (req.path.indexOf("/taskapi/") >= 0) {
next();
return;
}
......
......@@ -55,6 +55,13 @@ var settings = {
return "http://center-app-service/";
}
},
gatewayUrl: function () {
if (this.env == "dev") {
return "http://192.168.0.106:4005";
} else {
return "http://center-app-service";
}
},
centerOrderUrl: function () {
if (this.env == "dev") {
return "http://centerapp.apps.com:4011/";
......
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