|
|
@@ -444,19 +444,23 @@ class GhsController extends BaseController
|
|
|
//寻找附近批发店
|
|
|
public function actionSearchNearbyGhs()
|
|
|
{
|
|
|
- $shop = $this->shop;
|
|
|
- $toLat = $shop['lat'] ?? '';
|
|
|
- $toLnt = $shop['long'] ?? '';
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $toLat = $get['lat'] ?? '';
|
|
|
+ $toLnt = $get['long'] ?? '';
|
|
|
if ($toLat == '' || $toLnt == '') {
|
|
|
- util::fail('门店未定位');
|
|
|
+ util::fail('未获取到定位数据');
|
|
|
}
|
|
|
|
|
|
- if ($shop['province'] == '' || $shop['city'] == '') {
|
|
|
- util::fail('门店未设置所在省市');
|
|
|
+ $where = [];
|
|
|
+ $where['ownShopId'] = $this->shopId;
|
|
|
+ $where['delStatus'] = 0;
|
|
|
+ $gs = GhsClass::getAllList('*', $where, 'inTurn DESC, addTime ASC');
|
|
|
+ if(!empty($gs)){
|
|
|
+ util::fail('已有批发商,不使用定位获取附近批发商');
|
|
|
}
|
|
|
|
|
|
// 找出附近批发店,之后自动给建立关系,然后补充二个店之间的距离
|
|
|
- GhsClass::buildNearbyGhsRelations($shop['id'], $this->shop->pfShopId, $shop['province'], $shop['city'], $toLat, $toLnt);
|
|
|
+ GhsClass::buildNearbyGhsRelations($this->shop['id'], $this->shop->pfShopId, $toLat, $toLnt);
|
|
|
|
|
|
util::complete();
|
|
|
}
|