OrderActionEnum.php 7.1 KB

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