Commit 065f9b0a by 宋毅

Merge branch 'center-channel' of gitlab.gongsibao.com:jiangyong/zhichan into center-channel

parents a834e98f 3e6ce91c
var APIBase = require("../../api.base");
var system = require("../../../system");
class AliyunApi extends APIBase {
constructor() {
super();
this.aliclient = system.getObject("util.aliyunClient");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj, action_process, action_type, action_body, req) {
pobj.requestId = req.requestId;
var opResult = null;
switch (action_type) {
case "queryAvailabelNumbers":// 获取可用外呼号码列表
opResult = await this.aliclient.queryAvailabelNumbers(pobj.actionBody.bizType);
break;
case "startBackToBackCall":// 发起双呼接口
opResult = await this.aliclient.startBackToBackCall(pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = AliyunApi;
\ No newline at end of file
......@@ -183,7 +183,7 @@ class Order extends APIBase {
requestUrl: "/icp/order/notify",
requestjson: JSON.stringify(pobj),//请求地址
pushUrl: "/action/intentionapi/springBoard",//调用地址
pushActionType: "icpNotifyNew",//调用参数
pushActionType: "icpOrderStatus",//调用参数
pushtimes: 0,//推送次数
pushStatus: "wts",//推送状态
}
......
......@@ -77,37 +77,13 @@ class utils360Sve extends AppServiceBase {
}
let result = await this.restPostUrl(pushObj, url);
if (result.code == 200) {
this.pushlogSve.createDb({
op: "360-pushOrderStatus",
content: JSON.stringify(pushObj),//推送的参数信息
resultInfo: JSON.stringify(result),
returnType: '1',
logLevel: 1,
opTitle: "推送360信息返回成功"
});
this.disposePushResult(pobj, result, "utils360Sve---pushOrderStatus--推送成功", 4);
} else {
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushOrderStatus",
content: "error:" + result.msg,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushOrderStatus",
});
this.disposePushResultFail(pobj, result, "utils360Sve---pushOrderStatus--推送失败", 4);
}
console.log(result, '-------------push360-----------------')
return result;
} catch (e) {
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushOrderStatus",
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushOrderStatus",
});
this.disposePushResultFail(pobj, e.stack, "utils360Sve---pushOrderStatus", 4);
}
}
......@@ -132,63 +108,40 @@ class utils360Sve extends AppServiceBase {
}
let params = actionBody.itemCode.join(',');
let url = settings.requestUrl360() + `api/v1/eshop/GetGoodsLowestPrice?sku_ids=${params}`;
let rtn = await this.restClient.execGet("",url);
let rtn = await this.restClient.execGet("", url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "restGet data is empty");
}
let result = JSON.parse(rtn.stdout);
if(result.code != 200){
return system.getResultFail(-1,result.msg)
if (result.code != 200) {
return system.getResultFail(-1, result.msg)
}
return system.getResultSuccess(result.data);
}
async pushTmOrderStatus(pobj){
let token = await this.utilsAuthSve.get360Token();
let url = settings.pushUrl360() + 'api/v1/eshop/GsbOrderUpdate?token=' + token.access_token;
let order_id = pobj.orderNo;
let sub_status = pobj.sub_status;
let status = pobj.status;
let pushObj = {
order_id,
status,
sub_status: sub_status
}
let result = await this.restPostUrl(pushObj, url);
if (result.code == 200) {
this.pushlogSve.createDb({
op: "360-pushTMOrderStatus",
content: JSON.stringify(pushObj),//推送的参数信息
resultInfo: JSON.stringify(result),
returnType: '1',
logLevel: 1,
opTitle: "推送360信息返回成功"
});
} else {
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushTMOrderStatus",
content: "error:" + result.msg,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushTMOrderStatus",
});
async pushTmOrderStatus(pobj) {
try {
let token = await this.utilsAuthSve.get360Token();
let url = settings.pushUrl360() + 'api/v1/eshop/GsbOrderUpdate?token=' + token.access_token;
let order_id = pobj.orderNo;
let sub_status = pobj.sub_status;
let status = pobj.status;
let pushObj = {
order_id,
status,
sub_status: sub_status
}
let result = await this.restPostUrl(pushObj, url);
if (result.code == 200) {
this.disposePushResult(pobj, result, "utils360Sve---pushTmOrderStatus--推送成功", 4)
} else {
this.disposePushResultFail(pobj, result, "utils360Sve---pushTmOrderStatus--推送失败", 4);
}
return result;
} catch (e) {
this.disposePushResultFail(pobj, e.stack, "utils360Sve---pushTmOrderStatus--推送失败", 4);
}
console.log(result, '-------------push360-----------------')
return result;
} catch (e) {
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushTMOrderStatus",
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushOrderStatus",
});
}
}
}
module.exports = utils360Sve;
......@@ -11,34 +11,33 @@ class UtilsDeliverSystemService extends AppServiceBase {
/**
* 推送业务信息到交付系统
* 业务操作的信息不变外加增加组装的一些参数(推送需求商机、关闭需求、订单商机、关闭订单)
* @param {*} pobj
* @param {*} pobj
*/
async pushBusiness2DeliverSystem(pobj) {//推送业务信息到交付系统
console.log(pobj,"pushBusiness2DeliverSystem-zhuangbing------------------------------");
var verifyResult = await this.verifyParam(pobj);
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "deliver->pushBusiness2DeliverSystem->verifyResult", this.pushlogFailType.FQ);
}
var interface_params_info = verifyResult.data;
if(interface_params_info.headData){
if(pobj && pobj.appInfo && pobj.appInfo.app_code){
interface_params_info.headData.appcode = pobj.appInfo.app_code;
}
}
var reqParams = {
actionType: "produceData",// Y 功能名称
actionBody: {
pushUrl: interface_params_info.pushUrl,// Y 推送地址
actionType: interface_params_info.actionType,// Y 推送地址接收时的功能名称
notifyUrl: interface_params_info.notifyUrl || "",// N 推送成功后通知的Url
identifyCode: interface_params_info.identifyCode,// Y 操作的业务标识
messageBody: pobj.actionBody, // Y 推送的业务消息,必须有一项对象属性值
headData: interface_params_info.headData //N 请求头信息,Json格式,如:{token:"XXXXXXX"}
},
requestId: pobj.requestId || "" // N 请求id
// var reqParams = {
// actionType: "produceData",// Y 功能名称
// actionBody: {
// pushUrl: interface_params_info.pushUrl,// Y 推送地址
// actionType: interface_params_info.actionType,// Y 推送地址接收时的功能名称
// notifyUrl: interface_params_info.notifyUrl || "",// N 推送成功后通知的Url
// identifyCode: interface_params_info.identifyCode,// Y 操作的业务标识
// messageBody: pobj.actionBody, // Y 推送的业务消息,必须有一项对象属性值
// headData: interface_params_info.headData //N 请求头信息,Json格式,如:{token:"XXXXXXX"}
// },
// requestId: pobj.requestId || "" // N 请求id
// }
let parms = {
actionType:interface_params_info.actionType,
actionBody: pobj.actionBody
}
var opQueuePushClientPostRes = await this.opQueuePushClientPost(pobj, this.opPushQueueUrl, reqParams);
console.log(opQueuePushClientPostRes,"pushBusiness2DeliverSystem-zhuangbing----2--------------------------");
let url = interface_params_info.opUrl;
var opQueuePushClientPostRes = await this.opQueuePushClientPost(pobj, url, parms);
return await this.disposePushResult(pobj, opQueuePushClientPostRes, "delivery->pushBusiness2DeliverSystem->result", this.pushlogFailType.FQ);
}
//--------------------------------------------------内部辅助方法-------------------start-----------------
......@@ -47,21 +46,22 @@ class UtilsDeliverSystemService extends AppServiceBase {
try {
var rtn = await this.restPostUrl(reqParams, pushQueueUrl);
if (rtn.status != 1) {
this.execClientNew.execLogs(`推送队列接收数据失败->opQueuePushClientPost`, pobj, "center-channel-utilsDeliverSystemSve-opQueuePushClientPost", rtn, JSON.stringify(rtn));
return system.getResult(null, "推送队列接收数据失败,失败原因:" + JSON.stringify(rtn));
this.execClientNew.execLogs(`推送资质宝失败->opQueuePushClientPost`, pobj, "center-channel-utilsDeliverSystemSve-opQueuePushClientPost", rtn, JSON.stringify(rtn));
return system.getResult(null, "推送资质宝失败,失败原因:" + JSON.stringify(rtn));
}
return system.getResultSuccess(null, "推送成功");
} catch (e) {
//日志记录
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utilsDeliverSystemSve/opQueuePushClientPost",
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常deliver->opQueuePushClientPost",
});
// this.logCtl.error({
// appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
// appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
// requestId: pobj.requestId || "",
// op: "utilsSve/utilsDeliverSystemSve/opQueuePushClientPost",
// content: "error:" + e.stack,
// // clientIp: pobj.clientIp,
// optitle: pobj.opType + "推送操作异常deliver->opQueuePushClientPost",
// });
this.execClientNew.execLogs(`推送资质宝失败->opQueuePushClientPost`, pobj, "center-channel-utilsDeliverSystemSve-opQueuePushClientPost", null, JSON.stringify(e.stack));
return system.getResult(null, "推送操作异常deliver->opQueuePushClientPost->error:" + e.stack);
}
}
......@@ -71,8 +71,8 @@ class UtilsDeliverSystemService extends AppServiceBase {
verify = system.getResult(null, "interface_params can not be empty,100400");
}
var interface_params_info = JSON.parse(pobj.interface_params);
if (!interface_params_info || !interface_params_info.pushUrl || !interface_params_info.headData) {
verify = system.getResult(null, "interface_params(pushUrl、headData) can not be empty,100430");
if (!interface_params_info || !interface_params_info.opUrl || !interface_params_info.headData) {
verify = system.getResult(null, "interface_params(opUrl、headData) can not be empty,100430");
}
verify.data = interface_params_info;
return verify;
......
......@@ -68,11 +68,15 @@ class UtilsNeedService extends AppServiceBase {
pobj.actionBody.type = "ali.tmd";
pobj.actionBody.idempotentSource = "tmd_ali";
}else if (pobj.actionBody.channel_type_code == 1) {
// 阿里商标交易
pobj.actionBody.type = "ali.tmd";
pobj.actionBody.idempotentSource = "tmd_ali";
pobj.actionBody.contactsDingtalk = pobj.actionBody.idempotentId;
}else if (pobj.actionBody.channel_type_code == 2) {
// 阿里商标注册
pobj.actionBody.type = "ali.tm";
pobj.actionBody.idempotentSource = "tm_ali";
pobj.actionBody.contactsDingtalk = pobj.actionBody.idempotentId;
}else if (pobj.actionBody.channel_type_code == 'esp.companyreg'){
pobj.actionBody.type = "ali.ic";
pobj.actionBody.idempotentSource = "ic_ali";
......@@ -768,6 +772,7 @@ class UtilsNeedService extends AppServiceBase {
// }
pobj.actionBody.data = [];
await this.queryByAli(pobj, 1);
pobj.actionBody.data=pobj.actionBody.data.filter(item=>item.Type===1)
pobj.actionType = "getUnCreated";
let reqUrl = this.centerOrderUrl + "action/need/springBoard";
let result = await this.restPostUrl(pobj, reqUrl);
......@@ -776,7 +781,7 @@ class UtilsNeedService extends AppServiceBase {
type: "tmjy"
};
for (let item of result.data) {
if (item.Type == 1 && item.RegisterNumber) {
if (item.Type == 1) {
pobj.actionBody.intentionBizId = item.BizId;
pobj.actionBody.mobile = item.Mobile ? item.Mobile : "";
//pobj.actionBody.Area = item.Area || "北京"
......@@ -802,10 +807,10 @@ class UtilsNeedService extends AppServiceBase {
End: pobj.actionBody.End ? pobj.actionBody.End : "",
PageNum: page,
PageSize: 10,
}, apiVersion: "2019-05-08"
}, type: "TM"
});
if (res.status == 0) {
pobj.actionBody.data.push(...res.data.Data);
pobj.actionBody.data.push(...res.data.Data.Trademark);
if (page < res.data.TotalPageNum) {
await this.queryByAli(pobj, page + 1)
}
......
......@@ -3,7 +3,7 @@ var RPCClient = require('@alicloud/pop-core').RPCClient;
const system = require("../system");
class aliyunClient {
constructor() {
this.execClientNew = system.getObject("util.execClientNew");
this.pushlogSve = system.getObject("service.common.pushlogSve");
}
getAliClient() {
......@@ -95,6 +95,77 @@ class aliyunClient {
}
}
//-----------阿里云双呼能力接口接入------start--------chensicong----2022.01.17----------------------
getAliDoubleCallClient() {
return new RPCClient({
accessKeyId: 'LTAI1pJs7KQizBe2',
accessKeySecret: 'MMNibebAPqR9AnX5YWHnSL2tHMSIoL',
endpoint: "https://companyreg.aliyuncs.com",
apiVersion: '2020-03-06'
});
}
// 获取可用外呼号码列表
async queryAvailabelNumbers(bizType){
let res = null;
try{
console.log(`开始调用阿里云-获取可用外呼号码列表接口。参数bizType=${bizType}`)
// let reqAliclient = this.getAliDoubleCallClient()
var client = new RPCClient({
accessKeyId: 'LTAI1pJs7KQizBe2',
accessKeySecret: 'MMNibebAPqR9AnX5YWHnSL2tHMSIoL',
endpoint: "https://companyreg.aliyuncs.com",
apiVersion: '2020-03-06'
});
let obj = { bizType:bizType }
res = await client.request("QueryAvailableNumbers", obj, {
timeout: 3000, // default 3000 ms
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'POST', // set the http method, default is GET
headers: {}, // set the http request headers
});
console.log(`结束调用阿里云-获取可用外呼号码列表接口。参数bizType=${bizType},结果=${res}`)
this.execClientNew.execLogs(`获取可用外呼号码列表成功`, {bizType:bizType}, "center-channel-aliyunClient-queryAvailabelNumbers", res, null);
return system.getResultSuccess(res.data);
}catch (e){
console.log(`调用异常:阿里云-获取可用外呼号码列表接口。参数bizType=${bizType},结果=${res},异常信息=${e.stack}`)
this.execClientNew.execLogs(`获取可用外呼号码列表失败接口`, {bizType:bizType}, "center-channel-aliyunClient-queryAvailabelNumbers", res, JSON.stringify(e.stack));
return system.getResultFail(-200, "api调用出现异常,error:" + e.stack);
}
}
/**
* 发起双呼
* @param reqbody
* @returns {Promise<{msg: *, data: *, status: *}|{msg: *, data, status: number}>}
*/
async startBackToBackCall(reqbody){
let res = null;
try{
console.log(`开始调用阿里云-发起双呼接口。参数reqbody`,reqbody)
let reqAliclient = this.getAliDoubleCallClient()
res = await reqAliclient.request("StartBackToBackCall",reqbody, {
timeout: 10000, // default 3000 ms 2020 0916 lin修改3000为10000,原因ConfirmIcpIntention BizIds 超过5条会超时
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'POST', // set the http method, default is GET
headers: {}, // set the http request headers
});
console.log(`结束调用阿里云-发起双呼接口。参数reqbody=`,reqbody,'结果=',res)
this.execClientNew.execLogs(`获取可用外呼号码列表成功`, reqbody, "center-channel-aliyunClient-queryAvailabelNumbers", res, null);
return system.getResultSuccess(res.data);
}catch (e){
console.log(`调用异常:阿里云-发起双呼接口。参数reqbody=`,reqbody,'结果=',res,`异常信息=${e.stack}`)
this.execClientNew.execLogs(`调用阿里云发起双呼接口失败`, reqbody, "center-channel-aliyunClient-startBackToBackCall", res, JSON.stringify(e.stack));
return system.getResultFail(-200, "api调用出现异常,error:" + e.stack);
}
}
//-----------阿里云双呼能力接口接入------start--------chensicong----2022.01.17----------------------
// 2020 0924 lin 新增
async reqbyLTget(obj, cbk) {
var action = obj.action;
......
......@@ -2,8 +2,10 @@ const crypto = require('crypto');
const sha256 = require('sha256');
const system = require("../system");
var settings = require("../../config/settings");
class baiduClient {
const AppServiceBase = require("../service/app.base");
class baiduClient extends AppServiceBase{
constructor() {
super();
this.pushlogSve = system.getObject("service.common.pushlogSve");
this.execClient = system.getObject("util.execClient");
this.baiduClientParams = settings.baiduClientParams();
......@@ -50,11 +52,9 @@ class baiduClient {
data:actionBody
}
var rtn = await this.execClient.execBaiduPost(baiduObj, url);
console.log("baiduObj+++++",baiduObj)
console.log("url+++++",url)
console.log("rtn+++++",rtn)
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost data is empty");
this.execClientNew.execLogs(`baiduClient-opBaiduClientPost-result:url=${url}`, actionBody, "center-channel-opBaiduClientPost", null, rtn);
return system.getResult(null, rtn);
}
var result = JSON.parse(rtn.stdout);
return result;
......@@ -74,28 +74,33 @@ class baiduClient {
host:this.baiduClientParams.host
}, // set the http request headers
});
console.log('baidu++++res+++',res)
this.pushlogSve.createDb({
op: "new-baiduReqbyget",
content: JSON.stringify(obj),//推送的参数信息
resultInfo: JSON.stringify(res),
returnType: '1',
logLevel: '1',
opTitle: "new-baiduReqbyget推送百度信息返回成功"
});
if(res.status == 0){
await this.disposePushResult(obj, res, "baidu->pushBusiness2Baidu->result", "");
}else{
await this.disposePushResultFail(obj, res, "badiu->pushBusiness2Baidu->catchError", this.pushlogFailType.FAILLOG);
}
// this.pushlogSve.createDb({
// op: "new-baiduReqbyget",
// content: JSON.stringify(obj),//推送的参数信息
// resultInfo: JSON.stringify(res),
// returnType: '1',
// logLevel: '1',
// opTitle: "new-baiduReqbyget推送百度信息返回成功"
// });
return system.getResultSuccess(res);
} catch (e) {
this.pushlogSve.createFailLogDb({
appid: obj.appInfo ? obj.appInfo.uapp_id || "" : "",
appkey: obj.appInfo ? obj.appInfo.uapp_key || "" : "",
requestId: obj.requestId || "",
content: JSON.stringify(obj),//推送的参数信息
resultInfo: "error:" + JSON.stringify(e),
clientIp: obj.clientIp || "",
failType: 1,
opTitle: "new-baiduReqbyget推送百度信息返回异常",
pushNumber: obj.pushNumber || 1
});
await this.disposePushResultFail(obj, e, "badiu->pushBusiness2Baidu->catchError", this.pushlogFailType.FAILLOG);
// this.pushlogSve.createFailLogDb({
// appid: obj.appInfo ? obj.appInfo.uapp_id || "" : "",
// appkey: obj.appInfo ? obj.appInfo.uapp_key || "" : "",
// requestId: obj.requestId || "",
// content: JSON.stringify(obj),//推送的参数信息
// resultInfo: "error:" + JSON.stringify(e),
// clientIp: obj.clientIp || "",
// failType: 1,
// opTitle: "new-baiduReqbyget推送百度信息返回异常",
// pushNumber: obj.pushNumber || 1
// });
return system.getResultFail(-200, "出现异常,error:" + e.stack);
}
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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