DeliveryState.php 706 B

12345678910111213141516
  1. <?php
  2. declare(strict_types=1);
  3. namespace plugin\saiadmin\app\service\fulfillment;
  4. use plugin\saiadmin\exception\ApiException;
  5. /** Explicit state policy shared by settlement commands and route completion. */
  6. final class DeliveryState
  7. {
  8. public const ACTIVE = ['pending','assigned','transit','returning'];
  9. public const TERMINAL = ['completed','returned','cancelled'];
  10. public static function requireAction(string $state,string $action): void
  11. {
  12. $allowed=['receive'=>['transit'],'return_receive'=>['returning'],'redeliver'=>['returned']];
  13. if (!in_array($state,$allowed[$action]??[],true)) throw new ApiException('当前配送状态不允许此操作,请刷新任务');
  14. }
  15. }