| 
					
				 | 
			
			
				@@ -1,55 +0,0 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-'use strict'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * @author Mai 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * @date 2018/6/1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- * @version 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-module.exports = app => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    class CooperationPwd extends app.BaseService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         * 构造函数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         * @param {Object} ctx - egg全局变量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         * @return {void} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-         */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        constructor(ctx) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            super(ctx); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            this.tableName = 'cooperation_pwd'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        async save(data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const info = await this.getDataByCondition({ tid: this.ctx.tender.id, ledger_id: data.ledger_id, uid: this.ctx.session.sessionUser.accountId }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (info) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const updateData = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    id: info.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    pwd: data.pwd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    create_time: new Date(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return await this.db.update(this.tableName, updateData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const insertData = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                tid: this.ctx.tender.id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                uid: this.ctx.session.sessionUser.accountId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ledger_id: data.ledger_id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                pwd: data.pwd, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                create_time: new Date(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return await this.db.insert(this.tableName, insertData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        async getValidData(tid, uid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            const condition = { where: { tid } }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (uid) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                condition.where.uid = uid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                condition.colums = ['ledger_id', 'pwd']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return await this.getAllDataByCondition(condition); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return CooperationPwd; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-}; 
			 |