From 9d418b4f874d73445e71adc65ffed3503c820f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Tue, 20 May 2025 11:25:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=81=E5=9F=9F=E6=93=8D=E7=9B=98=E6=89=8B?= =?UTF-8?q?=20-=20=E4=BF=AE=E6=94=B9=E6=A3=80=E6=B5=8B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=88=90=E5=8A=9F=E7=9A=84=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cunkebao/app/plans/new/page.tsx | 2 +- Server/application/cunkebao/config/route.php | 5 +--- .../device/GetAddResultedV1Controller.php | 17 +++++++++---- .../PostCreateAddFriendPlanV1Controller.php | 24 ++++++++++--------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Cunkebao/app/plans/new/page.tsx b/Cunkebao/app/plans/new/page.tsx index b8c2e04c6..04ff09d12 100644 --- a/Cunkebao/app/plans/new/page.tsx +++ b/Cunkebao/app/plans/new/page.tsx @@ -149,7 +149,7 @@ export default function NewAcquisitionPlan() { } // 调用API创建获客计划 - fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/v1/plan/scenes/create`, { + fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/v1/plan/create`, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/Server/application/cunkebao/config/route.php b/Server/application/cunkebao/config/route.php index 521b6c947..b4d5a3d2f 100644 --- a/Server/application/cunkebao/config/route.php +++ b/Server/application/cunkebao/config/route.php @@ -37,10 +37,7 @@ Route::group('v1/', function () { // 获客场景相关 Route::group('plan', function () { Route::get('scenes', 'app\cunkebao\controller\plan\GetPlanSceneListV1Controller@index'); - - // 添加计划任务 - Route::post('add', 'app\cunkebao\controller\Plan@index'); - // 获取计划任务列表 + Route::post('create', 'app\cunkebao\controller\plan\PostCreateAddFriendPlanV1Controller@index'); Route::get('list', 'app\cunkebao\controller\Plan@getList'); diff --git a/Server/application/cunkebao/controller/device/GetAddResultedV1Controller.php b/Server/application/cunkebao/controller/device/GetAddResultedV1Controller.php index e9cb20faf..7b9f6e6d7 100644 --- a/Server/application/cunkebao/controller/device/GetAddResultedV1Controller.php +++ b/Server/application/cunkebao/controller/device/GetAddResultedV1Controller.php @@ -73,6 +73,16 @@ class GetAddResultedV1Controller extends BaseController Db::query($sql); } + protected function getCkbDeviceCount(): int + { + return DeviceModel::where( + [ + 'companyId' => $this->getUserInfo('companyId') + ] + ) + ->count('*'); + } + /** * 获取添加的关联设备结果。 * @@ -85,17 +95,16 @@ class GetAddResultedV1Controller extends BaseController [ 'accountId' => $accountId, 'pageIndex' => 0, - 'pageSize' => 1 + 'pageSize' => 100 ], true ); $result = json_decode($result, true); - $result = $result['data']['results'][0] ?? false; + $result = $result['data']['results'] ?? false; return $result ? ( - // 125是前端延迟5秒 + 轮询120次 1次/s - time() - strtotime($result['lastUpdateTime']) <= 65 + count($result) > $this->getCkbDeviceCount() ) : false; } diff --git a/Server/application/cunkebao/controller/plan/PostCreateAddFriendPlanV1Controller.php b/Server/application/cunkebao/controller/plan/PostCreateAddFriendPlanV1Controller.php index 9ea0e76a5..d9831dbf6 100644 --- a/Server/application/cunkebao/controller/plan/PostCreateAddFriendPlanV1Controller.php +++ b/Server/application/cunkebao/controller/plan/PostCreateAddFriendPlanV1Controller.php @@ -12,6 +12,13 @@ use think\facade\Request; */ class PostCreateAddFriendPlanV1Controller extends Controller { + + protected function yyyyyyy() + { + + } + + /** * 添加计划任务 * @@ -20,17 +27,12 @@ class PostCreateAddFriendPlanV1Controller extends Controller public function index() { try { - // 获取表单数据 - $data = [ - 'name' => Request::post('name', ''), - 'sceneId' => Request::post('sceneId', 0), - 'status' => Request::post('status', 0), - 'reqConf' => Request::post('reqConf', ''), - 'msgConf' => Request::post('msgConf', ''), - 'tagConf' => Request::post('tagConf', ''), - 'createTime' => time(), - 'updateTime' => time() - ]; + $params = $this->request->only(['name', 'sceneId', 'status', 'reqConf', 'msgConf', 'tagConf']); + + + dd($params); + + // 验证必填字段 if (empty($data['name'])) {