优化每日推送和积分转化逻辑
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace app\common\library;
|
||||
|
||||
use app\common\model\MallBusinessConfig;
|
||||
use app\common\model\MallDailyPush;
|
||||
use app\common\model\MallUserAsset;
|
||||
use ba\Random;
|
||||
@@ -28,9 +29,9 @@ class MallDailyPushLogReplay
|
||||
$stats['unique_members'] = count($records);
|
||||
|
||||
[$dailyMap, $assetByPlayxId, $assetByUsername] = $this->preloadExistingData($records);
|
||||
$ratios = MallPlayxRatios::get();
|
||||
$returnRatio = floatval($ratios['return_ratio'] ?? 0);
|
||||
$unlockRatio = floatval($ratios['unlock_ratio'] ?? 0);
|
||||
$configRow = MallBusinessConfig::ensureRow();
|
||||
$pointsConfig = MallPointsConversion::configFromRow($configRow);
|
||||
$unlockRatio = floatval($pointsConfig['unlock_ratio'] ?? 0);
|
||||
[$backupHandle, $backupPath] = $this->openBackup($dryRun);
|
||||
$stats['backup_file'] = $backupPath;
|
||||
|
||||
@@ -45,7 +46,7 @@ class MallDailyPushLogReplay
|
||||
$record,
|
||||
$daily,
|
||||
$asset,
|
||||
$returnRatio,
|
||||
$pointsConfig,
|
||||
$unlockRatio,
|
||||
$dryRun,
|
||||
$backupHandle,
|
||||
@@ -249,21 +250,29 @@ class MallDailyPushLogReplay
|
||||
array $record,
|
||||
?MallDailyPush $daily,
|
||||
?MallUserAsset $asset,
|
||||
float $returnRatio,
|
||||
array $pointsConfig,
|
||||
float $unlockRatio,
|
||||
bool $dryRun,
|
||||
$backupHandle,
|
||||
array &$stats
|
||||
): array {
|
||||
$oldWinLossNet = $daily ? floatval($daily->yesterday_win_loss_net ?? 0) : 0.0;
|
||||
$lockedDelta = $this->lockedContribution($record['yesterday_win_loss_net'], $returnRatio)
|
||||
- $this->lockedContribution($oldWinLossNet, $returnRatio);
|
||||
$newLocked = MallPointsConversion::dailyConvertedPoints(
|
||||
$record['date'],
|
||||
floatval($record['yesterday_win_loss_net']),
|
||||
$pointsConfig
|
||||
);
|
||||
$oldLocked = $daily
|
||||
? MallPointsConversion::dailyConvertedPoints($record['date'], $oldWinLossNet, $pointsConfig)
|
||||
: 0;
|
||||
$lockedDelta = $newLocked - $oldLocked;
|
||||
$todayLimit = intval(round($record['yesterday_total_deposit'] * $unlockRatio));
|
||||
$dailyData = [
|
||||
'user_id' => $record['user_id'],
|
||||
'date' => $record['date'],
|
||||
'username' => $record['username'],
|
||||
'yesterday_win_loss_net' => $record['yesterday_win_loss_net'],
|
||||
'converted_points' => $newLocked,
|
||||
'yesterday_total_deposit' => $record['yesterday_total_deposit'],
|
||||
'lifetime_total_deposit' => $record['lifetime_total_deposit'],
|
||||
'lifetime_total_withdraw' => $record['lifetime_total_withdraw'],
|
||||
@@ -317,6 +326,10 @@ class MallDailyPushLogReplay
|
||||
'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' => $record['create_time'],
|
||||
'update_time' => time(),
|
||||
]);
|
||||
@@ -336,7 +349,7 @@ class MallDailyPushLogReplay
|
||||
|
||||
if ($assetWillUpdate) {
|
||||
if ($lockedDelta !== 0) {
|
||||
$asset->locked_points = max(0, intval($asset->locked_points ?? 0) + $lockedDelta);
|
||||
MallPointsConversion::applyDailyConversionDelta($asset, $lockedDelta);
|
||||
}
|
||||
$this->applyDailyLimit($asset, $record['date'], $todayLimit);
|
||||
$asset->save();
|
||||
@@ -404,6 +417,7 @@ class MallDailyPushLogReplay
|
||||
}
|
||||
foreach ([
|
||||
'yesterday_win_loss_net',
|
||||
'converted_points',
|
||||
'yesterday_total_deposit',
|
||||
'lifetime_total_deposit',
|
||||
'lifetime_total_withdraw',
|
||||
|
||||
Reference in New Issue
Block a user