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

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