Exemplo n.º 1
0
 /**
  * 通过区县标识获取开通城市ID
  * @param $district
  * @return int
  */
 public static function districtToOpenCityId($district)
 {
     // 获取地区的区号
     $area = SysAreaZipDistrictPhonecode::findFirst('K_ID = ' . $district);
     if (!$area) {
         return 0;
     }
     $phoneCode = $area->PHONE_CODE;
     $openCityInfo = SysOpenCity::query()->where('city_code = :code:', ['code' => $phoneCode])->execute()->getFirst();
     if (!$openCityInfo) {
         return 0;
     }
     return $openCityInfo->city_id;
 }
Exemplo n.º 2
0
 /**
  * 获取开通城市的ID
  * @param $code
  * @return int
  */
 public function getCityId($code)
 {
     $city = SysOpenCity::query()->columns('city_id')->where('city_code=:code: and city_state = 1')->bind(['code' => $code])->limit(1)->execute()->getFirst();
     return $city ? $city->city_id : 0;
 }
Exemplo n.º 3
0
 /**
  * 开通城市管理列表
  * @date: 2016年1月6日 
  * @author: chenxiaolin
  */
 public function openCityListAction()
 {
     $this->setLeftNav('openCityList');
     $req = $this->request;
     $page = intval($req->getQuery('page', null, 1));
     $page = $page > 0 ? $page : 1;
     $limit = $this->pageNavLimit;
     $offset = $limit * ($page - 1);
     $filterCity = $req->getQuery('filterCity', null, -10000);
     $filterState = $req->getQuery('filterState', null, -10000);
     $where = [];
     if ($filterCity > -10000) {
         $where[] = " city_id = {$filterCity} ";
     }
     if ($filterState > -10000) {
         $where[] = " city_state = {$filterState} ";
     }
     $whereStr = implode(' AND ', $where);
     $data = SysOpenCity::query()->where($whereStr)->execute();
     $this->view->setVar('openCity', SysOpenCity::find());
     $this->view->setVar('filterCity', $filterCity);
     $this->view->setVar('filterState', $filterState);
     //$this->view->setVar('data', SysOpenCity::find($where));
     $this->view->setVar('data', $data);
 }
Exemplo n.º 4
0
 public function run()
 {
     $data = SysOpenCity::query()->columns(['city_code code', 'city_name name'])->where('city_state = 1')->orderBy('city_order DESC, city_id ASC')->execute()->toArray();
     $this->setResult($data);
 }