| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- /**
- * @package merchant
- * @Author: Qinii
- * @Date: 2020/5/6
- * @Time: 14:37
- */
- namespace app\controller\merchant\store\shipping;
- use app\common\repositories\user\UserAddressRepository;
- use think\App;
- use crmeb\basic\BaseController;
- use app\common\repositories\store\shipping\CityRepository as repository;
- use think\facade\Db;
- class City extends BaseController
- {
- protected $repository;
- /**
- * City constructor.
- * @param App $app
- * @param repository $repository
- */
- public function __construct(App $app, repository $repository)
- {
- parent::__construct($app);
- $this->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 newList()
- {
- $regions = Db::name('regions')
- ->where('level', '<=', 2)
- ->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]);
- }
- }
|