更新地址数据源
This commit is contained in:
parent
7006c44e73
commit
e33828e405
@ -16,6 +16,12 @@ namespace app\common\dao\store;
|
|||||||
use app\common\dao\BaseDao;
|
use app\common\dao\BaseDao;
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
use app\common\model\store\CityArea;
|
use app\common\model\store\CityArea;
|
||||||
|
use app\common\model\store\GeoProvince;
|
||||||
|
use app\common\model\store\GeoCity;
|
||||||
|
use app\common\model\store\GeoArea;
|
||||||
|
use app\common\model\store\GeoStreet;
|
||||||
|
use app\common\model\store\GeoVillage;
|
||||||
|
use app\common\model\store\GeoBrigade;
|
||||||
|
|
||||||
class CityAreaDao extends BaseDao
|
class CityAreaDao extends BaseDao
|
||||||
{
|
{
|
||||||
@ -53,10 +59,36 @@ class CityAreaDao extends BaseDao
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query->whereLike('path', $path . '%')->where('name', $street);
|
$query->getVillage('path', $path . '%')->where('name', $street);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function searchGeo(array $where)
|
||||||
|
{
|
||||||
|
if (!empty($where['street_code'])) {
|
||||||
|
return GeoVillage::getDB()->where('street_code', $where['street_code']);
|
||||||
|
}
|
||||||
|
if (!empty($where['area_code'])) {
|
||||||
|
return GeoStreet::getDB()->where('area_code', $where['area_code']);
|
||||||
|
}
|
||||||
|
if (!empty($where['city_code'])) {
|
||||||
|
return GeoArea::getDB()->where('city_code', $where['city_code']);
|
||||||
|
}
|
||||||
|
if (!empty($where['province_code'])) {
|
||||||
|
return GeoCity::getDB()->where('province_code', $where['province_code']);
|
||||||
|
}
|
||||||
|
if (empty($where['province_code'])) {
|
||||||
|
return GeoProvince::getDB();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchBrigade(array $where)
|
||||||
|
{
|
||||||
|
return GeoBrigade::getDB();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getCityList(CityArea $city)
|
public function getCityList(CityArea $city)
|
||||||
{
|
{
|
||||||
if (!$city->parent_id) return [$city];
|
if (!$city->parent_id) return [$city];
|
||||||
|
30
app/common/model/store/GeoBrigade.php
Normal file
30
app/common/model/store/GeoBrigade.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\common\model\store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
class GeoBrigade extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function tablePk(): ?string
|
||||||
|
{
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tableName(): string
|
||||||
|
{
|
||||||
|
return 'geo_brigade';
|
||||||
|
}
|
||||||
|
}
|
31
app/common/model/store/GeoCity.php
Normal file
31
app/common/model/store/GeoCity.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\common\model\store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
class GeoCity extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function tablePk(): ?string
|
||||||
|
{
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tableName(): string
|
||||||
|
{
|
||||||
|
return 'geo_city';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
app/common/model/store/GeoProvince.php
Normal file
30
app/common/model/store/GeoProvince.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\common\model\store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
class GeoProvince extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function tablePk(): ?string
|
||||||
|
{
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tableName(): string
|
||||||
|
{
|
||||||
|
return 'geo_province';
|
||||||
|
}
|
||||||
|
}
|
30
app/common/model/store/GeoStreet.php
Normal file
30
app/common/model/store/GeoStreet.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\common\model\store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
class GeoStreet extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function tablePk(): ?string
|
||||||
|
{
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tableName(): string
|
||||||
|
{
|
||||||
|
return 'geo_street';
|
||||||
|
}
|
||||||
|
}
|
30
app/common/model/store/GeoVillage.php
Normal file
30
app/common/model/store/GeoVillage.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
namespace app\common\model\store;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
class GeoVillage extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function tablePk(): ?string
|
||||||
|
{
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tableName(): string
|
||||||
|
{
|
||||||
|
return 'geo_village';
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,16 @@ class CityAreaRepository extends BaseRepository
|
|||||||
return $this->search(['pid' => $pid])->select();
|
return $this->search(['pid' => $pid])->select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getGeoChildren($where)
|
||||||
|
{
|
||||||
|
return $this->searchGeo($where)->select();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBrigade($where)
|
||||||
|
{
|
||||||
|
return $this->searchBrigade($where)->select();
|
||||||
|
}
|
||||||
|
|
||||||
public function getList($where)
|
public function getList($where)
|
||||||
{
|
{
|
||||||
return $this->dao->getSearch($where)->with(['parent'])->order('id ASC')->select()->append(['children','hasChildren']);
|
return $this->dao->getSearch($where)->with(['parent'])->order('id ASC')->select()->append(['children','hasChildren']);
|
||||||
|
@ -49,6 +49,70 @@ class City extends BaseController
|
|||||||
return app('json')->success(app()->make(CityAreaRepository::class)->getChildren(intval($pid)));
|
return app('json')->success(app()->make(CityAreaRepository::class)->getChildren(intval($pid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function lstV3()
|
||||||
|
{
|
||||||
|
$provinceCode = $this->request->param('province_code') ?? '';
|
||||||
|
$cityCode = $this->request->param('city_code') ?? '';
|
||||||
|
$areaCode = $this->request->param('area_code') ?? '';
|
||||||
|
$streetCode = $this->request->param('street_code') ?? '';
|
||||||
|
$list = app()->make(CityAreaRepository::class)->getGeoChildren(['province_code' => $provinceCode, 'city_code' => $cityCode, 'area_code' => $areaCode, 'street_code' => $streetCode]);
|
||||||
|
$geoList = [];
|
||||||
|
foreach ($list->toArray() as $v) {
|
||||||
|
if (!empty($v['village_id'])) {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'village',
|
||||||
|
'level' => 5,
|
||||||
|
'name' => $v['village_name'] ?? '',
|
||||||
|
'code' => $v['village_code'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
if (!empty($v['street_id'])) {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'street',
|
||||||
|
'level' => 4,
|
||||||
|
'name' => $v['street_name'] ?? '',
|
||||||
|
'code' => $v['street_code'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
if (!empty($v['area_id'])) {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'area',
|
||||||
|
'level' => 3,
|
||||||
|
'name' => $v['area_name'] ?? '',
|
||||||
|
'code' => $v['area_code'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
if (!empty($v['city_id'])) {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'city',
|
||||||
|
'level' => 2,
|
||||||
|
'name' => $v['city_name'] ?? '',
|
||||||
|
'code' => $v['city_code'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
if (!empty($v['province_id'])) {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'province',
|
||||||
|
'level' => 1,
|
||||||
|
'name' => $v['province_name'] ?? '',
|
||||||
|
'code' => $v['province_code'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return app('json')->success($geoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function brigade()
|
||||||
|
{
|
||||||
|
return app('json')->success(app()->make(CityAreaRepository::class)->getBrigade([]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function cityList()
|
public function cityList()
|
||||||
{
|
{
|
||||||
$address = $this->request->param('address');
|
$address = $this->request->param('address');
|
||||||
|
@ -562,6 +562,10 @@ Route::group('api/', function () {
|
|||||||
Route::get('system/city/lst', 'merchant.store.shipping.City/getlist');
|
Route::get('system/city/lst', 'merchant.store.shipping.City/getlist');
|
||||||
Route::get('v2/system/city/lst/:pid', 'merchant.store.shipping.City/lstV2');
|
Route::get('v2/system/city/lst/:pid', 'merchant.store.shipping.City/lstV2');
|
||||||
Route::get('v2/system/city', 'merchant.store.shipping.City/cityList');
|
Route::get('v2/system/city', 'merchant.store.shipping.City/cityList');
|
||||||
|
//更换城市源列表
|
||||||
|
Route::get('v2/system/geo/lst', 'merchant.store.shipping.City/lstV3');
|
||||||
|
//小队列表
|
||||||
|
Route::get('v2/system/brigade', 'merchant.store.shipping.City/brigade');
|
||||||
|
|
||||||
//热门搜索
|
//热门搜索
|
||||||
Route::get('common/hot_keyword', 'api.Common/hotKeyword')->append(['type' => 0]);
|
Route::get('common/hot_keyword', 'api.Common/hotKeyword')->append(['type' => 0]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user