【门店端 - AI数智员工】 代码优化

This commit is contained in:
wong
2025-10-21 11:06:53 +08:00
parent 252d02e7b9
commit 19734415f0
4 changed files with 30 additions and 30 deletions

View File

@@ -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']);

View File

@@ -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();
// 其他渠道(总数减去已知渠道)

View File

@@ -6,6 +6,7 @@ use think\Model;
class WechatFriendModel extends Model
{
protected $name = 'wechat_friendship';
//protected $name = 'wechat_friendship';
protected $table = 's2_wechat_friend';
}