repository = $repository; } /** * @Author:Qinii * @Date: 2020/5/8 * @Time: 14:40 * @return mixed */ public function lst() { return app('json')->success($this->repository->getFormatList([['is_show', '=', 1],['level','<',2]])); } /** * @return mixed * @author Qinii */ public function getlist() { return app('json')->success($this->repository->getFormatList(['is_show' => 1])); } public function newgetlist(){ $regions = Db::name('regions') -> field('id,name,pid') -> select() -> toArray(); return app('json')->success(formatCategory($regions)); } public function getNewFiveList() { $code_list=[]; $area_list = Db::name('area_manage')->cache('area_manage',3600)->column('code_list'); foreach ($area_list as $area) { $area = explode(',', $area); $code_list[] = end($area); } $pid = $this->request->param('pid',0);//上级地区id $regions = Db::name('regions_new')->field('id,name,pid')->where('pid', $pid)->select() ->each(function ($item) use ($code_list) { $item['is_exist_area'] = (int)in_array($item['id'], $code_list); if($item['name']=='其他') $item['is_exist_area'] =1; return $item; })->toArray(); return app('json')->success($regions); } /** * 默认地址是否是五级地址 * @return mixed */ public function getDefaultisFive() { $uid = $this->request->param('uid', 0);//上级地区id $addressRepository = app()->make(UserAddressRepository::class); $address = $addressRepository->getWhere(['uid' => $uid, 'is_default' => 1]); if (empty($address)) return app('json')->success(['is_five' => 0]); if (empty($address['village_id'])) return app('json')->success(['is_five' => 0]); return app('json')->success(['is_five' => 1]); } }