Пример #1
0
 public function testGetCity()
 {
     $regional = new Regional();
     $data = $regional->getCity('上海市');
     $this->assertEquals(array(array('上海市')), $data);
     $regional = new Regional();
     $data = $regional->getCity('北京市');
     $this->assertEquals(array(array('北京市')), $data);
     return $data;
 }
Пример #2
0
 /**
  * 设置Custom
  *
  * @param $startStandards
  * @param $startFees
  * @param $addStandards
  * @param $addFees
  * @param $destProvince
  * @param null $destCity
  * @param string $destCountry
  * @return $this
  * @throws ShopsException
  */
 public function setCustom($startStandards, $startFees, $addStandards, $addFees, $destProvince, $destCity = null, $destCountry = '中国')
 {
     if (empty($destProvince)) {
         throw new ShopsException('$destProvince不允许为空');
     }
     $this->custom = array();
     //todo 未做反选,排除一个城市,选择其他
     if (empty($destCity)) {
         //todo  $destProvince的判断
         //todo  加入 全国省直辖市的 简称等
         //todo 加入 某些不平等条约的存在 例如 江浙沪 ,你们懂得!!
         $destProvince = is_string($destProvince) ? array($destProvince) : $destProvince;
         $regional = new Regional();
         foreach ($destProvince as $province) {
             $citys = $regional->getCity($province);
             if (empty($citys)) {
                 throw new ShopsException('请传入合法的省份名!!!');
             }
             foreach ($citys[0] as $city) {
                 $this->data['custom'][] = array('StartStandards' => $startStandards, 'StartFees' => $startFees, 'AddStandards' => $addStandards, 'AddFees' => $addFees, 'DestCountry' => $destCountry, 'DestProvince' => $province, 'DestCity' => $city);
             }
         }
         return $this;
     } else {
         //todo 未做省份的检测
         //todo 未做市检测
         $destCity = is_string($destCity) ? array($destCity) : $destCity;
         if (is_array($destCity)) {
             foreach ($destCity as $city) {
                 $this->data['custom'][] = array('StartStandards' => $startStandards, 'StartFees' => $startFees, 'AddStandards' => $addStandards, 'AddFees' => $addFees, 'DestCountry' => $destCountry, 'DestProvince' => $destProvince, 'DestCity' => $city);
             }
         }
         return $this;
     }
 }