|  | @ -14,7 +14,7 @@ class mUser extends mBase { | 
			
		
	
		
		
			
				
					|  |  |         $this->tbl = 'tcm_user'; |  |  |         $this->tbl = 'tcm_user'; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |     public function getUid($code) { |  |  |     public function getUserInfo($code) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         $openid = $this->getOpenid($code); |  |  |         $openid = $this->getOpenid($code); | 
			
		
	
		
		
			
				
					|  |  |         if (!$openid) { |  |  |         if (!$openid) { | 
			
		
	
		
		
			
				
					|  |  |             $this->setError('获取openid失败'); |  |  |             $this->setError('获取openid失败'); | 
			
		
	
	
		
		
			
				
					|  | @ -22,23 +22,23 @@ class mUser extends mBase { | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         $user = $this->getUserByOpenid($openid); |  |  |         $user = $this->getUserByOpenid($openid); | 
			
		
	
		
		
			
				
					
					|  |  |         if ($user) return $user['uid']; |  |  |         if ($user) return $user; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         //获取唯一uid串 |  |  |         //获取唯一uid串 | 
			
		
	
		
		
			
				
					
					|  |  |         $uid = $this->createUniqueUid($openid); |  |  |         $identifier = $this->createUniqueID($openid); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         $user = $this->getUserByUid($uid); |  |  |         $user = $this->getUserByIdentifier($identifier); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |         if ($user) { |  |  |         if ($user) { | 
			
		
	
		
		
			
				
					|  |  |             $this->setError('uid生成失败'); |  |  |             $this->setError('uid生成失败'); | 
			
		
	
		
		
			
				
					|  |  |             return false; |  |  |             return false; | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |         $id = $this->createUser(array('uid' => $uid, 'openid' => $openid)); |  |  |         $uid = $this->createUser(array('identifier' => $identifier, 'openid' => $openid)); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         if (!$id) { |  |  |         if (!$uid) { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |             $this->setError('用户创建失败'); |  |  |             $this->setError('用户创建失败'); | 
			
		
	
		
		
			
				
					|  |  |             return false; |  |  |             return false; | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |         return $id; |  |  |         return $this->getUserByUid($uid); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     public function getOpenid($code) { |  |  |     public function getOpenid($code) { | 
			
		
	
	
		
		
			
				
					|  | @ -63,13 +63,17 @@ class mUser extends mBase { | 
			
		
	
		
		
			
				
					|  |  |         return $this->obj->select($this->tbl, array('sql' => '`openid`=?', 'vals' => array($openid))); |  |  |         return $this->obj->select($this->tbl, array('sql' => '`openid`=?', 'vals' => array($openid))); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |     function createUniqueUid($openid) { |  |  |     function createUniqueID($openid) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         $uuid = uniqid($openid, true); |  |  |         $uuid = uniqid($openid, true); | 
			
		
	
		
		
			
				
					|  |  |         $hash = hash('sha256', $uuid); |  |  |         $hash = hash('sha256', $uuid); | 
			
		
	
		
		
			
				
					|  |  |         $decimal = base_convert(substr($hash, 0, 16), 16, 10); |  |  |         $decimal = base_convert(substr($hash, 0, 16), 16, 10); | 
			
		
	
		
		
			
				
					|  |  |         return substr($decimal, 0, 10); |  |  |         return substr($decimal, 0, 10); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public function getUserByIdentifier($identifier) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return $this->obj->select($this->tbl, array('sql' => '`identifier`=?', 'vals' => array($identifier))); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     public function getUserByUid($uid) { |  |  |     public function getUserByUid($uid) { | 
			
		
	
		
		
			
				
					|  |  |         return $this->obj->select($this->tbl, array('sql' => '`uid`=?', 'vals' => array($uid))); |  |  |         return $this->obj->select($this->tbl, array('sql' => '`uid`=?', 'vals' => array($uid))); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
	
		
		
			
				
					|  | 
 |