群发
This commit is contained in:
@@ -140,6 +140,7 @@ class WorkbenchController extends Controller
|
||||
$config->groupDescription = $param['groupDescription'];
|
||||
$config->poolGroups = json_encode($param['poolGroups'] ?? []);
|
||||
$config->wechatGroups = json_encode($param['wechatGroups'] ?? []);
|
||||
$config->admins = json_encode($param['admins'] ?? [], JSON_UNESCAPED_UNICODE);
|
||||
$config->createTime = time();
|
||||
$config->updateTime = time();
|
||||
$config->save();
|
||||
@@ -229,7 +230,7 @@ class WorkbenchController extends Controller
|
||||
$query->field('workbenchId,pushType,targetType,groupPushSubType,startTime,endTime,maxPerDay,pushOrder,isLoop,status,groups,friends,ownerWechatIds,trafficPools,contentLibraries,friendIntervalMin,friendIntervalMax,messageIntervalMin,messageIntervalMax,isRandomTemplate,postPushTags,announcementContent,enableAiRewrite,aiRewritePrompt');
|
||||
},
|
||||
'groupCreate' => function ($query) {
|
||||
$query->field('workbenchId,devices,startTime,endTime,groupSizeMin,groupSizeMax,maxGroupsPerDay,groupNameTemplate,groupDescription,poolGroups,wechatGroups');
|
||||
$query->field('workbenchId,devices,startTime,endTime,groupSizeMin,groupSizeMax,maxGroupsPerDay,groupNameTemplate,groupDescription,poolGroups,wechatGroups,admins');
|
||||
},
|
||||
'importContact' => function ($query) {
|
||||
$query->field('workbenchId,devices,pools,num,remarkType,remark,clearContact,startTime,endTime');
|
||||
@@ -348,6 +349,18 @@ class WorkbenchController extends Controller
|
||||
$item->config->devices = json_decode($item->config->devices, true);
|
||||
$item->config->poolGroups = json_decode($item->config->poolGroups, true);
|
||||
$item->config->wechatGroups = json_decode($item->config->wechatGroups, true);
|
||||
$item->config->admins = json_decode($item->config->admins ?? '[]', true) ?: [];
|
||||
if (!empty($item->config->admins)) {
|
||||
$adminOptions = Db::table('s2_wechat_friend')->alias('wf')
|
||||
->join(['s2_wechat_account' => 'wa'], 'wa.id = wf.wechatAccountId', 'left')
|
||||
->where('wf.id', 'in', $item->config->admins)
|
||||
->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')
|
||||
->select();
|
||||
$item->config->adminsOptions = $adminOptions;
|
||||
} else {
|
||||
$item->config->adminsOptions = [];
|
||||
}
|
||||
}
|
||||
unset($item->groupCreate, $item->group_create);
|
||||
break;
|
||||
@@ -457,7 +470,7 @@ class WorkbenchController extends Controller
|
||||
$query->field('workbenchId,pushType,targetType,groupPushSubType,startTime,endTime,maxPerDay,pushOrder,isLoop,status,groups,friends,ownerWechatIds,trafficPools,contentLibraries,friendIntervalMin,friendIntervalMax,messageIntervalMin,messageIntervalMax,isRandomTemplate,postPushTags,announcementContent,enableAiRewrite,aiRewritePrompt');
|
||||
},
|
||||
'groupCreate' => function ($query) {
|
||||
$query->field('workbenchId,devices,startTime,endTime,groupSizeMin,groupSizeMax,maxGroupsPerDay,groupNameTemplate,groupDescription,poolGroups,wechatGroups');
|
||||
$query->field('workbenchId,devices,startTime,endTime,groupSizeMin,groupSizeMax,maxGroupsPerDay,groupNameTemplate,groupDescription,poolGroups,wechatGroups,admins');
|
||||
},
|
||||
'importContact' => function ($query) {
|
||||
$query->field('workbenchId,devices,pools,num,remarkType,remark,clearContact,startTime,endTime');
|
||||
@@ -567,6 +580,7 @@ class WorkbenchController extends Controller
|
||||
$workbench->config->deviceGroups = json_decode($workbench->config->devices, true);
|
||||
$workbench->config->poolGroups = json_decode($workbench->config->poolGroups, true);
|
||||
$workbench->config->wechatGroups = json_decode($workbench->config->wechatGroups, true);
|
||||
$workbench->config->admins = json_decode($workbench->config->admins ?? '[]', true) ?: [];
|
||||
unset($workbench->groupCreate, $workbench->group_create);
|
||||
}
|
||||
break;
|
||||
@@ -761,6 +775,18 @@ class WorkbenchController extends Controller
|
||||
$workbench->config->ownerWechatOptions = [];
|
||||
}
|
||||
|
||||
// 获取管理员选项(自动建群)
|
||||
if ($workbench->type == self::TYPE_GROUP_CREATE && !empty($workbench->config->admins)) {
|
||||
$adminOptions = Db::table('s2_wechat_friend')->alias('wf')
|
||||
->join(['s2_wechat_account' => 'wa'], 'wa.id = wf.wechatAccountId', 'left')
|
||||
->where('wf.id', 'in', $workbench->config->admins)
|
||||
->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')
|
||||
->select();
|
||||
$workbench->config->adminsOptions = $adminOptions;
|
||||
} else {
|
||||
$workbench->config->adminsOptions = [];
|
||||
}
|
||||
|
||||
return json(['code' => 200, 'msg' => '获取成功', 'data' => $workbench]);
|
||||
}
|
||||
@@ -882,6 +908,7 @@ class WorkbenchController extends Controller
|
||||
$config->groupDescription = $param['groupDescription'];
|
||||
$config->poolGroups = json_encode($param['poolGroups'] ?? []);
|
||||
$config->wechatGroups = json_encode($param['wechatGroups'] ?? []);
|
||||
$config->admins = json_encode($param['admins'] ?? [], JSON_UNESCAPED_UNICODE);
|
||||
$config->updateTime = time();
|
||||
$config->save();
|
||||
}
|
||||
@@ -1109,6 +1136,7 @@ class WorkbenchController extends Controller
|
||||
$newConfig->groupDescription = $config->groupDescription;
|
||||
$newConfig->poolGroups = $config->poolGroups;
|
||||
$newConfig->wechatGroups = $config->wechatGroups;
|
||||
$newConfig->admins = $config->admins ?? json_encode([], JSON_UNESCAPED_UNICODE);
|
||||
$newConfig->createTime = time();
|
||||
$newConfig->updateTime = time();
|
||||
$newConfig->save();
|
||||
|
||||
Reference in New Issue
Block a user