|
@@ -134,6 +134,35 @@ module.exports = app => {
|
|
|
}
|
|
|
return result.affectedRows === stagePays.length;
|
|
|
}
|
|
|
+ async reInitialStageData(preStage, stage, transaction) {
|
|
|
+ if (!stage || !preStage || !transaction) throw '检查合同支付数据失败';
|
|
|
+
|
|
|
+ const basesReg = new RegExp(payConst.calcBase.map(x => {return '(' + x.code + ')'}).join('|'));
|
|
|
+ const orderReg = /f\d+/im;
|
|
|
+
|
|
|
+ let pays = await this.ctx.service.pay.getAllDataByCondition({where: { tid: this.ctx.tender.id } });
|
|
|
+ const stagePays = [];
|
|
|
+ const prePays = await this.getStageLastestPays(preStage);
|
|
|
+ for (const pp of prePays) {
|
|
|
+ const p = this._.find(pays, {id: pp.pid});
|
|
|
+ if (!p.valid) continue;
|
|
|
+ stagePays.push({
|
|
|
+ tid: p.tid, sid: stage.id, pid: p.id,
|
|
|
+ stimes: stage.times, sorder: 0,
|
|
|
+ name: pp.name,
|
|
|
+ expr: (p.ptype === payConst.payType.normal || p.ptype === payConst.payType.sf)
|
|
|
+ ? (basesReg.test(pp.expr) || orderReg.test(pp.expr) ? pp.expr : null)
|
|
|
+ : (p.type === payConst.wc ? pp.expr : null),
|
|
|
+ pause: pp.pause,
|
|
|
+ pre_tp: pp.end_tp,
|
|
|
+ pre_used: pp.pre_used || !this.ctx.helper.checkZero(pp.tp),
|
|
|
+ pre_finish: pp.pre_finish || (pp.rprice ? pp.end_tp === pp.rprice : false),
|
|
|
+ start_stage_order: pp.start_stage_order,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ await transaction.delete(this.tableName, { sid: stage.id });
|
|
|
+ await transaction.insert(this.tableName, stagePays);
|
|
|
+ }
|
|
|
|
|
|
async getStagePay(stage, pid) {
|
|
|
return await this.getAuditorStagePay(pid, stage.id, stage.curTimes, stage.curOrder);
|