diff --git a/Cunkebao/app/plans/new/page.tsx b/Cunkebao/app/plans/new/page.tsx index b8c2e04c..04ff09d1 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 521b6c94..b4d5a3d2 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 e9cb20fa..7b9f6e6d 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 9ea0e76a..d9831dbf 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'])) {