优化
This commit is contained in:
@@ -52,18 +52,27 @@ class PlayxConfig extends Backend
|
||||
|
||||
$return = $data['return_ratio'] ?? null;
|
||||
$unlock = $data['unlock_ratio'] ?? null;
|
||||
$cash = $data['points_to_cash_ratio'] ?? null;
|
||||
if (!is_numeric($return) || !is_numeric($unlock) || !is_numeric($cash)) {
|
||||
if (!is_numeric($return) || !is_numeric($unlock)) {
|
||||
return $this->error(__('Parameter error'));
|
||||
}
|
||||
|
||||
$returnF = floatval($return);
|
||||
$unlockF = floatval($unlock);
|
||||
$cashF = floatval($cash);
|
||||
if ($returnF < 0 || $unlockF < 0 || $cashF < 0) {
|
||||
if ($returnF < 0 || $unlockF < 0) {
|
||||
return $this->error(__('Parameter error'));
|
||||
}
|
||||
|
||||
$cashF = null;
|
||||
if (array_key_exists('points_to_cash_ratio', $data) && $data['points_to_cash_ratio'] !== null && $data['points_to_cash_ratio'] !== '') {
|
||||
if (!is_numeric($data['points_to_cash_ratio'])) {
|
||||
return $this->error(__('Parameter error'));
|
||||
}
|
||||
$cashF = floatval($data['points_to_cash_ratio']);
|
||||
if ($cashF < 0) {
|
||||
return $this->error(__('Parameter error'));
|
||||
}
|
||||
}
|
||||
|
||||
$dailyEnabled = !empty($data['daily_points_enabled']) ? 1 : 0;
|
||||
$lifetimeEnabled = !empty($data['lifetime_points_enabled']) ? 1 : 0;
|
||||
$lifetimeRatio = $data['lifetime_points_ratio'] ?? null;
|
||||
@@ -85,10 +94,11 @@ class PlayxConfig extends Backend
|
||||
$now = time();
|
||||
if (!$row) {
|
||||
$effectiveOn = $mallOpenDate !== null ? MallPointsConversion::nextCalendarDate() : null;
|
||||
$cashPersist = $cashF ?? MallBusinessConfig::DEFAULT_POINTS_TO_CASH_RATIO;
|
||||
MallBusinessConfig::create([
|
||||
'return_ratio' => $returnF,
|
||||
'unlock_ratio' => $unlockF,
|
||||
'points_to_cash_ratio' => $cashF,
|
||||
'points_to_cash_ratio' => $cashPersist,
|
||||
'daily_points_enabled' => $dailyEnabled,
|
||||
'lifetime_points_enabled' => $lifetimeEnabled,
|
||||
'lifetime_points_ratio' => $lifetimeRatioF,
|
||||
@@ -112,7 +122,9 @@ class PlayxConfig extends Backend
|
||||
|
||||
$row->return_ratio = $returnF;
|
||||
$row->unlock_ratio = $unlockF;
|
||||
$row->points_to_cash_ratio = $cashF;
|
||||
if ($cashF !== null) {
|
||||
$row->points_to_cash_ratio = $cashF;
|
||||
}
|
||||
$row->daily_points_enabled = $dailyEnabled;
|
||||
$row->lifetime_points_enabled = $lifetimeEnabled;
|
||||
$row->lifetime_points_ratio = $lifetimeRatioF;
|
||||
|
||||
Reference in New Issue
Block a user