Commit cabe75f0 by 王勇飞

gyq

parent b444abec
...@@ -121,64 +121,30 @@ class BizOptCtl extends CtlBase { ...@@ -121,64 +121,30 @@ class BizOptCtl extends CtlBase {
async closeBizopt(mobj, qobj, req) { async closeBizopt(mobj, qobj, req) {
let pobj = mobj.d; let pobj = mobj.d;
pobj.business_status = "isClosed"; pobj.business_status = "isClosed";
if (!qobj.demand_code || !qobj.close_reason) {
return system.getResultError("缺少必要参数.");
}
//根据需求编号去更新该条需求的状态为已关闭 //根据需求编号去更新该条需求的状态为已关闭
try { try {
let res = await this.service.updateStatusByDemandCode(pobj); let res = await this.service.updateStatusByDemandCode(pobj);
//添加到记录表 //添加到记录表
pobj.operator = { pobj.operator = {
id: mobj.userid ? mobj.userid : "", id: mobj.userid ? mobj.userid : "",
name: mobj.username ? mobj.username : "" name: mobj.username ? mobj.username : ""
} }
pobj.operation_type = "close";
pobj.operation_details = {
close_reason: pobj.close_reason,
remarks: pobj.remarks
}
let recordRes = await this.operationrecordSve.insertInfo(pobj); let recordRes = await this.operationrecordSve.insertInfo(pobj);
//异步将该需求关闭信息同步到其他系统(走队列,融易算接口文档2.3) //异步将该需求关闭信息同步到其他系统(走队列,融易算接口文档2.3)
//构造参数,添加判断(有方案信息的才走队列同步到融易算,没有的直接关闭) //构造参数
let schemeRes = await this.schemeSve.findInfo(pobj); let pushUrl = this.rysUrl + "leads/proposal/close";
if (schemeRes && schemeRes.solution_bizid) { let pushObj = {
let pushObj = this.buildObj(pobj, schemeRes); pushUrl: pushUrl,
system.queueOper(pushObj); actionType: "close",
} else { messageBody: pobj
console.log(pobj.demand_code + "该需求没有方案信息,不需要同步");
} }
system.queueOper(pushObj);
return system.getResult("关闭需求成功!"); return system.getResult("关闭需求成功!");
} catch (error) { } catch (error) {
return system.getResultError("bizoptCtl/closeBizopt 关闭需求出错!"); return system.getResultError("bizoptCtl/closeBizopt 关闭需求出错!");
} }
} }
buildObj(pobj, schemeRes) {
let pushUrl = this.rysUrl + "leads/proposal/close";
let solutionBizId;
if (schemeRes.solution_bizid) {
solutionBizId = schemeRes.solution_bizid;
}
let pushObj = {
pushUrl: pushUrl,
actionType: "close",
messageBody: {
IntentionBizId: pobj.demand_code,
BizType: "bookkeeping",
Solution: {
SolutionBizId: solutionBizId,//方案编号
Note: pobj.close_reason //备注
}
},
headData: {
'Source': 'GSB'
}
}
return pushObj;
}
/** /**
* 获取跟进详情页所有信息 * 获取跟进详情页所有信息
* @param {*} mobj * @param {*} mobj
......
var system = require("../../../system");
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const { json, JSON } = require("sequelize");
const appconfig = system.getSysConfig();
class FitaxpushqueueCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(FitaxpushqueueCtl));
this.rysUrl = settings.rysUrl();
}
/**
* 新建信息
* @param {*} mobj
*/
async insertInfo(pobj, qobj, req) {
try {
if (!pobj.delivery_code || !pobj.current_period) {
return system.getResultError("FitaxpushqueueCtl/insertInfo 缺少必要参数!");
}
let res = await this.service.insertInfo(pobj);
return system.getResult(res);
} catch (error) {
console.log("FitaxpushqueueCtl/insertInfo---------------------------------------------------------------- " + error);
return system.getResultError("FitaxpushqueueCtl/insertInfo 新建方案出错!");
}
}
/**
* @param {*} pobj
* @param {*} qobj
* @param {*} req
*/
async updateInfo(pobj, qobj, req) {
let obj = {};
if (pobj.actionBody.bizNo) {
obj.demand_code = pobj.actionBody.bizNo;
}
if (pobj.actionBody.accountDate) {
obj.current_period = pobj.actionBody.pobj.actionBody.accountDate;
}
if (pobj.actionBody.dataType){
obj.data_type = pobj.actionBody.dataType;
}
if (pobj.actionBody.reqData){
obj.req_data = pobj.actionBody.reqData;
}
if (pobj.actionBody.resData){
obj.res_data = pobj.actionBody.resData;
}
if (pobj.actionBody.rysCheck){
obj.rys_check = pobj.actionBody.rysCheck;
}
if (pobj.actionBody.pushStatus){
obj.push_status = pobj.actionBody.pushStatus;
}
if (pobj.actionBody.checkDate){
obj.check_date = pobj.actionBody.checkDate;
}
try {
let res = await this.service.updateInfo(obj);
return system.getResult(res);
} catch (error) {
console.log("fitaxschemeCtl/updateInfo error: " + error);
return system.getResultError("updateInfo error: " + error)
}
}
}
module.exports = fitaxpushqueueCtl;
...@@ -37,8 +37,8 @@ class FitaxschemeCtl extends CtlBase { ...@@ -37,8 +37,8 @@ class FitaxschemeCtl extends CtlBase {
*/ */
async updateInfo(pobj, qobj, req) { async updateInfo(pobj, qobj, req) {
let obj = {}; let obj = {};
if (pobj.actionBody.messageBody.IntentionBizId) {//需求编号 if (pobj.actionBody.IntentionBizId) {//需求编号
obj.demand_code = pobj.actionBody.messageBody.IntentionBizId; obj.demand_code = pobj.actionBody.IntentionBizId;
} }
if (pobj.actionBody.resultInfo.data.SolutionBizId) {//方案编号 if (pobj.actionBody.resultInfo.data.SolutionBizId) {//方案编号
obj.solution_bizid = pobj.actionBody.resultInfo.data.SolutionBizId; obj.solution_bizid = pobj.actionBody.resultInfo.data.SolutionBizId;
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class FitaxpushqueueDao extends Dao {
constructor() {
super(Dao.getModelName(FitaxpushqueueDao));
}
/**
*查询
*@param {*} qobj
*/
async findInfo(qobj) {
let obj = {
"delivery_code": qobj.delivery_code// 交付单id
}
return await this.findOne(obj);
}
/**
* 插入信息
* @param {*} qobj
* @param {*} t
*/
async insertInfo(qobj, t) {
try {
let obj = this.buildObj(qobj);
console.log("obj------------------------------" + obj);
return await this.create(obj, t);
}
catch (error) {
console.log("error-------------------------" + error);
return error;
}
}
/**
*更新方案信息(主要是添加方案编号)
*@param {*} qobj
* @param {*} t
*/
async updateInfo(qobj, t) {
var obj = {};
if (qobj.req_data) {
obj.req_data = qobj.req_data;
}
if (qobj.res_data) {
obj.res_data = qobj.res_data;
}
if (qobj.push_status) {
obj.push_status = qobj.push_status;
}
if (qobj.rys_check) {
obj.rys_check = qobj.rys_check;
}
if (qobj.data_type){
obj.data_type = qobj.data_type;
}
if (qobj.check_date) {
obj.check_date = qobj.check_date;
}
let whereObj = { "delivery_code": qobj.delivery_code,"current_period": qobj.current_period};
return await this.updateByWhere(obj, whereObj, t);
}
buildObj(qobj) {
let obj = {
"delivery_code": qobj.delivery_code
}
if (qobj.current_period) {
obj.current_period = qobj.current_period;
}
if (qobj.data_type){
obj.data_type = qobj.data_type;
}
if (qobj.req_data) {
obj.req_data = qobj.req_data;
}
if (qobj.res_data) {
obj.res_data = qobj.res_data;
}
if (qobj.push_status) {
obj.push_status = qobj.push_status;
}
if (qobj.rys_check) {
obj.rys_check = qobj.rys_check;
}
if (qobj.check_date) {
obj.check_date = qobj.check_date;
}
return obj;
}
}
module.exports = FitaxpushqueueDao;
...@@ -2,7 +2,7 @@ const system = require("../../../system"); ...@@ -2,7 +2,7 @@ const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
/** /**
* 财税-方案 * 财税-推送信息
*/ */
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("fitaxpushqueue", { return db.define("fitaxpushqueue", {
...@@ -14,6 +14,10 @@ module.exports = (db, DataTypes) => { ...@@ -14,6 +14,10 @@ module.exports = (db, DataTypes) => {
allowNull: true, allowNull: true,
type: DataTypes.STRING type: DataTypes.STRING
}, },
data_type: { // 数据类型
allowNull: true,
type: DataTypes.STRING
},
req_data: { // 推送请求数据 req_data: { // 推送请求数据
allowNull: true, allowNull: true,
type: DataTypes.JSON type: DataTypes.JSON
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const { json } = require("sequelize");
const appconfig = system.getSysConfig();
class FitaxpushqueueService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(FitaxpushqueueService));
}
async insertInfo(qobj){//插入方案信息
var self = this;
return await self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t);
});
}
async updateInfo(qobj) {//更新方案信息
var self = this;
return await self.db.transaction(async function (t) {
return await self.dao.updateInfo(qobj, t);
})
}
}
module.exports = FitaxpushqueueService;
// var task = new FitaxschemeService();
// test()
// async function test() {
// var obj = {
// "demand_code": "20200728103902194844_book",
// }
// let res = await task.findInfo(obj);
// if (res) {
// console.log("返回结果:" + JSON.stringify(res));
// }
// }
\ No newline at end of file
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