Commit 9393fdaf by 王勇飞

add rys api

parent fa903c92
...@@ -18,6 +18,7 @@ class BizOptCtl extends CtlBase { ...@@ -18,6 +18,7 @@ class BizOptCtl extends CtlBase {
this.shisService = system.getObject("service.bizchance.salesmanhisSve"); this.shisService = system.getObject("service.bizchance.salesmanhisSve");
this.receiveUrl = settings.receiveUrl(); this.receiveUrl = settings.receiveUrl();
this.queueUrl = settings.queueUrl(); this.queueUrl = settings.queueUrl();
this.rysUrl = settings.rysUrl();
//this.wdyUrl = settings.wdyUrl(); //this.wdyUrl = settings.wdyUrl();
this.dateUtil = system.getObject("util.dateClient"); this.dateUtil = system.getObject("util.dateClient");
} }
...@@ -123,14 +124,21 @@ class BizOptCtl extends CtlBase { ...@@ -123,14 +124,21 @@ class BizOptCtl extends CtlBase {
//根据需求编号去更新该条需求的状态为已关闭 //根据需求编号去更新该条需求的状态为已关闭
try { try {
let res = await this.service.updateStatusByDemandCode(pobj); let res = await this.service.updateStatusByDemandCode(pobj);
//TODO 同步该需求关闭信息到其他系统(走队列,直接扔到队列里面)
//添加到记录表 //添加到记录表
pobj.operator = { pobj.operator = {
id: mobj.userid ? mobj.userid : "", id: mobj.userid ? mobj.userid : "",
name: mobj.username ? mobj.username : "" name: mobj.username ? mobj.username : ""
} }
let recordRes = await this.operationrecordSve.insertInfo(pobj); let recordRes = await this.operationrecordSve.insertInfo(pobj);
//异步将该需求关闭信息同步到其他系统(走队列,融易算接口文档2.3)
//构造参数
let pushUrl = this.rysUrl + "leads/proposal/close";
let pushObj = {
pushUrl: pushUrl,
actionType: "close",
messageBody: pobj
}
system.queueOper(pushObj);
return system.getResult("关闭需求成功!"); return system.getResult("关闭需求成功!");
} catch (error) { } catch (error) {
return system.getResultError("bizoptCtl/closeBizopt 关闭需求出错!"); return system.getResultError("bizoptCtl/closeBizopt 关闭需求出错!");
...@@ -248,45 +256,45 @@ class BizOptCtl extends CtlBase { ...@@ -248,45 +256,45 @@ class BizOptCtl extends CtlBase {
/*更新业务员信息*/ /*更新业务员信息*/
async updateSalesmanInfoByDemandCode(mobj, qobj, req) { async updateSalesmanInfoByDemandCode(mobj, qobj, req) {
var pobj = mobj.d; var pobj = mobj.d;
if (pobj.businessMode && pobj.businessMode != 'undefined') { if (pobj.businessMode && pobj.businessMode != 'undefined') {
try { try {
var res = await this.service.findInfoByDemandCode(pobj); var res = await this.service.findInfoByDemandCode(pobj);
if (res) { if (res) {
var sInfo = { var sInfo = {
"flowType": "BIZ", "flowType": "BIZ",
"flowId": res.id, "flowId": res.id,
"flowCode": pobj.businessMode, "flowCode": pobj.businessMode,
"salesmanInfo": { "salesmanInfo": {
"oldOpcode": res.salesman_opcode, "oldOpcode": res.salesman_opcode,
"oldClerkName": res.salesman_name, "oldClerkName": res.salesman_name,
"oldClerkId": res.salesman_id, "oldClerkId": res.salesman_id,
"oldClerkPhone": res.salesman_phone, "oldClerkPhone": res.salesman_phone,
"oldFacilitatorId": res.facilitator_id, "oldFacilitatorId": res.facilitator_id,
"oldFacilitatorName": res.facilitator_name, "oldFacilitatorName": res.facilitator_name,
"newOpcode": pobj.salesmanOpcode, "newOpcode": pobj.salesmanOpcode,
"newClerkName": pobj.salesmanName, "newClerkName": pobj.salesmanName,
"newClerkId": pobj.salesmanId, "newClerkId": pobj.salesmanId,
"newClerkPhone": pobj.salesmanPhone, "newClerkPhone": pobj.salesmanPhone,
"newFacilitatorId": pobj.facilitatorId, "newFacilitatorId": pobj.facilitatorId,
"newFacilitatorName": pobj.facilitatorName "newFacilitatorName": pobj.facilitatorName
}
} }
await this.shisService.insertInfo(sInfo); //之前业务员转历史
await this.service.updateSalesmanInfoByDemandCode(pobj); //更新业务员信息
return system.getResult("操作成功!");
} else {
return system.getResultError("未找到相关数据");
} }
await this.shisService.insertInfo(sInfo); //之前业务员转历史
} catch (error) { await this.service.updateSalesmanInfoByDemandCode(pobj); //更新业务员信息
return system.getResultError(error); return system.getResult("操作成功!");
} else {
return system.getResultError("未找到相关数据");
} }
} else {
return system.getResultError("参数错误!"); } catch (error) {
return system.getResultError(error);
} }
} else {
return system.getResultError("参数错误!");
} }
/*根据商机编号更新商机状态*/ }
/*根据商机编号更新商机状态*/
async updateStatusByDemandCode(mobj, qobj, req) { async updateStatusByDemandCode(mobj, qobj, req) {
var pobj = mobj.d; var pobj = mobj.d;
if (pobj.businessMode && pobj.businessMode != 'undefined' && pobj.currentStatus && pobj.currentStatus != 'undefined') { if (pobj.businessMode && pobj.businessMode != 'undefined' && pobj.currentStatus && pobj.currentStatus != 'undefined') {
...@@ -344,16 +352,16 @@ class BizOptCtl extends CtlBase { ...@@ -344,16 +352,16 @@ class BizOptCtl extends CtlBase {
var pobj = nobj.actionBody.messageBody; var pobj = nobj.actionBody.messageBody;
if (pobj.intentionBizId && pobj.intentionBizId != 'undefined') { if (pobj.intentionBizId && pobj.intentionBizId != 'undefined') {
try { try {
var  cachestr  =  sha235(JSON.stringify(nobj));       var cachestr = sha235(JSON.stringify(nobj));
var  cacheInfo  =  await  this.cacheManager["TxCache"].getCache(cachestr);  var cacheInfo = await this.cacheManager["TxCache"].getCache(cachestr);
if  (cacheInfo  &&  cacheInfo  !=  'undefined')  {         if (cacheInfo && cacheInfo != 'undefined') {
return  {           return {
"status":  1, "status": 1,
  //1代表成功,否则失败 //1代表成功,否则失败
"msg": "已处理成功!", "msg": "已处理成功!",
"data": cachestr , "data": cachestr,
"requestId": nobj.requestId "requestId": nobj.requestId
}       }
} else { } else {
pobj.businessStatus = 'received'; pobj.businessStatus = 'received';
pobj.sourceNumber = 'tx'; pobj.sourceNumber = 'tx';
...@@ -396,11 +404,11 @@ class BizOptCtl extends CtlBase { ...@@ -396,11 +404,11 @@ class BizOptCtl extends CtlBase {
} }
timeFormat(date) { timeFormat(date) {
let localTime = moment.utc(date).toDate(); let localTime = moment.utc(date).toDate();
localTime = moment(localTime).format("YYYY-MM-DD"); localTime = moment(localTime).format("YYYY-MM-DD");
return localTime; return localTime;
} }
//根据bizId查询商机表中的所有信息 //根据bizId查询商机表中的所有信息
async getInfo(pobj, qobj, req) { async getInfo(pobj, qobj, req) {
try { try {
if (!pobj.bizId) { if (!pobj.bizId) {
......
...@@ -5,6 +5,8 @@ const appconfig = system.getSysConfig(); ...@@ -5,6 +5,8 @@ const appconfig = system.getSysConfig();
class FitaxschemeCtl extends CtlBase { class FitaxschemeCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(FitaxschemeCtl)); super("bizchance", CtlBase.getServiceName(FitaxschemeCtl));
this.kongUrl = settings.kongurl();
this.rysUrl = settings.rysUrl();
} }
/** /**
* 新建方案信息 * 新建方案信息
...@@ -17,6 +19,17 @@ class FitaxschemeCtl extends CtlBase { ...@@ -17,6 +19,17 @@ class FitaxschemeCtl extends CtlBase {
return system.getResultError("fitaxschemeCtl/insertInfo 缺少需求编号!"); return system.getResultError("fitaxschemeCtl/insertInfo 缺少需求编号!");
} }
let res = await this.service.insertInfo(pobj); let res = await this.service.insertInfo(pobj);
//同步方案信息,获取方案编号(走队列,再写一个接收队列方案编号的方法,将方案编号更新到数据库 融易算接口文档2.2)
//构造参数
let pushUrl = this.rysUrl + "leads/proposal/create";
let notifyUrl = this.kongUrl + "web/fitaxschemeCtl/updateInfo";
let pushObj = {
pushUrl: pushUrl,
actionType: "create",
notifyUrl: notifyUrl,
messageBody: pobj
}
system.queueOper(pushObj);
return system.getResult("新建方案成功!"); return system.getResult("新建方案成功!");
} catch (error) { } catch (error) {
console.log("fitaxschemeCtl/insertInfo---------------------------------------------------------------- " + error); console.log("fitaxschemeCtl/insertInfo---------------------------------------------------------------- " + error);
...@@ -24,17 +37,37 @@ class FitaxschemeCtl extends CtlBase { ...@@ -24,17 +37,37 @@ class FitaxschemeCtl extends CtlBase {
} }
} }
async findInfoByBizid(pobj,qobj,req){//方案 /**
try{ * @param {*} pobj
if (pobj.bizId){ * @param {*} qobj
* @param {*} req
*/
async updateInfo(pobj, qobj, req) {
try {
let res = await this.service.updateInfo(pobj);
return system.getResult("添加方案编号成功!");
} catch (error) {
console.log("fitaxschemeCtl/updateInfo error: " + error);
return system.getResultError("添加方案编号失败: " + error)
}
}
/**
* @param {*} pobj
* @param {*} qobj
* @param {*} req
*/
async findInfoByBizid(pobj, qobj, req) {//方案
try {
if (pobj.bizId) {
var res = await this.service.findInfoByBizid(pobj); var res = await this.service.findInfoByBizid(pobj);
return system.getResult(res); return system.getResult(res);
} }
else{ else {
return system.getResultError("缺少方案编号"); return system.getResultError("缺少方案编号");
} }
} }
catch(error){ catch (error) {
return system.getResultError(error); return system.getResultError(error);
} }
} }
...@@ -42,20 +75,20 @@ class FitaxschemeCtl extends CtlBase { ...@@ -42,20 +75,20 @@ class FitaxschemeCtl extends CtlBase {
module.exports = FitaxschemeCtl; module.exports = FitaxschemeCtl;
var task = new FitaxschemeCtl(); var task = new FitaxschemeCtl();
var obj={ var obj = {
d:{ d: {
"demand_code":"20200728103902194844_book", "demand_code": "20200728103902194844_book",
"solution_bizid":"22222", "solution_bizid": "22222",
"service_type":"代理记账", "service_type": "代理记账",
"service_name":"海南省三亚市", "service_name": "海南省三亚市",
"company_type":"特殊行业", "company_type": "特殊行业",
"buy_duration":2, "buy_duration": 2,
"remarks":"SaaS", "remarks": "SaaS",
"taxpayer_type":"小规模纳税人", "taxpayer_type": "小规模纳税人",
"total_cost":"2222" "total_cost": "2222"
} }
} }
task.insertInfo(obj,{},{}).then(d=>{ task.insertInfo(obj, {}, {}).then(d => {
console.log(JSON.stringify(d)); console.log(JSON.stringify(d));
}) })
...@@ -18,7 +18,6 @@ class FitaxschemeDao extends Dao { ...@@ -18,7 +18,6 @@ class FitaxschemeDao extends Dao {
/** /**
* 插入方案信息 * 插入方案信息
* TODO 同步方案信息,获取方案编号(走队列,再写一个接收队列方案编号的方法,将方案编号更新到数据库)
* @param {*} qobj * @param {*} qobj
* @param {*} t * @param {*} t
*/ */
...@@ -35,12 +34,15 @@ class FitaxschemeDao extends Dao { ...@@ -35,12 +34,15 @@ class FitaxschemeDao extends Dao {
} }
/** /**
*更新方案编号 *更新方案信息(主要是添加方案编号)
*@param {*} qobj *@param {*} qobj
* @param {*} t * @param {*} t
*/ */
async updateInfo(qobj, t) { async updateInfo(qobj, t) {
let obj = this.buildObj(qobj); let obj = {};
if (qobj.solution_bizid) {// 方案编号
obj.solution_bizid = qobj.solution_bizid;
}
let whereObj = { "demand_code": obj.demand_code }; let whereObj = { "demand_code": obj.demand_code };
return await this.updateByWhere(obj, whereObj, t); return await this.updateByWhere(obj, whereObj, t);
} }
......
...@@ -59,6 +59,13 @@ var settings = { ...@@ -59,6 +59,13 @@ var settings = {
return "http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard"; return "http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard";
} }
}, },
rysUrl: function () {
if (this.env == "localhost") {
return "http://";
} else {
return "http://";
}
},
ftConfig: function () { ftConfig: function () {
if (this.env == "localhost") { if (this.env == "localhost") {
return { return {
......
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