You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

5 years ago
5 years ago
  1. <?php
  2. namespace App\Service\v3\Implementations;
  3. use Hyperf\Di\Annotation\Inject;
  4. use App\Service\v3\Interfaces\DistributionPriceServiceInterface;
  5. class DistributionPriceService implements DistributionPriceServiceInterface
  6. {
  7. public function do($distance)
  8. {
  9. $km = ceil($distance/1000);
  10. switch ($km){
  11. case ($km > 3 && $km < 5) :
  12. $distributionRrice = bcmul(0.70,($km-3),2);
  13. break;
  14. case ($km >= 5 && $km < 7) :
  15. $distributionRrice = bcmul(1.00,($km-3),2);
  16. break;
  17. case ($km >= 7 && $km < 10) :
  18. $distributionRrice = bcmul(1.50,($km-3),2);
  19. break;
  20. case ($km >= 10) :
  21. $distributionRrice = bcmul(1.50,($km-3),2);
  22. // throw new ErrorCodeException(ErrorCode::LOCATION_LONG_DISTANCE);
  23. break;
  24. default:
  25. $distributionRrice = 0;
  26. break;
  27. }
  28. $distributionRrice = bcadd($distributionRrice,3.50,2);
  29. return $distributionRrice;
  30. }
  31. public function check()
  32. {
  33. // TODO: Implement check() method.
  34. }
  35. public function undo()
  36. {
  37. // TODO: Implement undo() method.
  38. }
  39. }