OrderActionEnum.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. namespace app\common\Enum;
  3. /**
  4. * 订单操作记录枚举
  5. */
  6. class OrderActionEnum
  7. {
  8. // 操作类型
  9. const ACTION_CREATE = 'create'; // 创建订单
  10. const ACTION_PAY = 'pay'; // 支付订单
  11. const ACTION_SHIP = 'ship'; // 发货
  12. const ACTION_RECEIVE = 'receive'; // 确认收货
  13. const ACTION_CANCEL = 'cancel'; // 取消订单
  14. const ACTION_REFUND = 'refund'; // 退款
  15. const ACTION_RETURN = 'return'; // 退货
  16. const ACTION_COMPLETE = 'complete'; // 完成订单
  17. const ACTION_COMMENT = 'comment'; // 评价
  18. const ACTION_MODIFY = 'modify'; // 修改订单
  19. const ACTION_REMIND = 'remind'; // 催单
  20. const ACTION_ADMIN_CANCEL = 'admin_cancel'; // 管理员取消
  21. const ACTION_AUTO_CANCEL = 'auto_cancel'; // 系统自动取消
  22. const ACTION_AUTO_CONFIRM = 'auto_confirm'; // 系统自动确认收货
  23. // 用户类型
  24. const USER_TYPE_CUSTOMER = 'customer'; // 前端用户
  25. const USER_TYPE_ADMIN = 'admin'; // 后台管理员
  26. const USER_TYPE_SYSTEM = 'system'; // 系统操作
  27. // 操作员类型
  28. const OPERATOR_TYPE_USER = 'user'; // 用户操作
  29. const OPERATOR_TYPE_ADMIN = 'admin'; // 管理员操作
  30. const OPERATOR_TYPE_SYSTEM = 'system'; // 系统操作
  31. // 操作优先级
  32. const PRIORITY_LOW = 1; // 低优先级
  33. const PRIORITY_NORMAL = 2; // 普通优先级
  34. const PRIORITY_HIGH = 3; // 高优先级
  35. const PRIORITY_URGENT = 4; // 紧急优先级
  36. /**
  37. * 获取操作类型列表
  38. * @return array
  39. */
  40. public static function getActionTypeList()
  41. {
  42. return [
  43. self::ACTION_CREATE => '创建订单',
  44. self::ACTION_PAY => '支付订单',
  45. self::ACTION_SHIP => '发货',
  46. self::ACTION_RECEIVE => '确认收货',
  47. self::ACTION_CANCEL => '取消订单',
  48. self::ACTION_REFUND => '退款',
  49. self::ACTION_RETURN => '退货',
  50. self::ACTION_COMPLETE => '完成订单',
  51. self::ACTION_COMMENT => '评价',
  52. self::ACTION_MODIFY => '修改订单',
  53. self::ACTION_REMIND => '催单',
  54. self::ACTION_ADMIN_CANCEL => '管理员取消',
  55. self::ACTION_AUTO_CANCEL => '系统自动取消',
  56. self::ACTION_AUTO_CONFIRM => '系统自动确认收货',
  57. ];
  58. }
  59. /**
  60. * 获取操作类型文本
  61. * @param string $actionType
  62. * @return string
  63. */
  64. public static function getActionTypeText($actionType)
  65. {
  66. return self::getActionTypeList()[$actionType] ?? '未知操作';
  67. }
  68. /**
  69. * 获取用户类型列表
  70. * @return array
  71. */
  72. public static function getUserTypeList()
  73. {
  74. return [
  75. self::USER_TYPE_CUSTOMER => '前端用户',
  76. self::USER_TYPE_ADMIN => '后台管理员',
  77. self::USER_TYPE_SYSTEM => '系统操作',
  78. ];
  79. }
  80. /**
  81. * 获取用户类型文本
  82. * @param string $userType
  83. * @return string
  84. */
  85. public static function getUserTypeText($userType)
  86. {
  87. return self::getUserTypeList()[$userType] ?? '未知用户';
  88. }
  89. /**
  90. * 获取操作员类型列表
  91. * @return array
  92. */
  93. public static function getOperatorTypeList()
  94. {
  95. return [
  96. self::OPERATOR_TYPE_USER => '用户操作',
  97. self::OPERATOR_TYPE_ADMIN => '管理员操作',
  98. self::OPERATOR_TYPE_SYSTEM => '系统操作',
  99. ];
  100. }
  101. /**
  102. * 获取操作员类型文本
  103. * @param string $operatorType
  104. * @return string
  105. */
  106. public static function getOperatorTypeText($operatorType)
  107. {
  108. return self::getOperatorTypeList()[$operatorType] ?? '未知操作员';
  109. }
  110. /**
  111. * 获取优先级列表
  112. * @return array
  113. */
  114. public static function getPriorityList()
  115. {
  116. return [
  117. self::PRIORITY_LOW => '低优先级',
  118. self::PRIORITY_NORMAL => '普通优先级',
  119. self::PRIORITY_HIGH => '高优先级',
  120. self::PRIORITY_URGENT => '紧急优先级',
  121. ];
  122. }
  123. /**
  124. * 获取优先级文本
  125. * @param int $priority
  126. * @return string
  127. */
  128. public static function getPriorityText($priority)
  129. {
  130. return self::getPriorityList()[$priority] ?? '未知优先级';
  131. }
  132. /**
  133. * 验证操作类型是否有效
  134. * @param string $actionType
  135. * @return bool
  136. */
  137. public static function isValidActionType($actionType)
  138. {
  139. return array_key_exists($actionType, self::getActionTypeList());
  140. }
  141. /**
  142. * 验证用户类型是否有效
  143. * @param string $userType
  144. * @return bool
  145. */
  146. public static function isValidUserType($userType)
  147. {
  148. return array_key_exists($userType, self::getUserTypeList());
  149. }
  150. /**
  151. * 验证操作员类型是否有效
  152. * @param string $operatorType
  153. * @return bool
  154. */
  155. public static function isValidOperatorType($operatorType)
  156. {
  157. return array_key_exists($operatorType, self::getOperatorTypeList());
  158. }
  159. /**
  160. * 验证优先级是否有效
  161. * @param int $priority
  162. * @return bool
  163. */
  164. public static function isValidPriority($priority)
  165. {
  166. return array_key_exists($priority, self::getPriorityList());
  167. }
  168. /**
  169. * 根据操作类型获取默认优先级
  170. * @param string $actionType
  171. * @return int
  172. */
  173. public static function getDefaultPriority($actionType)
  174. {
  175. $priorityMap = [
  176. self::ACTION_CREATE => self::PRIORITY_NORMAL,
  177. self::ACTION_PAY => self::PRIORITY_HIGH,
  178. self::ACTION_SHIP => self::PRIORITY_HIGH,
  179. self::ACTION_RECEIVE => self::PRIORITY_NORMAL,
  180. self::ACTION_CANCEL => self::PRIORITY_HIGH,
  181. self::ACTION_REFUND => self::PRIORITY_URGENT,
  182. self::ACTION_RETURN => self::PRIORITY_HIGH,
  183. self::ACTION_COMPLETE => self::PRIORITY_NORMAL,
  184. self::ACTION_COMMENT => self::PRIORITY_LOW,
  185. self::ACTION_MODIFY => self::PRIORITY_NORMAL,
  186. self::ACTION_REMIND => self::PRIORITY_LOW,
  187. self::ACTION_ADMIN_CANCEL => self::PRIORITY_HIGH,
  188. self::ACTION_AUTO_CANCEL => self::PRIORITY_NORMAL,
  189. self::ACTION_AUTO_CONFIRM => self::PRIORITY_NORMAL,
  190. ];
  191. return $priorityMap[$actionType] ?? self::PRIORITY_NORMAL;
  192. }
  193. /**
  194. * 根据用户类型获取默认操作员类型
  195. * @param string $userType
  196. * @return string
  197. */
  198. public static function getDefaultOperatorType($userType)
  199. {
  200. $operatorMap = [
  201. self::USER_TYPE_CUSTOMER => self::OPERATOR_TYPE_USER,
  202. self::USER_TYPE_ADMIN => self::OPERATOR_TYPE_ADMIN,
  203. self::USER_TYPE_SYSTEM => self::OPERATOR_TYPE_SYSTEM,
  204. ];
  205. return $operatorMap[$userType] ?? self::OPERATOR_TYPE_USER;
  206. }
  207. }