|  | @@ -38,21 +38,17 @@ module.exports = app => {
 | 
	
		
			
				|  |  |           * @return {Promise<*>}
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          async getAuditor(tenderId, auditorId, times = 1) {
 | 
	
		
			
				|  |  | -            const sql =
 | 
	
		
			
				|  |  | -                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
 | 
	
		
			
				|  |  | -                'FROM ?? AS la, ?? AS pa ' +
 | 
	
		
			
				|  |  | -                'WHERE la.`tender_id` = ? and la.`audit_id` = ? and la.`times` = ?' +
 | 
	
		
			
				|  |  | -                '    and la.`audit_id` = pa.`id`';
 | 
	
		
			
				|  |  | +            const sql = 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
 | 
	
		
			
				|  |  | +                '  FROM ?? AS la Left Join ?? AS pa ON la.`audit_id` = pa.`id`' +
 | 
	
		
			
				|  |  | +                '  WHERE la.`tender_id` = ? and la.`audit_id` = ? and la.`times` = ?';
 | 
	
		
			
				|  |  |              const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditorId, times];
 | 
	
		
			
				|  |  |              return await this.db.queryOne(sql, sqlParam);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          async getAuditorByOrder(tenderId, order, times = 1) {
 | 
	
		
			
				|  |  | -            const sql =
 | 
	
		
			
				|  |  | -                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
 | 
	
		
			
				|  |  | -                'FROM ?? AS la, ?? AS pa ' +
 | 
	
		
			
				|  |  | -                'WHERE la.`tender_id` = ? and la.`audit_order` = ? and la.`times` = ?' +
 | 
	
		
			
				|  |  | -                '    and la.`audit_id` = pa.`id`';
 | 
	
		
			
				|  |  | +            const sql = 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
 | 
	
		
			
				|  |  | +                '  FROM ?? AS la Left Join ?? AS pa ON la.`audit_id` = pa.`id`' +
 | 
	
		
			
				|  |  | +                '  WHERE la.`tender_id` = ? and la.`audit_order` = ? and la.`times` = ?';
 | 
	
		
			
				|  |  |              const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, order, times];
 | 
	
		
			
				|  |  |              return await this.db.queryOne(sql, sqlParam);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -78,11 +74,8 @@ module.exports = app => {
 | 
	
		
			
				|  |  |           * @return {Promise<*>}
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          async getStatusName(tenderId, times) {
 | 
	
		
			
				|  |  | -            const sql =
 | 
	
		
			
				|  |  | -                'SELECT pa.`name` ' +
 | 
	
		
			
				|  |  | -                'FROM ?? AS la, ?? AS pa ' +
 | 
	
		
			
				|  |  | -                'WHERE la.`tender_id` = ?' +
 | 
	
		
			
				|  |  | -                '    and la.`audit_id` = pa.`id` and la.`status` != ? ORDER BY la.`times` DESC, la.`audit_order` DESC';
 | 
	
		
			
				|  |  | +            const sql = 'SELECT pa.`name` FROM ?? AS la Left Join ?? AS pa ON la.`audit_id` = pa.`id`' +
 | 
	
		
			
				|  |  | +                '  WHERE la.`tender_id` = ? and la.`status` != ? ORDER BY la.`times` DESC, la.`audit_order` DESC';
 | 
	
		
			
				|  |  |              const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.uncheck];
 | 
	
		
			
				|  |  |              return await this.db.queryOne(sql, sqlParam);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -113,8 +106,8 @@ module.exports = app => {
 | 
	
		
			
				|  |  |          async getFinalAuditGroup(tenderId, times = 1) {
 | 
	
		
			
				|  |  |              const sql =
 | 
	
		
			
				|  |  |                  'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.`sign_path`, la.`times`, la.`tender_id`, Max(la.`audit_order`) as max_order ' +
 | 
	
		
			
				|  |  | -                'FROM ?? AS la, ?? AS pa ' +
 | 
	
		
			
				|  |  | -                'WHERE la.`tender_id` = ? and la.`times` = ? and la.`audit_id` = pa.`id` GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
 | 
	
		
			
				|  |  | +                '  FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
 | 
	
		
			
				|  |  | +                '  WHERE la.`tender_id` = ? and la.`times` = ? GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
 | 
	
		
			
				|  |  |              const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, times];
 | 
	
		
			
				|  |  |              const result = await this.db.query(sql, sqlParam);
 | 
	
		
			
				|  |  |              for (const r of result) {
 | 
	
	
		
			
				|  | @@ -137,9 +130,8 @@ module.exports = app => {
 | 
	
		
			
				|  |  |          async getCurAuditor(tenderId, times = 1) {
 | 
	
		
			
				|  |  |              const sql =
 | 
	
		
			
				|  |  |                  'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
 | 
	
		
			
				|  |  | -                'FROM ?? AS la, ?? AS pa ' +
 | 
	
		
			
				|  |  | -                'WHERE la.`tender_id` = ? and la.`status` = ? and la.`times` = ?' +
 | 
	
		
			
				|  |  | -                '    and la.`audit_id` = pa.`id`';
 | 
	
		
			
				|  |  | +                '  FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
 | 
	
		
			
				|  |  | +                '  WHERE la.`tender_id` = ? and la.`status` = ? and la.`times` = ?';
 | 
	
		
			
				|  |  |              const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, auditConst.status.checking, times];
 | 
	
		
			
				|  |  |              return await this.db.queryOne(sql, sqlParam);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -441,9 +433,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |          async getAuditTender(auditorId) {
 | 
	
		
			
				|  |  |              const sql =
 | 
	
		
			
				|  |  |                  'SELECT la.`audit_id`, la.`times`, la.`audit_order`, la.`begin_time`, la.`end_time`, t.`id`, t.`name`, t.`project_id`, t.`type`, t.`user_id`, t.`ledger_status` ' +
 | 
	
		
			
				|  |  | -                'FROM ?? AS la, ?? AS t ' +
 | 
	
		
			
				|  |  | -                'WHERE ((la.`audit_id` = ? and la.`status` = ?) OR (t.`user_id` = ? and t.`ledger_status` = ? and la.`status` = ? and la.`times` = (t.`ledger_times`-1)))' +
 | 
	
		
			
				|  |  | -                '    and la.`tender_id` = t.`id` ORDER BY la.`begin_time` DESC';
 | 
	
		
			
				|  |  | +                '  FROM ?? AS la Left Join ?? AS t ON la.`tender_id` = t.`id` ' +
 | 
	
		
			
				|  |  | +                '  WHERE ((la.`audit_id` = ? and la.`status` = ?) OR (t.`user_id` = ? and t.`ledger_status` = ? and la.`status` = ? and la.`times` = (t.`ledger_times`-1)))' +
 | 
	
		
			
				|  |  | +                '    ORDER BY la.`begin_time` DESC';
 | 
	
		
			
				|  |  |              const sqlParam = [
 | 
	
		
			
				|  |  |                  this.tableName,
 | 
	
		
			
				|  |  |                  this.ctx.service.tender.tableName,
 | 
	
	
		
			
				|  | @@ -464,17 +456,6 @@ module.exports = app => {
 | 
	
		
			
				|  |  |           * @return {Promise<*>}
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          async getNoticeTender(pid, uid, noticeTime) {
 | 
	
		
			
				|  |  | -            // const sql = 'SELECT * FROM (SELECT la.`audit_id`, la.`times`, la.`audit_order`, la.`end_time`, la.`status`, t.`id`, t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
 | 
	
		
			
				|  |  | -            //             '    pa.name As `lu_name`, pa.role As `lu_role`, pa.company As `lu_company`' +
 | 
	
		
			
				|  |  | -            //             '  FROM (SELECT * FROM ?? WHERE `user_id` = ? OR `id` in (SELECT `tender_id` FROM ?? WHERE `audit_id` = ? GROUP BY `tender_id`)) As t ' +
 | 
	
		
			
				|  |  | -            //             '  LEFT JOIN ?? As la ON la.`tender_id` = t.`id`' +
 | 
	
		
			
				|  |  | -            //             '  LEFT JOIN ?? As pa ON la.`audit_id` = pa.`id`' +
 | 
	
		
			
				|  |  | -            //             '  WHERE la.`end_time` > ? and t.`project_id` = ?' +
 | 
	
		
			
				|  |  | -            //             '  ORDER By la.`end_time` DESC LIMIT 1000) as new_t GROUP BY new_t.`id` ORDER BY new_t.`end_time`';
 | 
	
		
			
				|  |  | -            // const sqlParam = [this.ctx.service.tender.tableName, auditorId, this.tableName, auditorId, this.tableName, this.ctx.service.projectAccount.tableName,
 | 
	
		
			
				|  |  | -            //     noticeTime, projectId];
 | 
	
		
			
				|  |  | -            // return await this.db.query(sql, sqlParam);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              let notice = await this.db.select('zh_notice', {
 | 
	
		
			
				|  |  |                  where: { pid, type: pushType.ledger, uid },
 | 
	
		
			
				|  |  |                  orders: [['create_time', 'desc']],
 | 
	
	
		
			
				|  | @@ -516,8 +497,8 @@ module.exports = app => {
 | 
	
		
			
				|  |  |          async getAuditGroupByList(tender_id, times = 1) {
 | 
	
		
			
				|  |  |              const sql =
 | 
	
		
			
				|  |  |                  'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.`audit_order` ' +
 | 
	
		
			
				|  |  | -                'FROM ?? AS la, ?? AS pa ' +
 | 
	
		
			
				|  |  | -                'WHERE la.`tender_id` = ? and la.`times` = ? and la.`audit_id` = pa.`id` GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
 | 
	
		
			
				|  |  | +                '  FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id`' +
 | 
	
		
			
				|  |  | +                '  WHERE la.`tender_id` = ? and la.`times` = ? GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
 | 
	
		
			
				|  |  |              const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tender_id, times];
 | 
	
		
			
				|  |  |              return await this.db.query(sql, sqlParam);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -532,12 +513,8 @@ module.exports = app => {
 | 
	
		
			
				|  |  |              const result = await this.getAuditGroupByList(tender_id, times);
 | 
	
		
			
				|  |  |              const sql =
 | 
	
		
			
				|  |  |                  'SELECT pa.`id` As audit_id, pa.`name`, pa.`company`, pa.`role`, ? As times, ? As tender_id, 0 As `audit_order`' +
 | 
	
		
			
				|  |  | -                '  FROM ' +
 | 
	
		
			
				|  |  | -                this.ctx.service.tender.tableName +
 | 
	
		
			
				|  |  | -                ' As s' +
 | 
	
		
			
				|  |  | -                '  LEFT JOIN ' +
 | 
	
		
			
				|  |  | -                this.ctx.service.projectAccount.tableName +
 | 
	
		
			
				|  |  | -                ' As pa' +
 | 
	
		
			
				|  |  | +                '  FROM ' + this.ctx.service.tender.tableName + ' As s' +
 | 
	
		
			
				|  |  | +                '  LEFT JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa' +
 | 
	
		
			
				|  |  |                  '  ON s.user_id = pa.id' +
 | 
	
		
			
				|  |  |                  '  WHERE s.id = ?';
 | 
	
		
			
				|  |  |              const sqlParam = [times, tender_id, tender_id];
 |