OrderEnum.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <?php
  2. namespace app\common\Enum;
  3. class OrderEnum
  4. {
  5. /**
  6. * 订单状态
  7. */
  8. const STATUS_CREATE = 101;
  9. const STATUS_PAY = 201;
  10. const STATUS_SHIP = 301;
  11. const STATUS_CONFIRM = 401;
  12. const STATUS_COMMENT = 501;
  13. const STATUS_CANCEL = 102;
  14. const STATUS_AUTO_CANCEL = 103;
  15. const STATUS_ADMIN_CANCEL = 104;
  16. const STATUS_REFUND = 202;
  17. const STATUS_REFUND_CONFIRM = 203;
  18. const STATUS_GROUPON_TIMEOUT = 204;
  19. const STATUS_AUTO_CONFIRM = 402;
  20. // pay_mode 支付模式:online=线上支付,offline=线下支付
  21. const PAY_MODE_ONLINE = 'online';
  22. const PAY_MODE_OFFLINE = 'offline';
  23. // 订单类型
  24. const TYPE_NORMAL = 1; // 普通订单
  25. const TYPE_GROUP = 2; // 拼团订单
  26. const TYPE_SECKILL = 3; // 秒杀订单
  27. const TYPE_PRESALE = 4; // 预售订单
  28. // 发货方式
  29. const DELIVERY_TYPE_EXPRESS = 1; // 快递配送
  30. const DELIVERY_TYPE_PICKUP = 2; // 门店自提
  31. const DELIVERY_TYPE_LOCAL = 3; // 同城配送
  32. const DELIVERY_TYPE_VIRTUAL = 4; // 无需配送
  33. // 发票状态
  34. const INVOICE_STATUS_UNAVAILABLE = -1; // 不可开具
  35. const INVOICE_STATUS_NOT_APPLIED = 0; // 未申请
  36. const INVOICE_STATUS_APPLIED = 1; // 已申请
  37. const INVOICE_STATUS_ISSUED = 2; // 已开具
  38. // 活动类型
  39. const ACTIVITY_TYPE_NORMAL = 'normal'; // 普通活动
  40. const ACTIVITY_TYPE_SECKILL = 'seckill'; // 秒杀活动
  41. const ACTIVITY_TYPE_GROUP = 'group'; // 拼团活动
  42. const ACTIVITY_TYPE_PRESALE = 'presale'; // 预售活动
  43. const ACTIVITY_TYPE_DISCOUNT = 'discount'; // 折扣活动
  44. // 操作类型
  45. const ACTION_TYPE_CREATE = 'create'; // 创建订单
  46. const ACTION_TYPE_PAY = 'pay'; // 支付订单
  47. const ACTION_TYPE_SHIP = 'ship'; // 发货
  48. const ACTION_TYPE_RECEIVE = 'receive'; // 确认收货
  49. const ACTION_TYPE_CANCEL = 'cancel'; // 取消订单
  50. const ACTION_TYPE_REFUND = 'refund'; // 退款
  51. const ACTION_TYPE_RETURN = 'return'; // 退货
  52. const ACTION_TYPE_COMPLETE = 'complete'; // 完成订单
  53. public static function getPayModeList()
  54. {
  55. return [
  56. self::PAY_MODE_ONLINE => '线上支付',
  57. self::PAY_MODE_OFFLINE => '线下支付',
  58. ];
  59. }
  60. public static function getPayModeText($pay_mode)
  61. {
  62. return self::getPayModeList()[$pay_mode] ?? '未知';
  63. }
  64. public static function getOrderTypeList()
  65. {
  66. return [
  67. self::TYPE_NORMAL => '普通订单',
  68. self::TYPE_GROUP => '拼团订单',
  69. self::TYPE_SECKILL => '秒杀订单',
  70. self::TYPE_PRESALE => '预售订单',
  71. ];
  72. }
  73. public static function getOrderTypeText($type)
  74. {
  75. return self::getOrderTypeList()[$type] ?? '未知类型';
  76. }
  77. public static function getDeliveryTypeList()
  78. {
  79. return [
  80. self::DELIVERY_TYPE_EXPRESS => '快递配送',
  81. self::DELIVERY_TYPE_PICKUP => '门店自提',
  82. self::DELIVERY_TYPE_LOCAL => '同城配送',
  83. self::DELIVERY_TYPE_VIRTUAL => '无需配送',
  84. ];
  85. }
  86. public static function getDeliveryTypeText($deliveryType)
  87. {
  88. return self::getDeliveryTypeList()[$deliveryType] ?? '未知';
  89. }
  90. public static function getInvoiceStatusList()
  91. {
  92. return [
  93. self::INVOICE_STATUS_UNAVAILABLE => '不可开具',
  94. self::INVOICE_STATUS_NOT_APPLIED => '未申请',
  95. self::INVOICE_STATUS_APPLIED => '已申请',
  96. self::INVOICE_STATUS_ISSUED => '已开具',
  97. ];
  98. }
  99. public static function getInvoiceStatusText($invoiceStatus)
  100. {
  101. return self::getInvoiceStatusList()[$invoiceStatus] ?? '未知';
  102. }
  103. public static function getActivityTypeList()
  104. {
  105. return [
  106. self::ACTIVITY_TYPE_NORMAL => '普通活动',
  107. self::ACTIVITY_TYPE_SECKILL => '秒杀活动',
  108. self::ACTIVITY_TYPE_GROUP => '拼团活动',
  109. self::ACTIVITY_TYPE_PRESALE => '预售活动',
  110. self::ACTIVITY_TYPE_DISCOUNT => '折扣活动',
  111. ];
  112. }
  113. public static function getActivityTypeText($activityType)
  114. {
  115. return self::getActivityTypeList()[$activityType] ?? $activityType;
  116. }
  117. public static function getActionTypeList()
  118. {
  119. return [
  120. self::ACTION_TYPE_CREATE => '创建订单',
  121. self::ACTION_TYPE_PAY => '支付订单',
  122. self::ACTION_TYPE_SHIP => '发货',
  123. self::ACTION_TYPE_RECEIVE => '确认收货',
  124. self::ACTION_TYPE_CANCEL => '取消订单',
  125. self::ACTION_TYPE_REFUND => '退款',
  126. self::ACTION_TYPE_RETURN => '退货',
  127. self::ACTION_TYPE_COMPLETE => '完成订单',
  128. ];
  129. }
  130. public static function getActionTypeText($actionType)
  131. {
  132. return self::getActionTypeList()[$actionType] ?? $actionType;
  133. }
  134. const STATUS_TEXT_MAP = [
  135. self::STATUS_CREATE => '未付款',
  136. self::STATUS_CANCEL => "已取消",
  137. self::STATUS_AUTO_CANCEL => "已取消(系统)",
  138. self::STATUS_ADMIN_CANCEL => "已取消(管理员)",
  139. self::STATUS_PAY => "已付款",
  140. self::STATUS_REFUND => "订单取消,退款中",
  141. self::STATUS_REFUND_CONFIRM => "已退款",
  142. self::STATUS_GROUPON_TIMEOUT => "已超时团购",
  143. self::STATUS_SHIP => "已发货",
  144. self::STATUS_CONFIRM => "已完成",
  145. self::STATUS_AUTO_CONFIRM => "已收货(系统)",
  146. self::STATUS_COMMENT => "已评价",
  147. ];
  148. const STATUS_TIME_MAP = [
  149. self::STATUS_CREATE => 'createtime',
  150. self::STATUS_PAY => 'pay_time',
  151. self::STATUS_SHIP => 'shipping_time',
  152. self::STATUS_CONFIRM => 'receive_time',
  153. self::STATUS_AUTO_CONFIRM => 'receive_time',
  154. self::STATUS_COMMENT => 'evaluate_time',
  155. self::STATUS_REFUND => 'refund_time',
  156. self::STATUS_REFUND_CONFIRM => 'refund_time',
  157. self::STATUS_AUTO_CANCEL => 'expire_time',
  158. self::STATUS_CANCEL => 'cancel_time',
  159. ];
  160. public static function isValidOrderStatus($status)
  161. {
  162. return isset(self::STATUS_TEXT_MAP[$status]);
  163. }
  164. public static function getOrderStatusList()
  165. {
  166. return self::STATUS_TEXT_MAP;
  167. }
  168. public static function getOrderStatusText($status)
  169. {
  170. return self::STATUS_TEXT_MAP[$status] ?? '未知';
  171. }
  172. const SHOW_TYPE_ALL = 0;//全部订单
  173. const SHOW_TYPE_WAIT_PAY = 1;//待付款订单
  174. const SHOW_TYPE_WAIT_DELIVERY = 2;//待发货订单
  175. const SHOW_TYPE_WAIT_RECEIPT = 3;//待收货订单
  176. const SHOW_TYPE_WAIT_COMMENT = 4;//待评价订单
  177. const SHOW_TYPE_STATUS_MAP = [
  178. self::SHOW_TYPE_ALL => [],
  179. self::SHOW_TYPE_WAIT_PAY => [self::STATUS_CREATE],
  180. self::SHOW_TYPE_WAIT_DELIVERY => [self::STATUS_PAY],
  181. self::SHOW_TYPE_WAIT_RECEIPT => [self::STATUS_SHIP],
  182. self::SHOW_TYPE_WAIT_COMMENT => [self::STATUS_CONFIRM],
  183. ];
  184. }