1234567891011121314151617181920212223242526272829303132333435363738 |
- 'use strict';
- /**
- * 调差表(多期独立单价使用) 数据模型
- *
- * @author Mai
- * @date 2018/8/13
- * @version
- */
- module.exports = app => {
- class MaterialStage extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'material_stage';
- }
- async updateMtp(transaction, id) {
- const sql = 'SELECT SUM(`m_tp`) as total_price, SUM(IF(`m_tax_tp` is null, `m_tp`, `m_tax_tp`)) as tax_total_price FROM ' + this.ctx.service.materialStageBills.tableName + ' WHERE `tid` = ? AND `ms_id` = ? AND `is_summary` = 1';
- const sqlParam = [this.ctx.tender.id, id];
- const tp = await transaction.queryOne(sql, sqlParam);
- const updateData2 = {
- id,
- m_tp: tp.total_price,
- m_tax_tp: tp.tax_total_price,
- };
- return await transaction.update(this.tableName, updateData2);
- }
- }
- return MaterialStage;
- };
|