优化每日推送和积分转化逻辑

This commit is contained in:
2026-07-24 11:12:29 +08:00
parent b2b4fd4fbc
commit 4bad91b8a3
29 changed files with 661 additions and 102 deletions

View File

@@ -15,11 +15,50 @@ class MallBusinessConfig extends Model
protected bool $autoWriteTimestamp = true;
public const DEFAULT_RETURN_RATIO = 0.1;
public const DEFAULT_UNLOCK_RATIO = 0.1;
public const DEFAULT_POINTS_TO_CASH_RATIO = 0.1;
public const DEFAULT_LIFETIME_POINTS_RATIO = 0.1;
protected array $type = [
'create_time' => 'integer',
'update_time' => 'integer',
'return_ratio' => 'float',
'unlock_ratio' => 'float',
'points_to_cash_ratio' => 'float',
'create_time' => 'integer',
'update_time' => 'integer',
'return_ratio' => 'float',
'unlock_ratio' => 'float',
'points_to_cash_ratio' => 'float',
'daily_points_enabled' => 'integer',
'lifetime_points_enabled' => 'integer',
'lifetime_points_ratio' => 'float',
'mall_open_date' => 'string',
'mall_open_date_previous' => 'string',
'mall_open_date_effective_on' => 'string',
];
/**
* 保证存在一条商城参数配置(比例仅来自后台 mall_business_config不再读 .env
*/
public static function ensureRow(): self
{
$row = self::order('id', 'asc')->find();
if ($row) {
return $row;
}
$now = time();
$created = self::create([
'return_ratio' => self::DEFAULT_RETURN_RATIO,
'unlock_ratio' => self::DEFAULT_UNLOCK_RATIO,
'points_to_cash_ratio' => self::DEFAULT_POINTS_TO_CASH_RATIO,
'daily_points_enabled' => 1,
'lifetime_points_enabled' => 0,
'lifetime_points_ratio' => self::DEFAULT_LIFETIME_POINTS_RATIO,
'create_time' => $now,
'update_time' => $now,
]);
if (!$created) {
throw new \RuntimeException('Failed to create mall_business_config');
}
return $created;
}
}

View File

@@ -15,9 +15,11 @@ class MallDailyPush extends Model
protected array $type = [
'yesterday_win_loss_net' => 'float',
'converted_points' => 'integer',
'yesterday_total_deposit' => 'float',
'lifetime_total_deposit' => 'float',
'lifetime_total_withdraw' => 'float',
'lifetime_win_loss_net' => 'float',
'create_time' => 'integer',
];
}

View File

@@ -24,6 +24,10 @@ class MallUserAsset extends Model
'today_limit' => 'integer',
'today_claimed' => 'integer',
'admin_id' => 'integer',
'points_claim_cap' => 'integer',
'total_points_claimed' => 'integer',
'lifetime_converted_points' => 'integer',
'daily_converted_points' => 'integer',
];
/**
@@ -62,6 +66,10 @@ class MallUserAsset extends Model
'today_limit' => 0,
'today_claimed' => 0,
'today_limit_date' => null,
'points_claim_cap' => 0,
'total_points_claimed' => 0,
'lifetime_converted_points' => 0,
'daily_converted_points' => 0,
'create_time' => $now,
'update_time' => $now,
]);