修改首次下单和后续默认下单拿最近订单下单的店铺的逻辑

This commit is contained in:
liu 2024-07-03 11:23:17 +08:00
parent 51948aaf35
commit f23348e8a1

View File

@ -192,8 +192,21 @@ class OrderLogic extends BaseLogic
$store['near_store'] = $nearestStore; $store['near_store'] = $nearestStore;
} }
}else{ }else{
if(empty($user)){
$store_id = getenv('STORE_ID') ?? 1; $store_id = getenv('STORE_ID') ?? 1;
$store['near_store'] =SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[]; $store['near_store'] =SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[];
}else{
$checkOrderStore = StoreOrder::where('uid',$user['id'])->field('id,store_id')
->order('id','desc')->find();
if($checkOrderStore){
$store['near_store'] =SystemStore::where('id', $checkOrderStore['store_id'])->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[];
}else{
$store_id = getenv('STORE_ID') ?? 1;
$store['near_store'] =SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[];
}
}
} }
} catch (\Exception $e) { } catch (\Exception $e) {
self::setError($e->getMessage()); self::setError($e->getMessage());