|
@@ -984,7 +984,7 @@ module.exports = app => {
|
|
* @return {Promise<void>}
|
|
* @return {Promise<void>}
|
|
*/
|
|
*/
|
|
async checkCancel(stageId, times = 1) {
|
|
async checkCancel(stageId, times = 1) {
|
|
- // 分3种情况,根据ctx.cancancel值判断:
|
|
|
|
|
|
+ // 分4种情况,根据ctx.cancancel值判断:
|
|
// 1.原报发起撤回,当前流程删除,并回到待上报
|
|
// 1.原报发起撤回,当前流程删除,并回到待上报
|
|
// 2.审批人撤回审批通过,增加流程,并回到它审批中
|
|
// 2.审批人撤回审批通过,增加流程,并回到它审批中
|
|
// 3.审批人撤回审批退回上一人,并删除退回人,增加流程,并回到它审批中,并更新计量期状态为审批中
|
|
// 3.审批人撤回审批退回上一人,并删除退回人,增加流程,并回到它审批中,并更新计量期状态为审批中
|
|
@@ -992,6 +992,8 @@ module.exports = app => {
|
|
const transaction = await this.db.beginTransaction();
|
|
const transaction = await this.db.beginTransaction();
|
|
const time = new Date();
|
|
const time = new Date();
|
|
try {
|
|
try {
|
|
|
|
+ await this._updateTender(transaction);
|
|
|
|
+ let newTimes, newOrder, newSaid, oldTimes, oldOrder, oldSaid = '';
|
|
if (this.ctx.stage.cancancel === 1) {
|
|
if (this.ctx.stage.cancancel === 1) {
|
|
// 原报撤回,判断是否为多次,多次则为退回状态
|
|
// 原报撤回,判断是否为多次,多次则为退回状态
|
|
// 整理当前流程审核人状态更新
|
|
// 整理当前流程审核人状态更新
|
|
@@ -1032,12 +1034,16 @@ module.exports = app => {
|
|
// 计算该审批人最终数据
|
|
// 计算该审批人最终数据
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
// 复制一份最新数据给下一人
|
|
// 复制一份最新数据给下一人
|
|
|
|
+ // 保留审批人数据,覆盖到原报中并删除该审批人合同支付数据
|
|
|
|
+ await this.ctx.service.stagePay.deleteAuditStagePays(this.ctx.stage, this.ctx.stage.times, 0, transaction);
|
|
|
|
+ await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, 0, transaction, this.ctx.stage.times, 1);
|
|
await this.ctx.service.stagePay.deleteAuditStagePays(this.ctx.stage, this.ctx.stage.times, 1, transaction);
|
|
await this.ctx.service.stagePay.deleteAuditStagePays(this.ctx.stage, this.ctx.stage.times, 1, transaction);
|
|
- await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageOther.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageSafeProd.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageTempLand.updateHistory(this.ctx.stage, transaction);
|
|
|
|
|
|
+ newTimes = this.ctx.stage.times;
|
|
|
|
+ newOrder = 0;
|
|
|
|
+ newSaid = this.ctx.stage.user_id;
|
|
|
|
+ oldTimes = this.ctx.stage.times;
|
|
|
|
+ oldOrder = 1;
|
|
|
|
+ oldSaid = curAudit.aid;
|
|
} else if (this.ctx.stage.cancancel === 2) {
|
|
} else if (this.ctx.stage.cancancel === 2) {
|
|
const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
|
|
const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage);
|
|
// 整理当前流程审核人状态更新
|
|
// 整理当前流程审核人状态更新
|
|
@@ -1107,13 +1113,13 @@ module.exports = app => {
|
|
// 计算该审批人最终数据
|
|
// 计算该审批人最终数据
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
// 复制一份最新数据给下一人
|
|
// 复制一份最新数据给下一人
|
|
- await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, curAudit.order + 1, transaction);
|
|
|
|
- await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageOther.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageSafeProd.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageTempLand.updateHistory(this.ctx.stage, transaction);
|
|
|
|
-
|
|
|
|
|
|
+ await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, curAudit.order + 1, transaction, this.ctx.stage.times, this.ctx.stage.curOrder + 1);
|
|
|
|
+ newTimes = this.ctx.stage.times;
|
|
|
|
+ newOrder = curAudit.order + 1;
|
|
|
|
+ newSaid = preAudit.aid;
|
|
|
|
+ oldTimes = this.ctx.stage.times;
|
|
|
|
+ oldOrder = curAudit.order;
|
|
|
|
+ oldSaid = curAudit.aid;
|
|
// 锁定本人数据,保留锁定数据相关确认状态
|
|
// 锁定本人数据,保留锁定数据相关确认状态
|
|
// await this.ctx.service.stageAuditAss.lockConfirm4CheckNoPre(this.ctx.stage, curAudit.aid, preAudit.aid, transaction);
|
|
// await this.ctx.service.stageAuditAss.lockConfirm4CheckNoPre(this.ctx.stage, curAudit.aid, preAudit.aid, transaction);
|
|
} else if (this.ctx.stage.cancancel === 3) {
|
|
} else if (this.ctx.stage.cancancel === 3) {
|
|
@@ -1186,12 +1192,14 @@ module.exports = app => {
|
|
// 计算该审批人最终数据
|
|
// 计算该审批人最终数据
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
// 复制一份最新数据给下一人
|
|
// 复制一份最新数据给下一人
|
|
- await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, curAudit.order + 1, transaction);
|
|
|
|
- await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageOther.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageSafeProd.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageTempLand.updateHistory(this.ctx.stage, transaction);
|
|
|
|
|
|
+ await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, curAudit.order + 1, transaction, this.ctx.stage.times, this.ctx.stage.curOrder + 1);
|
|
|
|
+
|
|
|
|
+ newTimes = this.ctx.stage.times;
|
|
|
|
+ newOrder = curAudit.order + 1;
|
|
|
|
+ newSaid = preAudit.aid;
|
|
|
|
+ oldTimes = this.ctx.stage.times;
|
|
|
|
+ oldOrder = curAudit.order;
|
|
|
|
+ oldSaid = curAudit.aid;
|
|
|
|
|
|
// 锁定本人数据,保留锁定数据相关确认状态
|
|
// 锁定本人数据,保留锁定数据相关确认状态
|
|
// await this.ctx.service.stageAuditAss.lockConfirm4CheckNoPre(this.ctx.stage, curAudit.aid, preAudit.aid, transaction);
|
|
// await this.ctx.service.stageAuditAss.lockConfirm4CheckNoPre(this.ctx.stage, curAudit.aid, preAudit.aid, transaction);
|
|
@@ -1235,7 +1243,7 @@ module.exports = app => {
|
|
// 计算并合同支付最终数据
|
|
// 计算并合同支付最终数据
|
|
const [yfPay, sfPay] = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
const [yfPay, sfPay] = await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
this.ctx.stage.tp_history.push({
|
|
this.ctx.stage.tp_history.push({
|
|
- times,
|
|
|
|
|
|
+ times: times - 1,
|
|
order: curAudit.order,
|
|
order: curAudit.order,
|
|
contract_tp: tpData.contract_tp,
|
|
contract_tp: tpData.contract_tp,
|
|
qc_tp: tpData.qc_tp,
|
|
qc_tp: tpData.qc_tp,
|
|
@@ -1260,15 +1268,28 @@ module.exports = app => {
|
|
// 计算该审批人最终数据
|
|
// 计算该审批人最终数据
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction);
|
|
// 复制一份最新数据给下一人
|
|
// 复制一份最新数据给下一人
|
|
|
|
+ await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times - 1, curAudit.order + 1, transaction, this.ctx.stage.times, 0);
|
|
|
|
+ await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times - 1, curAudit.order + 2, transaction, this.ctx.stage.times, 0);
|
|
await this.ctx.service.stagePay.deleteAuditStagePays(this.ctx.stage, this.ctx.stage.times, 0, transaction);
|
|
await this.ctx.service.stagePay.deleteAuditStagePays(this.ctx.stage, this.ctx.stage.times, 0, transaction);
|
|
- await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times - 1, curAudit.order + 1, transaction);
|
|
|
|
- await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times - 1, curAudit.order + 2, transaction);
|
|
|
|
- await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageOther.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageSafeProd.updateHistory(this.ctx.stage, transaction);
|
|
|
|
- await this.ctx.service.stageTempLand.updateHistory(this.ctx.stage, transaction);
|
|
|
|
|
|
+
|
|
|
|
+ newTimes = this.ctx.stage.times - 1;
|
|
|
|
+ newOrder = curAudit.order + 2;
|
|
|
|
+ newSaid = curAudit.aid;
|
|
|
|
+ oldTimes = this.ctx.stage.times;
|
|
|
|
+ oldOrder = 0;
|
|
|
|
+ oldSaid = this.ctx.stage.user_id;
|
|
}
|
|
}
|
|
|
|
+ // 先覆盖再删除
|
|
|
|
+ await this.ctx.service.stageBills.updateStageBills4CheckCancel(stageId, newSaid, newTimes, newOrder, oldSaid, oldTimes, oldOrder, transaction);
|
|
|
|
+ await this.ctx.service.stagePos.updateStagePos4CheckCancel(stageId, newSaid, newTimes, newOrder, oldSaid, oldTimes, oldOrder, transaction);
|
|
|
|
+ await this.ctx.service.stageDetail.updateStageDetail4CheckCancel(stageId, newTimes, newOrder, oldTimes, oldOrder, transaction);
|
|
|
|
+
|
|
|
|
+ await this.ctx.service.stageJgcl.updateHistory4CheckCancel(this.ctx.stage, newTimes, newOrder, transaction);
|
|
|
|
+ await this.ctx.service.stageBonus.updateHistory4CheckCancel(this.ctx.stage, newTimes, newOrder, transaction);
|
|
|
|
+ await this.ctx.service.stageOther.updateHistory4CheckCancel(this.ctx.stage, newTimes, newOrder, transaction);
|
|
|
|
+ await this.ctx.service.stageSafeProd.updateHistory4CheckCancel(this.ctx.stage, newTimes, newOrder, transaction);
|
|
|
|
+ await this.ctx.service.stageTempLand.updateHistory4CheckCancel(this.ctx.stage, newTimes, newOrder, transaction);
|
|
|
|
+
|
|
// 上报/审批 - 检查三方特殊推送
|
|
// 上报/审批 - 检查三方特殊推送
|
|
await this.ctx.service.specMsg.addStageMsg(transaction, this.ctx.session.sessionProject.id, this.ctx.stage, pushOperate.stage.flow);
|
|
await this.ctx.service.specMsg.addStageMsg(transaction, this.ctx.session.sessionProject.id, this.ctx.stage, pushOperate.stage.flow);
|
|
await transaction.commit();
|
|
await transaction.commit();
|