|
@@ -91,7 +91,7 @@ module.exports = app => {
|
|
|
* @return {Promise<*>}
|
|
|
*/
|
|
|
async getCurAuditor(materialId, times = 1) {
|
|
|
- const sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
|
+ const sql = 'SELECT la.`id`, la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
|
|
|
' FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
|
|
|
' WHERE la.`mid` = ? and la.`status` = ? and la.`times` = ?';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, materialId, auditConst.status.checking, times];
|
|
@@ -204,8 +204,8 @@ module.exports = app => {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- async getTpData(materialId) {
|
|
|
- const materialInfo = await this.ctx.service.material.getDataById(materialId);
|
|
|
+ async getTpData(transaction, materialId) {
|
|
|
+ const materialInfo = await transaction.get(this.ctx.service.material.tableName, { id: materialId });
|
|
|
const tp_data = {
|
|
|
m_tp: materialInfo.m_tp !== null ? this.ctx.helper.round(materialInfo.m_tp, this.ctx.material.decimal.tp) : null,
|
|
|
tax_tp: materialInfo.material_tax ? (materialInfo.m_tax_tp ? materialInfo.m_tax_tp : materialInfo.m_tp) :
|
|
@@ -216,7 +216,7 @@ module.exports = app => {
|
|
|
tp_data.total_tp = this.ctx.helper.add(tp_data.m_tp, tp_data.ex_tp);
|
|
|
tp_data.total_tax_tp = !materialInfo.material_tax ? this.ctx.helper.add(tp_data.tax_tp, tp_data.ex_tax_tp) : tp_data.ex_tax_tp;
|
|
|
if (materialInfo.is_stage_self) {
|
|
|
- const materialStageList = await this.ctx.service.materialStage.getAllDataByCondition({ where: { mid: materialId }});
|
|
|
+ const materialStageList = await transaction.select(this.ctx.service.materialStage.tableName, { where: { mid: materialId } });
|
|
|
const stage_tp = [];
|
|
|
for (const ms of materialStageList) {
|
|
|
stage_tp.push({
|
|
@@ -250,8 +250,8 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
- const tp_data = await this.getTpData(materialId);
|
|
|
try {
|
|
|
+ const tp_data = await this.getTpData(transaction, materialId);
|
|
|
await transaction.update(this.tableName, { id: audit.id, status: auditConst.status.checking, begin_time: new Date() });
|
|
|
await transaction.update(this.ctx.service.material.tableName, {
|
|
|
id: materialId, status: auditConst.status.checking, tp_data: JSON.stringify(tp_data),
|
|
@@ -315,11 +315,10 @@ module.exports = app => {
|
|
|
|
|
|
const nextAudit = await this.getDataByCondition({ mid: materialId, times, order: audit.order + 1 });
|
|
|
|
|
|
- // 获取当前总金额及独立单价期的金额,添加到tp_data中,报表使用
|
|
|
- const tp_data = await this.getTpData(materialId);
|
|
|
-
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
+ // 获取当前总金额及独立单价期的金额,添加到tp_data中,报表使用
|
|
|
+ const tp_data = await this.getTpData(transaction, materialId);
|
|
|
await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time, tp_data: JSON.stringify(tp_data) });
|
|
|
|
|
|
// 获取推送必要信息
|
|
@@ -500,8 +499,8 @@ module.exports = app => {
|
|
|
order++;
|
|
|
}
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
- const tp_data = await this.getTpData(materialId);
|
|
|
try {
|
|
|
+ const tp_data = await this.getTpData(transaction, materialId);
|
|
|
await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time, tp_data: JSON.stringify(tp_data), });
|
|
|
// 添加到消息推送表
|
|
|
const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid, checkData.opinion);
|
|
@@ -596,8 +595,8 @@ module.exports = app => {
|
|
|
const preAuditor = auditors2[auditorIndex - 1];
|
|
|
const noticeContent = await this.getNoticeContent(pid, audit.tid, materialId, audit.aid, checkData.opinion);
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
- const tp_data = await this.getTpData(materialId);
|
|
|
try {
|
|
|
+ const tp_data = await this.getTpData(transaction, materialId);
|
|
|
// 添加到消息推送表
|
|
|
const records = [{ pid, type: pushType.material, uid: this.ctx.material.user_id, status: auditConst.status.checkNoPre, content: noticeContent }];
|
|
|
auditors2.forEach(audit => {
|