文件
mashangyoujiu/Application/Common/Business/OrderStatusUtil.class.php

79 行
1.9 KiB
PHP

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Common\Business;
/**
* 骑手订单状态工具类
* 统一维护状态文本与数值/集合映射
*/
class OrderStatusUtil
{
/**
* 状态键到文本映射
*/
private static $statusTexts = array(
'pending' => '待分配',
'accepted' => '已接单',
'picking_up' => '取货中',
'delivering' => '配送中',
'completed' => '已完成',
'cancelled' => '已取消',
'exception' => '异常'
);
/**
* 状态键到数值/集合条件映射(用于 ThinkPHP where)
*/
private static $statusConditions = array(
'pending' => 0,
'accepted' => 1,
'picking_up' => array('in', array(2, 3, 4)),
'delivering' => 5,
'completed' => 6,
'cancelled' => 8,
'exception' => 7
);
/**
* 获取状态文本
*/
public static function getStatusText($key)
{
return isset(self::$statusTexts[$key]) ? self::$statusTexts[$key] : '未知';
}
/**
* 获取 where 条件值(可能为整数或 ['in', [...]])
*/
public static function getStatusCondition($key)
{
return isset(self::$statusConditions[$key]) ? self::$statusConditions[$key] : null;
}
/**
* 获取在途(包含取货中与配送中)的状态集合
*/
public static function getInTransitStatuses()
{
return array(2, 3, 4, 5);
}
/**
* 获取进行中订单的状态集合(用于当前任务统计)
*/
public static function getInProgressStatuses()
{
return array(1, 2, 3, 4, 5);
}
/**
* 获取指定键的数值状态(如 completed -> 6)
*/
public static function getNumericStatus($key)
{
$cond = self::getStatusCondition($key);
if (is_array($cond)) {
return null;
}
return $cond;
}
}