123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- <?php
- namespace app\common\Enum;
- /**
- * 抽奖活动相关枚举类
- */
- class ActivityEnum
- {
- // ============ 活动基础状态 ============
- const ACTIVITY_STATUS_DRAFT = 0; // 草稿
- const ACTIVITY_STATUS_ONGOING = 1; // 进行中
- const ACTIVITY_STATUS_ENDED = 2; // 已结束
- const ACTIVITY_STATUS_SUSPENDED = 3; // 已暂停
- // ============ 活动类型 ============
- const ACTIVITY_TYPE_CONSUMPTION_LOTTERY = 1; // 消费抽奖
- // ============ 开奖方式 ============
- const LOTTERY_TYPE_INSTANT = 1; // 即抽即中
- const LOTTERY_TYPE_TIME = 2; // 按时间开奖
- const LOTTERY_TYPE_PEOPLE = 3; // 按人数开奖
- // ============ 用户群体类型 ============
- const USER_LIMIT_ALL = 1; // 全部会员
- const USER_LIMIT_LEVEL = 2; // 会员等级
- const USER_LIMIT_TAG = 3; // 会员标签
- // ============ 引导样式 ============
- const GUIDE_STYLE_DEFAULT = 1; // 默认样式
- const GUIDE_STYLE_CUSTOM = 2; // 自定义
- // ============ 奖品类型 ============
- const PRIZE_TYPE_NO_PRIZE = 1; // 未中奖
- const PRIZE_TYPE_GOODS = 2; // 实物奖品
- const PRIZE_TYPE_POINTS = 3; // 积分
- const PRIZE_TYPE_BALANCE = 4; // 余额
- const PRIZE_TYPE_COUPON = 5; // 优惠券
- const PRIZE_TYPE_REDPACK = 6; // 红包
- const PRIZE_TYPE_CODE = 7; // 兑换码
- const PRIZE_TYPE_SHOP_GOODS = 8; // 商城奖品
- // ============ 奖品发放方式 ============
- const DELIVER_TYPE_AUTO = 1; // 自动发放
- const DELIVER_TYPE_MANUAL = 2; // 手动发放
- // ============ 奖品发放状态 ============
- const DELIVER_STATUS_PENDING = 0; // 待发放
- const DELIVER_STATUS_SUCCESS = 1; // 已发放
- const DELIVER_STATUS_FAILED = 2; // 发放失败
- const DELIVER_STATUS_CANCELLED = 3; // 已取消
- // ============ 参与条件类型 ============
- const CONDITION_TYPE_BUY_GOODS = 1; // 购买指定商品
- const CONDITION_TYPE_ORDER_AMOUNT = 2; // 单笔订单消费满额
- const CONDITION_TYPE_RECHARGE_AMOUNT = 3; // 单次充值满额
- const CONDITION_TYPE_TOTAL_AMOUNT = 4; // 活动期间累计消费满额
- // ============ 商品规则 ============
- const GOODS_RULE_INCLUDE = 1; // 指定商品参与
- const GOODS_RULE_EXCLUDE = 2; // 指定商品不可参与
- // ============ 触发类型 ============
- const TRIGGER_TYPE_BUY_GOODS = 1; // 购买商品
- const TRIGGER_TYPE_ORDER_CONSUME = 2; // 订单消费
- const TRIGGER_TYPE_RECHARGE = 3; // 充值
- const TRIGGER_TYPE_TOTAL_CONSUME = 4; // 累计消费
- // ============ 兑奖期限类型 ============
- const REDEEM_EXPIRE_FOREVER = 1; // 永久有效
- const REDEEM_EXPIRE_FIXED = 2; // 固定时长
- /**
- * 获取活动状态映射
- */
- public static function getActivityStatusMap()
- {
- return [
- self::ACTIVITY_STATUS_DRAFT => '草稿',
- self::ACTIVITY_STATUS_ONGOING => '进行中',
- self::ACTIVITY_STATUS_ENDED => '已结束',
- self::ACTIVITY_STATUS_SUSPENDED => '已暂停',
- ];
- }
- /**
- * 获取活动类型映射
- */
- public static function getActivityTypeMap()
- {
- return [
- self::ACTIVITY_TYPE_CONSUMPTION_LOTTERY => '消费抽奖',
- ];
- }
- /**
- * 获取开奖方式映射
- */
- public static function getLotteryTypeMap()
- {
- return [
- self::LOTTERY_TYPE_INSTANT => '即抽即中',
- self::LOTTERY_TYPE_TIME => '按时间开奖',
- self::LOTTERY_TYPE_PEOPLE => '按人数开奖',
- ];
- }
- /**
- * 获取用户群体类型映射
- */
- public static function getUserLimitTypeMap()
- {
- return [
- self::USER_LIMIT_ALL => '全部会员',
- self::USER_LIMIT_LEVEL => '会员等级',
- self::USER_LIMIT_TAG => '会员标签',
- ];
- }
- /**
- * 获取引导样式映射
- */
- public static function getGuideStyleMap()
- {
- return [
- self::GUIDE_STYLE_DEFAULT => '默认样式',
- self::GUIDE_STYLE_CUSTOM => '自定义',
- ];
- }
- /**
- * 获取奖品类型映射
- */
- public static function getPrizeTypeMap()
- {
- return [
- self::PRIZE_TYPE_NO_PRIZE => '未中奖',
- self::PRIZE_TYPE_GOODS => '实物奖品',
- self::PRIZE_TYPE_POINTS => '积分',
- self::PRIZE_TYPE_BALANCE => '余额',
- self::PRIZE_TYPE_COUPON => '优惠券',
- self::PRIZE_TYPE_REDPACK => '红包',
- self::PRIZE_TYPE_CODE => '兑换码',
- self::PRIZE_TYPE_SHOP_GOODS => '商城奖品',
- ];
- }
- /**
- * 获取奖品默认图片映射
- */
- public static function getPrizeDefaultImageMap()
- {
- return [
- self::PRIZE_TYPE_NO_PRIZE => '/assets/img/lottery/no_prize.png',
- self::PRIZE_TYPE_GOODS => '/assets/img/lottery/goods.png',
- self::PRIZE_TYPE_POINTS => '/assets/img/lottery/points.png',
- self::PRIZE_TYPE_BALANCE => '/assets/img/lottery/balance.png',
- self::PRIZE_TYPE_COUPON => '/assets/img/lottery/coupon.png',
- self::PRIZE_TYPE_REDPACK => '/assets/img/lottery/redpack.png',
- self::PRIZE_TYPE_CODE => '/assets/img/lottery/code.png',
- self::PRIZE_TYPE_SHOP_GOODS => '/assets/img/lottery/shop_goods.png',
- ];
- }
- /**
- * 获取奖品发放方式映射
- */
- public static function getDeliverTypeMap()
- {
- return [
- self::DELIVER_TYPE_AUTO => '自动发放',
- self::DELIVER_TYPE_MANUAL => '手动发放',
- ];
- }
- /**
- * 获取奖品发放状态映射
- */
- public static function getDeliverStatusMap()
- {
- return [
- self::DELIVER_STATUS_PENDING => '待发放',
- self::DELIVER_STATUS_SUCCESS => '已发放',
- self::DELIVER_STATUS_FAILED => '发放失败',
- self::DELIVER_STATUS_CANCELLED => '已取消',
- ];
- }
- /**
- * 获取参与条件类型映射
- */
- public static function getConditionTypeMap()
- {
- return [
- self::CONDITION_TYPE_BUY_GOODS => '购买指定商品',
- self::CONDITION_TYPE_ORDER_AMOUNT => '单笔订单消费满N元',
- self::CONDITION_TYPE_RECHARGE_AMOUNT => '单次充值金额满N元',
- self::CONDITION_TYPE_TOTAL_AMOUNT => '活动期间累计消费N元',
- ];
- }
- /**
- * 获取商品规则映射
- */
- public static function getGoodsRuleMap()
- {
- return [
- self::GOODS_RULE_INCLUDE => '指定商品参与',
- self::GOODS_RULE_EXCLUDE => '指定商品不可参与',
- ];
- }
- /**
- * 获取触发类型映射
- */
- public static function getTriggerTypeMap()
- {
- return [
- self::TRIGGER_TYPE_BUY_GOODS => '购买商品',
- self::TRIGGER_TYPE_ORDER_CONSUME => '订单消费',
- self::TRIGGER_TYPE_RECHARGE => '充值',
- self::TRIGGER_TYPE_TOTAL_CONSUME => '累计消费',
- ];
- }
- /**
- * 获取兑奖期限类型映射
- */
- public static function getRedeemExpireTypeMap()
- {
- return [
- self::REDEEM_EXPIRE_FOREVER => '永久有效',
- self::REDEEM_EXPIRE_FIXED => '固定时长',
- ];
- }
- /**
- * 获取活动状态文本
- */
- public static function getActivityStatusText($status)
- {
- $map = self::getActivityStatusMap();
- return $map[$status] ?? '未知';
- }
- /**
- * 获取奖品类型文本
- */
- public static function getPrizeTypeText($type)
- {
- $map = self::getPrizeTypeMap();
- return $map[$type] ?? '未知';
- }
- /**
- * 获取开奖方式文本
- */
- public static function getLotteryTypeText($type)
- {
- $map = self::getLotteryTypeMap();
- return $map[$type] ?? '未知';
- }
- /**
- * 获取条件类型文本
- */
- public static function getConditionTypeText($type)
- {
- $map = self::getConditionTypeMap();
- return $map[$type] ?? '未知';
- }
- /**
- * 验证活动状态是否有效
- */
- public static function isValidActivityStatus($status)
- {
- return array_key_exists($status, self::getActivityStatusMap());
- }
- /**
- * 验证奖品类型是否有效
- */
- public static function isValidPrizeType($type)
- {
- return array_key_exists($type, self::getPrizeTypeMap());
- }
- /**
- * 验证开奖方式是否有效
- */
- public static function isValidLotteryType($type)
- {
- return array_key_exists($type, self::getLotteryTypeMap());
- }
- /**
- * 验证条件类型是否有效
- */
- public static function isValidConditionType($type)
- {
- return array_key_exists($type, self::getConditionTypeMap());
- }
- }
|