Commit c64d3b9c authored by 刘小敏's avatar 刘小敏

数据中心优化

parent 32f0f5e6
...@@ -195,10 +195,10 @@ class DataStatsCenter extends Command ...@@ -195,10 +195,10 @@ class DataStatsCenter extends Command
$currentRegisterTotal = $this->getRegisterCount(0, $currentRange['end']); $currentRegisterTotal = $this->getRegisterCount(0, $currentRange['end']);
$previousRegisterTotal = $this->getRegisterCount(0, $previousRange['end']); $previousRegisterTotal = $this->getRegisterCount(0, $previousRange['end']);
// 计算转化率(订单数/访客数) // 计算转化率(购买用户数/访客数)
$this->customLog('info', '开始计算当前&上一期统计周期转化率'); $this->customLog('info', '开始计算当前&上一期统计周期转化率');
$currentConversion = $currentVisitors > 0 ? round($currentRevenue['order_count'] / $currentVisitors * 100, 2) : 0; $currentConversion = $currentVisitors > 0 ? round($currentRevenue['buyer_count'] / $currentVisitors * 100, 2) : 0;
$previousConversion = $previousVisitors > 0 ? round($previousRevenue['order_count'] / $previousVisitors * 100, 2) : 0; $previousConversion = $previousVisitors > 0 ? round($previousRevenue['buyer_count'] / $previousVisitors * 100, 2) : 0;
// 构建趋势数据 // 构建趋势数据
$this->customLog('info', '开始构建当前统计周期趋势数据'); $this->customLog('info', '开始构建当前统计周期趋势数据');
...@@ -332,6 +332,13 @@ class DataStatsCenter extends Command ...@@ -332,6 +332,13 @@ class DataStatsCenter extends Command
->where('paid_time', 'between', [$startTime, $endTime]) ->where('paid_time', 'between', [$startTime, $endTime])
->count(); ->count();
// 统计购买用户数(去重)
$buyerCount = (int)Db::name('shopro_order')
->whereIn('status', ['paid', 'completed'])
->where('paid_time', 'between', [$startTime, $endTime])
->where('user_id', '>', 0)
->count('DISTINCT user_id');
// 计算客单价(成交额/订单数) // 计算客单价(成交额/订单数)
$avgAmount = $orderCount > 0 ? round($totalAmount / $orderCount, 2) : 0; $avgAmount = $orderCount > 0 ? round($totalAmount / $orderCount, 2) : 0;
...@@ -355,6 +362,7 @@ class DataStatsCenter extends Command ...@@ -355,6 +362,7 @@ class DataStatsCenter extends Command
return [ return [
'total_amount' => $totalAmount, 'total_amount' => $totalAmount,
'order_count' => $orderCount, 'order_count' => $orderCount,
'buyer_count' => $buyerCount,
'avg_amount' => $avgAmount, 'avg_amount' => $avgAmount,
'cost_amount' => $costAmount, 'cost_amount' => $costAmount,
'refund_amount' => $refundAmount, 'refund_amount' => $refundAmount,
......
...@@ -50,6 +50,9 @@ if (Config.modulename == 'admin' && Config.controllername == 'index' && Config.a ...@@ -50,6 +50,9 @@ if (Config.modulename == 'admin' && Config.controllername == 'index' && Config.a
'ElementPlus': { 'ElementPlus': {
deps: ['css!../addons/shopro/libs/element-plus/index.css'] deps: ['css!../addons/shopro/libs/element-plus/index.css']
}, },
'ElementPlusIconsVue': {
deps: ['ElementPlusIconsVue3']
}
}, },
}); });
require(['vue3', 'ElementPlusIconsVue3'], function (Vue3, ElementPlusIconsVue3) { require(['vue3', 'ElementPlusIconsVue3'], function (Vue3, ElementPlusIconsVue3) {
...@@ -75,8 +78,11 @@ if (Config.modulename == 'admin' && Config.controllername == 'index' && Config.a ...@@ -75,8 +78,11 @@ if (Config.modulename == 'admin' && Config.controllername == 'index' && Config.a
const app = createApp({}) const app = createApp({})
app.use(ElementPlus) app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component) if (ElementPlusIconsVue && typeof ElementPlusIconsVue === 'object') {
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
} }
app.component('sa-chat', SaChat) app.component('sa-chat', SaChat)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment