|
@@ -18,234 +18,229 @@ module.exports = app => {
|
|
|
*/
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
- this.tableName = 'stage_pos';
|
|
|
- this.qtyFields = ['contract_qty', 'qc_qty']
|
|
|
+ this.tableName = 'stage_pay';
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 查询期计量最后审核人数据
|
|
|
- * @param {Number} tid - 标段id
|
|
|
+ * 查询 某期 某轮审批 某审核人数据
|
|
|
+ *
|
|
|
+ * @param {Number} pid - 合同支付id
|
|
|
* @param {Number} sid - 期id
|
|
|
- * @param {Number|Array} pid - 部位明细id(可以为空)
|
|
|
+ * @param {Number} times - 期第几轮审批
|
|
|
+ * @param {Number} order - 审核人顺序
|
|
|
+ * @param {Number|Array|Null} pid - 部位明细id - 为空则查询全部
|
|
|
* @returns {Promise<*>}
|
|
|
*/
|
|
|
- async getLastestStageData(tid, sid) {
|
|
|
- const sql = 'SELECT * FROM ' + this.tableName + ' As Pos ' +
|
|
|
- ' INNER JOIN ( ' +
|
|
|
- ' SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `pid` From ' + this.tableName +
|
|
|
- ' GROUP BY `pid`' +
|
|
|
- ' ) As MaxFilter ' +
|
|
|
- ' ON Pos.times = MaxFilter.times And Pos.order = MaxFilter.order And Pos.pid = MaxFilter.pid' +
|
|
|
- ' WHERE Pos.tid = ? And Pos.sid = ?';
|
|
|
- const sqlParam = [tid, sid];
|
|
|
- return await this.db.query(sql, sqlParam);
|
|
|
+ async getAuditorStagePay(pid, sid, times, order) {
|
|
|
+ const sql = 'SELECT SP.*, P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
+ ' FROM ?? As SP, ?? As P ' +
|
|
|
+ ' WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? AND SP.`pid` = P.`id` AND SP.`pid` = ? AND P.`valid`' +
|
|
|
+ ' ORDER BY P.`order`';
|
|
|
+ const sqlParam = [this.tableName, this.ctx.service.pay.tableName, sid, times, order, pid];
|
|
|
+ return await this.db.queryOne(sql, sqlParam);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 查询 某期 某轮审批 某审核人数据
|
|
|
- * @param {Number} tid - 标段id
|
|
|
* @param {Number} sid - 期id
|
|
|
* @param {Number} times - 期第几轮审批
|
|
|
* @param {Number} order - 审核人顺序
|
|
|
* @param {Number|Array|Null} pid - 部位明细id - 为空则查询全部
|
|
|
* @returns {Promise<*>}
|
|
|
*/
|
|
|
- async getAuditorStageData(tid, sid, times, order) {
|
|
|
- const sql = 'SELECT * FROM ' + this.tableName + ' As Pos ' +
|
|
|
- ' INNER JOIN ( ' +
|
|
|
- ' SELECT MAX(`times`) As `times`, MAX(`order`) As `order`, `pid` From ' + this.tableName +
|
|
|
- ' WHERE `times` <= ? AND `order` <= ?' +
|
|
|
- ' GROUP BY `pid`' +
|
|
|
- ' ) As MaxFilter ' +
|
|
|
- ' ON Pos.times = MaxFilter.times And Pos.order = MaxFilter.order And Pos.pid = MaxFilter.pid' +
|
|
|
- ' WHERE Pos.tid = ? And Pos.sid = ?';
|
|
|
- const sqlParam = [times, order, tid, sid];
|
|
|
+ async getAuditorStageData(sid, times, order) {
|
|
|
+ const sql = 'SELECT SP.*, P.`csorder`, P.`cstimes`, P.`csaorder`, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
+ ' FROM ?? As SP, ?? As P ' +
|
|
|
+ ' WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? AND SP.`pid` = P.`id` AND P.`valid`' +
|
|
|
+ ' ORDER BY P.`order`';
|
|
|
+ const sqlParam = [this.tableName, this.ctx.service.pay.tableName, sid, times, order];
|
|
|
return await this.db.query(sql, sqlParam);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 新增部位明细数据(仅供updateStageData调用)
|
|
|
- *
|
|
|
+ * 新增期时,初始化 期--合同支付 数据
|
|
|
+ * @param {Object} stage - 新增的期
|
|
|
* @param transaction - 事务
|
|
|
- * @param data - 新增数据
|
|
|
- * @returns {Promise<{}>}
|
|
|
- * @private
|
|
|
+ * @returns {Promise<void>}
|
|
|
*/
|
|
|
- // async _addStagePosData(transaction, data) {
|
|
|
- // const bills = await this.ctx.service.ledger.getDataById(data.lid);
|
|
|
- // const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
|
|
|
- // const result = {};
|
|
|
- // // 在主表pos中新增数据
|
|
|
- // const p = JSON.parse(JSON.stringify(data.updateData));
|
|
|
- // p.tid = this.ctx.tender.id;
|
|
|
- // p.add_stage = this.ctx.stage.id;
|
|
|
- // p.add_times = this.ctx.stage.times;
|
|
|
- // p.add_user = this.ctx.session.sessionUser.accountId;
|
|
|
- // if (p.contract_qty) { delete p.contract_qty; }
|
|
|
- // if (p.qc_qty) { delete p.qc_qty; }
|
|
|
- // if (p.postil) { delete p.postil; }
|
|
|
- // if (p.quantity) {
|
|
|
- // p.quantity = this.round(p.quantity, precision.value);
|
|
|
- // }
|
|
|
- // const addRst = await transaction.insert(this.ctx.service.pos.tableName, data.updateData);
|
|
|
- // p.id = addRst.insertId;
|
|
|
- // result.pos = p.id;
|
|
|
- // // 如果存在复核数据,更新计算主表清单
|
|
|
- // if (p.quantity) {
|
|
|
- // await this.ctx.service.ledger.calc(this.ctx.tender.id, p.lid, transaction);
|
|
|
- // result.ledger = p.lid;
|
|
|
- // }
|
|
|
- // // 如果存在本期计算数据,更新计算清单本期计量数据
|
|
|
- // if (data.contract_qty || data.qc_qty || data.postil) {
|
|
|
- // const ps = {
|
|
|
- // pid: p.id,
|
|
|
- // lid: p.lid,
|
|
|
- // tid: this.ctx.tender.id,
|
|
|
- // sid: this.ctx.stage.id,
|
|
|
- // said: this.ctx.session.sessionUser.accountId,
|
|
|
- // times: this.ctx.stage.times,
|
|
|
- // order: 0,
|
|
|
- // };
|
|
|
- // if (data.contract_qty) { ps.contract_qty = this.round(data.contract_qty, precision.value); }
|
|
|
- // if (data.qc_qty) { ps.qc_qty = this.round(data.qc_qty, precision.value); }
|
|
|
- // if (data.postil) { ps.postil = data.postil; }
|
|
|
- // await transaction.insert(ps);
|
|
|
- // await this.ctx.service.stageBills.calc(ctx.tender.id, ctx.stage.id, ps.lid, transaction);
|
|
|
- // result.stageUpdate = true;
|
|
|
- // }
|
|
|
- // return result;
|
|
|
- // }
|
|
|
+ async addInitialStageData(stage, transaction) {
|
|
|
+ if (!stage) {
|
|
|
+ throw '初始化期合同支付数据失败';
|
|
|
+ }
|
|
|
+ const pays = await this.ctx.service.pay.getAllDataByCondition({where: { tid: this.ctx.tender.id } });
|
|
|
+ const stagePays = [];
|
|
|
+ for (const p of pays) {
|
|
|
+ stagePays.push({
|
|
|
+ tid: p.tid,
|
|
|
+ sid: stage.id,
|
|
|
+ pid: p.id,
|
|
|
+ stimes: stage.times,
|
|
|
+ sorder: 0,
|
|
|
+ expr: p.expr,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 获取截止上期数据
|
|
|
+ if (stage.order > 1) {
|
|
|
+ const preStage = this.ctx.service.stage.getDataByCondition({tid: stage.tid, order: stage.order - 1});
|
|
|
+ if (!preStage) {
|
|
|
+ throw '标段数据有误';
|
|
|
+ }
|
|
|
+ const prePays = this.getStageLastestPays(preStage.id);
|
|
|
+ for (const pp of prePays) {
|
|
|
+ const sp = this._.find(stagePays, {pid: pp.pid});
|
|
|
+ sp.pre_total_price = pp.end_total_price;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let result;
|
|
|
+ if (transaction) {
|
|
|
+ result = await transaction.insert(this.tableName, stagePays);
|
|
|
+ } else {
|
|
|
+ result = await this.db.insert(this.tableName, stagePays);
|
|
|
+ }
|
|
|
+ return result.affectedRows === pays.length;
|
|
|
+ }
|
|
|
+
|
|
|
+ async getStagePay(stage, pid) {
|
|
|
+ return await this.getAuditorStagePay(pid, stage.id, stage.times, stage.curAuditor ? stage.curAuditor.order : 0);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 更新部位明细数据(仅供updateStageData调用)
|
|
|
+ * 获取某期合同支付数据
|
|
|
*
|
|
|
- * @param transaction - 事务
|
|
|
- * @param data - 更新数据(允许一次性提交多条)
|
|
|
- * @returns {Promise<{ledger: Array, pos: Array}>}
|
|
|
- * @private
|
|
|
+ * @param {Object} stage - 期数据(通过StageController._getStageData()获取)
|
|
|
+ * @returns {Promise<*>}
|
|
|
*/
|
|
|
- // async _updateStagePosData(transaction, data) {
|
|
|
- // let bills, precision;
|
|
|
- // const result = {ledger: [], pos: [], stageUpdate: true};
|
|
|
- // const datas = data instanceof Array ? data : [data];
|
|
|
- // const orgStagePos = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, this._.map(datas, 'pid'));
|
|
|
- // const userOrder = this.ctx.stage.curAuditor ? this.ctx.stage.curAuditor.order : 0;
|
|
|
- // for (const d of datas) {
|
|
|
- // if (!bills || bills.id !== data.lid) {
|
|
|
- // bills = await this.ctx.service.ledger.getDataById(data.lid);
|
|
|
- // precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
|
|
|
- // }
|
|
|
- // const osp = this._.find(orgStagePos, function (p) { return p.pid === d.pid; });
|
|
|
- // this.ctx.helper.checkFieldPrecision(d, this.qtyFields, precision.value);
|
|
|
- // if (osp && osp.times === this.ctx.stage.times && osp.order === userOrder) {
|
|
|
- // await transaction.update(this.tableName, d, {where: {id: osp.id}});
|
|
|
- // } else {
|
|
|
- // console.log(osp);
|
|
|
- // d.tid = this.ctx.tender.id;
|
|
|
- // d.sid = this.ctx.stage.id;
|
|
|
- // d.said = this.ctx.session.sessionUser.accountId;
|
|
|
- // d.times = this.ctx.stage.times;
|
|
|
- // d.order = userOrder;
|
|
|
- // await transaction.insert(this.tableName, d);
|
|
|
- // }
|
|
|
- // result.pos.push(d.pid);
|
|
|
- // if ((d.contract_qty === undefined || d.qc_qty === undefined) && (result.ledger.indexOf(d.lid) === -1)) {
|
|
|
- // result.ledger.push(d.lid);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // for (const lid of result.ledger) {
|
|
|
- // await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, lid, transaction);
|
|
|
- // }
|
|
|
- // return result;
|
|
|
- // }
|
|
|
+ async getStagePays(stage) {
|
|
|
+ return await this.getAuditorStageData(stage.id, stage.times, stage.curAuditor ? stage.curAuditor.order : 0);
|
|
|
+ // const sql = 'SELECT SP.*, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
+ // ' FROM ?? As SP, ?? As P ' +
|
|
|
+ // ' WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? AND SP.`pid` = P.`id` ' +
|
|
|
+ // ' ORDER BY P.`order`';
|
|
|
+ // const sqlParam = [this.tableName, this.ctx.service.pay.tableName, stage.id, stage.times, stage.curAuditor ? stage.curAuditor.order : 0];
|
|
|
+ // return await this.db.query(sql, sqlParam);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 删除部位明细数据(仅供updateStageData调用)
|
|
|
+ * 获取某期最后数据(不限制该期是否已经审批通过)
|
|
|
*
|
|
|
- * @param transaction - 事务
|
|
|
- * @param data - 删除的部位明细(允许一次提醒多条,也允许跨清单(但前端操作不允许))
|
|
|
- * @returns {Promise<{}>}
|
|
|
- * @private
|
|
|
+ * @param {Number} sid - 期id
|
|
|
+ * @returns {Promise<*>}
|
|
|
*/
|
|
|
- // async _deleteStagePosData(transaction, data) {
|
|
|
- // const result = {};
|
|
|
- // const pos = await this.ctx.service.pos.getPosData({tid: this.ctx.tender.id, id: data});
|
|
|
- // if (pos instanceof Array) {
|
|
|
- // for (const p of pos) {
|
|
|
- // if (p.add_stage !== this.ctx.stage.id || p.add_times !== this.ctx.stage.times || p.add_user !== this.ctx.session.sessionUser.accountId) {
|
|
|
- // throw '您无权删除该数据';
|
|
|
- // }
|
|
|
- // }
|
|
|
- // } else if (pos.add_stage !== this.ctx.stage.id || pos.add_times !== this.ctx.stage.times || pos.add_user !== this.ctx.session.sessionUser.accountId) {
|
|
|
- // throw '您无权删除该数据';
|
|
|
- // }
|
|
|
- // const ledgerIds = this._.map(pos, 'lid');
|
|
|
- // // 删除部位明细
|
|
|
- // await transaction.delete(this.ctx.service.pos.tableName, {tid: this.ctx.tender.id, id: data});
|
|
|
- // for (const lid of ledgerIds) {
|
|
|
- // await this.ctx.service.ledger.calc(tid, lid, transaction);
|
|
|
- // }
|
|
|
- // // 删除部位明细计量数据
|
|
|
- // await transaction.delete(this.tableName, {tid: this.ctx.tender.id, lid: data});
|
|
|
- // for (const lid of ledgerIds) {
|
|
|
- // await this.ctx.service.stageBills.calc(this.ctx.tender.id, this.ctx.stage.id, lid, transaction);
|
|
|
- // }
|
|
|
- // // 获取需要更新的数据
|
|
|
- // result.ledger = ledgerIds;
|
|
|
- // result.stageUpdate = true;
|
|
|
- // return result;
|
|
|
- // }
|
|
|
+ async getStageLastestPays(sid) {
|
|
|
+ const sql = 'SELECT SP.*, P.`order`, P.uid, P.name, P.minus, P.ptype, P.sprice, P.sexpr, P.rprice, P.rexpr, P.is_yf, P.dl_type, P.dl_count, P.dl_tp_type, P.dl_tp ' +
|
|
|
+ ' FROM ?? As SP, ?? As P, ( ' +
|
|
|
+ ' SELECT MAX(`stimes`) As `stimes`, MAX(`sorder`) As `sorder` ' +
|
|
|
+ ' FROM ?? ' +
|
|
|
+ ' WHERE `sid` = ? ' +
|
|
|
+ ' GOURP BY `sid`) As M' +
|
|
|
+ ' WHERE SP.`sid` = ? AND SP.`stimes` = M.`stimes` AND SP.`sorder` = M.`sorder` AND SP.`pid` = P.`id` AND P.`valid` = true' +
|
|
|
+ ' ORDER BY P.`order`';
|
|
|
+ const sqlParam = [this.tableName, this.ctx.service.pay.tableName, this.ctx.service.stage.tableName, this.ctx.service.stageAudit.tableName,
|
|
|
+ stage.id, stage.id];
|
|
|
+ return await this.db.query(sql, sqlParam);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 根据前端提交数据,更新并计算
|
|
|
- *
|
|
|
+ * 同步新增 (仅供合同支付新增时调用)
|
|
|
+ * @param {Object} pay - 合同支付项数据
|
|
|
+ * @param transaction - 新增合同支付的事务
|
|
|
+ * @returns {Promise<{tid, sid: number|*, pid, stimes: number|*, sorder: number|*}>}
|
|
|
+ */
|
|
|
+ async syncAdd(pay, transaction) {
|
|
|
+ const stagePay = {
|
|
|
+ tid: pay.tid,
|
|
|
+ sid: pay.csid,
|
|
|
+ pid: pay.id,
|
|
|
+ stimes: pay.cstimes,
|
|
|
+ sorder: pay.csaorder,
|
|
|
+ };
|
|
|
+ const result = await transaction.insert(this.tableName, stagePay);
|
|
|
+ if (result.affectedRows !== 1) {
|
|
|
+ throw '新增数据失败';
|
|
|
+ }
|
|
|
+ stagePay.id = result.insertId;
|
|
|
+ return stagePay;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存本期金额/表达式
|
|
|
* @param data
|
|
|
- * @returns {Promise<{ledger: {}, pos: {}}>}
|
|
|
+ * @returns {Promise<void>}
|
|
|
*/
|
|
|
- // async updateStageData(data) {
|
|
|
- // let refreshData;
|
|
|
- // const transaction = await this.db.beginTransaction();
|
|
|
- // try {
|
|
|
- // if ((data.updateType === 'add' || data.upateType === 'delete') && this.ctx.tender.measure_type === measureType.tz) {
|
|
|
- // throw '台账模式下,不可在计量中新增或删除部位明细,如需操作,请进行台账修订';
|
|
|
- // }
|
|
|
- // if (data.updateType === 'add') {
|
|
|
- // refreshData = await this._addStagePosData(transaction, data.updateData);
|
|
|
- // } else if (data.updateType === 'update') {
|
|
|
- // refreshData = await this._updateStagePosData(transaction, data.updateData);
|
|
|
- // console.log(refreshData);
|
|
|
- // } else if (data.updateType === 'delete') {
|
|
|
- // if (!data.updateData || data.updateData.length === 0) {
|
|
|
- // throw '提交数据错误';
|
|
|
- // }
|
|
|
- // refreshData = await this._deleteStagePosData(transaction, data.updateData);
|
|
|
- // } else {
|
|
|
- // throw '提交数据错误';
|
|
|
- // }
|
|
|
- // await transaction.commit();
|
|
|
- // } catch (err) {
|
|
|
- // await transaction.rollback();
|
|
|
- // throw err;
|
|
|
- // }
|
|
|
- //
|
|
|
- // try {
|
|
|
- // const result = {ledger: {}, pos: {}};
|
|
|
- // if (refreshData.ledger && refreshData.ledger.length > 0) {
|
|
|
- // result.ledger.bills = await this.ctx.service.ledger.getDataByIds(refreshData.ledger);
|
|
|
- // if (refreshData.stageUpdate) {
|
|
|
- // result.ledger.curStageData = await await this.ctx.service.stageBills.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, refreshData.ledger);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (refreshData.pos && refreshData.pos.length > 0) {
|
|
|
- // result.pos.pos = await this.ctx.service.pos.getPosData({id: refreshData.pos});
|
|
|
- // if (refreshData.stageUpdate) {
|
|
|
- // result.pos.curStageData = await this.getLastestStageData(this.ctx.tender.id, this.ctx.stage.id, refreshData.pos);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // return result;
|
|
|
- // } catch(err) {
|
|
|
- // throw '获取数据异常,请刷新页面。';
|
|
|
- // }
|
|
|
- // }
|
|
|
+ async save(data) {
|
|
|
+ const transaction = await this.db.beginTransaction();
|
|
|
+ try {
|
|
|
+ // 更新数据
|
|
|
+ const stagePay = await this.getStagePay(this.ctx.stage, data.pid);
|
|
|
+ const updateData = { id: stagePay.id };
|
|
|
+ if (data.expr !== undefined) { updateData.expr = data.expr }
|
|
|
+ if (data.tp !== undefined) { updateData.tp = data.tp }
|
|
|
+ if (data.pause !== undefined) { updateData.pause = data.pause }
|
|
|
+ const result = await transaction.update(this.tableName, updateData);
|
|
|
+ if (result.affectedRows !== 1) {
|
|
|
+ throw '保存数据失败';
|
|
|
+ }
|
|
|
+ // 缓存至pay
|
|
|
+ if (data.expr !== undefined) {
|
|
|
+ const pr = await transaction.update(this.ctx.service.pay.tableName, {
|
|
|
+ id: data.pid, expr: data.expr
|
|
|
+ });
|
|
|
+ if (pr.affectedRows !== 1) {
|
|
|
+ throw '保存数据失败';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ await transaction.commit();
|
|
|
+ } catch(err) {
|
|
|
+ await transaction.rollback();
|
|
|
+ throw err;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算
|
|
|
+ * @param stage
|
|
|
+ * @param transaction
|
|
|
+ * @returns {Promise<boolean>}
|
|
|
+ */
|
|
|
+ async calcAllStagePays(stage, transaction) {
|
|
|
+ if (!stage || !transaction) {
|
|
|
+ throw '计算数据错误';
|
|
|
+ }
|
|
|
+ const stagePays = await this.getStagePays(stage);
|
|
|
+ const PayCalculator = require('../lib/pay_calc');
|
|
|
+ const payCalculator = new PayCalculator(this.ctx, this.ctx.tender.info.decimal);
|
|
|
+ await payCalculator.calculateAll(stagePays);
|
|
|
+ for (const sp of stagePays) {
|
|
|
+ await transaction.update(this.tableName, {
|
|
|
+ id: sp.id,
|
|
|
+ tp: sp.tp,
|
|
|
+ end_tp: sp.end_tp
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 拷贝上一操作人数据 为 下一操作人数据
|
|
|
+ * @param stage - 期数据
|
|
|
+ * @param times - 下一操作人 该期第几次
|
|
|
+ * @param order - 下一操作人顺序
|
|
|
+ * @param transaction - 事务
|
|
|
+ * @returns {Promise<*>}
|
|
|
+ */
|
|
|
+ async copyAuditStagePays(stage, times, order, transaction) {
|
|
|
+ console.log(times);
|
|
|
+ console.log(order);
|
|
|
+ if (!stage || !transaction || !times || !order) {
|
|
|
+ throw '数据错误';
|
|
|
+ }
|
|
|
+ const sql = 'INSERT INTO ?? (`tid`, `sid`, `pid`, `stimes`, `sorder`, `expr`, `pause`, `attachment`, `pre_tp`) ' +
|
|
|
+ ' SELECT SP.`tid`, SP.`sid`, SP.`pid`, ?, ?, SP.`expr`, SP.`pause`, SP.`attachment`, SP.`pre_tp` ' +
|
|
|
+ ' FROM ?? As SP, ?? As P ' +
|
|
|
+ ' WHERE SP.`sid` = ? AND SP.`stimes` = ? AND SP.`sorder` = ? And SP.`pid` = P.`id` And P.`valid`';
|
|
|
+ const sqlParam = [this.tableName, times, order, this.tableName, this.ctx.service.pay.tableName,
|
|
|
+ stage.id, stage.times, stage.curAuditor ? stage.curAuditor.order : 0];
|
|
|
+ return await transaction.query(sql, sqlParam);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return StagePay;
|