123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- <?php
- namespace app\common\Enum;
- /**
- * 订单操作记录枚举
- */
- class OrderActionEnum
- {
- // 操作类型
- const ACTION_CREATE = 'create'; // 创建订单
- const ACTION_PAY = 'pay'; // 支付订单
- const ACTION_SHIP = 'ship'; // 发货
- const ACTION_RECEIVE = 'receive'; // 确认收货
- const ACTION_CANCEL = 'cancel'; // 取消订单
- const ACTION_REFUND = 'refund'; // 退款
- const ACTION_RETURN = 'return'; // 退货
- const ACTION_COMPLETE = 'complete'; // 完成订单
- const ACTION_COMMENT = 'comment'; // 评价
- const ACTION_MODIFY = 'modify'; // 修改订单
- const ACTION_REMIND = 'remind'; // 催单
- const ACTION_ADMIN_CANCEL = 'admin_cancel'; // 管理员取消
- const ACTION_AUTO_CANCEL = 'auto_cancel'; // 系统自动取消
- const ACTION_AUTO_CONFIRM = 'auto_confirm'; // 系统自动确认收货
- // 用户类型
- const USER_TYPE_CUSTOMER = 'customer'; // 前端用户
- const USER_TYPE_ADMIN = 'admin'; // 后台管理员
- const USER_TYPE_SYSTEM = 'system'; // 系统操作
- const USER_TYPE_INSPECTION = 'inspection'; // 验货端
- // 操作员类型
- const OPERATOR_TYPE_USER = 'user'; // 用户操作
- const OPERATOR_TYPE_ADMIN = 'admin'; // 管理员操作
- const OPERATOR_TYPE_SYSTEM = 'system'; // 系统操作
- const OPERATOR_TYPE_INSPECTION = 'inspection'; // 验货端
- // 操作优先级
- const PRIORITY_LOW = 1; // 低优先级
- const PRIORITY_NORMAL = 2; // 普通优先级
- const PRIORITY_HIGH = 3; // 高优先级
- const PRIORITY_URGENT = 4; // 紧急优先级
- /**
- * 获取操作类型列表
- * @return array
- */
- public static function getActionTypeList()
- {
- return [
- self::ACTION_CREATE => '创建订单',
- self::ACTION_PAY => '支付订单',
- self::ACTION_SHIP => '发货',
- self::ACTION_RECEIVE => '确认收货',
- self::ACTION_CANCEL => '取消订单',
- self::ACTION_REFUND => '退款',
- self::ACTION_RETURN => '退货',
- self::ACTION_COMPLETE => '完成订单',
- self::ACTION_COMMENT => '评价',
- self::ACTION_MODIFY => '修改订单',
- self::ACTION_REMIND => '催单',
- self::ACTION_ADMIN_CANCEL => '管理员取消',
- self::ACTION_AUTO_CANCEL => '系统自动取消',
- self::ACTION_AUTO_CONFIRM => '系统自动确认收货',
- ];
- }
- /**
- * 获取操作类型文本
- * @param string $actionType
- * @return string
- */
- public static function getActionTypeText($actionType)
- {
- return self::getActionTypeList()[$actionType] ?? '未知操作';
- }
- /**
- * 获取用户类型列表
- * @return array
- */
- public static function getUserTypeList()
- {
- return [
- self::USER_TYPE_CUSTOMER => '前端用户',
- self::USER_TYPE_ADMIN => '后台管理员',
- self::USER_TYPE_SYSTEM => '系统操作',
- ];
- }
- /**
- * 获取用户类型文本
- * @param string $userType
- * @return string
- */
- public static function getUserTypeText($userType)
- {
- return self::getUserTypeList()[$userType] ?? '未知用户';
- }
- /**
- * 获取操作员类型列表
- * @return array
- */
- public static function getOperatorTypeList()
- {
- return [
- self::OPERATOR_TYPE_USER => '用户操作',
- self::OPERATOR_TYPE_ADMIN => '管理员操作',
- self::OPERATOR_TYPE_SYSTEM => '系统操作',
- ];
- }
- /**
- * 获取操作员类型文本
- * @param string $operatorType
- * @return string
- */
- public static function getOperatorTypeText($operatorType)
- {
- return self::getOperatorTypeList()[$operatorType] ?? '未知操作员';
- }
- /**
- * 获取优先级列表
- * @return array
- */
- public static function getPriorityList()
- {
- return [
- self::PRIORITY_LOW => '低优先级',
- self::PRIORITY_NORMAL => '普通优先级',
- self::PRIORITY_HIGH => '高优先级',
- self::PRIORITY_URGENT => '紧急优先级',
- ];
- }
- /**
- * 获取优先级文本
- * @param int $priority
- * @return string
- */
- public static function getPriorityText($priority)
- {
- return self::getPriorityList()[$priority] ?? '未知优先级';
- }
- /**
- * 验证操作类型是否有效
- * @param string $actionType
- * @return bool
- */
- public static function isValidActionType($actionType)
- {
- return array_key_exists($actionType, self::getActionTypeList());
- }
- /**
- * 验证用户类型是否有效
- * @param string $userType
- * @return bool
- */
- public static function isValidUserType($userType)
- {
- return array_key_exists($userType, self::getUserTypeList());
- }
- /**
- * 验证操作员类型是否有效
- * @param string $operatorType
- * @return bool
- */
- public static function isValidOperatorType($operatorType)
- {
- return array_key_exists($operatorType, self::getOperatorTypeList());
- }
- /**
- * 验证优先级是否有效
- * @param int $priority
- * @return bool
- */
- public static function isValidPriority($priority)
- {
- return array_key_exists($priority, self::getPriorityList());
- }
- /**
- * 根据操作类型获取默认优先级
- * @param string $actionType
- * @return int
- */
- public static function getDefaultPriority($actionType)
- {
- $priorityMap = [
- self::ACTION_CREATE => self::PRIORITY_NORMAL,
- self::ACTION_PAY => self::PRIORITY_HIGH,
- self::ACTION_SHIP => self::PRIORITY_HIGH,
- self::ACTION_RECEIVE => self::PRIORITY_NORMAL,
- self::ACTION_CANCEL => self::PRIORITY_HIGH,
- self::ACTION_REFUND => self::PRIORITY_URGENT,
- self::ACTION_RETURN => self::PRIORITY_HIGH,
- self::ACTION_COMPLETE => self::PRIORITY_NORMAL,
- self::ACTION_COMMENT => self::PRIORITY_LOW,
- self::ACTION_MODIFY => self::PRIORITY_NORMAL,
- self::ACTION_REMIND => self::PRIORITY_LOW,
- self::ACTION_ADMIN_CANCEL => self::PRIORITY_HIGH,
- self::ACTION_AUTO_CANCEL => self::PRIORITY_NORMAL,
- self::ACTION_AUTO_CONFIRM => self::PRIORITY_NORMAL,
- ];
- return $priorityMap[$actionType] ?? self::PRIORITY_NORMAL;
- }
- /**
- * 根据用户类型获取默认操作员类型
- * @param string $userType
- * @return string
- */
- public static function getDefaultOperatorType($userType)
- {
- $operatorMap = [
- self::USER_TYPE_CUSTOMER => self::OPERATOR_TYPE_USER,
- self::USER_TYPE_ADMIN => self::OPERATOR_TYPE_ADMIN,
- self::USER_TYPE_SYSTEM => self::OPERATOR_TYPE_SYSTEM,
- ];
- return $operatorMap[$userType] ?? self::OPERATOR_TYPE_USER;
- }
- }
|