添加收货地址接口
This commit is contained in:
parent
60b50e7b88
commit
822fec6e64
@ -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\GeoArea;
|
||||||
|
use app\common\model\store\GeoBrigade;
|
||||||
|
use app\common\model\store\GeoCity;
|
||||||
|
use app\common\model\store\GeoProvince;
|
||||||
|
use app\common\model\store\GeoStreet;
|
||||||
|
use app\common\model\store\GeoVillage;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
|
|
||||||
class CityAreaDao extends BaseDao
|
class CityAreaDao extends BaseDao
|
||||||
@ -68,4 +74,28 @@ class CityAreaDao extends BaseDao
|
|||||||
$lst[] = $city;
|
$lst[] = $city;
|
||||||
return $lst;
|
return $lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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']);
|
||||||
|
} else {
|
||||||
|
return GeoProvince::getDB();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function searchBrigade(array $where)
|
||||||
|
{
|
||||||
|
return GeoBrigade::getDB();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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']);
|
||||||
|
@ -54,6 +54,10 @@ class StoreCouponRepository extends BaseRepository
|
|||||||
const TYPE_PLATFORM_CATE = 11;
|
const TYPE_PLATFORM_CATE = 11;
|
||||||
//平台跨店券
|
//平台跨店券
|
||||||
const TYPE_PLATFORM_STORE = 12;
|
const TYPE_PLATFORM_STORE = 12;
|
||||||
|
//平台购物卡,可全额抵扣,可结余
|
||||||
|
const TYPE_PLATFORM_CARD = 13;
|
||||||
|
//平台抵扣券,按比例部分抵扣,可结余
|
||||||
|
const TYPE_PLATFORM_COUPON = 14;
|
||||||
|
|
||||||
//获取方式
|
//获取方式
|
||||||
const GET_COUPON_TYPE_RECEIVE = 0;
|
const GET_COUPON_TYPE_RECEIVE = 0;
|
||||||
@ -392,6 +396,8 @@ class StoreCouponRepository extends BaseRepository
|
|||||||
['value' => self::TYPE_PLATFORM_ALL, 'label' => '通用券'],
|
['value' => self::TYPE_PLATFORM_ALL, 'label' => '通用券'],
|
||||||
['value' => self::TYPE_PLATFORM_CATE, 'label' => '品类券'],
|
['value' => self::TYPE_PLATFORM_CATE, 'label' => '品类券'],
|
||||||
['value' => self::TYPE_PLATFORM_STORE, 'label' => '跨店券'],
|
['value' => self::TYPE_PLATFORM_STORE, 'label' => '跨店券'],
|
||||||
|
['value' => self::TYPE_PLATFORM_CARD, 'label' => '购物卡'],
|
||||||
|
['value' => self::TYPE_PLATFORM_COUPON, 'label' => '抵扣券'],
|
||||||
])->control([
|
])->control([
|
||||||
[
|
[
|
||||||
'value' => self::TYPE_PLATFORM_CATE,
|
'value' => self::TYPE_PLATFORM_CATE,
|
||||||
|
@ -243,7 +243,7 @@ class Coupon extends BaseController
|
|||||||
} else unset($data['use_start_time']);
|
} else unset($data['use_start_time']);
|
||||||
unset($data['range_date']);
|
unset($data['range_date']);
|
||||||
if ($data['is_limited'] == 0) $data['total_count'] = 0;
|
if ($data['is_limited'] == 0) $data['total_count'] = 0;
|
||||||
if (!in_array($data['type'], [10, 11, 12])) {
|
if (!in_array($data['type'], [10, 11, 12, 13, 14])) {
|
||||||
throw new ValidateException('请选择有效的优惠券类型');
|
throw new ValidateException('请选择有效的优惠券类型');
|
||||||
}
|
}
|
||||||
$data['mer_id'] = $this->request->merId();
|
$data['mer_id'] = $this->request->merId();
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
namespace app\controller\merchant\store\shipping;
|
namespace app\controller\merchant\store\shipping;
|
||||||
|
|
||||||
use app\common\repositories\store\CityAreaRepository;
|
use app\common\repositories\store\CityAreaRepository;
|
||||||
|
use Overtrue\Pinyin\Pinyin;
|
||||||
use think\App;
|
use think\App;
|
||||||
use crmeb\basic\BaseController;
|
use crmeb\basic\BaseController;
|
||||||
use app\common\repositories\store\shipping\CityRepository as repository;
|
use app\common\repositories\store\shipping\CityRepository as repository;
|
||||||
@ -72,4 +73,157 @@ class City extends BaseController
|
|||||||
{
|
{
|
||||||
return app('json')->success($this->repository->getFormatList(['is_show' => 1]));
|
return app('json')->success($this->repository->getFormatList(['is_show' => 1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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') ?? '';
|
||||||
|
$pinyin = $this->request->param('pinyin') ?? 0;
|
||||||
|
/** @var CityAreaRepository $repo */
|
||||||
|
$repo = app()->make(CityAreaRepository::class);
|
||||||
|
$list = $repo->getGeoChildren(['province_code' => $provinceCode, 'city_code' => $cityCode, 'area_code' => $areaCode, 'street_code' => $streetCode]);
|
||||||
|
$geoList = [];
|
||||||
|
$pyList = [];
|
||||||
|
foreach ($list as $v) {
|
||||||
|
$temp = [];
|
||||||
|
if (!empty($v['village_id'])) {
|
||||||
|
if ($pinyin == 1) {
|
||||||
|
$py = strtoupper((new Pinyin)->abbr($v['village_name'])[0] ?? '-');
|
||||||
|
$pyList[$py][] = [
|
||||||
|
'type' => 'village',
|
||||||
|
'id' => $v['village_id'],
|
||||||
|
'level' => 5,
|
||||||
|
'name' => $v['village_name'] ?? '',
|
||||||
|
'code' => $v['village_code'] ?? ''
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'village',
|
||||||
|
'id' => $v['village_id'],
|
||||||
|
'level' => 5,
|
||||||
|
'name' => $v['village_name'] ?? '',
|
||||||
|
'code' => $v['village_code'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($v['street_id'])) {
|
||||||
|
if ($pinyin == 1) {
|
||||||
|
$py = strtoupper((new Pinyin)->abbr($v['street_name'])[0] ?? '-');
|
||||||
|
$pyList[$py][] = [
|
||||||
|
'type' => 'street',
|
||||||
|
'id' => $v['street_id'],
|
||||||
|
'level' => 4,
|
||||||
|
'name' => $v['street_name'] ?? '',
|
||||||
|
'code' => $v['street_code'] ?? ''
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'street',
|
||||||
|
'id' => $v['street_id'],
|
||||||
|
'level' => 4,
|
||||||
|
'name' => $v['street_name'] ?? '',
|
||||||
|
'code' => $v['street_code'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($v['area_id'])) {
|
||||||
|
if ($pinyin == 1) {
|
||||||
|
$py = strtoupper((new Pinyin)->abbr($v['area_name'])[0] ?? '-');
|
||||||
|
$pyList[$py][] = [
|
||||||
|
'type' => 'area',
|
||||||
|
'id' => $v['area_id'],
|
||||||
|
'level' => 3,
|
||||||
|
'name' => $v['area_name'] ?? '',
|
||||||
|
'code' => $v['area_code'] ?? ''
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'area',
|
||||||
|
'id' => $v['area_id'],
|
||||||
|
'level' => 3,
|
||||||
|
'name' => $v['area_name'] ?? '',
|
||||||
|
'code' => $v['area_code'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($v['city_id'])) {
|
||||||
|
if ($pinyin == 1) {
|
||||||
|
$py = strtoupper((new Pinyin)->abbr($v['city_name'])[0] ?? '-');
|
||||||
|
$pyList[$py][] = [
|
||||||
|
'type' => 'city',
|
||||||
|
'id' => $v['city_id'],
|
||||||
|
'level' => 2,
|
||||||
|
'name' => $v['city_name'] ?? '',
|
||||||
|
'code' => $v['city_code'] ?? ''
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'city',
|
||||||
|
'id' => $v['city_id'],
|
||||||
|
'level' => 2,
|
||||||
|
'name' => $v['city_name'] ?? '',
|
||||||
|
'code' => $v['city_code'] ?? '',
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($v['province_id'])) {
|
||||||
|
if ($pinyin == 1) {
|
||||||
|
$py = strtoupper((new Pinyin)->abbr($v['province_name'])[0] ?? '-');
|
||||||
|
$pyList[$py][] = [
|
||||||
|
'type' => 'province',
|
||||||
|
'id' => $v['province_id'],
|
||||||
|
'level' => 1,
|
||||||
|
'name' => $v['province_name'] ?? '',
|
||||||
|
'code' => $v['province_code'] ?? ''
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'province',
|
||||||
|
'id' => $v['province_id'],
|
||||||
|
'level' => 1,
|
||||||
|
'name' => $v['province_name'] ?? '',
|
||||||
|
'code' => $v['province_code'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($pinyin == 1) {
|
||||||
|
$geoList = [];
|
||||||
|
foreach($pyList as $k=>$v) {
|
||||||
|
$temp = [];
|
||||||
|
$temp['pinyin'] = $k;
|
||||||
|
$temp['data'] = $pyList[$k];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return app('json')->success($geoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function brigade()
|
||||||
|
{
|
||||||
|
/** @var CityAreaRepository $repo */
|
||||||
|
$repo = app()->make(CityAreaRepository::class);
|
||||||
|
$list = $repo->getBrigade([]);
|
||||||
|
$geoList = [];
|
||||||
|
foreach ($list as $v) {
|
||||||
|
$temp = [
|
||||||
|
'type' => 'brigade',
|
||||||
|
'id' => $v['id'],
|
||||||
|
'level' => 6,
|
||||||
|
'name' => $v['brigade_name'] ?? '',
|
||||||
|
'code' => $v['brigade_name'] ?? ''
|
||||||
|
];
|
||||||
|
$geoList[] = $temp;
|
||||||
|
}
|
||||||
|
return app('json')->success($geoList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class StoreCouponValidate extends Validate
|
|||||||
'use_start_time|有效期限' => 'requireIf:coupon_type,1|array|>:2',
|
'use_start_time|有效期限' => 'requireIf:coupon_type,1|array|>:2',
|
||||||
'sort|排序' => 'require|integer',
|
'sort|排序' => 'require|integer',
|
||||||
'status|状态' => 'require|in:0,1',
|
'status|状态' => 'require|in:0,1',
|
||||||
'type|优惠券类型' => 'require|in:0,1,10,11,12',
|
'type|优惠券类型' => 'require|in:0,1,10,11,12,13,14',
|
||||||
'product_id|商品' => 'requireIf:type,1|array|>:0',
|
'product_id|商品' => 'requireIf:type,1|array|>:0',
|
||||||
'send_type|类型' => 'require|in:0,1,2,3,4,5',
|
'send_type|类型' => 'require|in:0,1,2,3,4,5',
|
||||||
'full_reduction|满赠金额' => 'requireIf:send_type,1|float|>=:0',
|
'full_reduction|满赠金额' => 'requireIf:send_type,1|float|>=:0',
|
||||||
|
@ -605,6 +605,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