Commit cd8cda67 by 王勇飞

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

parents e414aaa3 e48d9a08
...@@ -5,6 +5,7 @@ var settings = require("../../../../config/settings"); ...@@ -5,6 +5,7 @@ var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base"); const CtlBase = require("../../ctl.base");
const moment = require('moment'); const moment = require('moment');
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
const sha235 = require("sha256");
class BizOptCtl extends CtlBase { class BizOptCtl extends CtlBase {
constructor() { constructor() {
super("bizchance", CtlBase.getServiceName(BizOptCtl)); super("bizchance", CtlBase.getServiceName(BizOptCtl));
...@@ -12,7 +13,7 @@ class BizOptCtl extends CtlBase { ...@@ -12,7 +13,7 @@ class BizOptCtl extends CtlBase {
this.schemeSve = system.getObject("service.bizchance.fitaxschemeSve"); //财税-方案信息 this.schemeSve = system.getObject("service.bizchance.fitaxschemeSve"); //财税-方案信息
this.fitaxcompanySve = system.getObject("service.bizchance.fitaxcompanySve"); //财税-企业信息 this.fitaxcompanySve = system.getObject("service.bizchance.fitaxcompanySve"); //财税-企业信息
this.operationrecordSve = system.getObject("service.bizchance.operationrecordSve"); //财税-需求分配记录 this.operationrecordSve = system.getObject("service.bizchance.operationrecordSve"); //财税-需求分配记录
this.deliverbillSve = system.getObject("service.bizchance.deliverybillSve");//财税-需求分配 this.deliverbillSve = system.getObject("service.bizchance.deliverybillSve"); //财税-需求分配
this.logService = system.getObject("service.bizchance.statuslogSve"); this.logService = system.getObject("service.bizchance.statuslogSve");
this.shisService = system.getObject("service.bizchance.salesmanhisSve"); this.shisService = system.getObject("service.bizchance.salesmanhisSve");
this.receiveUrl = settings.receiveUrl(); this.receiveUrl = settings.receiveUrl();
...@@ -340,17 +341,31 @@ class BizOptCtl extends CtlBase { ...@@ -340,17 +341,31 @@ class BizOptCtl extends CtlBase {
/*插入数据信息 */ /*插入数据信息 */
async insertInfo(nobj, qobj, req) { async insertInfo(nobj, qobj, req) {
var pobj = nobj.d; var pobj = nobj.actionBody.messageBody;
if (pobj.businessMode && pobj.businessMode != 'undefined' && pobj.businessType && pobj.businessType != 'undefined') { if (pobj.intentionBizId && pobj.intentionBizId != 'undefined') {
try { try {
//pobj.currentStatus = "beforeSubmission";//加上当前状态为待提交方案 var  cachestr  =  sha235(JSON.stringify(nobj));      
// pobj.channelSource = "tencentCloud";//目前渠道只有腾讯 var  cacheInfo  =  await  this.cacheManager["TxCache"].getCache(cachestr); 
// pobj.sourceNumber = "1111111"; if  (cacheInfo  &&  cacheInfo  !=  'undefined')  {        
// pobj.businessType = appconfig.pdict.dyDict[pobj.businessType]; return  {          
var buInfo = await this.service.insertInfo(pobj); "status":  1,
  //1代表成功,否则失败
"msg": "已处理成功!",
"data": cachestr ,
"requestId": nobj.requestId
}      
} else {
pobj.businessStatus = 'received';
pobj.sourceNumber = 'tx';
pobj.facilitatorId = '10';
pobj.facilitatorName = '公司宝';
pobj.sourceName = 'tencentCloud';
//插入操作
var buInfo = await this.service.insertInfo(pobj);
if (buInfo) {
await this.cacheManager["TxCache"].cache(cachestr, JSON.stringify({ cachestr: cachestr }), 180);
//日志
var logInfo = { var logInfo = {
"flowType": "BIZ", "flowType": "BIZ",
"flowId": buInfo.id, "flowId": buInfo.id,
...@@ -362,15 +377,20 @@ class BizOptCtl extends CtlBase { ...@@ -362,15 +377,20 @@ class BizOptCtl extends CtlBase {
return { return {
"status": 1, //1代表成功,否则失败 "status": 1, //1代表成功,否则失败
"message": "操作成功", "message": "操作成功",
"data": "", "data": buInfo,
"requestId": "" "requestId": nobj.requestId
}; };
}
}
} catch (error) { } catch (error) {
//异常处理
console.log("TTTTTTTTTTTTTTTTTTTTTTT"); console.log("TTTTTTTTTTTTTTTTTTTTTTT");
console.log(error); console.log(error);
return system.getResultError(error); return system.getResultError(error);
} }
} else { } else {
//字段错误处理
return system.getResultError("参数错误!"); return system.getResultError("参数错误!");
} }
} }
...@@ -381,16 +401,16 @@ class BizOptCtl extends CtlBase { ...@@ -381,16 +401,16 @@ class BizOptCtl extends CtlBase {
return localTime; return localTime;
} }
//根据bizId查询商机表中的所有信息 //根据bizId查询商机表中的所有信息
async getInfo(pobj,qobj,req){ async getInfo(pobj, qobj, req) {
try{ try {
if(!pobj.bizId){ if (!pobj.bizId) {
throw new Error("bizId 不能为空"); throw new Error("bizId 不能为空");
} }
const rs=await this.service.getInfo(pobj); const rs = await this.service.getInfo(pobj);
//console.log("got message"); //console.log("got message");
return system.getResult(rs); return system.getResult(rs);
}catch(err){ } catch (err) {
return system.getResult(null,err.message) return system.getResult(null, err.message)
} }
} }
} }
......
...@@ -5,7 +5,7 @@ class BizoptDao extends Dao { ...@@ -5,7 +5,7 @@ class BizoptDao extends Dao {
super(Dao.getModelName(BizoptDao)); super(Dao.getModelName(BizoptDao));
} }
extraWhere(qobj, qw, qc) {//根据业务员id获取商机信息的组装条件 extraWhere(qobj, qw, qc) { //根据业务员id获取商机信息的组装条件
qc.raw = true; qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不需要添加公司查询条件添加公司查询条件, 不添加路径条件,返回所有数据 //检查查询的用户所属公司是否是平台运营公司-1,如果是则不需要添加公司查询条件添加公司查询条件, 不添加路径条件,返回所有数据
if (qobj.company_id == 1) { if (qobj.company_id == 1) {
...@@ -19,15 +19,13 @@ class BizoptDao extends Dao { ...@@ -19,15 +19,13 @@ class BizoptDao extends Dao {
*/ */
if (!qobj.opath) { // 管理员 不做处理 if (!qobj.opath) { // 管理员 不做处理
} else if (qobj.isPrincipal) { // 销售主管 查询为空和自己组织结构下的 } else if (qobj.isPrincipal) { // 销售主管 查询为空和自己组织结构下的
qw["$or"] = [ qw["$or"] = [{
{
salesman_opcode: { salesman_opcode: {
$eq: null $eq: null
} }
}, { }, {
salesman_opcode: { $like: `%${qobj.opath}%` } salesman_opcode: { $like: `%${qobj.opath}%` }
} }]
]
} else { // 销售 查询自己的 } else { // 销售 查询自己的
qw["salesman_opcode"] = { $like: `%${qobj.opath}%` } qw["salesman_opcode"] = { $like: `%${qobj.opath}%` }
} }
...@@ -38,12 +36,12 @@ class BizoptDao extends Dao { ...@@ -38,12 +36,12 @@ class BizoptDao extends Dao {
[this.db.Op.eq]: "bookkeeping" [this.db.Op.eq]: "bookkeeping"
} }
if (qobj.bizpath && qobj.bizpath != "") { if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("demandAllocation") > 0) {//从需求分配列表过来的 if (qobj.bizpath.indexOf("demandAllocation") > 0) { //从需求分配列表过来的
qw["business_status"] = { qw["business_status"] = {
[this.db.Op.eq]: "received" [this.db.Op.eq]: "received"
}; };
} }
if (qobj.bizpath.indexOf("demandfollow") > 0 || qobj.bizpath.indexOf("distributionManagement") > 0) {//从需求跟进列表或分配记录列表过来的 if (qobj.bizpath.indexOf("demandfollow") > 0 || qobj.bizpath.indexOf("distributionManagement") > 0) { //从需求跟进列表或分配记录列表过来的
qw["business_status"] = { qw["business_status"] = {
[this.db.Op.ne]: "received" [this.db.Op.ne]: "received"
}; };
...@@ -101,13 +99,13 @@ class BizoptDao extends Dao { ...@@ -101,13 +99,13 @@ class BizoptDao extends Dao {
/*插入商机信息*/ /*插入商机信息*/
async insertInfo(qobj, t) { async insertInfo(qobj, t) {
var obj = { var obj = {
"demand_code": qobj.businessMode, "demand_code": qobj.intentionBizId,
"business_type": qobj.businessType, "business_type": qobj.type,
"business_status": qobj.bussinessStatus, "business_status": qobj.bussinessStatus,
"business_info": {}, "business_info": {},
"source_number": qobj.sourceNumber, "source_number": qobj.sourceNumber,
"service_address": qobj.serviceAddress, "service_address": qobj.area,
"facilitator_id": qobj.favilitatorID, "facilitator_id": qobj.favilitatorId,
"facilitator_name": qobj.favilitatorName, "facilitator_name": qobj.favilitatorName,
"source_name": qobj.sourceName, "source_name": qobj.sourceName,
}; };
...@@ -115,19 +113,12 @@ class BizoptDao extends Dao { ...@@ -115,19 +113,12 @@ class BizoptDao extends Dao {
if (qobj.topOrgCode && qobj.topOrgCode != 'undefined') { if (qobj.topOrgCode && qobj.topOrgCode != 'undefined') {
obj.business_info.topOrgCode = qobj.topOrgCode obj.business_info.topOrgCode = qobj.topOrgCode
} }
if (qobj.intentionBizId && qobj.intentionBizId != 'undefined') { if (qobj.requestId && qobj.requestId != 'undefined') {
obj.business_info.intentionBizId = qobj.intentionBizId; obj.business_info.requestId = qobj.requestId;
}
if (qobj.contactsPhone && qobj.contactsPhone != 'undefined') {
obj.business_info.contactsPhone = qobj.contactsPhone; //已经加密
} }
if (qobj.contactsName && qobj.contactsName != 'undefined') { if (qobj.mobile && qobj.mobile != 'undefined') {
obj.business_info.contactsName = qobj.contactsName; obj.business_info.contactsPhone = qobj.mobile; //已经加密
} }
if (qobj.serviceName && qobj.serviceName != 'undefined') {
obj.business_info.serviceName = qobj.serviceName;
}
//bussiness_info END //bussiness_info END
//other //other
if (qobj.closeReason && qobj.closeReason != 'undefined') { if (qobj.closeReason && qobj.closeReason != 'undefined') {
...@@ -152,9 +143,9 @@ class BizoptDao extends Dao { ...@@ -152,9 +143,9 @@ class BizoptDao extends Dao {
/** /**
* 根据服务实例id查找服务所有信息 * 根据服务实例id查找服务所有信息
*/ */
async findByBizId(pobj){ async findByBizId(pobj) {
var oid=pobj.bizId; var oid = pobj.bizId;
return await this.findOne({biz_id:oid}); return await this.findOne({ biz_id: oid });
} }
} }
......
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