612155,'GY'=>215851,'YD'=>721143,'XS'=>116555,'YH'=>135435,'ZY'=> 123456]; public static function encodeId($type,$id){ if(!isset(self::$offset[$type])){ throw new ApiException("{$type}类型不存在"); } return $type.($id+self::$offset[$type]); } public static function decodeId($id){ if(!$id){ return 0; } preg_match('/([A-Z]{2})(\d+)/s',$id,$macths); if(!isset($macths[1]) || !isset(self::$offset[$macths[1]])){ throw new ApiException("{$macths[1]}类型不存在"); } ; return (int)$macths[2]-self::$offset[$macths[1]]; } }