From 19734415f05eac5bb1af30ab96d711178ce53d4c Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Tue, 21 Oct 2025 11:06:53 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E9=97=A8=E5=BA=97=E7=AB=AF=20-=20AI?= =?UTF-8?q?=E6=95=B0=E6=99=BA=E5=91=98=E5=B7=A5=E3=80=91=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/application/store/config/route.php | 30 +++++++++---------- .../store/controller/StatisticsController.php | 23 +++++++------- .../store/model/WechatFriendModel.php | 5 ++-- Store_vue/components/DataStatistics.vue | 2 +- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Server/application/store/config/route.php b/Server/application/store/config/route.php index d8658fd8..dbae6f08 100644 --- a/Server/application/store/config/route.php +++ b/Server/application/store/config/route.php @@ -7,42 +7,42 @@ use think\facade\Route; Route::group('v1/store', function () { // 流量套餐相关路由 Route::group('flow-packages', function () { - Route::get('', 'app\\store\\controller\\FlowPackageController@getList'); // 获取流量套餐列表 - Route::get('remaining-flow', 'app\\store\\controller\\FlowPackageController@remainingFlow'); // 获取用户剩余流量 - Route::get(':id', 'app\\store\\controller\\FlowPackageController@detail'); // 获取流量套餐详情 - Route::post('order', 'app\\store\\controller\\FlowPackageController@createOrder'); // 创建流量采购订单 + Route::get('', 'app\store\controller\FlowPackageController@getList'); // 获取流量套餐列表 + Route::get('remaining-flow', 'app\store\controller\FlowPackageController@remainingFlow'); // 获取用户剩余流量 + Route::get(':id', 'app\store\controller\FlowPackageController@detail'); // 获取流量套餐详情 + Route::post('order', 'app\store\controller\FlowPackageController@createOrder'); // 创建流量采购订单 }); // 流量订单相关路由 Route::group('flow-orders', function () { - Route::get('list', 'app\\store\\controller\\FlowPackageController@getOrderList'); // 获取订单列表 - Route::get(':orderNo', 'app\\store\\controller\\FlowPackageController@getOrderDetail'); // 获取订单详情 + Route::get('list', 'app\store\controller\FlowPackageController@getOrderList'); // 获取订单列表 + Route::get(':orderNo', 'app\store\controller\FlowPackageController@getOrderDetail'); // 获取订单详情 }); // 客户相关路由 Route::group('customers', function () { - Route::get('list', 'app\\store\\controller\\CustomerController@getList'); // 获取客户列表 + Route::get('list', 'app\store\controller\CustomerController@getList'); // 获取客户列表 }); // 系统配置相关路由 Route::group('system-config', function () { - Route::get('switch-status', 'app\\store\\controller\\SystemConfigController@getSwitchStatus'); // 获取系统开关状态 - Route::post('update-switch-status', 'app\\store\\controller\\SystemConfigController@updateSwitchStatus'); // 更新系统开关状态 + Route::get('switch-status', 'app\store\controller\SystemConfigController@getSwitchStatus'); // 获取系统开关状态 + Route::post('update-switch-status', 'app\store\controller\SystemConfigController@updateSwitchStatus'); // 更新系统开关状态 }); // 数据统计相关路由 Route::group('statistics', function () { - Route::get('overview', 'app\\store\\controller\\StatisticsController@getOverview'); // 获取数据概览 - Route::get('customer-analysis', 'app\\store\\controller\\StatisticsController@getCustomerAnalysis'); // 获取客户分析数据 - Route::get('interaction-analysis', 'app\\store\\controller\\StatisticsController@getInteractionAnalysis'); // 获取互动分析数据 + Route::get('overview', 'app\store\controller\StatisticsController@getOverview'); // 获取数据概览 + Route::get('customer-analysis', 'app\store\controller\StatisticsController@getCustomerAnalysis'); // 获取客户分析数据 + Route::get('interaction-analysis', 'app\store\controller\StatisticsController@getInteractionAnalysis'); // 获取互动分析数据 }); // 供应商相关路由 Route::group('vendor', function () { - Route::get('list', 'app\\store\\controller\\VendorController@getList'); // 获取供应商列表 - Route::get('detail', 'app\\store\\controller\\VendorController@detail'); // 获取供应商详情 - Route::post('order', 'app\\store\\controller\\VendorController@createOrder'); // 创建订单 + Route::get('list', 'app\store\controller\VendorController@getList'); // 获取供应商列表 + Route::get('detail', 'app\store\controller\VendorController@detail'); // 获取供应商详情 + Route::post('order', 'app\store\controller\VendorController@createOrder'); // 创建订单 }); })->middleware(['jwt']); \ No newline at end of file diff --git a/Server/application/store/controller/StatisticsController.php b/Server/application/store/controller/StatisticsController.php index 11cda5fb..2096b2bc 100644 --- a/Server/application/store/controller/StatisticsController.php +++ b/Server/application/store/controller/StatisticsController.php @@ -50,15 +50,11 @@ class StatisticsController extends BaseController // 1. 总客户数 $totalCustomers = WechatFriendModel::whereIn('ownerWechatId',$ownerWechatIds) - ->whereTime('createTime', '>=', $startTime) - ->whereTime('createTime', '<', $endTime) + ->where('isDeleted',0) ->count(); // 上期总客户数 - $lastTotalCustomers = WechatFriendModel::whereIn('ownerWechatId',$ownerWechatIds) - ->whereTime('createTime', '>=', $lastStartTime) - ->whereTime('createTime', '<', $lastEndTime) - ->count(); + $lastTotalCustomers = WechatFriendModel::whereIn('ownerWechatId',$ownerWechatIds)->count(); // 2. 新增客户数 $newCustomers = WechatFriendModel::whereIn('ownerWechatId',$ownerWechatIds) @@ -143,35 +139,38 @@ class StatisticsController extends BaseController // 1. 客户增长趋势数据 $totalCustomers = WechatFriendModel::whereIn('ownerWechatId', $ownerWechatIds) + ->where('isDeleted',0) ->whereTime('createTime', '<', $endTime) ->count(); $newCustomers = WechatFriendModel::whereIn('ownerWechatId', $ownerWechatIds) + ->where('isDeleted',0) ->whereTime('createTime', '>=', $startTime) ->whereTime('createTime', '<', $endTime) ->count(); - // 计算流失客户数(假设超过30天未互动的客户为流失客户) - $thirtyDaysAgo = strtotime('-30 days'); + // 计算流失客户数 $lostCustomers = WechatFriendModel::whereIn('ownerWechatId', $ownerWechatIds) + ->where('isDeleted',1) ->where('createTime', '>', 0) - ->where('deleteTime', '<', $thirtyDaysAgo) + ->whereTime('deleteTime', '>=', $startTime) + ->whereTime('deleteTime', '<', $endTime) ->count(); // 2. 客户来源分布数据 // 朋友推荐 $friendRecommend = WechatFriendModel::whereIn('ownerWechatId', $ownerWechatIds) - // ->whereIn('addFrom', [17, 1000017]) + ->whereIn('addFrom', [17, 1000017]) ->count(); // 微信搜索 $wechatSearch = WechatFriendModel::whereIn('ownerWechatId', $ownerWechatIds) - // ->whereIn('addFrom', [3, 15, 1000003, 1000015]) + ->whereIn('addFrom', [3, 15, 1000003, 1000015]) ->count(); // 微信群 $wechatGroup = WechatFriendModel::whereIn('ownerWechatId', $ownerWechatIds) - // ->whereIn('addFrom', [14, 1000014]) + ->whereIn('addFrom', [14, 1000014]) ->count(); // 其他渠道(总数减去已知渠道) diff --git a/Server/application/store/model/WechatFriendModel.php b/Server/application/store/model/WechatFriendModel.php index 02a8610a..0dcb7580 100644 --- a/Server/application/store/model/WechatFriendModel.php +++ b/Server/application/store/model/WechatFriendModel.php @@ -6,6 +6,7 @@ use think\Model; class WechatFriendModel extends Model { - protected $name = 'wechat_friendship'; - + //protected $name = 'wechat_friendship'; + protected $table = 's2_wechat_friend'; + } \ No newline at end of file diff --git a/Store_vue/components/DataStatistics.vue b/Store_vue/components/DataStatistics.vue index 3c455ce4..6329b225 100644 --- a/Store_vue/components/DataStatistics.vue +++ b/Store_vue/components/DataStatistics.vue @@ -557,7 +557,7 @@ tempEndDate: parseInt(today.getTime()), minDate: parseInt(new Date(new Date().getFullYear() - 1, 0, 1).getTime()), maxDate: parseInt(new Date().getTime()), - subsectionList: ['客户分析', '互动分析', '转化分析', '收入分析'], + subsectionList: ['客户分析', '互动分析'/* , '转化分析', '收入分析' */], currentSubsection: 0, overviewData: { totalCustomers: 0,