Commit c5262c54 by 宋毅

tj

parent b9ac3b63
var APIBase = require("../../api.base");
var system = require("../../../system");
class PushBusinessAPI extends APIBase {
constructor() {
super();
this.toolSve = system.getObject("service.trademark.toolSve");
this.toolApi = system.getObject("api.tool.toolApi");
this.appSourceList = {
"tm_ali": "阿里云应用", "ic_ali": "阿里云应用", "icp_ali": "阿里云应用",
"tm_jdyun": "京东云应用", "ic_jdyun": "京东云应用", "icp_jdyun": "京东云应用",
"tm_1688": "1688应用", "ic_1688": "1688应用", "icp_1688": "1688应用",
};
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
var self = this;
if (!req.app) {
return system.getResult(null, "app is not empty");
}
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "tm_1688":
opResult = await self.opActionProcess(pobj.actionProcess);
break;
case "ic_1688":
opResult = await this.toolSve.getNclByLikeNameAndNcl(action_body);
break;
case "icp_1688":
opResult = await this.toolSve.word2pic(action_body);
break;
case "tm_ali":
opResult = await this.toolSve.getNcl(action_body);
break;
case "ic_ali":
opResult = await this.toolSve.getNclByLikeNameAndNcl(action_body);
break;
case "icp_ali":
opResult = await this.toolSve.word2pic(action_body);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async opActionProcess(pushBusinessSource, action_type, action_body) {
if (!pobj.actionBody.idempotentId) {
return system.getResult(null, "idempotentId is not empty");
}//接入方业务产品 ID
if (!pobj.actionBody.idempotentSource) {
return system.getResult(null, "idempotentSource is not empty");
}//业务来源(ali、jdyun、1688)
if (!pobj.actionBody.idempotentSourceName) {
return system.getResult(null, "idempotentSourceName is not empty");
}//业务来源名称 京东云应用、阿里云应用、1688应用
if (!pobj.actionBody.phone) {
return system.getResult(null, "phone is not empty");
}//手机号
if (!pobj.actionBody.orderPrice) {
return system.getResult(null, "orderPrice is not empty");
}//订单金额 double
if (!pobj.actionBody.productId) {
return system.getResult(null, "productId is not empty");
}//订单金额 string
if (!pobj.actionBody.productQuantity) {
return system.getResult(null, "productQuantity is not empty");
}//产品数量 int
// city、companyName
var opResult = null;
switch (action_type) {
case "fqdev"://dev
result = await this.opActionProcess(pushBusinessSource, reqEnv, action_body);
break;
case "fqProd"://prod
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = PushBusinessAPI;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class PushBusinessDao extends Dao {
constructor() {
super(Dao.getModelName(PushBusinessDao));
}
async getItemByUappKey(uappKey, reqEnv) {
return this.model.findOne({
where: {
uappKey: uappKey,
reqEnv: reqEnv
},
attributes: ["id",
"sourceCode",
"sourceName",
"uappKey",
"aliAppkey",
"aliSecret",
"status",
"pushSveUrl",
"pushProductId",
"sveProductId",
"reqEnv",
"notes"],
raw: true
});
}
}
module.exports = PushBusinessDao;
module.exports = {
"appid": "40d64e586551405c9bcafab87266bc04",
"label": "研发开放平台",
"appid": "201911051030",
"label": "知产api应用",
"config": {
"rstree": {
"code": "paasroot",
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("pushbusiness", {
sourceCode: DataTypes.STRING(100), // 业务来源
sourceName: DataTypes.STRING(100), // 业务来源名称
uappKey: DataTypes.STRING(64), // 平台应用key
aliAppkey: DataTypes.STRING(64), // 阿里网关appkey
aliSecret: DataTypes.STRING(255), // 阿里网关密钥
status: DataTypes.INTEGER, // 状态 0禁用 1启用
pushSveUrl: DataTypes.STRING(500), // 推送服务url
pushProductId: DataTypes.STRING(255), // 推送方产品ID
sveProductId: DataTypes.STRING(255), // 服务方产品ID
notes: DataTypes.STRING(255), // 备注
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_push_business',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class PushBusinessService extends ServiceBase {
constructor() {
super("dbpush", ServiceBase.getDaoName(PushBusinessService));
this.pushbusinessDao = system.getObject("db.dbpush.pushbusinessDao");
}
async opFqPushBusiness(pushBusinessSource, reqEnv, action_body) {
var item = await this.pushbusinessDao.getItemByUappKey(action_body.app.uappKey, reqEnv);
if (!item) {
return system.getResult(null, "push_business item is not empty");
}
var body = {
idempotentId: item.pushProductId,// 是 接入方业务产品 ID
productId: item.sveProductId,// 是 产品 ID
idempotentSource: item.sourceCode || "tm_1688",// 是 业务来源(ali、jd)
idempotentSourceName: item.sourceName || "1688应用",// 是 阿里,京东
city: action_body.city || "",// 否 所属城市
phone: action_body.phone || "15010929366",// 是 手机号
userId: action_body.userId || "channelUserIdtest01",// 否 用户 ID
companyName: action_body.companyName || "",// 否 公司名称
orderPrice: action_body.phoneaction_body.orderPrice || 899,// 是 订单金额
productQuantity: action_body.productQuantity || 1,// 是 产品数量
};
if (!body.idempotentId) {
return system.getResult(null, "idempotentId is not empty");
}//接入方业务产品 ID
if (!body.idempotentSource) {
return system.getResult(null, "idempotentSource is not empty");
}//业务来源(ali、jdyun、1688)
if (!body.idempotentSourceName) {
return system.getResult(null, "idempotentSourceName is not empty");
}//业务来源名称 京东云应用、阿里云应用、1688应用
if (!body.phone) {
return system.getResult(null, "phone is not empty");
}//手机号
if (!body.orderPrice) {
return system.getResult(null, "orderPrice is not empty");
}//订单金额 double
if (!body.productId) {
return system.getResult(null, "productId is not empty");
}//订单金额 string
if (!body.productQuantity) {
return system.getResult(null, "productQuantity is not empty");
}//产品数量 int
// city、companyName
var aliGateway = system.getObject("util.aliyunClient");
var result = await aliGateway.post(item.aliAppkey, item.aliSecret, item.pushSveUrl, body);
return result;
// if (reqEnv == "fqdev") {
// aliGateway=system.getObject("util.aliyunFqDevClient");
// }
// else if (reqEnv == "fqProd") {
// aliGateway=system.getObject("util.aliyunFqProdClient");
// }
}
}
module.exports = PushBusinessService;
const system=require("../../../system");
var settings=require("../../../../config/settings");
const system = require("../../../system");
var settings = require("../../../../config/settings");
class ToolService {
constructor(){
constructor() {
}
async pushFqBusiness(pushBusinessSource, reqEnv, action_body) {
}
}
module.exports=ToolService;
module.exports = ToolService;
// var test = new TmqueryService();
// test.bigtmcount({tmreg_year:2018,apply_addr_province:""}).then(function(d){
// console.log("#################################");
......
const settings = require("../../config/settings");
const Client = require('aliyun-api-gateway').Client;
// const client = new Client('203756805', 'crkyej0xlmqa6bmvqijun6ltxparllyn');
class AliyunClient {
constructor() {
}
async post(appkey, secret, aliReqUrl, actionBody) {
var client = new Client(appkey, secret);
var param = {
data: actionBody,
timeout: 20000,
headers: {
accept: 'application/json'
}
};
console.log(JSON.stringify(param), "______________峰擎---阿里云Prod参数_______");
var result = await client.post(aliReqUrl, param);
console.log(JSON.stringify(result), "______________峰擎---阿里云返回Prod结果_______");
return result;
}
}
module.exports = AliyunClient;
const settings = require("../../config/settings");
const Client = require('aliyun-api-gateway').Client;
const client = new Client('203756805', 'crkyej0xlmqa6bmvqijun6ltxparllyn');
class aliyunFqDevClient {
constructor() {
}
async post(aliReqUrl, actionBody) {
var param = {
data: actionBody,
timeout: 20000,
headers: {
accept: 'application/json'
}
};
console.log(JSON.stringify(param), "______________峰擎---阿里云dev参数_______");
var result = await client.post(aliReqUrl, param);
console.log(JSON.stringify(result), "______________峰擎---阿里云返回dev结果_______");
return result;
}
}
module.exports = aliyunFqDevClient;
const settings = require("../../config/settings");
const Client = require('aliyun-api-gateway').Client;
const client = new Client('203756805', 'crkyej0xlmqa6bmvqijun6ltxparllyn');
class aliyunFqProdClient {
constructor() {
}
async post(aliReqUrl, actionBody) {
var param = {
data: actionBody,
timeout: 20000,
headers: {
accept: 'application/json'
}
};
console.log(JSON.stringify(param), "______________峰擎---阿里云Prod参数_______");
var result = await client.post(aliReqUrl, param);
console.log(JSON.stringify(result), "______________峰擎---阿里云返回Prod结果_______");
return result;
}
}
module.exports = aliyunFqProdClient;
var path = require('path');
var ENVINPUT={
DB_HOST:process.env.DB_HOST,
DB_PORT:process.env.DB_PORT,
DB_USER:process.env.DB_USER,
DB_PWD:process.env.DB_PWD,
REDIS_HOST:process.env.REDIS_HOST,
REDIS_PORT:process.env.REDIS_PORT,
REDIS_PWD:process.env.REDIS_PWD,
var ENVINPUT = {
DB_HOST: process.env.DB_HOST,
DB_PORT: process.env.DB_PORT,
DB_USER: process.env.DB_USER,
DB_PWD: process.env.DB_PWD,
REDIS_HOST: process.env.REDIS_HOST,
REDIS_PORT: process.env.REDIS_PORT,
REDIS_PWD: process.env.REDIS_PWD,
DB_NAME:process.env.ZC_API_DB_NAME,
REDIS_DB:process.env.ZC_API_REDIS_DB,
DB_NAME: process.env.ZC_API_DB_NAME,
REDIS_DB: process.env.ZC_API_REDIS_DB,
APP_ENV:process.env.APP_ENV?process.env.APP_ENV:"dev"
APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev"
};
var settings = {
env: ENVINPUT.APP_ENV,
appKey: "40d64e586551405c9bcafab87266bc04",
appKey: "201911051030",
paasKey: "wx76a324c5d201d1a4",
secret: "f99d413b767f09b5dff0b3610366cc46",
secret: "aeea89de9e8049b09233ec146173de4a",
salt: "%iatpD1gcxz7iF#B",
cacheprefix: "sjb",
usertimeout: 3600,//单位秒
......@@ -229,7 +229,14 @@ var settings = {
}
},
},
gatewayAli: function () {
return {
devFqAppkey: "203756805",
devFqSecret: "crkyej0xlmqa6bmvqijun6ltxparllyn",
prodFqAppkey: "203756805",
prodFqSecret: "crkyej0xlmqa6bmvqijun6ltxparllyn"
}
},
homePage: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
......@@ -244,10 +251,10 @@ var settings = {
return localsettings.redis;
} else {
return {
host:ENVINPUT.REDIS_HOST,
port:ENVINPUT.REDIS_PORT,
password:ENVINPUT.REDIS_PWD,
db:ENVINPUT.REDIS_DB,
host: ENVINPUT.REDIS_HOST,
port: ENVINPUT.REDIS_PORT,
password: ENVINPUT.REDIS_PWD,
db: ENVINPUT.REDIS_DB,
};
}
},
......@@ -257,28 +264,28 @@ var settings = {
return localsettings.database;
} else {
return {
dbname : ENVINPUT.DB_NAME,
user : ENVINPUT.DB_USER,
password : ENVINPUT.DB_PWD,
config : {
host: ENVINPUT.DB_HOST,
dialect: 'mysql',
operatorsAliases: false,
pool: {
max: 5,
min: 0,
acquire: 90000000,
idle: 1000000
},
debug:false,
dialectOptions:{
requestTimeout: 999999,
// instanceName:'DEV'
} //设置MSSQL超时时间
dbname: ENVINPUT.DB_NAME,
user: ENVINPUT.DB_USER,
password: ENVINPUT.DB_PWD,
config: {
host: ENVINPUT.DB_HOST,
dialect: 'mysql',
operatorsAliases: false,
pool: {
max: 5,
min: 0,
acquire: 90000000,
idle: 1000000
},
debug: false,
dialectOptions: {
requestTimeout: 999999,
// instanceName:'DEV'
} //设置MSSQL超时时间
},
};
}
}
};
settings.ENVINPUT=ENVINPUT;
settings.ENVINPUT = ENVINPUT;
module.exports = settings;
......@@ -29,9 +29,11 @@
"exif-js": "^2.3.0",
"express": "^4.16.2",
"express-session": "^1.15.6",
"glob": "^7.1.6",
"gm": "^1.23.1",
"marked": "^0.7.0",
"method-override": "^2.3.10",
"moment": "^2.24.0",
"mongoose": "^5.7.1",
"morgan": "^1.9.0",
"multer": "^1.3.0",
......
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