Commit 7cfbb929 by Sxy

优化 手动 分配

parent cf87929c
...@@ -557,7 +557,7 @@ class DeliverybillCtl extends CtlBase { ...@@ -557,7 +557,7 @@ class DeliverybillCtl extends CtlBase {
const sInfo = { const sInfo = {
flowType: 'DELIVERY', flowType: 'DELIVERY',
flowId: res.id, flowId: res.id,
flowCode: pobj.deliverNumber, flowCode: res.master_source_number || res.delivery_code,
salesmanInfo: { salesmanInfo: {
// "oldClerkPhone": res.salesman_phone, // "oldClerkPhone": res.salesman_phone,
oldFacilitatorId: res.facilitator_id, oldFacilitatorId: res.facilitator_id,
...@@ -588,7 +588,7 @@ class DeliverybillCtl extends CtlBase { ...@@ -588,7 +588,7 @@ class DeliverybillCtl extends CtlBase {
}; };
} }
await this.shisService.insertInfo(sInfo);// 之前业务员转历史 await this.shisService.insertInfo(sInfo);// 之前业务员转历史
await this.service.updateSalesmanInfoByDeliverCode(pobj);// 更新业务员信息 await this.service.updateSalesmanInfoByDeliverCode({ ...pobj, masterSourceNumber: res.master_source_number });// 更新业务员信息
return system.getResult('操作成功!'); return system.getResult('操作成功!');
} }
...@@ -601,6 +601,39 @@ class DeliverybillCtl extends CtlBase { ...@@ -601,6 +601,39 @@ class DeliverybillCtl extends CtlBase {
} }
} }
/** 查询子订单的关联单 */
async findRelationOrder(mobj) {
try {
if (!mobj.deliverNumber) {
throw new Error("deliverNumber 不能为空");
}
const data = await this.service.findOne({
delivery_code: mobj.deliverNumber,
facilitator_id: mobj.company_id,
});
if (data) {
let result = [];
if (data.master_source_number) {
const orders = await this.service.findOrderByMasterNumber(data.master_source_number);
if (orders && orders.length > 0) {
result = orders.map(item => {
return item.delivery_code
}).filter(item => {
return item !== mobj.deliverNumber
})
}
}
return system.getResult(result);
} else {
throw new Error(`单号错误 ${mobj.deliverNumber}`)
}
} catch (error) {
return system.getResultError(error.message);
}
}
/* 更新业务员信息*/ /* 更新业务员信息*/
async updateSalesmanInfoByDeliverCode(mobj, qobj, req) { async updateSalesmanInfoByDeliverCode(mobj, qobj, req) {
const pobj = mobj.d; const pobj = mobj.d;
......
...@@ -83,7 +83,7 @@ class DeliverybillDao extends Dao { ...@@ -83,7 +83,7 @@ class DeliverybillDao extends Dao {
} }
/* 更新业务员/交付员信息*/ /* 更新业务员/交付员信息*/
async updateSalesmanInfoByDeliverCode(qobj, t) { async updateSalesmanInfoByDeliverCode(qobj) {
const setobj = {}; const setobj = {};
if (qobj.type == 'salesman') { if (qobj.type == 'salesman') {
if (qobj.salesmanId && qobj.salesmanId != 'undefined') { if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
...@@ -116,8 +116,13 @@ class DeliverybillDao extends Dao { ...@@ -116,8 +116,13 @@ class DeliverybillDao extends Dao {
if (qobj.facilitatorName && qobj.facilitatorName != 'undefined') { if (qobj.facilitatorName && qobj.facilitatorName != 'undefined') {
setobj.facilitator_name = qobj.facilitatorName; setobj.facilitator_name = qobj.facilitatorName;
}; };
const whereobj = { delivery_code: qobj.deliverNumber }; let whereobj = { delivery_code: qobj.deliverNumber }
const result = await this.updateByWhere(setobj, whereobj, t); if (qobj.masterSourceNumber) {
whereobj = {
master_source_number: qobj.masterSourceNumber
}
}
const result = await this.updateByWhere(setobj, whereobj);
return result; return result;
} }
......
...@@ -206,10 +206,8 @@ class DeliverybillService extends ServiceBase { ...@@ -206,10 +206,8 @@ class DeliverybillService extends ServiceBase {
/* 更新业务员信息*/ /* 更新业务员信息*/
async updateSalesmanInfoByDeliverCode(qobj) { async updateSalesmanInfoByDeliverCode(qobj) {
const self = this; const self = this;
return self.db.transaction(async (t) => { const result = await self.dao.updateSalesmanInfoByDeliverCode(qobj);
const result = await self.dao.updateSalesmanInfoByDeliverCode(qobj, t); return result;
return result;
});
} }
async updateInfoByDeliverCode(qobj) { //* 更新交付单信息 */ async updateInfoByDeliverCode(qobj) { //* 更新交付单信息 */
console.log('--------------------------------------------------------------------------------------------------------------------------------------'); console.log('--------------------------------------------------------------------------------------------------------------------------------------');
...@@ -250,5 +248,14 @@ class DeliverybillService extends ServiceBase { ...@@ -250,5 +248,14 @@ class DeliverybillService extends ServiceBase {
return system.getResultSuccess(); return system.getResultSuccess();
}); });
} }
findOrderByMasterNumber(masterSourceNumber) {
return this.dao.model.findAll({
where: {
master_source_number: masterSourceNumber
},
attributes: ["id", "delivery_code"]
})
}
} }
module.exports = DeliverybillService; module.exports = DeliverybillService;
...@@ -8,7 +8,7 @@ class LogClient { ...@@ -8,7 +8,7 @@ class LogClient {
const u = uuid.replace(/-/g, ''); const u = uuid.replace(/-/g, '');
return u; return u;
} }
async log(pobj, req, rtninfo, errinfo) { async log(pobj, req, rtninfo = {}, errinfo) {
rtninfo.requestId = this.getUUID(); rtninfo.requestId = this.getUUID();
req.params.param = pobj; req.params.param = pobj;
// 第三个字段应该存公司id // 第三个字段应该存公司id
......
...@@ -22,7 +22,8 @@ module.exports = function (app) { ...@@ -22,7 +22,8 @@ module.exports = function (app) {
if (invokeObj.doexec) { if (invokeObj.doexec) {
p = invokeObj.doexec.apply(invokeObj, params); p = invokeObj.doexec.apply(invokeObj, params);
p.then((r) => { p.then((r) => {
res.end(JSON.stringify(r)); // res.end(JSON.stringify(r));
res.json(r)
}); });
} }
}); });
...@@ -49,7 +50,8 @@ module.exports = function (app) { ...@@ -49,7 +50,8 @@ module.exports = function (app) {
if (invokeObj.doexec) { if (invokeObj.doexec) {
p = invokeObj.doexec.apply(invokeObj, params); p = invokeObj.doexec.apply(invokeObj, params);
p.then((r) => { p.then((r) => {
res.end(JSON.stringify(r)); // res.end(JSON.stringify(r));
res.json(r)
}); });
} }
}); });
......
...@@ -17,7 +17,8 @@ module.exports = function (app) { ...@@ -17,7 +17,8 @@ module.exports = function (app) {
if (invokeObj.doexec) { if (invokeObj.doexec) {
p = invokeObj.doexec.apply(invokeObj, params); p = invokeObj.doexec.apply(invokeObj, params);
p.then((r) => { p.then((r) => {
res.end(JSON.stringify(r)); // res.end(JSON.stringify(r));
res.json(r)
}); });
} }
}); });
...@@ -41,7 +42,8 @@ module.exports = function (app) { ...@@ -41,7 +42,8 @@ module.exports = function (app) {
if (invokeObj.doexec) { if (invokeObj.doexec) {
p = invokeObj.doexec.apply(invokeObj, params); p = invokeObj.doexec.apply(invokeObj, params);
p.then((r) => { p.then((r) => {
res.end(JSON.stringify(r)); // res.end(JSON.stringify(r));
res.json(r)
}); });
} }
}); });
......
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