| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace App\Services;
- use App\Logistic;
- use App\LogisticTiming;
- use App\Province;
- Class LogisticTimingService
- {
- /**
- * @param string $cityName
- * @param string $provinceName
- * @param string $logisticName
- * @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
- */
- public function findByParams($cityName,$provinceName,$logisticId)
- {
- $logistic = Logistic::query()->where('id',$logisticId)->first();
- if( str_starts_with($logistic->name,'顺丰')){
- $city = app(CityService::class)->findByName($cityName);
- $province = app(ProvinceService::class)->findByName($provinceName);
- if(isset($city) && isset($province)){
- return $this->findByCityIdAndProvinceIdAndLogisticName($city->id,$province->id,$logisticId);
- }
- return null;
- }
- $city = app(CityService::class)->findByName($cityName);
- $province = app(ProvinceService::class)->findByName($provinceName);
- if($city == null|| $province==null)return null;
- return $this->findByCityIdAndProvinceIdAndLogisticName($city->id,$province->id,$logisticId);
- }
- public function findByCityIdAndProvinceIdAndLogisticName($cityId,$provinceId,$logisticId)
- {
- return LogisticTiming::query()->where('to_province_id',$provinceId)->where('to_city_id',$cityId)->where('logistic_id',$logisticId)->first();
- }
- }
|