ActivityEnum.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <?php
  2. namespace app\common\Enum;
  3. /**
  4. * 抽奖活动相关枚举类
  5. */
  6. class ActivityEnum
  7. {
  8. // ============ 活动基础状态 ============
  9. const ACTIVITY_STATUS_DRAFT = 0; // 草稿
  10. const ACTIVITY_STATUS_ONGOING = 1; // 进行中
  11. const ACTIVITY_STATUS_ENDED = 2; // 已结束
  12. const ACTIVITY_STATUS_SUSPENDED = 3; // 已暂停
  13. // ============ 活动类型 ============
  14. const ACTIVITY_TYPE_CONSUMPTION_LOTTERY = 1; // 消费抽奖
  15. // ============ 开奖方式 ============
  16. const LOTTERY_TYPE_INSTANT = 1; // 即抽即中
  17. const LOTTERY_TYPE_TIME = 2; // 按时间开奖
  18. const LOTTERY_TYPE_PEOPLE = 3; // 按人数开奖
  19. // ============ 用户群体类型 ============
  20. const USER_LIMIT_ALL = 1; // 全部会员
  21. const USER_LIMIT_LEVEL = 2; // 会员等级
  22. const USER_LIMIT_TAG = 3; // 会员标签
  23. // ============ 引导样式 ============
  24. const GUIDE_STYLE_DEFAULT = 1; // 默认样式
  25. const GUIDE_STYLE_CUSTOM = 2; // 自定义
  26. // ============ 奖品类型 ============
  27. const PRIZE_TYPE_NO_PRIZE = 1; // 未中奖
  28. const PRIZE_TYPE_GOODS = 2; // 实物奖品
  29. const PRIZE_TYPE_POINTS = 3; // 积分
  30. const PRIZE_TYPE_BALANCE = 4; // 余额
  31. const PRIZE_TYPE_COUPON = 5; // 优惠券
  32. const PRIZE_TYPE_REDPACK = 6; // 红包
  33. const PRIZE_TYPE_CODE = 7; // 兑换码
  34. const PRIZE_TYPE_SHOP_GOODS = 8; // 商城奖品
  35. // ============ 奖品发放方式 ============
  36. const DELIVER_TYPE_AUTO = 1; // 自动发放
  37. const DELIVER_TYPE_MANUAL = 2; // 手动发放
  38. // ============ 奖品发放状态 ============
  39. const DELIVER_STATUS_PENDING = 0; // 待发放
  40. const DELIVER_STATUS_SUCCESS = 1; // 已发放
  41. const DELIVER_STATUS_FAILED = 2; // 发放失败
  42. const DELIVER_STATUS_CANCELLED = 3; // 已取消
  43. // ============ 参与条件类型 ============
  44. const CONDITION_TYPE_BUY_GOODS = 1; // 购买指定商品
  45. const CONDITION_TYPE_ORDER_AMOUNT = 2; // 单笔订单消费满额
  46. const CONDITION_TYPE_RECHARGE_AMOUNT = 3; // 单次充值满额
  47. const CONDITION_TYPE_TOTAL_AMOUNT = 4; // 活动期间累计消费满额
  48. // ============ 商品规则 ============
  49. const GOODS_RULE_INCLUDE = 1; // 指定商品参与
  50. const GOODS_RULE_EXCLUDE = 2; // 指定商品不可参与
  51. // ============ 触发类型 ============
  52. const TRIGGER_TYPE_BUY_GOODS = 1; // 购买商品
  53. const TRIGGER_TYPE_ORDER_CONSUME = 2; // 订单消费
  54. const TRIGGER_TYPE_RECHARGE = 3; // 充值
  55. const TRIGGER_TYPE_TOTAL_CONSUME = 4; // 累计消费
  56. // ============ 兑奖期限类型 ============
  57. const REDEEM_EXPIRE_FOREVER = 1; // 永久有效
  58. const REDEEM_EXPIRE_FIXED = 2; // 固定时长
  59. /**
  60. * 获取活动状态映射
  61. */
  62. public static function getActivityStatusMap()
  63. {
  64. return [
  65. self::ACTIVITY_STATUS_DRAFT => '草稿',
  66. self::ACTIVITY_STATUS_ONGOING => '进行中',
  67. self::ACTIVITY_STATUS_ENDED => '已结束',
  68. self::ACTIVITY_STATUS_SUSPENDED => '已暂停',
  69. ];
  70. }
  71. /**
  72. * 获取活动类型映射
  73. */
  74. public static function getActivityTypeMap()
  75. {
  76. return [
  77. self::ACTIVITY_TYPE_CONSUMPTION_LOTTERY => '消费抽奖',
  78. ];
  79. }
  80. /**
  81. * 获取开奖方式映射
  82. */
  83. public static function getLotteryTypeMap()
  84. {
  85. return [
  86. self::LOTTERY_TYPE_INSTANT => '即抽即中',
  87. self::LOTTERY_TYPE_TIME => '按时间开奖',
  88. self::LOTTERY_TYPE_PEOPLE => '按人数开奖',
  89. ];
  90. }
  91. /**
  92. * 获取用户群体类型映射
  93. */
  94. public static function getUserLimitTypeMap()
  95. {
  96. return [
  97. self::USER_LIMIT_ALL => '全部会员',
  98. self::USER_LIMIT_LEVEL => '会员等级',
  99. self::USER_LIMIT_TAG => '会员标签',
  100. ];
  101. }
  102. /**
  103. * 获取引导样式映射
  104. */
  105. public static function getGuideStyleMap()
  106. {
  107. return [
  108. self::GUIDE_STYLE_DEFAULT => '默认样式',
  109. self::GUIDE_STYLE_CUSTOM => '自定义',
  110. ];
  111. }
  112. /**
  113. * 获取奖品类型映射
  114. */
  115. public static function getPrizeTypeMap()
  116. {
  117. return [
  118. self::PRIZE_TYPE_NO_PRIZE => '未中奖',
  119. self::PRIZE_TYPE_GOODS => '实物奖品',
  120. self::PRIZE_TYPE_POINTS => '积分',
  121. self::PRIZE_TYPE_BALANCE => '余额',
  122. self::PRIZE_TYPE_COUPON => '优惠券',
  123. self::PRIZE_TYPE_REDPACK => '红包',
  124. self::PRIZE_TYPE_CODE => '兑换码',
  125. self::PRIZE_TYPE_SHOP_GOODS => '商城奖品',
  126. ];
  127. }
  128. /**
  129. * 获取奖品默认图片映射
  130. */
  131. public static function getPrizeDefaultImageMap()
  132. {
  133. return [
  134. self::PRIZE_TYPE_NO_PRIZE => '/assets/img/lottery/no_prize.png',
  135. self::PRIZE_TYPE_GOODS => '/assets/img/lottery/goods.png',
  136. self::PRIZE_TYPE_POINTS => '/assets/img/lottery/points.png',
  137. self::PRIZE_TYPE_BALANCE => '/assets/img/lottery/balance.png',
  138. self::PRIZE_TYPE_COUPON => '/assets/img/lottery/coupon.png',
  139. self::PRIZE_TYPE_REDPACK => '/assets/img/lottery/redpack.png',
  140. self::PRIZE_TYPE_CODE => '/assets/img/lottery/code.png',
  141. self::PRIZE_TYPE_SHOP_GOODS => '/assets/img/lottery/shop_goods.png',
  142. ];
  143. }
  144. /**
  145. * 获取奖品发放方式映射
  146. */
  147. public static function getDeliverTypeMap()
  148. {
  149. return [
  150. self::DELIVER_TYPE_AUTO => '自动发放',
  151. self::DELIVER_TYPE_MANUAL => '手动发放',
  152. ];
  153. }
  154. /**
  155. * 获取奖品发放状态映射
  156. */
  157. public static function getDeliverStatusMap()
  158. {
  159. return [
  160. self::DELIVER_STATUS_PENDING => '待发放',
  161. self::DELIVER_STATUS_SUCCESS => '已发放',
  162. self::DELIVER_STATUS_FAILED => '发放失败',
  163. self::DELIVER_STATUS_CANCELLED => '已取消',
  164. ];
  165. }
  166. /**
  167. * 获取参与条件类型映射
  168. */
  169. public static function getConditionTypeMap()
  170. {
  171. return [
  172. self::CONDITION_TYPE_BUY_GOODS => '购买指定商品',
  173. self::CONDITION_TYPE_ORDER_AMOUNT => '单笔订单消费满N元',
  174. self::CONDITION_TYPE_RECHARGE_AMOUNT => '单次充值金额满N元',
  175. self::CONDITION_TYPE_TOTAL_AMOUNT => '活动期间累计消费N元',
  176. ];
  177. }
  178. /**
  179. * 获取商品规则映射
  180. */
  181. public static function getGoodsRuleMap()
  182. {
  183. return [
  184. self::GOODS_RULE_INCLUDE => '指定商品参与',
  185. self::GOODS_RULE_EXCLUDE => '指定商品不可参与',
  186. ];
  187. }
  188. /**
  189. * 获取触发类型映射
  190. */
  191. public static function getTriggerTypeMap()
  192. {
  193. return [
  194. self::TRIGGER_TYPE_BUY_GOODS => '购买商品',
  195. self::TRIGGER_TYPE_ORDER_CONSUME => '订单消费',
  196. self::TRIGGER_TYPE_RECHARGE => '充值',
  197. self::TRIGGER_TYPE_TOTAL_CONSUME => '累计消费',
  198. ];
  199. }
  200. /**
  201. * 获取兑奖期限类型映射
  202. */
  203. public static function getRedeemExpireTypeMap()
  204. {
  205. return [
  206. self::REDEEM_EXPIRE_FOREVER => '永久有效',
  207. self::REDEEM_EXPIRE_FIXED => '固定时长',
  208. ];
  209. }
  210. /**
  211. * 获取活动状态文本
  212. */
  213. public static function getActivityStatusText($status)
  214. {
  215. $map = self::getActivityStatusMap();
  216. return $map[$status] ?? '未知';
  217. }
  218. /**
  219. * 获取奖品类型文本
  220. */
  221. public static function getPrizeTypeText($type)
  222. {
  223. $map = self::getPrizeTypeMap();
  224. return $map[$type] ?? '未知';
  225. }
  226. /**
  227. * 获取开奖方式文本
  228. */
  229. public static function getLotteryTypeText($type)
  230. {
  231. $map = self::getLotteryTypeMap();
  232. return $map[$type] ?? '未知';
  233. }
  234. /**
  235. * 获取条件类型文本
  236. */
  237. public static function getConditionTypeText($type)
  238. {
  239. $map = self::getConditionTypeMap();
  240. return $map[$type] ?? '未知';
  241. }
  242. /**
  243. * 验证活动状态是否有效
  244. */
  245. public static function isValidActivityStatus($status)
  246. {
  247. return array_key_exists($status, self::getActivityStatusMap());
  248. }
  249. /**
  250. * 验证奖品类型是否有效
  251. */
  252. public static function isValidPrizeType($type)
  253. {
  254. return array_key_exists($type, self::getPrizeTypeMap());
  255. }
  256. /**
  257. * 验证开奖方式是否有效
  258. */
  259. public static function isValidLotteryType($type)
  260. {
  261. return array_key_exists($type, self::getLotteryTypeMap());
  262. }
  263. /**
  264. * 验证条件类型是否有效
  265. */
  266. public static function isValidConditionType($type)
  267. {
  268. return array_key_exists($type, self::getConditionTypeMap());
  269. }
  270. }