From 63df35b79cd9c30a935118137199e633d976b925 Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Fri, 5 Dec 2025 11:36:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workspace/moments-sync/new/index.tsx | 4 ++-- .../api/controller/MomentsController.php | 18 ++++++++--------- .../application/job/WorkbenchMomentsJob.php | 20 ++++++++++++------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Cunkebao/src/pages/mobile/workspace/moments-sync/new/index.tsx b/Cunkebao/src/pages/mobile/workspace/moments-sync/new/index.tsx index aa15519d..017216bc 100644 --- a/Cunkebao/src/pages/mobile/workspace/moments-sync/new/index.tsx +++ b/Cunkebao/src/pages/mobile/workspace/moments-sync/new/index.tsx @@ -63,8 +63,8 @@ const NewMomentsSync: React.FC = () => { if (res) { setFormData({ taskName: res.name, - startTime: res.timeRange?.start || "06:00", - endTime: res.timeRange?.end || "23:59", + startTime: res.config?.startTime || "06:00", + endTime: res.config?.endTime || "23:59", syncCount: res.config?.syncCount || res.syncCount || 5, syncInterval: res.config?.syncInterval || res.syncInterval || 30, syncType: res.config?.syncType, diff --git a/Server/application/api/controller/MomentsController.php b/Server/application/api/controller/MomentsController.php index 715f68be..812ec4bf 100644 --- a/Server/application/api/controller/MomentsController.php +++ b/Server/application/api/controller/MomentsController.php @@ -17,7 +17,7 @@ class MomentsController extends BaseController // 获取授权token $authorization = $this->authorization; if (empty($authorization)) { - return errorJson('缺少授权信息'); + return json_encode(['msg' => '缺少授权信息','code' => 400]); } try { @@ -42,18 +42,18 @@ class MomentsController extends BaseController // 必填参数验证 if (empty($jobPublishWechatMomentsItems) || !is_array($jobPublishWechatMomentsItems)) { - return errorJson('至少需要选择一个发布账号'); + return json_encode(['msg' => '至少需要选择一个发布账号','code' => 400]); } // 根据朋友圈类型验证必填字段 if ($momentContentType == 1 && empty($text)) { // 纯文本 - return errorJson('朋友圈内容不能为空'); + return json_encode(['msg' => '朋友圈内容不能为空','code' => 400]); } else if ($momentContentType == 2 && (empty($picUrlList) || empty($text))) { // 图片+文字 - return errorJson('朋友圈内容和图片不能为空'); + return json_encode(['msg' => '朋友圈内容和图片不能为空','code' => 400]); } else if ($momentContentType == 3 && (empty($videoUrl) || empty($text))) { // 视频+文字 - return errorJson('朋友圈内容和视频不能为空'); + return json_encode(['msg' => '朋友圈内容和视频不能为空','code' => 400]); } else if ($momentContentType == 4 && (empty($link) || empty($text))) { // 链接+文字 - return errorJson('朋友圈内容和链接不能为空'); + return json_encode(['msg' => '朋友圈内容和链接不能为空','code' => 400]); } // 构建请求参数 @@ -84,13 +84,13 @@ class MomentsController extends BaseController $result = requestCurl($this->baseUrl . 'api/JobPublishWechatMoments/addJob', $params, 'POST', $header, 'json'); // 处理响应 if (empty($result)) { - return successJson([], '朋友圈任务创建成功'); + return json_encode(['msg' => '朋友圈任务创建成功','code' => 200]); } else { // 如果返回的是错误信息 - return errorJson($result); + return json_encode(['msg' => $result,'code' => 400]); } } catch (\Exception $e) { - return errorJson('发布朋友圈失败:' . $e->getMessage()); + return json_encode(['msg' => '发布朋友圈失败','code' => 400]); } } diff --git a/Server/application/job/WorkbenchMomentsJob.php b/Server/application/job/WorkbenchMomentsJob.php index 6a3bb474..751c4e65 100644 --- a/Server/application/job/WorkbenchMomentsJob.php +++ b/Server/application/job/WorkbenchMomentsJob.php @@ -130,11 +130,14 @@ class WorkbenchMomentsJob // 3) 下发 $moments = new Moments(); - $moments->addJob($sendData); - KfMoments::where(['id' => $val['id']])->update(['isSend' => 1]); + $res = $moments->addJob($sendData); + $res = json_decode($res, true); + if ($res['code'] == 200){ + KfMoments::where(['id' => $val['id']])->update(['isSend' => 1]); - // 4) 统计 - $this->incrementSendStats($companyId, $userId, $allowed); + // 4) 统计 + $this->incrementSendStats($companyId, $userId, $allowed); + } } } catch (\Exception $e) { Log::error("朋友圈同步任务异常: " . $e->getMessage()); @@ -334,9 +337,12 @@ class WorkbenchMomentsJob ]; // 发送朋友圈 $moments = new Moments(); - $moments->addJob($data); - // 记录发送记录 - $this->recordSendHistory($workbench, $devices, $contentLibrary); + $res = $moments->addJob($data); + $res = json_decode($res,true); + if ($res['code'] == 200){ + // 记录发送记录 + $this->recordSendHistory($workbench, $devices, $contentLibrary); + } }