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

View File

@ -242,11 +242,6 @@ class Merchant extends BaseController
if ($data['mer_state'] && !$merchant['sub_mchid'] && systemConfig('open_wx_combine')) if ($data['mer_state'] && !$merchant['sub_mchid'] && systemConfig('open_wx_combine'))
return app('json')->fail('开启店铺前请先完成微信子商户入驻'); 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); Db::name('merchant')->where('mer_id',$id)->update($data);
Queue::push(ChangeMerchantStatusJob::class, $id); Queue::push(ChangeMerchantStatusJob::class, $id);

View File

@ -61,14 +61,14 @@ class StoreSpu extends BaseController
'type_id', 'type_id',
'street_id' 'street_id'
]); ]);
if($where['type_id']){ if ($where['type_id']) {
$arr=['status' => 1, 'mer_state' => 1, 'is_del' => 0]; $arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0];
if($where['street_id']){ if ($where['street_id']) {
$arr['street_id']=$where['street_id']; $arr['street_id'] = $where['street_id'];
} }
$where['mer_ids'] = Merchant::getInstance()->whereIn('type_id', explode(',', $where['type_id']))->where($arr)->column('mer_id'); $where['mer_ids'] = Merchant::getInstance()->whereIn('type_id', explode(',', $where['type_id']))->where($arr)->column('mer_id');
} }
unset($where['type_id'],$where['street_id']); unset($where['type_id'], $where['street_id']);
$where['is_gift_bag'] = 0; $where['is_gift_bag'] = 0;
$where['product_type'] = 0; $where['product_type'] = 0;
@ -87,7 +87,7 @@ class StoreSpu extends BaseController
public function streetLst($id) public function streetLst($id)
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id'); $typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' . Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$where = $this->request->params([ $where = $this->request->params([
'keyword', 'keyword',
'cate_id', 'cate_id',
@ -150,14 +150,14 @@ class StoreSpu extends BaseController
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common' 'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common'
]); ]);
if ($where['action']) unset($where['product_type']); if ($where['action']) unset($where['product_type']);
$currentMerchant = Db::name('merchant')->where('mer_id',$id)->field('category_id,street_id')->find(); $currentMerchant = Db::name('merchant')->where('mer_id', $id)->field('category_id,street_id')->find();
$typeIdArray = Db::name('MerchantType')->whereIn('type_code', (string)Merchant::TypeCode['TypeTownSupplyChain'])->column('mer_type_id'); $typeIdArray = Db::name('MerchantType')->whereIn('type_code', (string)Merchant::TypeCode['TypeTownSupplyChain'])->column('mer_type_id');
$merIdArray = Db::name('merchant') $merIdArray = Db::name('merchant')
->where('street_id',$currentMerchant['street_id']) ->where('street_id', $currentMerchant['street_id'])
->where('mer_state',1) ->where('mer_state', 1)
->where('status',1) ->where('status', 1)
->where('category_id',$currentMerchant['category_id']) ->where('category_id', $currentMerchant['category_id'])
->whereIn('type_id', implode(',', $typeIdArray)) ->whereIn('type_id', implode(',', $typeIdArray))
->column('mer_id'); ->column('mer_id');
$where['mer_array_id'] = $merIdArray; $where['mer_array_id'] = $merIdArray;
@ -177,7 +177,7 @@ class StoreSpu extends BaseController
public function recommend() public function recommend()
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$where = $this->request->params(['common','mer_id']); $where = $this->request->params(['common', 'mer_id']);
$params = $this->request->params(['location']); $params = $this->request->params(['location']);
// $typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id'); // $typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
$where['is_gift_bag'] = 0; $where['is_gift_bag'] = 0;
@ -205,16 +205,20 @@ class StoreSpu extends BaseController
} }
$where['product_type'] = 0; $where['product_type'] = 0;
$where['is_stock'] = 1; $where['is_stock'] = 1;
if($params['location']!=''){ if ($params['location'] != '') {
[$lon,$lat]=explode(',',$params['location']); [$lng, $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;"); $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(
$arr=[]; SQRT(
foreach($select as $k=>$v){ POW( SIN( PI( ) * ( $lng- `long` ) / 360 ), 2 ) + COS( PI( ) * $lat / 180 ) * COS( `lat` * PI( ) / 180 ) * POW( SIN( PI( ) * ( $lat- `lat` ) / 360 ), 2 )
$arr[]=$v['mer_id']; )
)
) ASC "));
$arr = [];
foreach ($select as $k => $v) {
$arr[] = $v['mer_id'];
} }
if($arr){ if ($arr) {
$where['mer_ids'] =$arr; $where['mer_ids'] = $arr;
} }
} }
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
@ -230,7 +234,7 @@ class StoreSpu extends BaseController
public function hot($type) public function hot($type)
{ {
[$page, $limit] = $this->getPage(); [$page, $limit] = $this->getPage();
$where = $this->request->params(['common','mer_id']); $where = $this->request->params(['common', 'mer_id']);
$where['hot_type'] = $type; $where['hot_type'] = $type;
$where['is_gift_bag'] = 0; $where['is_gift_bag'] = 0;
$where['order'] = 'star'; $where['order'] = 'star';
@ -362,8 +366,8 @@ class StoreSpu extends BaseController
public function getHotRanking() public function getHotRanking()
{ {
$cateId = $this->request->param('cate_pid',0); $cateId = $this->request->param('cate_pid', 0);
$cateId = is_array($cateId) ?:explode(',',$cateId); $cateId = is_array($cateId) ?: explode(',', $cateId);
$data = []; $data = [];
foreach ($cateId as $cate_id) { foreach ($cateId as $cate_id) {
$cate = app()->make(StoreCategoryRepository::class)->get($cate_id); $cate = app()->make(StoreCategoryRepository::class)->get($cate_id);
@ -378,7 +382,4 @@ class StoreSpu extends BaseController
} }
return app('json')->success($data); return app('json')->success($data);
} }
} }