Browse Source

fleat: sales

igb 2 weeks ago
parent
commit
cef81b78b8
2 changed files with 12 additions and 8 deletions
  1. 11 5
      sales_stats.php
  2. 1 3
      statistics_sales.php

+ 11 - 5
sales_stats.php

@@ -6,6 +6,12 @@ require_once 'conn.php';
 require_once 'statistics_utils.php';
 require_once 'statistics_sales.php';
 
+// Helper functions for formatting
+
+function formatCurrency($value) {
+    return '¥' . number_format($value ?? 0, 2);
+}
+
 // 检查登录状态
 if (!isset($_SESSION['employee_id'])) {
     checkLogin();
@@ -320,23 +326,23 @@ include('statistics_header.php');
         <div class="performance-grid">
             <div class="performance-card">
                 <div class="performance-label">总订单数</div>
-                <div class="performance-value"><?php echo number_format($employee_stats['total_orders']); ?></div>
+                <div class="performance-value"><?php echo formatNumber($employee_stats['total_orders']); ?></div>
             </div>
             <div class="performance-card">
                 <div class="performance-label">总销售额</div>
-                <div class="performance-value">¥<?php echo number_format($employee_stats['total_revenue'], 2); ?></div>
+                <div class="performance-value"><?php echo formatCurrency($employee_stats['total_revenue']); ?></div>
             </div>
             <div class="performance-card">
                 <div class="performance-label">客户数量</div>
-                <div class="performance-value"><?php echo number_format($employee_stats['customer_count']); ?></div>
+                <div class="performance-value"><?php echo formatNumber($employee_stats['customer_count']); ?></div>
             </div>
             <div class="performance-card">
                 <div class="performance-label">平均订单金额</div>
-                <div class="performance-value">¥<?php echo number_format($employee_stats['avg_order_value'], 2); ?></div>
+                <div class="performance-value"><?php echo formatCurrency($employee_stats['avg_order_value']); ?></div>
             </div>
             <div class="performance-card">
                 <div class="performance-label">订单完成率</div>
-                <div class="performance-value"><?php echo formatNumber(($employee_stats['completion_rate'] / 100) * 100, 1); ?>%</div>
+                <div class="performance-value"><?php echo formatNumber($employee_stats['completion_rate'], 1); ?>%</div>
             </div>
         </div>
 

+ 1 - 3
statistics_sales.php

@@ -213,9 +213,7 @@ function renderSalesOverviewCards($sales_overview) {
     // 添加空值检查函数
 
     
-    function formatCurrency($value) {
-        return '¥' . number_format($value ?? 0, 2);
-    }
+
     ?>
     <div class="stats-grid">
         <div class="stat-card">