request->param()); $i++) { if ($obj = $this->request->param($i)) { $code = $obj["code"]; $dict = \app\common\model\Dict::where("code", $code)->findOrEmpty(); $childs = \app\common\model\Dict::where("pid", $dict["id"])->order("num")->select(); $result[$obj["name"]] = $childs; } } return json(["code" => "200", "msg" => "", "obj" => $result]); } public function getProvinceSelect() { $where = []; $where[] = ["code", "like", "%0000"]; return json(Db::table("un_common_location")->where($where)->select()->toArray()); } public function findCityByProvinceSelect() { $code = $this->request->param("code"); $province_prefix = substr($code, 0, 2); return json(Db::table("un_common_location")->where("code", "like", $province_prefix . "%00")->select()->toArray()); } public function findCountyByCitySelect() { $code = $this->request->param("code"); $city_prefix = substr($code, 0, 4); return json(Db::table("un_common_location")->where("code", "like", $city_prefix . "%")->select()->toArray()); } /** * 通过地区编码找下级地区,比如传入35就找35**00,传入3505就找3505** * @return type */ public function findChildAreaByCode() { $param = $this->request->param(); $code = $param["code"]; $where[] = ["code", "like", str_pad($code . "%%", 6, 0)]; $where[] = ["code", "<>", str_pad($code . "00", 6, 0)]; if (isset($param["no"])) { $where[] = ["code", "<>", $param["no"]]; } return json(Db::table("un_common_location")->where($where)->select()->toArray()); } }