LogisticTimingService.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. public function findByParams($cityName,$provinceName,$logisticId)
  11. {
  12. $logistic = Logistic::query()->where('id',$logisticId)->first();
  13. if(!str_starts_with($logistic->name,'新杰')){
  14. $city = app(CityService::class)->findByName($cityName);
  15. $province = app(ProvinceService::class)->findByName($provinceName);
  16. $logistic = Logistic::query()->where('name','顺丰特惠')->first();
  17. if(isset($city) && isset($province)){
  18. return $this->findByCityIdAndProvinceIdAndLogisticName($city->id,$province->id,$logistic->id);
  19. }
  20. return null;
  21. }
  22. $city = app(CityService::class)->findByName($cityName);
  23. $province = app(ProvinceService::class)->findByName($provinceName);
  24. if($city == null|| $province==null)return null;
  25. return $this->findByCityIdAndProvinceIdAndLogisticName($city->id,$province->id,$logisticId);
  26. }
  27. public function findByCityIdAndProvinceIdAndLogisticName($cityId,$provinceId,$logisticId)
  28. {
  29. return LogisticTiming::query()->where('to_province_id',$provinceId)->where('to_city_id',$cityId)->where('logistic_id',$logisticId)->first();
  30. }
  31. }