修改自动推广的相关任务 退订相关

This commit is contained in:
wangjinlei
2026-04-27 14:53:46 +08:00
parent 1ff6bef655
commit 5645b87669
7 changed files with 362 additions and 6 deletions

View File

@@ -653,4 +653,58 @@ class ExpertManage extends Base
return jsonSuccess([]);
}
/**
* 后台手工将专家标记为退订
* 参数: expert_id(必填) 或 expert_ids(逗号分隔批量)
*/
public function unsubscribe()
{
$data = $this->request->post();
$idsRaw = trim((string)(isset($data['expert_ids']) ? $data['expert_ids'] : (isset($data['expert_id']) ? $data['expert_id'] : '')));
if ($idsRaw === '') {
return jsonError('expert_id 或 expert_ids 必填');
}
$ids = array_filter(array_map('intval', explode(',', $idsRaw)));
if (empty($ids)) {
return jsonError('expert_id 无效');
}
$affected = Db::name('expert')
->where('expert_id', 'in', $ids)
->where('unsubscribed', 0)
->update(['unsubscribed' => 1]);
return jsonSuccess([
'requested' => count($ids),
'affected' => intval($affected),
]);
}
/**
* 后台手工恢复专家订阅状态
* 参数: expert_id(必填) 或 expert_ids(逗号分隔批量)
*/
public function resubscribe()
{
$data = $this->request->post();
$idsRaw = trim((string)(isset($data['expert_ids']) ? $data['expert_ids'] : (isset($data['expert_id']) ? $data['expert_id'] : '')));
if ($idsRaw === '') {
return jsonError('expert_id 或 expert_ids 必填');
}
$ids = array_filter(array_map('intval', explode(',', $idsRaw)));
if (empty($ids)) {
return jsonError('expert_id 无效');
}
$affected = Db::name('expert')
->where('expert_id', 'in', $ids)
->where('unsubscribed', 1)
->update(['unsubscribed' => 0]);
return jsonSuccess([
'requested' => count($ids),
'affected' => intval($affected),
]);
}
}