1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date 2018/8/14
- * @version
- */
- const audit = require('../const/audit');
- module.exports = app => {
- class ChangeAuditList extends app.BaseService {
- /**
- * 构造函数
- *
- * @param {Object} ctx - egg全局变量
- * @return {void}
- */
- constructor(ctx) {
- super(ctx);
- this.tableName = 'change_audit_list';
- }
- async gatherBgBills(tid) {
- const sql = 'SELECT cb.code, cb.name, cb.unit, cb.unit_price, Round(Sum(cb.samount + 0), 6) as quantity' +
- ' FROM ' + this.tableName + ' cb' +
- ' LEFT JOIN ' + this.ctx.service.change.tableName + ' c ON cb.cid = c.cid' +
- ' WHERE cb.tid = ? and c.status = ?' +
- ' GROUP BY code, name, unit, unit_price';
- const param = [tid, audit.flow.status.checked];
- const result = await this.db.query(sql, param);
- for (const b of result) {
- b.total_price = this.ctx.helper.mul(b.unit_price, b.quantity, this.ctx.tender.info.decimal.tp);
- }
- return result;
- }
- /**
- * 报表用
- * Tony Kang
- * @param {tid} tid - 标段id
- * @return {void}
- */
- async getChangeAuditBills(tid) {
- const sql = 'SELECT cb.*' +
- ' FROM ' + this.tableName + ' cb' +
- ' LEFT JOIN ' + this.ctx.service.change.tableName + ' c ON cb.cid = c.cid' +
- ' WHERE c.tid = ? and c.status = 3' +
- ' ORDER BY cb.cid, cb.code';
- const param = [tid];
- const result = await this.db.query(sql, param);
- return result;
- }
- }
- return ChangeAuditList;
- };
|