|  | @@ -341,7 +341,7 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                          sql =
 | 
	
		
			
				|  |  |                              'SELECT a.* FROM ?? AS a WHERE a.tid = ? AND' +
 | 
	
		
			
				|  |  |                              ' (a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
 | 
	
		
			
				|  |  | -                            ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid))' +
 | 
	
		
			
				|  |  | +                            // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
 | 
	
		
			
				|  |  |                              ' OR a.status = ?)' + stateSql;
 | 
	
		
			
				|  |  |                          sqlParam = [
 | 
	
		
			
				|  |  |                              this.tableName,
 | 
	
	
		
			
				|  | @@ -350,9 +350,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                              audit.change.status.uncheck,
 | 
	
		
			
				|  |  |                              this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  |                              this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | -                            audit.change.status.checkNo,
 | 
	
		
			
				|  |  | -                            this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | -                            this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | +                            // audit.change.status.checkNo,
 | 
	
		
			
				|  |  | +                            // this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | +                            // this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  |                              audit.change.status.checked,
 | 
	
		
			
				|  |  |                          ];
 | 
	
		
			
				|  |  |                          break;
 | 
	
	
		
			
				|  | @@ -364,8 +364,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                          sql =
 | 
	
		
			
				|  |  |                              'SELECT a.* FROM ?? AS a WHERE' +
 | 
	
		
			
				|  |  |                              ' (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
 | 
	
		
			
				|  |  | -                            (this.ctx.session.sessionUser.is_admin ? '' : ' AND ((a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
 | 
	
		
			
				|  |  | -                            ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid)))');
 | 
	
		
			
				|  |  | +                            (this.ctx.session.sessionUser.is_admin ? '' : ' AND (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))'
 | 
	
		
			
				|  |  | +                            // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)))'
 | 
	
		
			
				|  |  | +                            );
 | 
	
		
			
				|  |  |                          sqlParam = [
 | 
	
		
			
				|  |  |                              this.tableName,
 | 
	
		
			
				|  |  |                              audit.change.status.uncheck,
 | 
	
	
		
			
				|  | @@ -375,18 +376,18 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                              audit.change.status.uncheck,
 | 
	
		
			
				|  |  |                              this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  |                              this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | -                            audit.change.status.checkNo,
 | 
	
		
			
				|  |  | -                            this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | -                            this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | +                            // audit.change.status.checkNo,
 | 
	
		
			
				|  |  | +                            // this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | +                            // this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  |                          ];
 | 
	
		
			
				|  |  |                          break;
 | 
	
		
			
				|  |  |                      case 2: // 进行中(所有的)
 | 
	
		
			
				|  |  |                      case 4: // 终止(所有的)
 | 
	
		
			
				|  |  |                          sql =
 | 
	
		
			
				|  |  |                              'SELECT a.* FROM ?? AS a WHERE ' +
 | 
	
		
			
				|  |  | -                            'a.status = ? AND a.tid = ?' + stateSql +
 | 
	
		
			
				|  |  | +                            '(a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
 | 
	
		
			
				|  |  |                              (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)');
 | 
	
		
			
				|  |  | -                        sqlParam = [this.tableName, status, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
 | 
	
		
			
				|  |  | +                        sqlParam = [this.tableName, status, audit.change.status.checkNoPre, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
 | 
	
		
			
				|  |  |                          break;
 | 
	
		
			
				|  |  |                      case 3: // 已完成(所有的)
 | 
	
		
			
				|  |  |                          sql = 'SELECT a.* FROM ?? AS a WHERE a.status = ? AND a.tid = ?' + stateSql;
 | 
	
	
		
			
				|  | @@ -434,7 +435,7 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                      const sql =
 | 
	
		
			
				|  |  |                          'SELECT count(*) AS count FROM ?? AS a WHERE a.tid = ? AND ' +
 | 
	
		
			
				|  |  |                          '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
 | 
	
		
			
				|  |  | -                        ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid))' +
 | 
	
		
			
				|  |  | +                        // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
 | 
	
		
			
				|  |  |                          ' OR a.status = ? )' + stateSql;
 | 
	
		
			
				|  |  |                      const sqlParam = [
 | 
	
		
			
				|  |  |                          this.tableName,
 | 
	
	
		
			
				|  | @@ -443,9 +444,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                          audit.change.status.uncheck,
 | 
	
		
			
				|  |  |                          this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  |                          this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | -                        audit.change.status.checkNo,
 | 
	
		
			
				|  |  | -                        this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | -                        this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | +                        // audit.change.status.checkNo,
 | 
	
		
			
				|  |  | +                        // this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | +                        // this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  |                          audit.change.status.checked,
 | 
	
		
			
				|  |  |                      ];
 | 
	
		
			
				|  |  |                      const result = await this.db.query(sql, sqlParam);
 | 
	
	
		
			
				|  | @@ -464,8 +465,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                      const sql2 =
 | 
	
		
			
				|  |  |                          'SELECT count(*) AS count FROM ?? AS a WHERE' +
 | 
	
		
			
				|  |  |                          ' (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
 | 
	
		
			
				|  |  | -                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND ((a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
 | 
	
		
			
				|  |  | -                            ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid)))');
 | 
	
		
			
				|  |  | +                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))'
 | 
	
		
			
				|  |  | +                        // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)))'
 | 
	
		
			
				|  |  | +                        );
 | 
	
		
			
				|  |  |                      const sqlParam2 = [
 | 
	
		
			
				|  |  |                          this.tableName,
 | 
	
		
			
				|  |  |                          audit.change.status.uncheck,
 | 
	
	
		
			
				|  | @@ -475,9 +477,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                          audit.change.status.uncheck,
 | 
	
		
			
				|  |  |                          this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  |                          this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | -                        audit.change.status.checkNo,
 | 
	
		
			
				|  |  | -                        this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | -                        this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | +                        // audit.change.status.checkNo,
 | 
	
		
			
				|  |  | +                        // this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | +                        // this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  |                      ];
 | 
	
		
			
				|  |  |                      const result2 = await this.db.query(sql2, sqlParam2);
 | 
	
		
			
				|  |  |                      return result2[0].count;
 | 
	
	
		
			
				|  | @@ -485,9 +487,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                  case 4: // 终止(所有的)
 | 
	
		
			
				|  |  |                      const sql3 =
 | 
	
		
			
				|  |  |                          'SELECT count(*) AS count FROM ?? AS a WHERE ' +
 | 
	
		
			
				|  |  | -                        'a.status = ? AND a.tid = ?' + stateSql +
 | 
	
		
			
				|  |  | +                        '(a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
 | 
	
		
			
				|  |  |                          (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)');
 | 
	
		
			
				|  |  | -                    const sqlParam3 = [this.tableName, status, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
 | 
	
		
			
				|  |  | +                    const sqlParam3 = [this.tableName, status, audit.change.status.checkNoPre, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
 | 
	
		
			
				|  |  |                      const result3 = await this.db.query(sql3, sqlParam3);
 | 
	
		
			
				|  |  |                      return result3[0].count;
 | 
	
		
			
				|  |  |                  case 3: // 已完成(所有的)
 | 
	
	
		
			
				|  | @@ -513,7 +515,7 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                      const sql =
 | 
	
		
			
				|  |  |                          'SELECT SUM(cast (a.total_price as decimal(18,6))) AS total_price FROM ?? AS a WHERE a.tid = ? AND ' +
 | 
	
		
			
				|  |  |                          '(a.uid = ? OR (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
 | 
	
		
			
				|  |  | -                        ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid))' +
 | 
	
		
			
				|  |  | +                        // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid))' +
 | 
	
		
			
				|  |  |                          ' OR a.status = ? )' + stateSql;
 | 
	
		
			
				|  |  |                      const sqlParam = [
 | 
	
		
			
				|  |  |                          this.tableName,
 | 
	
	
		
			
				|  | @@ -522,9 +524,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                          audit.change.status.uncheck,
 | 
	
		
			
				|  |  |                          this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  |                          this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | -                        audit.change.status.checkNo,
 | 
	
		
			
				|  |  | -                        this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | -                        this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | +                        // audit.change.status.checkNo,
 | 
	
		
			
				|  |  | +                        // this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | +                        // this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  |                          audit.change.status.checked,
 | 
	
		
			
				|  |  |                      ];
 | 
	
		
			
				|  |  |                      const result = await this.db.query(sql, sqlParam);
 | 
	
	
		
			
				|  | @@ -538,8 +540,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                      const sql2 =
 | 
	
		
			
				|  |  |                          'SELECT SUM(cast (a.total_price as decimal(18,6))) AS total_price FROM ?? AS a WHERE' +
 | 
	
		
			
				|  |  |                          ' (a.status = ? OR a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
 | 
	
		
			
				|  |  | -                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND ((a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))' +
 | 
	
		
			
				|  |  | -                            ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid)))');
 | 
	
		
			
				|  |  | +                        (this.ctx.session.sessionUser.is_admin ? '' : ' AND (a.status != ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid))'
 | 
	
		
			
				|  |  | +                        // ' OR (a.status = ? AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? AND a.times - 1 = b.times GROUP BY b.cid)))'
 | 
	
		
			
				|  |  | +                        );
 | 
	
		
			
				|  |  |                      const sqlParam2 = [
 | 
	
		
			
				|  |  |                          this.tableName,
 | 
	
		
			
				|  |  |                          audit.change.status.uncheck,
 | 
	
	
		
			
				|  | @@ -549,9 +552,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                          audit.change.status.uncheck,
 | 
	
		
			
				|  |  |                          this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  |                          this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | -                        audit.change.status.checkNo,
 | 
	
		
			
				|  |  | -                        this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | -                        this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  | +                        // audit.change.status.checkNo,
 | 
	
		
			
				|  |  | +                        // this.ctx.service.changeAudit.tableName,
 | 
	
		
			
				|  |  | +                        // this.ctx.session.sessionUser.accountId,
 | 
	
		
			
				|  |  |                      ];
 | 
	
		
			
				|  |  |                      const result2 = await this.db.query(sql2, sqlParam2);
 | 
	
		
			
				|  |  |                      return result2[0].total_price ? result2[0].total_price : 0;
 | 
	
	
		
			
				|  | @@ -559,9 +562,9 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                  case 4: // 终止(所有的)
 | 
	
		
			
				|  |  |                      const sql3 =
 | 
	
		
			
				|  |  |                          'SELECT SUM(cast (a.total_price as decimal(18,6))) AS total_price FROM ?? AS a WHERE ' +
 | 
	
		
			
				|  |  | -                        'a.status = ? AND a.tid = ?' + stateSql +
 | 
	
		
			
				|  |  | +                        '(a.status = ? OR a.status = ?) AND a.tid = ?' + stateSql +
 | 
	
		
			
				|  |  |                          (this.ctx.session.sessionUser.is_admin ? '' : ' AND a.cid IN (SELECT b.cid FROM ?? AS b WHERE b.uid = ? GROUP BY b.cid)');
 | 
	
		
			
				|  |  | -                    const sqlParam3 = [this.tableName, status, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
 | 
	
		
			
				|  |  | +                    const sqlParam3 = [this.tableName, status, audit.change.status.checkNoPre, tenderId, this.ctx.service.changeAudit.tableName, this.ctx.session.sessionUser.accountId];
 | 
	
		
			
				|  |  |                      const result3 = await this.db.query(sql3, sqlParam3);
 | 
	
		
			
				|  |  |                      return result3[0].total_price ? result3[0].total_price : 0;
 | 
	
		
			
				|  |  |                  case 3: // 已完成(所有的)
 |