Commit a0f35f12 by 王勇飞

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

parents ada9e984 f0480d90
...@@ -59,10 +59,10 @@ class CtlBase { ...@@ -59,10 +59,10 @@ class CtlBase {
//添加组织结构路径,如果是上级,取上级 //添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != "") { if (req.xctx.ptags && req.xctx.ptags != "") {
pobj.opath = req.xctx.ptags pobj.opath = req.xctx.ptags
pob.isPrincipal = true pobj.isPrincipal = true
} else { } else {
pobj.opath = req.xctx.opath pobj.opath = req.xctx.opath
pob.isPrincipal = false pobj.isPrincipal = false
} }
if (!req.xctx.appkey) { if (!req.xctx.appkey) {
return [-200, "请求头缺少应用x-app-key"] return [-200, "请求头缺少应用x-app-key"]
......
...@@ -75,30 +75,30 @@ class BizOptCtl extends CtlBase { ...@@ -75,30 +75,30 @@ class BizOptCtl extends CtlBase {
* @param {*} mobj * @param {*} mobj
* @param {*} qobj * @param {*} qobj
* @param {*} req * @param {*} req
*/ * {
async distribution(mobj, qobj, req) {
let pobj = mobj.d;
let params = {
demand_code_list: ["1", "2", "3"],//至少一个需求编号 demand_code_list: ["1", "2", "3"],//至少一个需求编号
salesman_opcode: "",//唯一标识 salesman_opcode: "",//唯一标识
salesman_id: "jdlfaj",//销售员id salesman_id: "jdlfaj",//销售员id
salesman_name: "",//销售员姓名 salesman_name: "",//销售员姓名
salesman_phone: "",//销售员手机号 salesman_phone: "",//销售员手机号
} }
*/
async distribution(mobj, qobj, req) {
let pobj = mobj.d;
} }
/** /**
* 关闭需求 * 关闭需求
* @param {*} mobj * @param {*} mobj
*/ * {
async closeBizopt(mobj, qobj, req) {
let pobj = mobj.d;
pobj.business_status = "isClosed";
let params = {
demand_code: "",//需求编号 demand_code: "",//需求编号
close_reason: "",//关闭原因 close_reason: "",//关闭原因
remarks: ""//备注 remarks: ""//备注
} }
*/
async closeBizopt(mobj, qobj, req) {
let pobj = mobj.d;
pobj.business_status = "isClosed";
//根据需求编号去更新该条需求的状态为已关闭 //根据需求编号去更新该条需求的状态为已关闭
try { try {
let res = await this.service.updateStatusByDemandCode(pobj); let res = await this.service.updateStatusByDemandCode(pobj);
......
...@@ -112,5 +112,32 @@ class DeliverybillCtl extends CtlBase { ...@@ -112,5 +112,32 @@ class DeliverybillCtl extends CtlBase {
return system.getResult(null, err.message) return system.getResult(null, err.message)
} }
} }
/**
* 分配人
*/
async distributionPerson(pobj, qobj, req) {
try {
if (!Array.isArray(pobj.numbers) && pobj.numbers.length > 0) {
throw new Error("numbers 为数组 且 不能为空");
}
if (!pobj.nickName) {
throw new Error("nickName 不能为空");
}
if (!pobj.userId) {
throw new Error("userId 不能为空");
}
if (!pobj.opCode) {
throw new Error("opCode 不能为空");
}
if (![system.FLOWCODE.BIZ, system.FLOWCODE.DELIVERY].includes(pobj.type)) {
throw new Error("type 不合规");
}
const rs = await this.service.distributionPerson(pobj);
return system.getResult(rs);
} catch (err) {
return system.getResult(null, err.message)
}
}
} }
module.exports = DeliverybillCtl; module.exports = DeliverybillCtl;
\ No newline at end of file
...@@ -10,46 +10,46 @@ class OperationrecordCtl extends CtlBase { ...@@ -10,46 +10,46 @@ class OperationrecordCtl extends CtlBase {
/** /**
* 查询记录信息 * 查询记录信息
* @param {*} mobj * @param {*} mobj
*/ * {
async findOne(mobj, qobj, req) {
let pobj = mobj.d;
let params = {
demand_code: "",//需求编号 demand_code: "",//需求编号
close_reason: "",//关闭原因 operation_type: ""//操作类型
remarks: ""//备注
} }
*/
async findAllInfo(mobj, qobj, req) {
let pobj = mobj.d;
try { try {
if (!pobj.demand_code) { if (!pobj.demand_code) {
return system.getResultError("fitaxschemeCtl/findOne 缺少需求编号!"); return system.getResultError("operationrecordCtl/findAllInfo 缺少需求编号!");
} }
let res = await this.service.findInfo(pobj); let res = await this.service.findAllInfo(pobj);
return system.getResult(res); return system.getResult(res);
} catch (error) { } catch (error) {
console.log("fitaxschemeCtl/findOne " + error); console.log("operationrecordCtl/findAllInfo " + error);
return system.getResultError("fitaxschemeCtl/findOne 查询企业失败!"); return system.getResultError("operationrecordCtl/findAllInfo 查询企业失败!");
} }
} }
/** /**
* 新建记录信息 * 新建记录信息
* @param {*} mobj * @param {*} mobj
* {
demand_code: "",//需求编号
operator: { id: "", name: "" },//操作人
operation_type: "",//操作类型
operation_details: {}//操作详细记录
}
*/ */
async insertInfo(mobj, qobj, req) { async insertInfo(mobj, qobj, req) {
let pobj = mobj.d; let pobj = mobj.d;
let params = {
demand_code: "",//需求编号
close_reason: "",//关闭原因
remarks: ""//备注
}
try { try {
if (!pobj.demand_code) { if (!pobj.demand_code) {
return system.getResultError("fitaxschemeCtl/insertInfo 缺少需求编号!"); return system.getResultError("fitaxschemeCtl/insertInfo 缺少需求编号!");
} }
let insertRes = await this.service.insertInfo(pobj); let insertRes = await this.service.insertInfo(pobj);
return system.getResult("添加企业成功!"); return system.getResult("添加记录信息成功!");
} catch (error) { } catch (error) {
console.log("operationrecordCtl/insertInfo " + error); console.log("operationrecordCtl/insertInfo " + error);
return system.getResultError("operationrecordCtl/insertInfo 添加&修改企业信息失败!"); return system.getResultError("operationrecordCtl/insertInfo 添加记录信息失败!");
} }
} }
} }
......
...@@ -30,7 +30,7 @@ class Dao { ...@@ -30,7 +30,7 @@ class Dao {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Dao")).toLowerCase() return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Dao")).toLowerCase()
} }
async refQuery(qobj) { async refQuery(qobj) {
var w =qobj.refwhere? qobj.refwhere:{}; var w = qobj.refwhere ? qobj.refwhere : {};
if (qobj.levelinfo) { if (qobj.levelinfo) {
w[qobj.levelinfo.levelfield] = qobj.levelinfo.level; w[qobj.levelinfo.levelfield] = qobj.levelinfo.level;
} }
...@@ -38,8 +38,8 @@ class Dao { ...@@ -38,8 +38,8 @@ class Dao {
w[qobj.parentinfo.parentfield] = qobj.parentinfo.parentcode; w[qobj.parentinfo.parentfield] = qobj.parentinfo.parentcode;
} }
//如果需要控制数据权限 //如果需要控制数据权限
if(qobj.datapriv){ if (qobj.datapriv) {
w["id"]={ [this.db.Op.in]: qobj.datapriv}; w["id"] = { [this.db.Op.in]: qobj.datapriv };
} }
if (qobj.likestr) { if (qobj.likestr) {
w[qobj.fields[0]] = { [this.db.Op.like]: "%" + qobj.likestr + "%" }; w[qobj.fields[0]] = { [this.db.Op.like]: "%" + qobj.likestr + "%" };
...@@ -64,13 +64,13 @@ class Dao { ...@@ -64,13 +64,13 @@ class Dao {
async delete(qobj, t) { async delete(qobj, t) {
var en = null var en = null
if (t != null && t != 'undefined') { if (t != null && t != 'undefined') {
en=await this.model.findOne({ where: {id:qobj.id},transaction:t}); en = await this.model.findOne({ where: { id: qobj.id }, transaction: t });
if (en != null) { if (en != null) {
await en.destroy({ transaction: t }); await en.destroy({ transaction: t });
return en return en
} }
} else { } else {
en=await this.model.findOne({ where: {id:qobj.id}}); en = await this.model.findOne({ where: { id: qobj.id } });
if (en != null) { if (en != null) {
return en.destroy(); return en.destroy();
} }
...@@ -202,16 +202,16 @@ class Dao { ...@@ -202,16 +202,16 @@ class Dao {
} }
async updateByWhere(setObj, whereObj, t) { async updateByWhere(setObj, whereObj, t) {
let inWhereObj={} let inWhereObj = {}
if (t && t != 'undefined') { if (t && t != 'undefined') {
if (whereObj && whereObj != 'undefined') { if (whereObj && whereObj != 'undefined') {
inWhereObj["where"]=whereObj; inWhereObj["where"] = whereObj;
inWhereObj["transaction"] = t; inWhereObj["transaction"] = t;
} else { } else {
inWhereObj["transaction"] = t; inWhereObj["transaction"] = t;
} }
}else{ } else {
inWhereObj["where"]=whereObj; inWhereObj["where"] = whereObj;
} }
return this.model.update(setObj, inWhereObj); return this.model.update(setObj, inWhereObj);
} }
...@@ -224,16 +224,16 @@ class Dao { ...@@ -224,16 +224,16 @@ class Dao {
* p.group.aliasField=' as xxx' * p.group.aliasField=' as xxx'
* @param {*} p * @param {*} p
*/ */
async statGroupBy(p,paras,t){ async statGroupBy(p, paras, t) {
let groupFields=p.group.byFields.join(",") let groupFields = p.group.byFields.join(",")
let aggField=p.group.aggField?p.group.aggField:'' let aggField = p.group.aggField ? p.group.aggField : ''
let tblName=p.group.tblName?p.group.tblName:'' let tblName = p.group.tblName ? p.group.tblName : ''
let where=p.group.where?p.group.where:'' let where = p.group.where ? p.group.where : ''
let having=p.group.having?p.group.having:'' let having = p.group.having ? p.group.having : ''
let aliasField=p.group.aliasField?p.group.aliasField:'' let aliasField = p.group.aliasField ? p.group.aliasField : ''
let actionType=p.group.actionType?p.group.actionType:'count' let actionType = p.group.actionType ? p.group.actionType : 'count'
let sql=`select ${groupFields},${actionType}(${aggField}) ${aliasField} from ${tblName} ${where} group by ${groupFields} ${having} WITH ROLLUP` let sql = `select ${groupFields},${actionType}(${aggField}) ${aliasField} from ${tblName} ${where} group by ${groupFields} ${having} WITH ROLLUP`
return this.customQuery(sql,paras,t) return this.customQuery(sql, paras, t)
} }
async customQuery(sql, paras, t) { async customQuery(sql, paras, t) {
...@@ -275,7 +275,7 @@ class Dao { ...@@ -275,7 +275,7 @@ class Dao {
if (includeObj != null && includeObj.length > 0) { if (includeObj != null && includeObj.length > 0) {
tmpWhere.include = includeObj; tmpWhere.include = includeObj;
tmpWhere.distinct = true; tmpWhere.distinct = true;
}else{ } else {
tmpWhere.raw = true; tmpWhere.raw = true;
} }
return await this.model.findAndCountAll(tmpWhere); return await this.model.findAndCountAll(tmpWhere);
...@@ -286,5 +286,8 @@ class Dao { ...@@ -286,5 +286,8 @@ class Dao {
async findById(oid) { async findById(oid) {
return this.model.findById(oid); return this.model.findById(oid);
} }
async findAll(obj, include = []) {
return this.model.findAll({ "where": obj, include, row: true });
}
} }
module.exports = Dao; module.exports = Dao;
...@@ -10,6 +10,7 @@ class OperationrecordDao extends Dao { ...@@ -10,6 +10,7 @@ class OperationrecordDao extends Dao {
*@param {*} qobj *@param {*} qobj
*/ */
async findAllInfo(qobj) { async findAllInfo(qobj) {
qobj.order_type = "BIZ",//数据类型需求|订单
qobj.raw = true; qobj.raw = true;
return await this.model.findAll(qobj); return await this.model.findAll(qobj);
} }
...@@ -22,6 +23,7 @@ class OperationrecordDao extends Dao { ...@@ -22,6 +23,7 @@ class OperationrecordDao extends Dao {
async insertInfo(qobj, t) { async insertInfo(qobj, t) {
let obj = { let obj = {
"demand_code": qobj.demand_code,// 需求编码 "demand_code": qobj.demand_code,// 需求编码
"order_type": "BIZ",
} }
if (qobj.operator) {// 操作人 if (qobj.operator) {// 操作人
obj.operator = qobj.operator; obj.operator = qobj.operator;
......
...@@ -16,7 +16,7 @@ module.exports = { ...@@ -16,7 +16,7 @@ module.exports = {
"tencentCloud": "腾讯云" "tencentCloud": "腾讯云"
}, },
"bizoptStatus": { "bizoptStatus": {//财税需求状态
"pending": "待处理", "pending": "待处理",
"beforeFollowUp": "待跟进", "beforeFollowUp": "待跟进",
"followingUp": "跟进中", "followingUp": "跟进中",
...@@ -25,6 +25,12 @@ module.exports = { ...@@ -25,6 +25,12 @@ module.exports = {
"isClosed": "已关闭" "isClosed": "已关闭"
}, },
"operationType": {//财税需求-分配记录-操作类型
"distribution": "分配",
"followUp": "跟进",
"close": "关闭"
},
"businessType": {//商机类型 "businessType": {//商机类型
"companyCase": "公司注册", "companyCase": "公司注册",
"psCase": "云上园区注册", "psCase": "云上园区注册",
...@@ -37,10 +43,10 @@ module.exports = { ...@@ -37,10 +43,10 @@ module.exports = {
"sealSevCase": "刻章服务", "sealSevCase": "刻章服务",
"icChangeCase": "工商变更", "icChangeCase": "工商变更",
"ssOpenCase": "社保开户", "ssOpenCase": "社保开户",
"ICP":"icp", "ICP": "icp",
"EDI":"edi", "EDI": "edi",
"ICPANNUALREPORT":"icp年报", "ICPANNUALREPORT": "icp年报",
"EDIANNUALREPORT":"edi年报" "EDIANNUALREPORT": "edi年报"
}, },
"businessStatus": {//商机状态 "businessStatus": {//商机状态
...@@ -156,62 +162,62 @@ module.exports = { ...@@ -156,62 +162,62 @@ module.exports = {
}, },
"registeredAreaDict": {//注册地区 "registeredAreaDict": {//注册地区
"110100":"北京", "110100": "北京",
"310100":"上海", "310100": "上海",
"330100":"杭州", "330100": "杭州",
"370200":"青岛", "370200": "青岛",
"320500":"苏州", "320500": "苏州",
"330200":"宁波", "330200": "宁波",
"320100":"南京", "320100": "南京",
"320200":"无锡", "320200": "无锡",
"330300":"温州", "330300": "温州",
"130100":"石家庄", "130100": "石家庄",
"330700":"金华", "330700": "金华",
"320400":"常州", "320400": "常州",
"320600":"南通", "320600": "南通",
"320300":"徐州", "320300": "徐州",
"330400":"嘉兴", "330400": "嘉兴",
"331000":"台州", "331000": "台州",
"330600":"绍兴", "330600": "绍兴",
"140100":"太原", "140100": "太原",
"370600":"烟台", "370600": "烟台",
"321000":"扬州", "321000": "扬州",
"440100":"广州", "440100": "广州",
"440300":"深圳", "440300": "深圳",
"510100":"成都", "510100": "成都",
"420100":"武汉", "420100": "武汉",
"500100":"重庆", "500100": "重庆",
"410100":"郑州", "410100": "郑州",
"430100":"长沙", "430100": "长沙",
"530100":"昆明", "530100": "昆明",
"610100":"西安", "610100": "西安",
"441900":"东莞", "441900": "东莞",
"350100":"福州", "350100": "福州",
"520100":"贵阳", "520100": "贵阳",
"360100":"南昌", "360100": "南昌",
"440600":"佛山", "440600": "佛山",
"120100":"天津", "120100": "天津",
"370100":"济南", "370100": "济南",
"210100":"沈阳", "210100": "沈阳",
"210200":"大连", "210200": "大连",
"230100":"哈尔滨", "230100": "哈尔滨",
"220100":"长春", "220100": "长春",
"340100":"合肥", "340100": "合肥",
"410200":"开封", "410200": "开封",
"321300":"宿迁", "321300": "宿迁",
"370783":"寿光", "370783": "寿光",
"442000":"中山", "442000": "中山",
"420500":"宜昌", "420500": "宜昌",
"350200":"厦门", "350200": "厦门",
"350700":"南平" "350700": "南平"
}, },
"TaxpayerTypeDict": {//纳税人类型 "TaxpayerTypeDict": {//纳税人类型
"smallScaleTaxpayer": "小规模纳税人", "smallScaleTaxpayer": "小规模纳税人",
"generalTaxpayer": "一般纳税人" "generalTaxpayer": "一般纳税人"
}, },
"TaxpayerTypeDictT": {//纳税人类型取反 "TaxpayerTypeDictT": {//纳税人类型取反
"小规模纳税人":"smallScaleTaxpayer", "小规模纳税人": "smallScaleTaxpayer",
"一般纳税人":"generalTaxpayer", "一般纳税人": "generalTaxpayer",
}, },
"companyNatureDict": {//公司类型 "companyNatureDict": {//公司类型
"limitedLiabilityCompany": "有限责任公司", "limitedLiabilityCompany": "有限责任公司",
...@@ -219,9 +225,9 @@ module.exports = { ...@@ -219,9 +225,9 @@ module.exports = {
"groupLimitedCompany": "集团公司" "groupLimitedCompany": "集团公司"
}, },
"companyNatureDictT": {//公司类型取反 "companyNatureDictT": {//公司类型取反
"有限责任公司":"limitedLiabilityCompany" , "有限责任公司": "limitedLiabilityCompany",
"股份有限公司":"incorporatedCompany" , "股份有限公司": "incorporatedCompany",
"集团公司":"groupLimitedCompany" "集团公司": "groupLimitedCompany"
}, },
"engagedIndustryDict": {//从事行业 "engagedIndustryDict": {//从事行业
"culturalMedia": "文化传媒类", "culturalMedia": "文化传媒类",
...@@ -239,19 +245,19 @@ module.exports = { ...@@ -239,19 +245,19 @@ module.exports = {
"engineering": "工程类" "engineering": "工程类"
}, },
"engagedIndustryDictT": {//从事行业取反 "engagedIndustryDictT": {//从事行业取反
"文化传媒类":"culturalMedia" , "文化传媒类": "culturalMedia",
"科技类":"scienceAndTechnology", "科技类": "scienceAndTechnology",
"影业类":"filmIndustry" , "影业类": "filmIndustry",
"贸易类":"trade", "贸易类": "trade",
"咨询类":"consult" , "咨询类": "consult",
"广告类":"advertisement", "广告类": "advertisement",
"管理类":"administration" , "管理类": "administration",
"租赁类":"lease", "租赁类": "lease",
"代理类":"proxy" , "代理类": "proxy",
"培训类":"train", "培训类": "train",
"设计类":"design", "设计类": "design",
"服务类":"service", "服务类": "service",
"工程类":"engineering" "工程类": "engineering"
}, },
"SealSevCaseDict": {//是否刻章 "SealSevCaseDict": {//是否刻章
...@@ -274,25 +280,25 @@ module.exports = { ...@@ -274,25 +280,25 @@ module.exports = {
"company": "有限公司" "company": "有限公司"
}, },
"registeredTypeDictT": {//个体户类型反 "registeredTypeDictT": {//个体户类型反
"个体工商":"selfEmployed" , "个体工商": "selfEmployed",
"个人独资":"soleProprietorship", "个人独资": "soleProprietorship",
"有限公司":"company" "有限公司": "company"
}, },
"registeredParkDict": {//注册园区 "registeredParkDict": {//注册园区
"410200":"开封", "410200": "开封",
"321300":"宿迁", "321300": "宿迁",
"310100":"上海", "310100": "上海",
"370783":"寿光", "370783": "寿光",
"442000":"中山", "442000": "中山",
"420500":"宜昌", "420500": "宜昌",
"440600":"佛山", "440600": "佛山",
"340100":"合肥", "340100": "合肥",
"510100":"成都", "510100": "成都",
"500100":"重庆", "500100": "重庆",
"350200":"厦门", "350200": "厦门",
"350700":"南平", "350700": "南平",
"330100":"杭州", "330100": "杭州",
"441900":"东莞" "441900": "东莞"
}, },
"sealSevTypeDict": {//刻章类型 "sealSevTypeDict": {//刻章类型
...@@ -330,10 +336,10 @@ module.exports = { ...@@ -330,10 +336,10 @@ module.exports = {
"/ic/gsnb/": "icCheckCase", "/ic/gsnb/": "icCheckCase",
"/ic/gschangs/": "icChangeCase", "/ic/gschangs/": "icChangeCase",
"/ic/sbopen/": "ssOpenCase", "/ic/sbopen/": "ssOpenCase",
"/qcfw/icp/":"ICP", "/qcfw/icp/": "ICP",
"/qcfw/edi/":"EDI", "/qcfw/edi/": "EDI",
"/qcfw/icpannals/":"ICPANNUALREPORT", "/qcfw/icpannals/": "ICPANNUALREPORT",
"/qcfw/ediannals/":"EDIANNUALREPORT" "/qcfw/ediannals/": "EDIANNUALREPORT"
}, },
"fdyDict": {//产品反对应关系 "fdyDict": {//产品反对应关系
"companyCase": "/ic/gsreg/", "companyCase": "/ic/gsreg/",
...@@ -347,10 +353,10 @@ module.exports = { ...@@ -347,10 +353,10 @@ module.exports = {
"icCheckCase": "/ic/gsnb/", "icCheckCase": "/ic/gsnb/",
"icChangeCase": "/ic/gschangs/", "icChangeCase": "/ic/gschangs/",
"ssOpenCase": "/ic/sbopen/", "ssOpenCase": "/ic/sbopen/",
"ICP":"/qcfw/icp/", "ICP": "/qcfw/icp/",
"EDI":"/qcfw/edi/", "EDI": "/qcfw/edi/",
"ICPANNUALREPORT":"/qcfw/icpannals/", "ICPANNUALREPORT": "/qcfw/icpannals/",
"EDIANNUALREPORT":"/qcfw/ediannals/" "EDIANNUALREPORT": "/qcfw/ediannals/"
}, },
"ddyDict": {//和庄冰的交付单对应关系 "ddyDict": {//和庄冰的交付单对应关系
"paid": 1, "paid": 1,
......
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const System = require("../../../system");
const appconfig = system.getSysConfig(); const appconfig = system.getSysConfig();
class DeliverybillService extends ServiceBase { class DeliverybillService extends ServiceBase {
constructor() { constructor() {
super("bizchance", ServiceBase.getDaoName(DeliverybillService)); super("bizchance", ServiceBase.getDaoName(DeliverybillService));
this.logService = system.getObject("service.bizchance.statuslogSve"); this.logService = system.getObject("service.bizchance.statuslogSve");
this.fitaxschemeDao = system.getObject("service.bizchance.fitaxschemeDao"); this.fitaxschemeDao = system.getObject("service.bizchance.fitaxschemeDao");
this.bizoptDao = system.getObject("service.bizchance.bizoptDao");
this.operationrecordDao = system.getObject("service.bizchance.operationrecordDao");
} }
async updateOrderStatus(pobj) { async updateOrderStatus(pobj) {
...@@ -124,5 +126,113 @@ class DeliverybillService extends ServiceBase { ...@@ -124,5 +126,113 @@ class DeliverybillService extends ServiceBase {
} }
return result return result
} }
async distributionPerson(pobj) {
let { numbers, nickName, userId, opCode, phone, type } = pobj;
switch (type) {
case System.FLOWCODE.DELIVERY:
let datas = await this.dao.findAll({
delivery_code: {
$in: numbers
}
});
if (datas.length !== numbers.length) {
throw new Error("请检查单号是否正确");
}
await this.dao.updateByWhere({
salesman_id: userId,
salesman_opcode: opCode,
salesman_phone: phone,
salesman_name: nickName
}, {
delivery_code: {
$in: numbers
}
});
// 插入 流转 记录
let logs = [];
for (let val of datas) {
logs.push({
demand_code: val.delivery_code,
operator: {
id: pobj.userid,
username: pobj.username
},
operation_type: "distribution",
operation_details: {
isFirst: val.salesman_id ? true : false,
fromUserId: val.salesman_id,
fromUserName: val.salesman_name,
toUserId: userId,
toUserName: nickName
},
order_type: System.FLOWCODE.DELIVERY
})
}
this.operationrecordDao.bulkCreate(logs);
break
case System.FLOWCODE.BIZ:
let datas = await this.bizoptDao.findAll({
demand_code: {
$in: numbers
}
});
if (datas.length !== datas.length) {
throw new Error("请检查单号是否正确");
}
return this.db.transaction(async (t) => {
// 更新 操作人
await this.bizoptDao.updateByWhere({
salesman_id: userId,
salesman_opcode: opCode,
salesman_phone: phone,
salesman_name: nickName
}, {
demand_code: {
$in: numbers
}
}, t);
// 更新 状态
await this.bizoptDao.updateByWhere({
business_status: "beforeFollowUp"
}, {
$and: [
{
demand_code: {
$in: numbers
}
}, {
business_status: "received"
}
]
}, t);
// 插入 流转 记录
let logs = [];
for (let val of datas) {
logs.push({
demand_code: val.demand_code,
operator: {
id: pobj.userid,
username: pobj.username
},
operation_type: "distribution",
operation_details: {
isFirst: val.salesman_id ? true : false,
fromUserId: val.salesman_id,
fromUserName: val.salesman_name,
toUserId: userId,
toUserName: nickName
},
order_type: System.FLOWCODE.BIZ
})
}
this.operationrecordDao.bulkCreate(logs);
return "success"
});
break
}
return "SUCCESS"
}
} }
module.exports = DeliverybillService; module.exports = DeliverybillService;
\ 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