| 
					
				 | 
			
			
				@@ -60,18 +60,9 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 'FROM ?? AS la, ?? AS pa, (SELECT `aid`,(@i:=@i+1) as `sort` FROM ??, (select @i:=0) as it WHERE `sid` = ? AND `times` = ? GROUP BY `aid`) as g ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 'WHERE la.`sid` = ? and la.`times` = ? and la.`aid` = pa.`id` and g.`aid` = la.`aid` order by la.`order` ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 order_sort 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sqlParam = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.projectAccount.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                stageId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                times, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                stageId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                times 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.tableName, stageId, times, stageId, times] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const result = await this.db.query(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql2 = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'SELECT COUNT(a.`aid`) as num FROM (SELECT `aid` FROM ?? WHERE `sid` = ? AND `times` = ? GROUP BY `aid`) as a' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sql2 = 'SELECT COUNT(a.`aid`) as num FROM (SELECT `aid` FROM ?? WHERE `sid` = ? AND `times` = ? GROUP BY `aid`) as a' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const sqlParam2 = [this.tableName, stageId, times] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const count = await this.db.queryOne(sql2, sqlParam2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             for (const i in result) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -81,15 +72,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getAllAuditors(tenderId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'SELECT sa.aid, sa.tid FROM ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.tableName + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ' sa' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                '  LEFT JOIN ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.tender.tableName + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ' t On sa.tid = t.id' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                '  WHERE t.id = ?' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                '  GROUP BY  sa.aid' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sql = 'SELECT sa.aid, sa.tid FROM ' + this.tableName + ' sa' + '  LEFT JOIN ' + this.ctx.service.tender.tableName + ' t On sa.tid = t.id' + '  WHERE t.id = ?' + '  GROUP BY  sa.aid' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const sqlParam = [tenderId] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return this.db.query(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -103,17 +86,8 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * @return {Promise<*>} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getStatusName(stageId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'SELECT pa.`name` ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'FROM ?? AS sa, ?? AS pa ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'WHERE sa.`sid` = ?' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                '    and sa.`aid` = pa.`id` and sa.`status` != ? ORDER BY sa.`times` DESC, sa.`order` DESC' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sqlParam = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.projectAccount.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                stageId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                auditConst.status.uncheck 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sql = 'SELECT pa.`name` ' + 'FROM ?? AS sa, ?? AS pa ' + 'WHERE sa.`sid` = ?' + '    and sa.`aid` = pa.`id` and sa.`status` != ? ORDER BY sa.`times` DESC, sa.`order` DESC' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, auditConst.status.uncheck] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return await this.db.queryOne(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -130,13 +104,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 'FROM ?? AS la, ?? AS pa ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 'WHERE la.`sid` = ? and la.`status` = ? and la.`times` = ?' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '    and la.`aid` = pa.`id`' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sqlParam = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.projectAccount.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                stageId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                auditConst.status.checking, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                times 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, auditConst.status.checking, times] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return await this.db.queryOne(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -300,21 +268,8 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const stageInfo = await this.ctx.service.stage.getDataById(audit.sid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const shenpiUrl = await this.ctx.helper.urlToShort( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'http://' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.request.header.host + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        '/wap/tender/' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.tender.id + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        '/stage/' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        stageInfo.order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.helper.sendAliSms( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    audit.aid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    smsTypeConst.const.JL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    smsTypeConst.judge.approval.toString(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    SmsAliConst.template.stage_check, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    { qi: stageInfo.order, code: shenpiUrl } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.helper.sendAliSms(audit.aid, smsTypeConst.const.JL, smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order, code: shenpiUrl }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // todo 更新标段tender状态 ? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.commit() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -345,7 +300,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         pid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         type: pushType.stage, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         uid: this.ctx.stage.user_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        status: auditConst.status.checkNo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        status: auditConst.status.checked, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         content: noticeContent 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ] 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -354,7 +309,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         pid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         type: pushType.stage, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         uid: audit.aid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        status: auditConst.status.checkNo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        status: auditConst.status.checked, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         content: noticeContent 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -379,12 +334,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 无下一审核人表示,审核结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (nextAudit) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 复制一份下一审核人数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    await this.ctx.service.stagePay.copyAuditStagePays( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.stage, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.stage.times, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        nextAudit.order, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        transaction 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, nextAudit.order, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     await this.ctx.service.stageOther.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -424,32 +374,13 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     const stageInfo = await this.ctx.service.stage.getDataById(nextAudit.sid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    const shenpiUrl = await this.ctx.helper.urlToShort( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        'http://' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            this.ctx.request.header.host + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            '/wap/tender/' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            this.ctx.tender.id + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            '/stage/' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            stageInfo.order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    await this.ctx.helper.sendAliSms( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        nextAudit.aid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        smsTypeConst.const.JL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        smsTypeConst.judge.approval.toString(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        SmsAliConst.template.stage_check, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        { qi: stageInfo.order, code: shenpiUrl } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    await this.ctx.helper.sendAliSms(nextAudit.aid, smsTypeConst.const.JL, smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order, code: shenpiUrl }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 本期结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 生成截止本期数据 final数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    console.time('generatePre') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    await this.ctx.service.stageBillsFinal.generateFinalData( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        transaction, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.tender, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.stage 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    await this.ctx.service.stageBillsFinal.generateFinalData(transaction, this.ctx.tender, this.ctx.stage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     await this.ctx.service.stagePosFinal.generateFinalData(transaction, this.ctx.tender, this.ctx.stage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    console.timeEnd('generatePre') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 同步 期信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     await transaction.update(this.ctx.service.stage.tableName, { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         id: stageId, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -492,13 +423,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     //     sms.send(mobile_array, content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     const users = this._.pull(this._.map(auditList, 'aid'), stageInfo.user_id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    await this.ctx.helper.sendAliSms( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        users, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        smsTypeConst.const.JL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        smsTypeConst.judge.result.toString(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        SmsAliConst.template.stage_result, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        { qi: stageInfo.order, status: SmsAliConst.status.success } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    await this.ctx.helper.sendAliSms(users, smsTypeConst.const.JL, smsTypeConst.judge.result.toString(), SmsAliConst.template.stage_result, { qi: stageInfo.order, status: SmsAliConst.status.success }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.commit() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (err) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -515,8 +440,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw '审核数据错误' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const tpData = await this.ctx.service.stageBills.getSumTotalPrice(this.ctx.stage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'SELECT `tid`, `sid`, `aid`, `order` FROM ?? WHERE `sid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sql = 'SELECT `tid`, `sid`, `aid`, `order` FROM ?? WHERE `sid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const sqlParam = [this.tableName, stageId, times] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const auditors = await this.db.query(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             let order = 1 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -584,12 +508,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 计算该审批人最终数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 复制一份最新数据给原报 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.service.stagePay.copyAuditStagePays( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage.times + 1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    transaction 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times + 1, 0, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -623,13 +542,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //     sms.send(mobile_array, content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const users = this._.pull(this._.map(auditList, 'aid'), stageInfo.user_id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.helper.sendAliSms( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    users, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    smsTypeConst.const.JL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    smsTypeConst.judge.result.toString(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    SmsAliConst.template.stage_result, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    { qi: stageInfo.order, status: SmsAliConst.status.back } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.helper.sendAliSms(users, smsTypeConst.const.JL, smsTypeConst.judge.result.toString(), SmsAliConst.template.stage_result, { qi: stageInfo.order, status: SmsAliConst.status.back }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.commit() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.rollback() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -735,12 +648,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 计算该审批人最终数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stagePay.calcAllStagePays(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 复制一份最新数据给下一人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.service.stagePay.copyAuditStagePays( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage.times, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    audit.order + 1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    transaction 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, audit.order + 1, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stageOther.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -769,21 +677,8 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const stageInfo = await this.ctx.service.stage.getDataById(audit.sid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const shenpiUrl = await this.ctx.helper.urlToShort( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'http://' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.request.header.host + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        '/wap/tender/' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.tender.id + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        '/stage/' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        stageInfo.order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.helper.sendAliSms( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    preAuditor.aid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    smsTypeConst.const.JL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    smsTypeConst.judge.approval.toString(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    SmsAliConst.template.stage_check, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    { qi: stageInfo.order, code: shenpiUrl } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.helper.sendAliSms(preAuditor.aid, smsTypeConst.const.JL, smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order, code: shenpiUrl }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.commit() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (err) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -800,11 +695,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * @return {Promise<void>} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async check(stageId, checkData, times = 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                checkData.checkType !== auditConst.status.checked && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                checkData.checkType !== auditConst.status.checkNo && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                checkData.checkType !== auditConst.status.checkNoPre 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (checkData.checkType !== auditConst.status.checked && checkData.checkType !== auditConst.status.checkNo && checkData.checkType !== auditConst.status.checkNoPre) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw '提交数据错误' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // // 整理当前流程审核人状态更新 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -990,29 +881,15 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.insert(this.tableName, newAuditors) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 复制一份最新数据给下一人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.service.stagePay.copyAuditStagePays( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage.times, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    audit.order + 1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    transaction 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.service.stagePay.copyAuditStagePays( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage.times, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    audit.order + 2, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    transaction 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, audit.order + 1, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, audit.order + 2, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stageJgcl.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stageBonus.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stageOther.updateHistory(this.ctx.stage, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 本期结束 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 生成截止本期数据 final数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.service.stageBillsFinal.delGenerateFinalData( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    transaction, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.tender, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.service.stageBillsFinal.delGenerateFinalData(transaction, this.ctx.tender, this.ctx.stage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await this.ctx.service.stagePosFinal.delGenerateFinalData(transaction, this.ctx.tender, this.ctx.stage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 同步 期信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.update(this.ctx.service.stage.tableName, { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1038,21 +915,8 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const stageInfo = await this.ctx.service.stage.getDataById(audit.sid) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const shenpiUrl = await this.ctx.helper.urlToShort( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'http://' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.request.header.host + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        '/wap/tender/' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.tender.id + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        '/stage/' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        stageInfo.order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.helper.sendAliSms( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    audit.aid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    smsTypeConst.const.JL, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    smsTypeConst.judge.approval.toString(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    SmsAliConst.template.stage_check, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    { qi: stageInfo.order, code: shenpiUrl } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const shenpiUrl = await this.ctx.helper.urlToShort('http://' + this.ctx.request.header.host + '/wap/tender/' + this.ctx.tender.id + '/stage/' + stageInfo.order) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.helper.sendAliSms(audit.aid, smsTypeConst.const.JL, smsTypeConst.judge.approval.toString(), SmsAliConst.template.stage_check, { qi: stageInfo.order, code: shenpiUrl }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.commit() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } catch (err) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 await transaction.rollback() 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1074,16 +938,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  FROM ?? AS sa, ?? AS s, ?? As t ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  WHERE ((sa.`aid` = ? and sa.`status` = ?) OR (s.`user_id` = ? and sa.`status` = ? and s.`status` = ? and sa.`times` = (s.`times`-1)))' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '    and sa.`sid` = s.`id` and sa.`tid` = t.`id`' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sqlParam = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.stage.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.tender.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                auditorId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                auditConst.status.checking, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                auditorId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                auditConst.status.checkNo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                auditConst.status.checkNo 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sqlParam = [this.tableName, this.ctx.service.stage.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checking, auditorId, auditConst.status.checkNo, auditConst.status.checkNo] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return await this.db.query(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1138,15 +993,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  LEFT JOIN ?? As s On s.`id` =  ?' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  LEFT JOIN ?? As pa ON pa.`id` = ?' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  WHERE  t.`project_id` = ? ) as new_t GROUP BY new_t.`tid`' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const noticeSqlParam = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.tender.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                tid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.stage.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                sid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.projectAccount.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                uid, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                pid 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const noticeSqlParam = [this.ctx.service.tender.tableName, tid, this.ctx.service.stage.tableName, sid, this.ctx.service.projectAccount.tableName, uid, pid] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const content = await this.db.query(noticeSql, noticeSqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return content.length ? JSON.stringify(content[0]) : '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1247,13 +1094,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order` ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         'FROM ?? AS la, ?? AS pa ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         'WHERE la.`sid` = ? and la.`status` = ? and la.`times` = ? and la.`aid` = pa.`id` order by la.`times` desc, la.`order` desc' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    sqlParam = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        this.ctx.service.projectAccount.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        stageId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        auditConst.status.checkNo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        parseInt(times) - 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, auditConst.status.checkNo, parseInt(times) - 1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     auditor = await this.db.queryOne(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     break 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 case auditConst.status.uncheck: 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1271,11 +1112,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          * @return {Promise<boolean>} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				          */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         async getStageAudit(stageId, times = 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sql = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'SELECT a1.aid, a1.begin_time, a1.end_time, a1.status, a1.opinion ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'FROM ?? AS a1 ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'WHERE a1.`sid` = ? and a1.`times` = ? ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                'ORDER BY a1.order' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sql = 'SELECT a1.aid, a1.begin_time, a1.end_time, a1.status, a1.opinion ' + 'FROM ?? AS a1 ' + 'WHERE a1.`sid` = ? and a1.`times` = ? ' + 'ORDER BY a1.order' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const sqlParam = [this.tableName, stageId, times] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             const rst = await this.db.query(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return rst 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1297,14 +1134,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  FROM ?? AS sa, ?? AS s, ?? As t, ?? AS ti ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '  WHERE sa.`aid` = ? and sa.`status` = ?' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 '    and sa.`sid` = s.`id` and sa.`tid` = t.`id` and ti.`tid` = t.`id`' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const sqlParam = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.stage.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.tender.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                this.ctx.service.tenderInfo.tableName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                auditorId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                auditConst.status.checking 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const sqlParam = [this.tableName, this.ctx.service.stage.tableName, this.ctx.service.tender.tableName, this.ctx.service.tenderInfo.tableName, auditorId, auditConst.status.checking] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return await this.db.query(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1350,8 +1180,7 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     await this._timesDelete(this.ctx.stage.id, nowTimes, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 // 添加上一次审批人 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const sql = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    'SELECT `tid`, `sid`, `aid`, `order` FROM ?? WHERE `sid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const sql = 'SELECT `tid`, `sid`, `aid`, `order` FROM ?? WHERE `sid` = ? and `times` = ? GROUP BY `aid` ORDER BY `id` ASC' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const sqlParam = [this.tableName, this.ctx.stage.id, nowTimes - 1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const auditors = await this.db.query(sql, sqlParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 let order = 1 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1375,19 +1204,8 @@ module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (!lastAudit) throw '审批数据错误' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                await this.ctx.service.stagePay.copyStagePays4DeleteTimes( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    nowTimes, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    0, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    lastAudit.times, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    lastAudit.order, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    transaction 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const stagePay = await this.ctx.service.stagePay.getAuditorStageData( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    this.ctx.stage.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    lastAudit.times, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    lastAudit.order 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                await this.ctx.service.stagePay.copyStagePays4DeleteTimes(this.ctx.stage, nowTimes, 0, lastAudit.times, lastAudit.order, transaction) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                const stagePay = await this.ctx.service.stagePay.getAuditorStageData(this.ctx.stage.id, lastAudit.times, lastAudit.order) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 const yfPay = stagePay.find(function (x) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     return x.ptype === payConst.payType.yf 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 }) 
			 |