pinyin($update); $update['where_id'] = $id; Dever::db($table)->update($update); } } public function level($id, $name, $data) { $update = array(); $city = Dever::param('city', $data); if ($city) { Dever::db('area/city')->updateLevel(array('where_level_id' => $id, 'set_level_id' => -1)); $city = explode('、', $city); foreach ($city as $k => $v) { $v = trim($v); if (!$v) { continue; } $w['name'] = $v; $source = Dever::db('area/city')->getDatas($w); if ($source) { foreach ($source as $k => $v) { $update['where_id'] = $v['id']; $update['level_id'] = $id; Dever::db('area/city')->update($update); } } } if ($id == 1) { $this->setTown_api(); } } } # 设置国家镇级市、超级街道 public function setTown_api() { $data = array ( # 镇级市 '河南省,安阳市,安阳县,水冶镇', '河南省,信阳市,平桥区,明港镇', '河南省,郑州市,巩义市,回郭镇',//'河南省,巩义市,安阳县,回郭镇', '甘肃省,武威市,凉州区,黄羊镇', '甘肃省,定西市,陇西县,首阳镇', '甘肃省,天水市,甘谷县,磐安镇', '广西,南宁市,宾阳县,黎塘镇', '广西,梧州市,藤县,太平镇', '广西,北海市,合浦县,公馆镇', '广西,贵港市,平南县,大安镇', '吉林省,长春市,公主岭市,范家屯镇',//'吉林省,四平市,公主岭市,范家屯镇', '吉林省,四平市,梨树县,郭家店镇', '吉林省,吉林市,吉林中国新加坡食品区,岔路河镇',// '吉林省,吉林市,永吉县,岔路河镇', '吉林省,白山市,抚松县,松江河镇',//'吉林省,吉林市,抚松县,松江河镇', '辽宁省,锦州市,北镇市,沟帮子街道 ',//'辽宁省,锦州市,北镇市,沟帮子镇', '辽宁省,辽阳市,辽阳县,刘二堡镇',//'辽宁省,辽阳市,辽阳县,刘二堡新市镇', '辽宁省,铁岭市,昌图县,八面城镇', '黑龙江省,哈尔滨市,巴彦县,兴隆镇', '黑龙江省,牡丹江市,海林市,柴河镇', '黑龙江省,牡丹江市,宁安市,东京城镇', '黑龙江省,伊春市,大箐山县,朗乡镇',//'黑龙江省,伊春市,铁力市,朗乡镇', '黑龙江省,黑龙江农垦总局,建三江农垦分局,三江镇',//未知 '黑龙江省,红兴隆市,红兴隆农垦分局,兴隆镇',//未知 '黑龙江省,鹤岗市,萝北县,宝泉岭农场',//'黑龙江省,宝泉岭市,宝泉岭农垦分局,宝泉岭镇', '黑龙江省,鸡西市,密山市,裴德镇',//'黑龙江省,牡丹江市,牡丹江农垦分局,裴德镇', '黑龙江省,黑河市,嫩江市,双山镇',//'黑龙江省,九三垦区分局,九三垦区分局,双山镇', '江苏省,苏州市,吴江区,盛泽镇', '江苏省,无锡市,宜兴市,丁蜀镇', '江苏省,南通市,启东市,启东吕四镇',//未知 '河北省,廊坊市,三河市,燕郊镇', '河北省,廊坊市,霸州市,胜芳镇', '江西省,南昌市,南昌县,向塘镇', '安徽省,宿州市,萧县,黄口镇', '安徽省,亳州市,谯城区,古城镇', '湖南省,郴州市,永兴县,马田镇', '湖南省,怀化市,洪江市,安江镇', '湖南省,益阳市,桃江县,灰山港镇', '湖北省,襄阳市,樊城区,太平店镇',//'湖北省,襄阳市,襄阳区,太平店镇', '湖北省,荆门市,钟祥市,胡集镇', '湖北省,孝感市,汉川市,马口镇', '湖北省,宜昌市,夷陵区,龙泉镇', '福建省,漳州市,龙海市,角美镇', '福建省,泉州市,南安市,水头镇', '福建省,泉州市,晋江市,东石镇', '福建省,莆田市,秀屿区,忠门镇', '浙江省,温州,苍南县,龙港镇', '浙江省,绍兴市,诸暨市,店口镇', '重庆市,重庆市,江津区,白沙镇', '重庆市,重庆市,大足区,龙水镇', '重庆市,重庆市,九龙坡区,西彭镇', '四川省,南充市,仪陇县,金城镇', '四川省,内江市,资中县,重龙镇', '四川省,广元市,利州区,宝轮镇', '四川省,达州市,宣汉县,南坝镇', '广东省,佛山市,南海区,狮山镇', '广东省,东莞市,东莞市,长安镇', '广东省,东莞市,东莞市,虎门镇', '广东省,东莞市,东莞市,塘厦镇', # 超级街道 '广东省,深圳市,南山区,粤海街道', '广东省,深圳市,龙岗区,坂田街道', '广东省,深圳市,龙岗区,布吉街道', '广东省,深圳市,龙岗区,龙城街道', '广东省,深圳市,龙岗区,平湖街道', '广东省,深圳市,龙岗区,龙岗街道', ); foreach ($data as $k => $v) { $temp = explode(',', $v); if (isset($temp[3])) { $province = Dever::db('area/province')->getLike(array('name' => $temp[0])); if ($province) { $city = Dever::db('area/city')->getLike(array('name' => $temp[1], 'province_id' => $province['id'])); if ($city) { $county = Dever::db('area/county')->getLike(array('name' => $temp[2], 'city_id' => $city['id'])); if ($county) { $town = Dever::db('area/town')->getLike(array('name' => $temp[3], 'county_id' => $county['id'])); if ($town) { if (strstr($temp[3], '街道')) { $type = 3; } else { $type = 2; } Dever::db('area/town')->update(array('where_id' => $town['id'], 'type' => $type)); } } } } } } return 'ok'; } public function outProvince($data) { $file = Dever::input('excel_name'); $header = array('区域ID', '区域名称', '区域拼音', '区域拼音首字母'); $body = array(); if ($data) { foreach ($data as $k => $v) { if (is_array($v)) { $d = array ( $v['id'], $v['name'], $v['pinyin'], $v['pinyin_first'], ); $body[] = $d; } } } return Dever::excelExport($body, $header, $file); } public function outCity($data) { $file = Dever::input('excel_name'); $header = array('区域ID', '区域名称', '区域拼音', '区域拼音首字母', '区域价值', '区域状态', '上级区域ID', '上级区域名称'); $body = array(); if ($data) { foreach ($data as $k => $v) { if (is_array($v)) { $province = Dever::db('area/province')->find($v['province_id']); if (!$province) { $province['name'] = ''; } $status = '未占用'; if ($v['status'] == 2) { $status = '已占用'; } if ($v['price'] < 0) { $price = Dever::load('area/api')->getPrice(1, $v['province_id'] . ',' . $v['id']); } else { $price = $v['price'] * 10000; } $d = array ( $v['id'], $v['name'], $v['pinyin'], $v['pinyin_first'], $price, $status, $v['province_id'], $province['name'] ); $body[] = $d; } } } return Dever::excelExport($body, $header, $file); } public function outCounty($data) { $file = Dever::input('excel_name'); $header = array('区域ID', '区域名称', '区域拼音', '区域拼音首字母', '区域价值', '区域状态', '上级区域ID', '上级区域名称'); $body = array(); if ($data) { foreach ($data as $k => $v) { if (is_array($v)) { $province = Dever::db('area/province')->find($v['province_id']); $city = Dever::db('area/city')->find($v['city_id']); if (!$province) { $province['name'] = ''; } if (!$city) { $city['name'] = ''; } $status = '未占用'; if ($v['status'] == 2) { $status = '已占用'; } //$v['name'] = $province['name'] . '' . $city['name'] . '' . $v['name']; if ($v['price'] < 0) { $price = Dever::load('area/api')->getPrice(2, $v['province_id'] . ',' . $v['city_id'] . ',' . $v['id']); } else { $price = $v['price'] * 10000; } $d = array ( $v['id'], $v['name'], $v['pinyin'], $v['pinyin_first'], $price, $status, $v['city_id'], $province['name'] . $city['name'] ); $body[] = $d; } } } return Dever::excelExport($body, $header, $file); } public function outTown($data) { $file = Dever::input('excel_name'); $header = array('区域ID', '区域名称', '区域拼音', '区域拼音首字母', '区域价值', '区域状态', '上级区域ID', '上级区域名称'); $body = array(); if ($data) { foreach ($data as $k => $v) { if (is_array($v)) { $province = Dever::db('area/province')->find($v['province_id']); $city = Dever::db('area/city')->find($v['city_id']); $county = Dever::db('area/county')->find($v['county_id']); if (!$province) { $province['name'] = ''; } if (!$city) { $city['name'] = ''; } if (!$county) { $county['name'] = ''; } $status = '未占用'; if ($v['status'] == 2) { $status = '已占用'; } //$v['name'] = $province['name'] . '' . $city['name'] . '' . $county['name'] . '' . $v['name']; if ($v['price'] < 0) { $price = Dever::load('area/api')->getPrice(3, $v['province_id'] . ',' . $v['city_id'] . ',' . $v['county_id'] . ',' . $v['id']); } else { $price = $v['price'] * 10000; } $d = array ( $v['id'], $v['name'], $v['pinyin'], $v['pinyin_first'], $price, $status, $v['county_id'], $province['name'] . $city['name'] . $county['name'] ); $body[] = $d; } } } return Dever::excelExport($body, $header, $file); } }