change_audit_list.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2018/8/14
  7. * @version
  8. */
  9. const audit = require('../const/audit');
  10. module.exports = app => {
  11. class ChangeAuditList extends app.BaseService {
  12. /**
  13. * 构造函数
  14. *
  15. * @param {Object} ctx - egg全局变量
  16. * @return {void}
  17. */
  18. constructor(ctx) {
  19. super(ctx);
  20. this.tableName = 'change_audit_list';
  21. }
  22. async gatherBgBills (tid) {
  23. const sql = 'SELECT code, name, unit, unit_price, Sum(camount) as quantity' +
  24. ' FROM ' + this.tableName +
  25. ' WHERE tid = ?' +
  26. ' GROUP BY code, name, unit, unit_price';
  27. const param = [tid];
  28. const result = await this.db.query(sql, param);
  29. for (const b of result) {
  30. b.total_price = this.ctx.helper.mul(b.unit_price, b.quantity, this.ctx.tender.info.decimal.tp);
  31. }
  32. return result;
  33. }
  34. }
  35. return ChangeAuditList;
  36. };