Commit d5a3d51f by 庄冰

aliyun

parent bccbe06b
......@@ -7,22 +7,61 @@ class FqUtilsService {
this.execClient = system.getObject("util.execClient");
this.logClient = system.getObject("util.logClient");
}
/**
* 推送投放落地页需求至蜂擎
* @param {*} pobj
* @param {*} code
*/
async pushNeedInfo2Fq(pobj,code){
try {
var url = fqBaseUrl+"/open/ex/flux/advisory?code="+code;
var rtn = await this.execClient.execPost(pobj, url);
var data = JSON.parse(rtn.stdout);
this.logClient.pushlog("测试数据---推送需求数据至蜂擎返回结果-pushNeedInfo2Fq-success",pobj, rtn, null);
this.logClient.pushlog("推送投放落地页需求数据至蜂擎返回结果-pushNeedInfo2Fq-success",pobj, rtn, null);
return data;
} catch (e) {
this.logClient.pushlog("测试数据---推送需求数据至蜂擎返回异常-pushNeedInfo2Fq-error", pobj, null, e.stack);
this.logClient.pushlog("推送投放落地页需求数据至蜂擎返回异常-pushNeedInfo2Fq-error", pobj, null, e.stack);
return null;
}
}
/**
* 推送媒体聚合页需求至蜂擎
* @param {*} pobj
*/
async pushMediaNeedInfo2Fq(pobj) {
try {
var url = "https://yunfuapi-dev.gongsibao.com/cloudapi/cyg/lead/fluxAllot";
var rc = system.getObject("util.aliyunClient");
console.log(rc,"aliyunClient++++++++++++++++++++++++++");
var rtn = await rc.post(url, pobj);
console.log(rtn,"rtn+++++++++++++++++++++++++++++++++++++")
this.logClient.pushlog("推送媒体聚合页需求数据至蜂擎返回结果-pushMediaNeedInfo2Fq-success",pobj, rtn, null);
return rtn;
} catch (e) {
console.log(e,"e+++++++++++++++++++++++++++++++++++++++")
this.logClient.pushlog("推送投放落地页需求数据至蜂擎返回异常-pushMediaNeedInfo2Fq-error", pobj, null, e.stack);
return null;
}
}
}
module.exports = FqUtilsService;
// var task = new FqUtilsService();
// var pobj=
// {
// "customer_name": "庄冰测试",
// "customer_phone": "1371307555669384839864",
// "customer_region": "北京市",
// "demand_list": [{
// "product_id": "5df73b903949e1000990f078",
// "region": "北京市 北京市 朝阳区"
// }],
// "remark": "测试数据",
// "source": "marketmedia"
// };
// task.pushMediaNeedInfo2Fq(pobj).then(d=>{
// console.log(d,"res++++++++++++++++++++++++++");
// })
\ No newline at end of file
const Client = require('aliyun-api-gateway').Client;
var RPCClient = require('@alicloud/pop-core').RPCClient;
const client = new Client('203756805', 'crkyej0xlmqa6bmvqijun6ltxparllyn');//开发
// const client = new Client('203763771', 'e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu');//线上
class aliyunClient {
constructor() {
// this.aliReqUrl = "https://aliapi.gongsibao.com/tm/springboard";
this.aliclient = new RPCClient({
accessKeyId: 'LTAI4FmyipY1wuLHjLhMWiPa',
accessKeySecret: 'hp4FF18IDCSym1prqzxrAjnnhNH3ju',
endpoint: 'https://trademark.aliyuncs.com',
apiVersion: '2018-07-24'
});
}
async post(aliReqUrl, actionBody) {
var param = {
data: actionBody,
timeout: 20000,
headers: {
accept: 'application/json'
}
};
console.log(JSON.stringify(param), "______________峰擎---阿里云参数_______");
var result = await client.post(aliReqUrl, param);
console.log(JSON.stringify(result), "______________峰擎---阿里云返回结果_______");
return result;
}
//阿里接口
async reqbyget(obj, cbk) {
var self = this;
var action = obj.action;
var reqbody = obj.reqbody;
return self.aliclient.request(action, reqbody, {
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: 'GET', // set the http method, default is GET
headers: {}, // set the http request headers
});
}
}
module.exports = aliyunClient;
......@@ -14,6 +14,7 @@
"MD5": "^1.3.0",
"after": "^0.8.2",
"ali-oss": "^4.12.2",
"aliyun-api-gateway": "^1.1.6",
"babel-polyfill": "^6.26.0",
"base64id": "^1.0.0",
"bluebird": "^3.5.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