积分与余额账务系统硬切重构
This commit is contained in:
@@ -170,6 +170,17 @@ class SchemaProvider {
|
||||
$errors[] = sprintf('%s is required', $field['label'] ?? $key);
|
||||
continue;
|
||||
}
|
||||
if (($field['sanitize_type'] ?? '') === 'money_decimal') {
|
||||
try {
|
||||
if (!is_string($value)) {
|
||||
throw new \InvalidArgumentException('money_decimal_must_be_string');
|
||||
}
|
||||
\AKSRT\Ledger\AssetAmount::balance(trim($value));
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$errors[] = sprintf('%s must be a decimal string with at most two fractional digits', $field['label'] ?? $key);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$type = $field['type'] ?? 'input';
|
||||
if (($type === 'number' || $type === 'slider') && !is_numeric($value)) {
|
||||
@@ -259,13 +270,20 @@ class SchemaProvider {
|
||||
$stored = get_option('aksrt_settings', []);
|
||||
$merged = is_array($stored) ? array_merge($stored, $data) : $data;
|
||||
$count = $merged['affiliate_daily_withdrawal_count'] ?? 3;
|
||||
$min = (float) ($merged['affiliate_min_withdrawal'] ?? 50);
|
||||
$limit = (float) ($merged['affiliate_daily_withdrawal_limit'] ?? 500);
|
||||
$min_raw = $merged['affiliate_min_withdrawal'] ?? '50.00';
|
||||
$limit_raw = $merged['affiliate_daily_withdrawal_limit'] ?? '500.00';
|
||||
$time = (string) ($merged['affiliate_withdrawal_reset_time'] ?? '00:00');
|
||||
if (filter_var($count, FILTER_VALIDATE_INT) === false || (int) $count < 0) {
|
||||
$errors[] = __('每日可提现次数必须是非负整数', 'aksrt');
|
||||
}
|
||||
if ($limit < $min) {
|
||||
try {
|
||||
$min_minor = \AKSRT\Ledger\AssetAmount::balance(is_string($min_raw) ? $min_raw : '')->minor();
|
||||
$limit_minor = \AKSRT\Ledger\AssetAmount::balance(is_string($limit_raw) ? $limit_raw : '')->minor();
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$min_minor = 0;
|
||||
$limit_minor = 0;
|
||||
}
|
||||
if ($limit_minor < $min_minor) {
|
||||
$errors[] = __('每日提现上限不得低于最低提现金额', 'aksrt');
|
||||
}
|
||||
if (preg_match('/^(?:[01]\\d|2[0-3]):[0-5]\\d$/', $time) !== 1) {
|
||||
@@ -463,6 +481,15 @@ class SchemaProvider {
|
||||
return !empty($value);
|
||||
case 'float':
|
||||
return (float) $value;
|
||||
case 'money_decimal':
|
||||
if (!is_string($value)) {
|
||||
return '';
|
||||
}
|
||||
try {
|
||||
return \AKSRT\Ledger\AssetAmount::balance(trim($value))->decimal();
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
return '';
|
||||
}
|
||||
case 'array':
|
||||
// 深层字符串净化,保留嵌套服务商配置(如 geetest.captcha_id)
|
||||
if (!is_array($value)) {
|
||||
|
||||
Reference in New Issue
Block a user