123456789101112131415161718192021222324252627282930313233343536373839404142 |
- '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, Sum(cb.samount + 0) 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;
- }
- }
- return ChangeAuditList;
- };
|