Commit 15a7657a by 王勇飞

Merge branch 'tx-fi-tax' of gitlab.gongsibao.com:jiangyong/zhichan into tx-fi-tax

parents 956b0f44 95b21064
......@@ -121,30 +121,64 @@ class BizOptCtl extends CtlBase {
async closeBizopt(mobj, qobj, req) {
let pobj = mobj.d;
pobj.business_status = "isClosed";
if (!qobj.demand_code || !qobj.close_reason) {
return system.getResultError("缺少必要参数.");
}
//根据需求编号去更新该条需求的状态为已关闭
try {
let res = await this.service.updateStatusByDemandCode(pobj);
//添加到记录表
pobj.operator = {
id: mobj.userid ? mobj.userid : "",
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);
//异步将该需求关闭信息同步到其他系统(走队列,融易算接口文档2.3)
//构造参数
let pushUrl = this.rysUrl + "leads/proposal/close";
let pushObj = {
pushUrl: pushUrl,
actionType: "close",
messageBody: pobj
//构造参数,添加判断(有方案信息的才走队列同步到融易算,没有的直接关闭)
let schemeRes = await this.schemeSve.findInfo(pobj);
if (schemeRes && schemeRes.solution_bizid) {
let pushObj = this.buildObj(pobj, schemeRes);
system.queueOper(pushObj);
} else {
console.log(pobj.demand_code + "该需求没有方案信息,不需要同步");
}
system.queueOper(pushObj);
return system.getResult("关闭需求成功!");
} catch (error) {
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
......
var system = require("../../../system");
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const { json, JSON } = require("sequelize");
const appconfig = system.getSysConfig();
class FitaxschemeCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(FitaxschemeCtl));
this.kongUrl = settings.kongurl();
this.rysUrl = settings.rysUrl();
}
/**
......@@ -15,20 +15,13 @@ class FitaxschemeCtl extends CtlBase {
async insertInfo(mobj, qobj, req) {
let pobj = mobj.d;
try {
if (!pobj.demand_code) {
return system.getResultError("fitaxschemeCtl/insertInfo 缺少需求编号!");
if (!pobj.demand_code || !pobj.company_type || !pobj.taxpayer_type || !pobj.service_code || !pobj.number) {
return system.getResultError("fitaxschemeCtl/insertInfo 缺少必要参数!");
}
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
}
let pushObj = this.buildObj(pobj);
system.queueOper(pushObj);
return system.getResult("新建方案成功!");
} catch (error) {
......@@ -43,8 +36,15 @@ class FitaxschemeCtl extends CtlBase {
* @param {*} req
*/
async updateInfo(pobj, qobj, req) {
let obj = {};
if (pobj.actionBody.messageBody.IntentionBizId) {//需求编号
obj.demand_code = pobj.actionBody.messageBody.IntentionBizId;
}
if (pobj.actionBody.resultInfo.data.SolutionBizId) {//方案编号
obj.solution_bizid = pobj.actionBody.resultInfo.data.SolutionBizId;
}
try {
let res = await this.service.updateInfo(pobj);
let res = await this.service.updateInfo(obj);
return system.getResult("添加方案编号成功!");
} catch (error) {
console.log("fitaxschemeCtl/updateInfo error: " + error);
......@@ -71,24 +71,57 @@ class FitaxschemeCtl extends CtlBase {
return system.getResultError(error);
}
}
buildObj(pobj) {
let pushUrl = this.rysUrl + "leads/proposal/create";
let notifyUrl = "http://book.com/web/bizchance/fitaxschemeCtl/updateInfo";
let companyType, sreaCode, quantity, taxQualify;
if (pobj.company_type) { //公司类型
if (pobj.company_type == "商业型") {
companyType = 1;
} else if (pobj.company_type == "服务型") {
companyType = 2;
} else if (pobj.company_type == "特殊行业") {
companyType = 3;
} else {
companyType = 4;
}
}
if (pobj.service_code) { //区域编码
sreaCode = parseInt(pobj.service_code);
}
if (pobj.number) { //数量
quantity = parseInt(pobj.number);
}
if (pobj.taxpayer_type) { //纳税人类型
if (pobj.taxpayer_type == "一般纳税人") {
taxQualify = 1;
} else {
taxQualify = 2;
}
}
let pushObj = {
pushUrl: pushUrl,
actionType: "create",
notifyUrl: notifyUrl,
messageBody: {
IntentionBizId: pobj.demand_code,
BizType: "bookkeeping",
Solution: {
CompanyType: companyType,
SreaCode: sreaCode,
Quantity: quantity,
TaxQualify: taxQualify
}
},
headData: {
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTg0MzQ2ODcsImlzcyI6InJFRVN6TU5ZUlM2RnBWNnZlY09vdExPNWdPcUNXSmFQIiwiaWF0IjoxNTk4NDMxMDg3fQ.isQ40HqHHfJ-rTsUQOhRIdu4XCitZU-AfzeqSH4kPbQ',
'XAPPKEY': 'f6b59b74-f943-4735-bb86-e05d6b7fd78e',
'Source': 'GSB'
}
}
return pushObj;
}
}
module.exports = FitaxschemeCtl;
// var task = new FitaxschemeCtl();
// var obj = {
// d: {
// "demand_code": "20200728103902194844_book",
// "solution_bizid": "22222",
// "service_type": "代理记账",
// "service_name": "海南省三亚市",
// "company_type": "特殊行业",
// "buy_duration": 2,
// "remarks": "SaaS",
// "taxpayer_type": "小规模纳税人",
// "total_cost": "2222"
// }
// }
// task.insertInfo(obj, {}, {}).then(d => {
// console.log(JSON.stringify(d));
// })
......@@ -43,7 +43,7 @@ class FitaxschemeDao extends Dao {
if (qobj.solution_bizid) {// 方案编号
obj.solution_bizid = qobj.solution_bizid;
}
let whereObj = { "demand_code": obj.demand_code };
let whereObj = { "demand_code": qobj.demand_code };
return await this.updateByWhere(obj, whereObj, t);
}
......@@ -66,6 +66,9 @@ class FitaxschemeDao extends Dao {
if (qobj.service_name) {// 服务地区
obj.service_name = qobj.service_name;
}
if (qobj.service_code) {// 服务地区编码
obj.service_code = qobj.service_code;
}
if (qobj.buy_duration) {// 购买时长
obj.buy_duration = qobj.buy_duration;
}
......
......@@ -30,6 +30,10 @@ module.exports = (db, DataTypes) => {
allowNull: true,
type: DataTypes.STRING
},
service_code: { // 服务地区编码
allowNull: true,
type: DataTypes.STRING
},
buy_duration: { // 购买时长
allowNull: true,
type: DataTypes.STRING
......
......@@ -8,9 +8,9 @@ class DeliverybillService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(DeliverybillService));
this.logService = system.getObject("service.bizchance.statuslogSve");
this.fitaxschemeDao = system.getObject("service.bizchance.fitaxschemeDao");
this.bizoptDao = system.getObject("service.bizchance.bizoptDao");
this.operationrecordDao = system.getObject("service.bizchance.operationrecordDao");
this.fitaxschemeDao = system.getObject("db.bizchance.fitaxschemeDao");
this.bizoptDao = system.getObject("db.bizchance.bizoptDao");
this.operationrecordDao = system.getObject("db.bizchance.operationrecordDao");
}
async updateOrderStatus(pobj) {
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const { json } = require("sequelize");
const appconfig = system.getSysConfig();
class FitaxschemeService extends ServiceBase {
constructor() {
......@@ -30,4 +31,16 @@ class FitaxschemeService extends ServiceBase {
})
}
}
module.exports = FitaxschemeService;
\ No newline at end of file
module.exports = FitaxschemeService;
// 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
......@@ -395,7 +395,7 @@ class System {
param.actionBody.notifyUrl = obj.notifyUrl;
}
if (obj.headData) {
param.actionBody.headData;
param.actionBody.headData = obj.headData;
}
if (obj.requestId) {
param.requestId = obj.requestId;
......
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