LogisticTimingService.php 1.3 KB

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