Commit 47b6a1ce authored by liuyuzhen's avatar liuyuzhen

测试地址信息

parent f9869d22
...@@ -12,8 +12,9 @@ class CityController extends \Our\Controller_AbstractIndex { ...@@ -12,8 +12,9 @@ class CityController extends \Our\Controller_AbstractIndex {
} }
public function getCityListAction(){ public function getCityListAction(){
$fromWx = $this->req[\Our\NameConst::data]['fromWx'];
$addressService = \Business\User\AddressServiceModel::getInstance(); $addressService = \Business\User\AddressServiceModel::getInstance();
$cityList = $addressService->getCityList(); $cityList = $addressService->getCityList($fromWx);
$this->success($cityList); $this->success($cityList);
} }
} }
\ No newline at end of file
...@@ -395,9 +395,13 @@ class AddressServiceModel extends \Business\AbstractModel { ...@@ -395,9 +395,13 @@ class AddressServiceModel extends \Business\AbstractModel {
* 获取城市列表 * 获取城市列表
* @return bool * @return bool
*/ */
public function getCityList(){ public function getCityList($fromWx=false){
$areaDao =\DAO\AreaModel::getInstance(); $areaDao =\DAO\AreaModel::getInstance();
$citList = $areaDao->getCityList(); if($fromWx){
$citList = $areaDao->getCityListWithoutCounty();
}else{
$citList = $areaDao->getCityList();
}
if($citList){ if($citList){
return $citList; return $citList;
} }
......
...@@ -50,6 +50,32 @@ class AreaModel extends \DAO\AbstractModel { ...@@ -50,6 +50,32 @@ class AreaModel extends \DAO\AbstractModel {
return $result; return $result;
} }
public function getCityListWithoutCounty(){
$addressRedis = AddressRedisModel::getInstance();
$cityList = $addressRedis->find('cityListWithoutCounty');
if($cityList){
return $cityList;
}
$areaList = $this->getAllCityList(true);
$addressRedis->update('allCityListWithoutCounty',$areaList);
$cityListInitial = array();
$cityInitialList = array();
foreach($areaList as $area){
if(isset($area['initial'])&&$area['initial']&&!($cityInitialList&&in_array($area['initial'],$cityInitialList))){
$cityInitialList[] = $area['initial'];
}
$cityListInitial[$area['initial']][] = $area['area_name'];
}
$list = array();
foreach($cityInitialList as $inital){
$initalCity['initial'] = $inital;
$initalCity['list'] = $cityListInitial[$inital];
$list[] = $initalCity;
}
$addressRedis->update('cityListWithoutCounty',$list);
return $list;
}
public function getCityList(){ public function getCityList(){
$addressRedis = AddressRedisModel::getInstance(); $addressRedis = AddressRedisModel::getInstance();
...@@ -78,14 +104,18 @@ class AreaModel extends \DAO\AbstractModel { ...@@ -78,14 +104,18 @@ class AreaModel extends \DAO\AbstractModel {
return $list; return $list;
} }
public function getAllCityList(){ public function getAllCityList($withoutCounty=false){
$this->setDb($this->dbName); $this->setDb($this->dbName);
$sql = " SELECT t1.area_name, t2.f_py as initial FROM han_area t1 "; $sql = " SELECT t1.area_name, t2.f_py as initial FROM han_area t1 ";
$sql .= " left join han_coslers t2 "; $sql .= " left join han_coslers t2 ";
$sql .= " on CONV(HEX(LEFT(CONVERT(t1.area_name USING gbk ), 1)), 16, 10) BETWEEN t2.cbegin AND t2.cend $sql .= " on CONV(HEX(LEFT(CONVERT(t1.area_name USING gbk ), 1)), 16, 10) BETWEEN t2.cbegin AND t2.cend
where t1.is_city=1 "; where t1.is_city=1 ";
if($withoutCounty){
$sql .= " and t1.area_name not like '%县'";
}
$sql .= " ORDER BY t1.area_deep,convert(t1.area_name using gbk) ASC "; $sql .= " ORDER BY t1.area_deep,convert(t1.area_name using gbk) ASC ";
$area_list = $this->db->query($sql)->rows; $area_list = $this->db->query($sql)->rows;
echo $this->db->getLastSql();
return $area_list; return $area_list;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment