Commit d41060e7 by 王勇飞

gyq

parents 10f38c18 8d3f4baa
......@@ -18,6 +18,7 @@ class BizOptCtl extends CtlBase {
this.shisService = system.getObject("service.bizchance.salesmanhisSve");
this.receiveUrl = settings.receiveUrl();
this.queueUrl = settings.queueUrl();
this.rysUrl = settings.rysUrl();
//this.wdyUrl = settings.wdyUrl();
this.dateUtil = system.getObject("util.dateClient");
}
......@@ -123,14 +124,21 @@ class BizOptCtl extends CtlBase {
//根据需求编号去更新该条需求的状态为已关闭
try {
let res = await this.service.updateStatusByDemandCode(pobj);
//TODO 同步该需求关闭信息到其他系统(走队列,直接扔到队列里面)
//添加到记录表
pobj.operator = {
id: mobj.userid ? mobj.userid : "",
name: mobj.username ? mobj.username : ""
}
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("关闭需求成功!");
} catch (error) {
return system.getResultError("bizoptCtl/closeBizopt 关闭需求出错!");
......
......@@ -91,7 +91,7 @@ class DeliverybillCtl extends CtlBase {
if (!pobj.deliverId) {
throw new Error("deliverId 不能为空");
}
if (!pobj.contactsName || !pobj.time || !pobj.accountingType || !pobj.taxpayerType || !pobj.supplier) {
if (!pobj.contactsName || !pobj.time || !pobj.accountingType || !pobj.taxpayerType || (!pobj.supplier && pobj.supplier != 0)) {
throw new Error("参数不能为空");
}
const rs = await this.service.setupBill(pobj);
......
......@@ -5,6 +5,8 @@ const appconfig = system.getSysConfig();
class FitaxschemeCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(FitaxschemeCtl));
this.kongUrl = settings.kongurl();
this.rysUrl = settings.rysUrl();
}
/**
* 新建方案信息
......@@ -17,6 +19,17 @@ class FitaxschemeCtl extends CtlBase {
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
}
system.queueOper(pushObj);
return system.getResult("新建方案成功!");
} catch (error) {
console.log("fitaxschemeCtl/insertInfo---------------------------------------------------------------- " + error);
......@@ -24,38 +37,58 @@ class FitaxschemeCtl extends CtlBase {
}
}
async findInfoByBizid(pobj,qobj,req){//方案
try{
if (pobj.bizId){
/**
* @param {*} pobj
* @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);
return system.getResult(res);
}
else{
else {
return system.getResultError("缺少方案编号");
}
}
catch(error){
catch (error) {
return system.getResultError(error);
}
}
}
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));
})
// 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));
// })
......@@ -18,7 +18,6 @@ class FitaxschemeDao extends Dao {
/**
* 插入方案信息
* TODO 同步方案信息,获取方案编号(走队列,再写一个接收队列方案编号的方法,将方案编号更新到数据库)
* @param {*} qobj
* @param {*} t
*/
......@@ -35,12 +34,15 @@ class FitaxschemeDao extends Dao {
}
/**
*更新方案编号
*更新方案信息(主要是添加方案编号)
*@param {*} qobj
* @param {*} 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 };
return await this.updateByWhere(obj, whereObj, t);
}
......
......@@ -38,6 +38,10 @@ module.exports = (db, DataTypes) => {
allowNull: true,
type: DataTypes.STRING
},
v_creditCode: { //社会统一信用代码
allowNull: true,
type: DataTypes.STRING
},
demand_code: {// 商机编号
allowNull: true,
type: DataTypes.STRING
......
......@@ -3,6 +3,7 @@ const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const System = require("../../../system");
const appconfig = system.getSysConfig();
const toFtClient = require("../../../utils/toFtClient");
class DeliverybillService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(DeliverybillService));
......@@ -65,6 +66,7 @@ class DeliverybillService extends ServiceBase {
if (deliverData.delivery_info.setupStatus && deliverData.delivery_info.setupStatus === system.SERVERSESTATUS.SETUP) {
throw new Error("已建账");
}
await toFtClient.addCusAccApplyInfo(deliverData, pobj);
await this.dao.updateByWhere({
delivery_info: {
...delivery_info,
......
......@@ -23,7 +23,7 @@ const postRequest = async (url, data, headers = {}) => {
timeout: 5000,
});
result = result.data;
console.log("${url} : 返回数据 ------- ");
console.log(`${url} : 返回数据 ------- `);
console.log(JSON.stringify(result));
if (result.code == 1) {
return result.data
......@@ -54,7 +54,7 @@ const postToFt = (url, data, headers = {}) => {
* @param {*} headers
*/
const postToFtBySign = async (url, data, headers = {}) => {
let tenantInfo = await getChannelCompany();
let tenantInfo = await getChannelCompany(data.companyId);
data.companyId = tenantInfo.id;
let sign = system.signValid(data, tenantInfo.signSecret);
return postRequest(`${ftConfig.url}${url}`, { ...data, sign }, headers = {})
......@@ -74,7 +74,12 @@ const getChannelCompany = async (id) => {
});
companyData = companyData.datas;
if (id) {
// TODO: 获取单个信息
companyData = _.find(companyData, (item) => {
return item.id === id
})
if (!companyData) {
throw new Error(("查不到租户信息"));
}
}
return companyData;
}
......@@ -104,9 +109,9 @@ const addCusAccApplyInfo = async (deliverData, pobj) => {
valueAddedTax: valueAddedTax[pobj.taxpayerType],
serviceTime: moment(deliverData.delivery_info.serviceEndTime).diff(moment(deliverData.delivery_info.serviceStartTime), 'months').toString(),
initPeriod: parseInt(moment(deliverData.delivery_info.serviceStartTime).format('YYYYMMDD')),
companyId: pobj.supplier
}
const data = await postToFtBySign('/cusAccApplyInfo/addCusAccApplyInfo', reqData);
console.log(data);
await postToFtBySign('/cusAccApplyInfo/addCusAccApplyInfo', reqData);
}
// console.log(moment("2021-05-31").diff(moment("2020-06-01"), 'months', true).toString())
......
......@@ -59,6 +59,13 @@ var settings = {
return "http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard";
}
},
rysUrl: function () {
if (this.env == "localhost") {
return "http://";
} else {
return "http://";
}
},
ftConfig: function () {
if (this.env == "localhost") {
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