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

This commit is contained in:
2026-08-24 15:59:11 +08:00
parent ca12226b39
commit 5cae5b5c93
159 changed files with 7275 additions and 4718 deletions
+15 -8
View File
@@ -94,17 +94,16 @@ class PayProducts {
$modo_label = $modo === 'points' ? __('积分', 'aksrt') : __('现金', 'aksrt');
if ($modo === 'points') {
$list_price = (int) ceil((float) ($meta['points_price'] ?? $meta['price'] ?? 0));
$list_price = max(0, (int) ($meta['points_price'] ?? 0));
$price_text = sprintf(__('%d 积分', 'aksrt'), $list_price);
} else {
$list_price = round((float) ($meta['price'] ?? 0), 2);
$price_text = number_format($list_price, 2);
$price_text = $this->cash_decimal((string) ($meta['price'] ?? '0'));
}
$sales = $sales_map[$post_id] ?? ['sales_count' => 0, 'avg_amount' => 0.0, 'revenue' => 0.0];
$sales = $sales_map[$post_id] ?? ['sales_count' => 0, 'avg_amount' => '0.00', 'revenue' => '0.00'];
$db_sales = (int) ($sales['sales_count'] ?? 0);
$avg = (float) ($sales['avg_amount'] ?? 0);
$revenue = (float) ($sales['revenue'] ?? 0);
$avg = $this->cash_decimal((string) ($sales['avg_amount'] ?? '0'));
$revenue = $this->cash_decimal((string) ($sales['revenue'] ?? '0'));
$meta_sales = (int) get_post_meta($post_id, \AKSRT\Core\DomainModel::RESOURCE_SALES_VOLUME_KEY, true);
$edit_url = get_edit_post_link($post_id, 'raw');
@@ -130,10 +129,10 @@ class PayProducts {
echo '<td>' . esc_html((string) $pt_label) . '</td>';
echo '<td>' . esc_html($modo_label) . '</td>';
echo '<td>' . esc_html($price_text) . '</td>';
echo '<td>' . esc_html(number_format($avg, 2)) . '</td>';
echo '<td>' . esc_html($avg) . '</td>';
echo '<td>' . esc_html((string) $db_sales) . '</td>';
echo '<td>' . esc_html((string) max(0, $meta_sales)) . '</td>';
echo '<td>' . esc_html(number_format($revenue, 2)) . '</td>';
echo '<td>' . esc_html($revenue) . '</td>';
echo '<td style="display:flex;gap:6px;flex-wrap:wrap;">';
if ($edit_url) {
echo '<a class="button button-small" href="' . esc_url($edit_url) . '">' . esc_html__('编辑', 'aksrt') . '</a>';
@@ -337,6 +336,14 @@ class PayProducts {
}
}
private function cash_decimal(string $value): string {
try {
return \AKSRT\Ledger\AssetAmount::balance($value)->decimal();
} catch (\InvalidArgumentException $e) {
return '0.00';
}
}
private function render_header(string $title): void {
echo '<div class="wrap">';
echo '<h1>' . esc_html($title) . '</h1>';