代码提交
This commit is contained in:
@@ -95,7 +95,7 @@ class ContentLibraryController extends Controller
|
||||
// 来源类型
|
||||
'sourceType' => $sourceType, // 1=好友,2=群,3=好友和群
|
||||
// 表单类型
|
||||
'formType' => isset($param['formType']) ? intval($param['formType']) : 0, // 表单类型,默认为0
|
||||
'formType' => isset($param['formType']) ? intval($param['formType']) : 1, // 表单类型,默认为0
|
||||
// 基础信息
|
||||
'status' => isset($param['status']) ? $param['status'] : 0, // 状态:0=禁用,1=启用
|
||||
'userId' => $this->request->userInfo['id'],
|
||||
@@ -131,7 +131,7 @@ class ContentLibraryController extends Controller
|
||||
$limit = $this->request->param('limit', 10);
|
||||
$keyword = $this->request->param('keyword', '');
|
||||
$sourceType = $this->request->param('sourceType', ''); // 来源类型,1=好友,2=群
|
||||
$formType = $this->request->param('formType', ''); // 表单类型筛选
|
||||
$formType = $this->request->param('formType', 0); // 表单类型筛选
|
||||
$companyId = $this->request->userInfo['companyId'];
|
||||
$userId = $this->request->userInfo['id'];
|
||||
$isAdmin = !empty($this->request->userInfo['isAdmin']);
|
||||
|
||||
@@ -1,34 +1,54 @@
|
||||
<?php
|
||||
namespace app\job;
|
||||
|
||||
use app\chukebao\model\Reply;
|
||||
use app\chukebao\model\ReplyGroup;
|
||||
use think\queue\Job;
|
||||
|
||||
class SyncContentJob
|
||||
{
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
try {
|
||||
// TODO: 在这里实现具体的同步逻辑
|
||||
// 1. 获取需要同步的数据
|
||||
// 2. 处理数据
|
||||
// 3. 更新到目标位置
|
||||
|
||||
// 如果任务执行成功,删除任务
|
||||
$job->delete();
|
||||
|
||||
// 记录日志
|
||||
\think\Log::info('内容库同步成功:' . json_encode($data));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// 如果任务执行失败,记录日志
|
||||
\think\Log::error('内容库同步失败:' . $e->getMessage());
|
||||
|
||||
// 如果任务失败次数小于3次,重新放入队列
|
||||
if ($job->attempts() < 3) {
|
||||
$job->release(60); // 延迟60秒后重试
|
||||
} else {
|
||||
$job->delete();
|
||||
return true;
|
||||
/*$ddd= '[{"id":21909,"groupName":"私域运营招聘","sortIndex":240426546,"parentId":0,"replyType":1,"children":[],"replys":null},{"id":8074,"groupName":"存客宝新客户介绍","sortIndex":230,"parentId":0,"replyType":1,"children":[{"id":8081,"groupName":"客户系统上线准备","sortIndex":1,"parentId":8074,"replyType":1,"children":[],"replys":null}],"replys":null},{"id":10441,"groupName":"BOSS直聘","sortIndex":229,"parentId":0,"replyType":1,"children":[],"replys":null},{"id":15111,"groupName":"点了码新客户了解","sortIndex":228,"parentId":0,"replyType":1,"children":[],"replys":null},{"id":12732,"groupName":"测试","sortIndex":219,"parentId":0,"replyType":1,"children":[],"replys":null},{"id":8814,"groupName":"封单话术","sortIndex":176,"parentId":0,"replyType":1,"children":[],"replys":null},{"id":8216,"groupName":"私域合伙人","sortIndex":172,"parentId":0,"replyType":1,"children":[],"replys":null},{"id":6476,"groupName":"新客户了解","sortIndex":119,"parentId":0,"replyType":1,"children":[],"replys":null}]';
|
||||
$ddd=json_decode($ddd,1);*/
|
||||
|
||||
$ddd = ReplyGroup::where('companyId',2778)->where('companyId','<>',21898)->where('isDel',0)->select()->toArray();
|
||||
|
||||
|
||||
$authorization = 'OE7kh6Dsw_0SqqH1FTAPCB2ewCQDhx7VvPw6PrsE_p9tcRKbtlFsZau8kjk2NQ829Yah90KhTh0C_35ek569uRQgM_gC0NtKzfRPDDoqMIUE5mI6AO_hm0dm-xDJqhAFYkXHCdXnJYzQZxWS5dleJCIwtQxgRuIzIbr-_G_5C-7DeLEOSt2vi1oGPleLt00QGQ1WYVYqoHYrbPGMghMQpWIbgk5qNcUCeANlLJ_s7QFC3QzArU95_YiK0HlhU81hZqr8kI_5lmdrRBoR-yNIlyhySLRCmEZYGzOxCiUHL3uFHYZA1VnLBAVbryNj5DElZjMgwA';
|
||||
// 设置请求头
|
||||
$headerData = ['client:system'];
|
||||
$header = setHeader($headerData, $authorization, 'json');
|
||||
|
||||
|
||||
|
||||
foreach ($ddd as $key => $value) {
|
||||
$data = [];
|
||||
// 发送请求获取公司账号列表
|
||||
$result = requestCurl('https://s2.siyuguanli.com:9991/api/Reply/listReply?groupId='.$value['id'], '', 'GET', $header,'json');
|
||||
$response = handleApiResponse($result);
|
||||
foreach ($response as $k => $v) {
|
||||
$data[] = [
|
||||
'groupId' => $v['groupId'],
|
||||
'userId' => $value['userId'],
|
||||
'title' => $v['title'],
|
||||
'msgType' => $v['msgType'],
|
||||
'content' => $v['content'],
|
||||
'createTime' => strtotime($v['createTime']),
|
||||
'lastUpdateTime' => strtotime($v['lastUpdateTime']),
|
||||
'sortIndex' => 50
|
||||
];
|
||||
}
|
||||
$Reply = new Reply();
|
||||
$Reply->insertAll($data);
|
||||
}
|
||||
|
||||
|
||||
exit_data(11111);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user