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