| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace App\Services;
- use App\Logistic;
- use App\LogisticTiming;
- use App\Province;
- use App\Traits\ServiceAppAop;
- class LogisticTimingService
- {
- use ServiceAppAop;
- protected $modelClass=LogisticTiming::class;
- 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);
- $logistic = Logistic::query()->where('code','SFTH')->first();
- if(isset($city) && isset($province)){
- return $this->findByCityIdAndProvinceIdAndLogisticName($city->id,$province->id,$logistic->id);
- }
- 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();
- }
- }
|