Commit ed65d873 by 庄冰

pushpolicy2fq

parent 373ff7af
......@@ -20,6 +20,13 @@ class APIBase {
return system.getResultSuccess();
}
}
var method = pobj.actionType;
if (method && method.length > 4) {
var prefixStr = method.substr(0,4);
if (prefixStr == "task") {
return system.getResultSuccess();
}
}
if (!pobj.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !!");
}
......
......@@ -74,6 +74,9 @@ class PolicyAPI extends APIBase {
case "getPolicyNeedInfo"://政策需求信息(icompany)
opResult = this.policyneedSve.getPolicyNeedInfo(pobj);
break;
case "taskpolicyneed2fq"://推送政策需求数据至蜂擎系统(任务)
opResult = this.policyneedSve.taskpolicyneed2fq(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -24,7 +24,11 @@ module.exports = (db, DataTypes) => {
this.setDataValue("customerIntention", val);
this.setDataValue("customerIntentionName", uiconfig.config.pdict.customer_intention[val]);
}
},
},
isPushAlready: {//是否已推送
type: DataTypes.BOOLEAN,
defaultValue: false
},
}, {
paranoid: false,//假的删除
underscored: true,
......
......@@ -4,6 +4,7 @@ class PolicyneedService extends ServiceBase {
constructor() {
super("dbpolicy", ServiceBase.getDaoName(PolicyneedService));
this.policyinfoDao = system.getObject("db.dbpolicy.policyinfoDao");
this.oplogDao = system.getObject("db.common.oplogDao");
}
//提交政策需求
async submitPolicyNeed(pobj){
......@@ -280,5 +281,50 @@ class PolicyneedService extends ServiceBase {
result.dataCount = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return result;
}
//推送政策需求数据至蜂擎系统
async taskpolicyneed2fq(pobj) {
var obj = pobj.actionBody;
var limit = obj.limit || 100;
var pns = await this.dao.model.findAll({
where:{isPushAlready:false},
raw:true,
offset:0,
limit:limit
});
for(var i=0;i<pns.length;i++){
var pn = pns[i];
var needNo=await this.getBusUid("pn");
var pobj = {
"idempotentId": needNo,
"idempotentSource": "policyMpm",
"idempotentSourceName": "政策_政策申请",
"phone": pn.mobile,
"customerName": pn.contacts,
"companyName":[pn.company],
"city":pn.region,
"operator_phone":pn.popularizeUserCode
};
var rtn = "";
try {
var rc = system.getObject("util.aliyunClient");
//rtn = await rc.post("https://yunfuapi.gongsibao.com/crm/opportunity/submit", pobj);//线上
rtn = await rc.post("https://yunfuapi-dev.gongsibao.com/crm/opportunity/submit",pobj);//开发
if(rtn && rtn.code=="200"){
await this.dao.update({id:pn.id,isPushAlready:true});//标记需求数据,已推送
}
} catch (e) {
var logObj = {
op: "app/base/service/impl/dbpolicy/policyneedSve.js",
content: JSON.stringify(rtn),
resultInfo: JSON.stringify(e),
opTitle: "推送政策需求数据至蜂擎系统--异常",
};
await this.oplogDao.create(logObj);
}
}
return system.getResultSuccess();
}
}
module.exports = PolicyneedService;
......@@ -2,8 +2,8 @@ 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');//线上
const client = new Client('203756805', 'crkyej0xlmqa6bmvqijun6ltxparllyn');//开发
//const client = new Client('203763771', 'e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu');//线上
class aliyunClient {
constructor() {
// this.aliReqUrl = "https://aliapi.gongsibao.com/tm/springboard";
......
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