Commit 249f3e8b by Sxy

feat: 接入360百度

parent c359cffb
......@@ -31,7 +31,7 @@ class logCtl extends CtlBase {
}
return {
opTitle: opTitle,
url: `${messageBody.gname}/${messageBody.qname}/${messageBody.method}`,
url: messageBody.url || `${messageBody.gname}/${messageBody.qname}/${messageBody.method}`,
user: messageBody.param && messageBody.param.username || '',
ip: messageBody.param && messageBody.param.clientIp,
created_at,
......
......@@ -6,19 +6,21 @@ class ChannelCache extends CacheBase {
super();
this.channelDao = system.getObject("db.common.channelDao");
}
isdebug () {
isdebug() {
return true;
}
desc () {
desc() {
return "缓存本地应用对象";
}
prefix () {
prefix() {
return "g_channel_cm:"
}
async buildCacheVal (cachekey, inputkey, val, ex, ...items) {
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
const configValue = await this.channelDao.model.findOne(
{
where: { routehost: inputkey },
where: {
code: inputkey
},
include: [{ model: this.db.models.pathtomethod, as: "pts" }]
});
if (configValue) {
......
......@@ -356,14 +356,11 @@ class AliHandler {
console.log("推送数据obj: " + JSON.stringify(obj));
var rtn = await rc.execPost3({ "d": obj }, requrl);
console.log("pushOrderDelivery插入数据成功---------------------------------" + rtn.stdout);
let cacheDeliveryInfo = await this.cacheManager["AliCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180);
console.log("交付单缓存信息: " + JSON.stringify(cacheDeliveryInfo));
return {
"status": 1, //1代表成功,否则失败
"msg": "",
"data": "",
"requestId": ""
if (rtn.stdout.status == 0) {
await this.cacheManager["AliCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180);
rtn.stdout.status = 1;
}
return rtn.stdout
}
catch (error) {
console.log("error-------------------------------------" + error);
......
var system = require("../../../../system");
const sha235 = require("sha256");
var settings = require("../../../../../config/settings");
const rc = system.getObject("util.execClient");
class PannongHandler {
constructor() {
this.icpUrl = settings.icpUrl();
this.cacheManager = system.getObject("db.common.cacheManager");
}
async submitService(datajson) {
try {
let cachestr = sha235(JSON.stringify(datajson));
let cacheInfo = await this.cacheManager["AliCache"].getCache(cachestr);
if (cacheInfo && cacheInfo != 'undefined') {
return {
"status": 1, //1代表成功,否则失败
"msg": "已处理成功!",
"data": "",
"requestId": ""
}
} else {
let requrl = `${this.icpUrl}/web/delivery/servicebillCtl/create`;
let { actionBody } = datajson;
let rtn = await rc.execPost3(actionBody, requrl);
let j = JSON.parse(rtn.stdout);
if (j.status == 0) {
j.status = 1;
await this.cacheManager["AliCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180000);//插入redis缓存
j.status = 1;
}
return j;
}
} catch (error) {
console.log(error);
return system.getResultError(error);
}
}
}
module.exports = new PannongHandler();
\ No newline at end of file
var system = require("../../../../system");
const sha235 = require("sha256");
var settings = require("../../../../../config/settings");
class Zc360Handler {
constructor() {
this.icUrl = settings.icUrl() + "/web/bizchance";
this.userService = system.getObject("service.auth.userSve");
this.cmpService = system.getObject("service.common.companySve");
this.cacheManager = system.getObject("db.common.cacheManager");
}
//交付单处理
async pushOrderDelivery(datajson, channelobj) {
try {
var cachestr = sha235(JSON.stringify(datajson));
var cacheInfo = await this.cacheManager["AliCache"].getCache(cachestr);
if (cacheInfo && cacheInfo != 'undefined') {
return {
"status": 1, //1代表成功,否则失败
"msg": "已处理成功!",
"data": "",
"requestId": ""
}
}
let rc = system.getObject("util.execClient");
let obj = this.actionBodyHandler(datajson.actionBody);
let requrl = this.icUrl + "/deliverybillCtl/createOrderByPush";
//渠道名称和渠道编码
obj.channelSource = channelobj.name;
obj.channelNumber = channelobj.code;
//如果订单状态为已支付
//查询业务员信息并填充到obj
if (datajson.actionBody.needsolution.salesmanInfo.salesmanId) {
//去数据库查询该业务员信息
try {
let resInfo = await this.userService.getSalesmanInfo(datajson.actionBody.needsolution.salesmanInfo.salesmanId);
if (resInfo) {
obj.salesmanOpcode = resInfo.opath;
obj.salesmanName = obj.salesmanName || resInfo.nickName;
obj.servicerCode = resInfo.company_id;
}
} catch (error) {
console.log("salesmanId: " + datajson.actionBody.needsolution.salesmanInfo.salesmanId + "获取业务员opcode失败:" + error)
}
}
//获取交付商id
if (!obj.servicerCode) {
let companyInfo = await this.userService.getCompanyIdByName(obj.servicerName);
if (companyInfo && companyInfo.id) {
obj.servicerCode = companyInfo.id;
}
}
obj.servicerCode = obj.servicerCode ? obj.servicerCode : 10;
//设置成本
if (obj.skuCode) {
obj.costPrice = await this.userService.findCostBySkuCode(obj.skuCode)
}
let rtn = await rc.execPost3({ "d": obj }, requrl);
console.log("pushOrderDelivery插入数据成功---------------------------------" + rtn.stdout);
if (rtn.stdout.status == 0) {
rtn.stdout.status = 1;
await this.cacheManager["AliCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180);
}
return rtn.stdout
}
catch (error) {
console.log("error-------------------------------------" + error);
return system.getResultError(error);
}
}
actionBodyHandler(actionBody) {
let data = actionBody;
let obj = {};
obj.baseInfo = {};
obj.companyInfo = {};
obj.registeredInfo = {};
obj.positionInfo = {};
obj.regInfo = {};
obj.express_info = {};
if (data.orderNo) {//交付单编号
obj.deliverNumber = data.orderNo;
}
if (data.servicer) {//服务商信息
if (data.servicer.name) {//服务商名称
obj.servicerName = data.servicer.name;
}
}
// if (data.channelNeedNo) {//需求编号
// obj.businessMode = data.channelNeedNo;
// }
// if (data.channelSolutionNo) {//方案编号
// obj.schemeNumber = data.channelSolutionNo;
// }
if (data.needsolution.solution.Area) {//服务地区编码和服务地区
obj.serviceCode = data.needsolution.solution.Area;
obj.serviceName = data.needsolution.solution.Area;
obj.baseInfo.serviceName = data.needsolution.solution.Area;
}
if (data.needsolution.solution.CompanyName) {//公司名称
obj.baseInfo.companyName = data.needsolution.solution.CompanyName;
obj.companyName = data.needsolution.solution.CompanyName;
}
if (data.needsolution.solution.CompanyAddress) {//公司地址
obj.baseInfo.companyAddress = data.needsolution.solution.CompanyAddress;
}
if (data.needsolution.solution.companyLocation) {//服务地区编码和服务地区
obj.serviceCode = data.needsolution.solution.companyLocation;
obj.serviceName = data.needsolution.solution.companyLocation;
obj.baseInfo.serviceName = data.needsolution.solution.companyLocation;
}
if (data.needsolution.solution.actionType) {//证件类型:新办 续期 变更
obj.baseInfo.actionType = data.needsolution.solution.actionType;
}
if (data.needsolution.solution.licenseType) {//⽹⽂类型:⽹络表演
obj.baseInfo.licenseType = data.needsolution.solution.licenseType;
}
if (data.needsolution.bizType) { //产品编码
if (data.needsolution.bizType == "icpsq") {
obj.businessType = "ICP";
}
if (data.needsolution.bizType == "edisq") {
obj.businessType = "EDI";
}
if (data.needsolution.bizType == "wangwen") {
obj.businessType = "wangwen";
}
if (data.needsolution.bizType == "food") {
obj.businessType = "food";
}
}
if (data.needsolution.typeName) { //产品名称
if (data.needsolution.typeName == "icp申请") {
obj.businessName = "icp";
} else if (data.needsolution.typeName == "edi申请") {
obj.businessName = "edi";
} else if (data.needsolution.typeName == "文网文") {
obj.businessName = "文网文";
} else {
obj.businessName = data.needsolution.typeName
}
}
if (data.skuCode) { //产品的sku
obj.skuCode = data.skuCode;
}
if (data.needsolution.status) { //交付单状态码
if (data.needsolution.status == "PAID") {//已支付
obj.deliverStatus = "received";
}
if (data.needsolution.status == "USER_PAY_PRODUCE") {//已支付
obj.deliverStatus = "received";
}
}
if (data.needsolution.customerRemark) { //状态原因
obj.statusReason = data.needsolution.customerRemark;
}
if (data.needsolution.totalSum) { //价格
obj.sellingPrice = data.needsolution.totalSum;
}
if (data.needsolution.salesmanInfo) {//业务员id
if (data.needsolution.salesmanInfo.salesmanId) {
obj.salesmanId = data.needsolution.salesmanInfo.salesmanId;
}
if (data.needsolution.salesmanInfo.salesmanName) {//业务员name
obj.salesmanName = data.needsolution.salesmanInfo.salesmanName;
}
if (data.needsolution.salesmanInfo.salesmanMobile) {//业务员手机
obj.salesmanPhone = data.needsolution.salesmanInfo.salesmanMobile;
}
}
if (data.needsolution.customerInfo) {//联系人
if (data.needsolution.customerInfo.publishName) {
obj.baseInfo.contactsName = data.needsolution.customerInfo.publishName;
}
if (data.needsolution.customerInfo.publishMobile) {//联系电话
obj.baseInfo.contactsPhone = data.needsolution.customerInfo.publishMobile;
}
if (data.needsolution.customerRemark) {//备注信息
obj.baseInfo.memoInfo = data.needsolution.customerRemark;
}
}
if (data.needsolution.customerMaterial) {//客户上传所有材料
obj.baseInfo.customerMaterial = data.needsolution.customerMaterial;
}
if (data.needsolution.solutionFlowList) {//流程记录
obj.baseInfo.solutionFlowList = data.needsolution.solutionFlowList;
}
return obj;
}
}
module.exports = new Zc360Handler();
\ No newline at end of file
......@@ -6,7 +6,7 @@ const jwk2pem = require('pem-jwk').jwk2pem
const jwt = require('jsonwebtoken')
const CryptoJS = require("crypto-js")
class System {
static declare (ns) {
static declare(ns) {
var ar = ns.split('.');
var root = System;
for (var i = 0, len = ar.length; i < len; ++i) {
......@@ -24,10 +24,10 @@ class System {
* @param {String} token jwt token
* @param {Object} publicKey 公钥
*/
static verify (token, publicKey) {
static verify(token, publicKey) {
return jwt.verify(token, jwk2pem(publicKey));
}
static async delReq (url, qdata) {
static async delReq(url, qdata) {
let rtn = {}
let promise = new Promise(function (resv, rej) {
request.del({
......@@ -50,7 +50,7 @@ class System {
})
return promise;
}
static async getReq (url, qdata) {
static async getReq(url, qdata) {
let rtn = {}
let promise = new Promise(function (resv, rej) {
request.get({
......@@ -73,7 +73,7 @@ class System {
})
return promise;
}
static async postJsonTypeReq (url, data, md = "POST") {
static async postJsonTypeReq(url, data, md = "POST") {
let rtn = {}
let promise = new Promise(function (resv, rej) {
request({
......@@ -86,7 +86,6 @@ class System {
body: data
}, function (error, response, body) {
if (!error) {
console.log(body);
rtn.statusCode = response.statusCode
if (body) {
rtn.data = body
......@@ -102,7 +101,7 @@ class System {
})
return promise;
}
static async post3wFormTypeReq (url, data) {
static async post3wFormTypeReq(url, data) {
let rtn = {}
let promise = new Promise(function (resv, rej) {
request.post({
......@@ -123,7 +122,7 @@ class System {
})
return promise;
}
static async postMpFormTypeReq (url, formdata) {
static async postMpFormTypeReq(url, formdata) {
let promise = new Promise(function (resv, rej) {
request.post({
url: url,
......@@ -145,7 +144,7 @@ class System {
* @param {*} okmsg 操作成功的描述
* @param {*} req 请求头信息
*/
static getResult (data, opmsg = "操作成功", req) {
static getResult(data, opmsg = "操作成功", req) {
return {
status: !data ? -1 : 0,
msg: opmsg,
......@@ -158,7 +157,7 @@ class System {
* @param {*} data 操作成功返回的数据
* @param {*} okmsg 操作成功的描述
*/
static getResultSuccess (data, okmsg = "success") {
static getResultSuccess(data, okmsg = "success") {
return {
status: 0,
msg: okmsg,
......@@ -171,7 +170,7 @@ class System {
* @param {*} errmsg 操作失败的描述,默认为fail
* @param {*} data 操作失败返回的数据
*/
static getResultFail (status = -1, errmsg = "fail", data = null) {
static getResultFail(status = -1, errmsg = "fail", data = null) {
return {
status: status,
msg: errmsg,
......@@ -183,14 +182,14 @@ class System {
* @param {*} errmsg 操作失败的描述,默认为fail
* @param {*} data 操作失败返回的数据
*/
static getResultError (errmsg = "fail", data = null) {
static getResultError(errmsg = "fail", data = null) {
return {
status: -200,
msg: errmsg,
data: data,
};
}
static register (key, ClassObj, groupName, filename) {
static register(key, ClassObj, groupName, filename) {
if (System.objTable[key] != null) {
throw new Error("相同key的对象已经存在");
} else {
......@@ -205,7 +204,7 @@ class System {
return System.objTable[key];
}
static getObject (objpath) {
static getObject(objpath) {
var pathArray = objpath.split(".");
var packageName = pathArray[0];
var groupName = pathArray[1];
......@@ -246,7 +245,7 @@ class System {
}
}
static getSysConfig () {
static getSysConfig() {
var configPath = settings.basepath + "/app/base/db/metadata/index.js";
// if(settings.env=="dev"){
// console.log("delete "+configPath+"cache config");
......@@ -256,7 +255,7 @@ class System {
var configValue = require(configPath);
return configValue.config;
}
static get_client_ip (req) {
static get_client_ip(req) {
var ip = req.headers['x-forwarded-for'] ||
req.ip ||
req.connection.remoteAddress ||
......@@ -278,7 +277,7 @@ class System {
* @param {*} resultInfo 返回结果
* @param {*} errorInfo 错误信息
*/
static execLogs (opTitle, params, identifyCode, resultInfo, errorInfo) {
static execLogs(opTitle, params, identifyCode, resultInfo, errorInfo) {
var reqUrl = settings.logUrl();
let isLogData = true
if (params.method && (params.method.indexOf("find") >= 0 || params.method.indexOf("get") >= 0)) {
......@@ -296,7 +295,6 @@ class System {
requestId: resultInfo.requestId || ""
}
};
console.log(JSON.stringify(param))
let P = new Promise((resv, rej) => {
this.postJsonTypeReq(reqUrl, param).then(res => {
if (res.statusCode == 200) {
......@@ -309,16 +307,16 @@ class System {
return P
}
static desEncript (desstr) {
static desEncript(desstr) {
let deskey = '647a68c9-da01-40d3-9763-1ffa0f64cf3f'
var keyHex = CryptoJS.enc.Utf8.parse(deskey);
// direct decrypt ciphertext
var decrypted = CryptoJS.DES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse(desstr)
}, keyHex, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return decrypted.toString(CryptoJS.enc.Utf8);
}
}
......
......@@ -63,32 +63,6 @@ class LogClient {
query.startTime = new Date(created_at[0]).getTime();
query.entTime = new Date(created_at[1]).getTime();
}
console.log("请求--------日志");
console.log(settings.logUrl());
console.log(query);
// return {
// "totalCount": 1,
// "pageSize": 20,
// "currentPage": 0,
// "list": [
// {
// "opTitle": "center_manage_首页",
// "identifyCode": "10_",
// "messageBody": "{\"gname\":\"msg\",\"qname\":\"msgCtl\",\"method\":\"findUnreadCount\",\"param\":{\"clientIp\":\"9.223.9.138\",\"agent\":\"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36\",\"classname\":\"msg.msgCtl\",\"app_id\":1,\"company_id\":\"10\",\"userid\":\"15\",\"username\":\"j2\",\"bizpath\":\"/home\",\"is_read\":false},\"actionType\":\"\",\"pushUrl\":\"\"}",
// "resultInfo": "{\"status\":0}",
// "errorInfo": "null",
// "requestId": "19a258474e384a0db939270580f01407",
// "created_at": "2020-07-16T05:18:48.454Z"
// }, {
// "opTitle": "center_manage_消息中心",
// "identifyCode": "10_",
// "messageBody": "{\"gname\":\"msg\",\"qname\":\"msgCtl\",\"method\":\"findUnreadCount\",\"param\":{\"clientIp\":\"9.223.9.138\",\"agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36\",\"classname\":\"msg.msgCtl\",\"app_id\":1,\"company_id\":\"10\",\"userid\":\"15\",\"username\":\"j2\",\"bizpath\":\"/message/message_page\",\"is_read\":false},\"actionType\":\"\",\"pushUrl\":\"\"}",
// "resultInfo": "{\"status\":-1}",
// "errorInfo": "null",
// "requestId": "06d94fbcd05b44a1ae292a21f5931f41",
// "created_at": "2020-07-16T05:51:54.888Z"
// }]
// }
let rtn = await system.postJsonTypeReq(settings.logUrl(), {
"actionType": "queryLogsData",// Y 功能名称
"actionBody": query
......
......@@ -54,19 +54,26 @@ var settings = {
return "http://icdeliver-service";
}
},
icpUrl: function () {
if (this.env == "dev") {
return "http://192.168.201.22:8002" || "http://icp.com:8000";
} else {
return "http://icpdeliver-service";
}
},
logUrl: function () {
if (this.env == "dev") {
return "http://192.168.1.128:4019/api/queueAction/producer/springBoard";
return "http://192.168.18.101:4019/api/queueAction/producer/springBoard";
} else {
return "http://logs-sytxpublic-msgq-service.chaolai/api/queueAction/producer/springBoard";
}
},
pushUrl: function () {
if (this.env == "dev") {
return "http://192.168.18.101:4018/api/queueAction/producer/springBoard";
} else {
return "http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard";
}
if (this.env == "dev") {
return "http://192.168.18.101:4018/api/queueAction/producer/springBoard";
} else {
return "http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard";
}
},
pmappname: "center-app",
pmappid: 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