LogisticTimingService.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Services;
  3. use App\Logistic;
  4. use App\LogisticTiming;
  5. use App\Province;
  6. use App\Traits\ServiceAppAop;
  7. class LogisticTimingService
  8. {
  9. use ServiceAppAop;
  10. protected $modelClass=LogisticTiming::class;
  11. public function findByParams($cityName,$provinceName,$logisticId)
  12. {
  13. $logistic = Logistic::query()->where('id',$logisticId)->first();
  14. if(!str_starts_with($logistic->name,'新杰')){
  15. $city = app(CityService::class)->findByName($cityName);
  16. $province = app(ProvinceService::class)->findByName($provinceName);
  17. $logistic = Logistic::query()->where('code','SFTH')->first();
  18. if(isset($city) && isset($province)){
  19. return $this->findByCityIdAndProvinceIdAndLogisticName($city->id,$province->id,$logistic->id);
  20. }
  21. return null;
  22. }
  23. $city = app(CityService::class)->findByName($cityName);
  24. $province = app(ProvinceService::class)->findByName($provinceName);
  25. if($city == null|| $province==null)return null;
  26. return $this->findByCityIdAndProvinceIdAndLogisticName($city->id,$province->id,$logisticId);
  27. }
  28. public function findByCityIdAndProvinceIdAndLogisticName($cityId,$provinceId,$logisticId)
  29. {
  30. return LogisticTiming::query()->where('to_province_id',$provinceId)->where('to_city_id',$cityId)->where('logistic_id',$logisticId)->first();
  31. }
  32. }