This commit is contained in:
mkm 2023-11-13 14:48:07 +08:00
parent 5f43305313
commit fe41046409
3 changed files with 31 additions and 35 deletions

View File

@ -223,7 +223,7 @@ class MerchantRepository extends BaseRepository
*/
public function updateForm($id)
{
$data = $this->dao->get($id)->hidden(['coordinates'])->toArray();
$data = $this->dao->get($id)->toArray();
/** @var MerchantAdminRepository $make */
$make = app()->make(MerchantAdminRepository::class);
$data['mer_account'] = $make->merIdByAccount($id);
@ -369,7 +369,7 @@ class MerchantRepository extends BaseRepository
*/
public function detail($id, $userInfo)
{
$merchant = $this->dao->apiGetOne($id)->hidden(['coordinates']);
$merchant = $this->dao->apiGetOne($id);
$merchant->append(['type_names', 'isset_certificate', 'services_type']);
$merchant['care'] = false;
if ($userInfo)

View File

@ -242,11 +242,6 @@ class Merchant extends BaseController
if ($data['mer_state'] && !$merchant['sub_mchid'] && systemConfig('open_wx_combine'))
return app('json')->fail('开启店铺前请先完成微信子商户入驻');
}
if($data['long']!=''&& $data['lat']!=''){
$long=$data['long'];
$lat=$data['lat'];
Db::query("UPDATE eb_merchant SET coordinates = ST_GeomFromText('POINT($long $lat)') WHERE mer_id = $id");
}
Db::name('merchant')->where('mer_id',$id)->update($data);
Queue::push(ChangeMerchantStatusJob::class, $id);

View File

@ -206,15 +206,19 @@ class StoreSpu extends BaseController
$where['product_type'] = 0;
$where['is_stock'] = 1;
if ($params['location'] != '') {
[$lon,$lat]=explode(',',$params['location']);
$select=Db::query("select mer_id,ST_Distance(coordinates, POINT($lon,$lat)) AS distance from eb_merchant where coordinates !='' and type_id IN ('10', '17') and is_del=0 and mer_state=1 ORDER BY distance LIMIT 100;");
[$lng, $lat] = explode(',', $params['location']);
$select = Db::name('merchant')->where('type_id', 'IN', ["10", "17"])->where(['is_del' => 0, 'mer_state' => 1])->whereNotNull('lat')->whereNotNull('long')->order(Db::raw("(2 * 6378.137 * ASIN(
SQRT(
POW( SIN( PI( ) * ( $lng- `long` ) / 360 ), 2 ) + COS( PI( ) * $lat / 180 ) * COS( `lat` * PI( ) / 180 ) * POW( SIN( PI( ) * ( $lat- `lat` ) / 360 ), 2 )
)
)
) ASC "));
$arr = [];
foreach ($select as $k => $v) {
$arr[] = $v['mer_id'];
}
if ($arr) {
$where['mer_ids'] = $arr;
}
}
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
@ -378,7 +382,4 @@ class StoreSpu extends BaseController
}
return app('json')->success($data);
}
}