修改自动推广的相关任务 退订相关
This commit is contained in:
@@ -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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user