Commit ec700c4c by Sxy

fix: 分配

parent 471f0989
......@@ -128,110 +128,111 @@ class DeliverybillService extends ServiceBase {
}
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"
let { numbers, nickName, userId, opCode, phone, type } = pobj;
switch (type) {
case System.FLOWCODE.DELIVERY:
let bizDatas = await this.dao.findAll({
delivery_code: {
$in: numbers
}
});
if (bizDatas.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 bizDatas) {
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 delDatas = await this.bizoptDao.findAll({
demand_code: {
$in: numbers
}
});
if (delDatas.length !== numbers.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 delDatas) {
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"
}
async insertInfo(qobj) {
......
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