积分与余额账务系统硬切重构

This commit is contained in:
kate522 committed 2026-08-24 15:59:11 +08:00
1 parent ca12226b39
commit 5cae5b5c93
159 files changed
+7275 -4718

No files matched your search

+18 -8
View File
@@ -161,11 +161,11 @@ class Setup {
'enum' => array_keys(DomainModel::pay_type_labels()),
],
'pay_modo' => ['type' => 'string', 'enum' => ['0', 'points']],
'price' => ['type' => 'number'],
'price' => ['type' => 'string', 'pattern' => '^(0|[1-9]\\d*)(?:\\.\\d{1,2})?$'],
'points_price' => ['type' => 'integer'],
'original_price' => ['type' => 'number'],
'vip1_price' => ['type' => 'number'],
'vip2_price' => ['type' => 'number'],
'original_price' => ['type' => 'string', 'pattern' => '^(0|[1-9]\\d*)(?:\\.\\d{1,2})?$'],
'vip1_price' => ['type' => 'string', 'pattern' => '^(0|[1-9]\\d*)(?:\\.\\d{1,2})?$'],
'vip2_price' => ['type' => 'string', 'pattern' => '^(0|[1-9]\\d*)(?:\\.\\d{1,2})?$'],
'vip1_points' => ['type' => 'integer'],
'vip2_points' => ['type' => 'integer'],
'pay_limit' => ['type' => 'integer', 'enum' => [0, 1, 2]],
@@ -221,13 +221,23 @@ class Setup {
]);
register_post_meta('post', DomainModel::PAY_PRICE_KEY, [
'type' => 'number',
'type' => 'string',
'description' => 'Query-friendly paid content price.',
'single' => true,
'default' => 0,
'default' => '0.00',
'show_in_rest' => true,
'sanitize_callback' => static function ($value) {
return max(0, (float) $value);
'sanitize_callback' => static function ($value): string {
if (is_int($value)) {
return (string) max(0, $value);
}
if (!is_string($value)) {
return '0.00';
}
try {
return \AKSRT\Ledger\AssetAmount::balance($value)->decimal();
} catch (\InvalidArgumentException $e) {
return '0.00';
}
},
'auth_callback' => $post_edit_auth,
]);