Merge branch 'feature/groupPush' into develop
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace app\cunkebao\controller;
|
||||
|
||||
use app\common\model\Device as DeviceModel;
|
||||
use app\common\model\DeviceWechatLogin as DeviceWechatLoginModel;
|
||||
use app\common\model\WechatCustomer as WechatCustomerModel;
|
||||
use app\cunkebao\model\ContentLibrary;
|
||||
use app\cunkebao\model\ContentItem;
|
||||
use library\s2\titleFavicon;
|
||||
@@ -64,6 +67,7 @@ class ContentLibraryController extends Controller
|
||||
|
||||
$keywordInclude = isset($param['keywordInclude']) ? json_encode($param['keywordInclude'], 256) : json_encode([]);
|
||||
$keywordExclude = isset($param['keywordExclude']) ? json_encode($param['keywordExclude'], 256) : json_encode([]);
|
||||
$devices = isset($param['devices']) ? json_encode($param['devices'], 256) : json_encode([]);
|
||||
$sourceType = isset($param['sourceType']) ? $param['sourceType'] : 1;
|
||||
|
||||
|
||||
@@ -75,6 +79,7 @@ class ContentLibraryController extends Controller
|
||||
'sourceGroups' => $sourceType == 2 && isset($param['wechatGroups']) ? json_encode($param['wechatGroups']) : json_encode([]), // 选择的微信群
|
||||
'groupMembers' => $sourceType == 2 && isset($param['groupMembers']) ? json_encode($param['groupMembers']) : json_encode([]), // 群组成员
|
||||
'catchType' => isset($param['catchType']) ? json_encode($param['catchType']) : json_encode([]), // 采集类型
|
||||
'devices' => $devices,
|
||||
// 关键词配置
|
||||
'keywordInclude' => $keywordInclude, // 包含的关键词
|
||||
'keywordExclude' => $keywordExclude, // 排除的关键词
|
||||
@@ -314,7 +319,7 @@ class ContentLibraryController extends Controller
|
||||
|
||||
// 查询内容库信息
|
||||
$library = ContentLibrary::where($where)
|
||||
->field('id,name,sourceType,sourceFriends,sourceGroups,keywordInclude,keywordExclude,aiEnabled,aiPrompt,timeEnabled,timeStart,timeEnd,status,userId,companyId,createTime,updateTime,groupMembers,catchType')
|
||||
->field('id,name,sourceType,devices ,sourceFriends,sourceGroups,keywordInclude,keywordExclude,aiEnabled,aiPrompt,timeEnabled,timeStart,timeEnd,status,userId,companyId,createTime,updateTime,groupMembers,catchType')
|
||||
->find();
|
||||
|
||||
if (empty($library)) {
|
||||
@@ -322,13 +327,14 @@ class ContentLibraryController extends Controller
|
||||
}
|
||||
|
||||
// 处理JSON字段转数组
|
||||
$library['friendsGroups'] = json_decode($library['sourceFriends'] ?: '[]', true);
|
||||
$library['wechatGroups'] = json_decode($library['sourceGroups'] ?: '[]', true);
|
||||
$library['keywordInclude'] = json_decode($library['keywordInclude'] ?: '[]', true);
|
||||
$library['keywordExclude'] = json_decode($library['keywordExclude'] ?: '[]', true);
|
||||
$library['groupMembers'] = json_decode($library['groupMembers'] ?: '[]', true);
|
||||
$library['catchType'] = json_decode($library['catchType'] ?: '[]', true);
|
||||
unset($library['sourceFriends'], $library['sourceGroups']);
|
||||
$library['friendsGroups'] = json_decode($library['sourceFriends'] ?: [], true);
|
||||
$library['wechatGroups'] = json_decode($library['sourceGroups'] ?: [], true);
|
||||
$library['keywordInclude'] = json_decode($library['keywordInclude'] ?: [], true);
|
||||
$library['keywordExclude'] = json_decode($library['keywordExclude'] ?: [], true);
|
||||
$library['groupMembers'] = json_decode($library['groupMembers'] ?: [], true);
|
||||
$library['catchType'] = json_decode($library['catchType'] ?: [], true);
|
||||
$library['deviceGroups'] = json_decode($library['devices'] ?: [], true);
|
||||
unset($library['sourceFriends'], $library['sourceGroups'],$library['devices']);
|
||||
|
||||
// 将时间戳转换为日期格式(精确到日)
|
||||
if (!empty($library['timeStart'])) {
|
||||
@@ -369,6 +375,32 @@ class ContentLibraryController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
//获取设备信息
|
||||
if (!empty($library['deviceGroups'])) {
|
||||
$deviceList = DeviceModel::alias('d')
|
||||
->field([
|
||||
'd.id', 'd.imei', 'd.memo', 'd.alive',
|
||||
'l.wechatId',
|
||||
'a.nickname', 'a.alias', 'a.avatar', 'a.alias', '0 totalFriend'
|
||||
])
|
||||
->leftJoin('device_wechat_login l', 'd.id = l.deviceId and l.alive =' . DeviceWechatLoginModel::ALIVE_WECHAT_ACTIVE . ' and l.companyId = d.companyId')
|
||||
->leftJoin('wechat_account a', 'l.wechatId = a.wechatId')
|
||||
->whereIn('d.id', $library['deviceGroups'])
|
||||
->order('d.id desc')
|
||||
->select();
|
||||
|
||||
foreach ($deviceList as &$device) {
|
||||
$curstomer = WechatCustomerModel::field('friendShip')->where(['wechatId' => $device['wechatId']])->find();
|
||||
$device['totalFriend'] = $curstomer->friendShip->totalFriend ?? 0;
|
||||
}
|
||||
unset($device);
|
||||
$library['deviceGroupsOptions'] = $deviceList;
|
||||
} else {
|
||||
$library['deviceGroupsOptions'] = [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
return json([
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
@@ -401,7 +433,8 @@ class ContentLibraryController extends Controller
|
||||
|
||||
$where = [
|
||||
['companyId', '=', $this->request->userInfo['companyId']],
|
||||
['isDel', '=', 0] // 只查询未删除的记录
|
||||
['isDel', '=', 0], // 只查询未删除的记录
|
||||
['id', '=', $param['id']]
|
||||
];
|
||||
|
||||
if (empty($this->request->userInfo['isAdmin'])) {
|
||||
@@ -420,6 +453,7 @@ class ContentLibraryController extends Controller
|
||||
|
||||
$keywordInclude = isset($param['keywordInclude']) ? json_encode($param['keywordInclude'], 256) : json_encode([]);
|
||||
$keywordExclude = isset($param['keywordExclude']) ? json_encode($param['keywordExclude'], 256) : json_encode([]);
|
||||
$devices = isset($param['devices']) ? json_encode($param['devices'], 256) : json_encode([]);
|
||||
|
||||
// 更新内容库基本信息
|
||||
$library->name = $param['name'];
|
||||
@@ -428,6 +462,7 @@ class ContentLibraryController extends Controller
|
||||
$library->sourceGroups = $param['sourceType'] == 2 && isset($param['wechatGroups']) ? json_encode($param['wechatGroups']) : json_encode([]);
|
||||
$library->groupMembers = $param['sourceType'] == 2 && isset($param['groupMembers']) ? json_encode($param['groupMembers']) : json_encode([]);
|
||||
$library->catchType = isset($param['catchType']) ? json_encode($param['catchType']) : json_encode([]);// 采集类型
|
||||
$library->devices = $devices;
|
||||
$library->keywordInclude = $keywordInclude;
|
||||
$library->keywordExclude = $keywordExclude;
|
||||
$library->aiEnabled = isset($param['aiEnabled']) ? $param['aiEnabled'] : 0;
|
||||
@@ -437,8 +472,6 @@ class ContentLibraryController extends Controller
|
||||
$library->timeEnd = isset($param['endTime']) ? strtotime($param['endTime']) : 0;
|
||||
$library->status = isset($param['status']) ? $param['status'] : 0;
|
||||
$library->updateTime = time();
|
||||
|
||||
|
||||
$library->save();
|
||||
|
||||
Db::commit();
|
||||
@@ -597,8 +630,8 @@ class ContentLibraryController extends Controller
|
||||
$item['content'] = !empty($item['contentAi']) ? $item['contentAi'] : $item['content'];
|
||||
|
||||
// 处理JSON字段
|
||||
$item['resUrls'] = json_decode($item['resUrls'] ?: '[]', true);
|
||||
$item['urls'] = json_decode($item['urls'] ?: '[]', true);
|
||||
$item['resUrls'] = json_decode($item['resUrls'] ?: [], true);
|
||||
$item['urls'] = json_decode($item['urls'] ?: [], true);
|
||||
|
||||
// 格式化时间
|
||||
if (!empty($item['createMomentTime']) && is_numeric($item['createMomentTime'])) {
|
||||
@@ -798,8 +831,8 @@ class ContentLibraryController extends Controller
|
||||
}
|
||||
|
||||
// 处理JSON字段
|
||||
$item['resUrls'] = json_decode($item['resUrls'] ?: '[]', true);
|
||||
$item['urls'] = json_decode($item['urls'] ?: '[]', true);
|
||||
$item['resUrls'] = json_decode($item['resUrls'] ?: [], true);
|
||||
$item['urls'] = json_decode($item['urls'] ?: [], true);
|
||||
|
||||
// 添加内容类型的文字描述
|
||||
$contentTypeMap = [
|
||||
@@ -1083,12 +1116,12 @@ class ContentLibraryController extends Controller
|
||||
// 预处理内容库数据
|
||||
foreach ($libraries as &$library) {
|
||||
// 解析JSON字段
|
||||
$library['sourceFriends'] = json_decode($library['sourceFriends'] ?: '[]', true);
|
||||
$library['sourceGroups'] = json_decode($library['sourceGroups'] ?: '[]', true);
|
||||
$library['keywordInclude'] = json_decode($library['keywordInclude'] ?: '[]', true);
|
||||
$library['keywordExclude'] = json_decode($library['keywordExclude'] ?: '[]', true);
|
||||
$library['groupMembers'] = json_decode($library['groupMembers'] ?: '[]', true);
|
||||
$library['catchType'] = json_decode($library['catchType'] ?: '[]', true);
|
||||
$library['sourceFriends'] = json_decode($library['sourceFriends'] ?: [], true);
|
||||
$library['sourceGroups'] = json_decode($library['sourceGroups'] ?: [], true);
|
||||
$library['keywordInclude'] = json_decode($library['keywordInclude'] ?: [], true);
|
||||
$library['keywordExclude'] = json_decode($library['keywordExclude'] ?: [], true);
|
||||
$library['groupMembers'] = json_decode($library['groupMembers'] ?: [], true);
|
||||
$library['catchType'] = json_decode($library['catchType'] ?: [], true);
|
||||
}
|
||||
unset($library); // 解除引用
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ class WorkbenchController extends Controller
|
||||
$config->endTime = $param['endTime'];
|
||||
$config->contentTypes = json_encode($param['contentTypes']);
|
||||
$config->devices = json_encode($param['deviceGroups']);
|
||||
$config->friends = json_encode($param['friendsGroups']);
|
||||
$config->friends = json_encode($param['wechatFriends']);
|
||||
// $config->targetGroups = json_encode($param['targetGroups']);
|
||||
// $config->tagOperator = $param['tagOperator'];
|
||||
$config->friendMaxLikes = $param['friendMaxLikes'];
|
||||
@@ -490,7 +490,8 @@ class WorkbenchController extends Controller
|
||||
if (!empty($workbench->autoLike)) {
|
||||
$workbench->config = $workbench->autoLike;
|
||||
$workbench->config->deviceGroups = json_decode($workbench->config->devices, true);
|
||||
$workbench->config->friendsGroups = json_decode($workbench->config->friends, true);
|
||||
$workbench->config->wechatFriends = json_decode($workbench->config->friends, true);
|
||||
$workbench->config->targetType = 2;
|
||||
//$workbench->config->targetGroups = json_decode($workbench->config->targetGroups, true);
|
||||
$workbench->config->contentTypes = json_decode($workbench->config->contentTypes, true);
|
||||
|
||||
@@ -689,7 +690,7 @@ class WorkbenchController extends Controller
|
||||
// 获取好友(当targetType=2时)
|
||||
if (!empty($workbench->config->wechatFriends) && isset($workbench->config->targetType) && $workbench->config->targetType == 2) {
|
||||
$friendList = Db::table('s2_wechat_friend')->alias('wf')
|
||||
->join('s2_wechat_account wa', 'wa.id = wf.wechatAccountId', 'left')
|
||||
->join(['s2_wechat_account' => 'wa'], 'wa.id = wf.wechatAccountId', 'left')
|
||||
->where('wf.id', 'in', $workbench->config->wechatFriends)
|
||||
->order('wf.id', 'desc')
|
||||
->field('wf.id,wf.wechatId,wf.nickname as friendName,wf.avatar as friendAvatar,wf.conRemark,wf.ownerWechatId,wa.nickName as accountName,wa.avatar as accountAvatar')
|
||||
@@ -819,7 +820,7 @@ class WorkbenchController extends Controller
|
||||
$config->endTime = $param['endTime'];
|
||||
$config->contentTypes = json_encode($param['contentTypes']);
|
||||
$config->devices = json_encode($param['deviceGroups']);
|
||||
$config->friends = json_encode($param['friendsGroups']);
|
||||
$config->friends = json_encode($param['wechatFriends']);
|
||||
// $config->targetGroups = json_encode($param['targetGroups']);
|
||||
// $config->tagOperator = $param['tagOperator'];
|
||||
$config->friendMaxLikes = $param['friendMaxLikes'];
|
||||
|
||||
@@ -115,4 +115,64 @@ crontab -l
|
||||
- 本地: php think worker:server
|
||||
- 线上: php think worker:server -d (自带守护进程,无需搭配Supervisor 之类的工具)
|
||||
- php think worker:server stop php think worker:server status
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
|
||||
# 设备列表 - 未删除设备(每半小时执行)
|
||||
*/5 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think device:list --isDel=0 >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_device_active.log 2>&1
|
||||
# 设备列表 - 已删除设备(每天1点执行)
|
||||
0 1 * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think device:list --isDel=1 >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_device_deleted.log 2>&1
|
||||
# 设备列表 - 已停用设备(每天1:10执行)
|
||||
10 1 * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think device:list --isDel=2 >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_device_stopped.log 2>&1
|
||||
# 微信好友列表 - 未删除好友(每1分钟执行)
|
||||
*/1 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think wechatFriends:list --isDel=0 >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_wechatFriends_active.log 2>&1
|
||||
# 微信好友列表 - 已删除好友(每天1:30分执行)
|
||||
30 1 * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think wechatFriends:list --isDel=1 >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_wechatFriends_deleted.log 2>&1
|
||||
# 微信群列表 - 未删除群(每5分钟执行)
|
||||
*/5 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think wechatChatroom:list --isDel=0 >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_wechatChatroom_active.log 2>&1
|
||||
# 微信群列表 - 已删除群(每天1:30分执行)
|
||||
30 1 * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think wechatChatroom:list --isDel=1 >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_wechatChatroom_deleted.log 2>&1
|
||||
# 微信群好友列表(没5分钟执行)
|
||||
*/5 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think groupFriends:list >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_groupFriends.log 2>&1
|
||||
# 添加好友任务列表(每1分钟执行)
|
||||
*/1 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think friendTask:list >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_friendTask.log 2>&1
|
||||
# 微信客服列表(每5分钟执行)
|
||||
*/5 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think wechatList:list >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_wechatList.log 2>&1
|
||||
# 公司账号列表(每5分钟执行)
|
||||
*/5 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think account:list >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_account.log 2>&1
|
||||
# 微信好友消息列表(每30分钟执行)
|
||||
*/1 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think message:friendsList >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_messageFriends.log 2>&1
|
||||
# 微信群聊消息列表(每30分钟执行)
|
||||
*/1 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think message:chatroomList >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_messageChatroom.log 2>&1
|
||||
# 获取通话记录
|
||||
*/30 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think call-recording:list >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/call_recording.log 2>&1
|
||||
# 清洗微信数据
|
||||
*/2 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think sync:wechatData >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/sync_wechat_data.log 2>&1
|
||||
# 内容采集任务(每5分钟执行)
|
||||
*/5 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think content:collect >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_contentCollect.log 2>&1
|
||||
# 工作台任务_自动点赞(每10分钟执行)
|
||||
*/6 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think workbench:autoLike >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/crontab_workbench_autoLike.log 2>&1
|
||||
# 每3天的3点同步所有好友
|
||||
0 3 */3 * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think sync:allFriends >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/all_friends.log 2>&1
|
||||
# 工作台流量分发
|
||||
*/2 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think workbench:trafficDistribute >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/traffic_distribute.log 2>&1
|
||||
# 工作台朋友圈同步任务
|
||||
*/2 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think workbench:moments >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/workbench_moments.log 2>&1
|
||||
# 工作台群发消息
|
||||
#*/2 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think workbench:groupPush >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/workbench_groupPush.log 2>&1
|
||||
# 预防性切换好友
|
||||
*/2 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think switch:friends >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/switch_friends.log 2>&1
|
||||
# 工作台建群
|
||||
*/5 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think workbench:groupCreate >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/workbench_groupCreate.log 2>&1
|
||||
# 工作台通讯录导入
|
||||
*/5 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think workbench:import-contact >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/import_contact.log 2>&1
|
||||
# 消息提醒
|
||||
*/1 * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think kf:notice >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/kf_notice.log 2>&1
|
||||
# 客服评分
|
||||
0 2 * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think wechat:calculate-score >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/calculate_score.log 2>&1
|
||||
|
||||
|
||||
|
||||
# 每分钟执行一次调度器(调度器内部会自动判断哪些任务需要执行)
|
||||
* * * * * cd /www/wwwroot/mckb_quwanzhi_com/Server && php think scheduler:run >> /www/wwwroot/mckb_quwanzhi_com/Server/runtime/log/scheduler.log 2>&1
|
||||
|
||||
Reference in New Issue
Block a user