|
@@ -7,10 +7,14 @@ 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_STATUS_NOT_STARTED = 1; // 未开始
|
|
|
+ const ACTIVITY_STATUS_ONGOING = 2; // 进行中
|
|
|
+ const ACTIVITY_STATUS_ENDED = 3; // 已结束
|
|
|
+ const ACTIVITY_STATUS_CANCELLED = 4; // 已取消
|
|
|
+ const ACTIVITY_STATUS_SUSPENDED = 5; // 已暂停
|
|
|
+ const ACTIVITY_STATUS_CLOSED = 6; // 已关闭
|
|
|
+ const ACTIVITY_STATUS_DELETED = 7; // 已删除
|
|
|
+ const ACTIVITY_STATUS_EXPIRED = 8; // 已过期
|
|
|
|
|
|
// ============ 活动类型 ============
|
|
|
const ACTIVITY_TYPE_CONSUMPTION_LOTTERY = 1; // 消费抽奖
|
|
@@ -70,17 +74,35 @@ class ActivityEnum
|
|
|
const REDEEM_EXPIRE_FIXED = 2; // 固定时长
|
|
|
|
|
|
/**
|
|
|
- * 获取活动状态映射
|
|
|
+ * 获取活动状态映射(页面显示用)
|
|
|
*/
|
|
|
public static function getActivityStatusMap()
|
|
|
{
|
|
|
return [
|
|
|
- self::ACTIVITY_STATUS_DRAFT => '草稿',
|
|
|
+ self::ACTIVITY_STATUS_NOT_STARTED => '未开始',
|
|
|
self::ACTIVITY_STATUS_ONGOING => '进行中',
|
|
|
self::ACTIVITY_STATUS_ENDED => '已结束',
|
|
|
+ self::ACTIVITY_STATUS_CANCELLED => '已取消',
|
|
|
self::ACTIVITY_STATUS_SUSPENDED => '已暂停',
|
|
|
];
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取全部活动状态映射(包含逻辑状态)
|
|
|
+ */
|
|
|
+ public static function getAllActivityStatusMap()
|
|
|
+ {
|
|
|
+ return [
|
|
|
+ self::ACTIVITY_STATUS_NOT_STARTED => '未开始',
|
|
|
+ self::ACTIVITY_STATUS_ONGOING => '进行中',
|
|
|
+ self::ACTIVITY_STATUS_ENDED => '已结束',
|
|
|
+ self::ACTIVITY_STATUS_CANCELLED => '已取消',
|
|
|
+ self::ACTIVITY_STATUS_SUSPENDED => '已暂停',
|
|
|
+ self::ACTIVITY_STATUS_CLOSED => '已关闭',
|
|
|
+ self::ACTIVITY_STATUS_DELETED => '已删除',
|
|
|
+ self::ACTIVITY_STATUS_EXPIRED => '已过期',
|
|
|
+ ];
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 获取活动类型映射
|
|
@@ -149,15 +171,18 @@ class ActivityEnum
|
|
|
*/
|
|
|
public static function getPrizeDefaultImageMap()
|
|
|
{
|
|
|
+ // 从配置文件获取图片路径
|
|
|
+ $config = config('site');
|
|
|
+
|
|
|
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',
|
|
|
+ self::PRIZE_TYPE_NO_PRIZE => $config['prize_losing_lottery'] ?? '/assets/img/avatar.png',
|
|
|
+ self::PRIZE_TYPE_GOODS => $config['prize_goods'] ?? '/assets/img/package.png',
|
|
|
+ self::PRIZE_TYPE_POINTS => $config['prize_credit'] ?? '/assets/img/circle.png',
|
|
|
+ self::PRIZE_TYPE_BALANCE => $config['prize_balance'] ?? '/assets/img/circle.png',
|
|
|
+ self::PRIZE_TYPE_COUPON => $config['prize_coupon'] ?? '/assets/img/circle.png',
|
|
|
+ self::PRIZE_TYPE_REDPACK => $config['prize_redbag'] ?? '/assets/img/circle.png',
|
|
|
+ self::PRIZE_TYPE_CODE => $config['prize_code'] ?? '/assets/img/circle.png',
|
|
|
+ self::PRIZE_TYPE_SHOP_GOODS => $config['prize_shop_goods'] ?? '/assets/img/package.png',
|
|
|
];
|
|
|
}
|
|
|
|
|
@@ -238,7 +263,7 @@ class ActivityEnum
|
|
|
*/
|
|
|
public static function getActivityStatusText($status)
|
|
|
{
|
|
|
- $map = self::getActivityStatusMap();
|
|
|
+ $map = self::getAllActivityStatusMap();
|
|
|
return $map[$status] ?? '未知';
|
|
|
}
|
|
|
|
|
@@ -270,14 +295,34 @@ class ActivityEnum
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 验证活动状态是否有效
|
|
|
+ * 验证活动状态是否有效(包含所有状态)
|
|
|
*/
|
|
|
public static function isValidActivityStatus($status)
|
|
|
{
|
|
|
+ return array_key_exists($status, self::getAllActivityStatusMap());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断是否为可在页面显示的状态
|
|
|
+ */
|
|
|
+ public static function isDisplayableStatus($status)
|
|
|
+ {
|
|
|
return array_key_exists($status, self::getActivityStatusMap());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 判断是否为逻辑状态(不在页面显示)
|
|
|
+ */
|
|
|
+ public static function isLogicalStatus($status)
|
|
|
+ {
|
|
|
+ return in_array($status, [
|
|
|
+ self::ACTIVITY_STATUS_CLOSED,
|
|
|
+ self::ACTIVITY_STATUS_DELETED,
|
|
|
+ self::ACTIVITY_STATUS_EXPIRED
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 验证奖品类型是否有效
|
|
|
*/
|
|
|
public static function isValidPrizeType($type)
|