0, 'update_time' => date('Y-m-d H:i:s')]; $query = "`enable` = 1 and `sys_group_id` = " . $sysGroupId . " and `pid` = '" . $pid . "' and `account_id` in ('" . implode("','", $bindAccountIds) . "')"; $updateRes = AdqAccountBindPidConf::updateDataByQuery($query, $updateData); if(!$updateRes) { \DB::rollBack(); return ['程序异常', 500]; } } } $res = AdqAccountBindPidConf::saveData($sysGroupId, $accountId, $pid, $note); if(!$res) { \DB::rollBack(); return ['程序异常', 500]; } \DB::commit(); return ['成功', 0]; } public static function bindPidList($sysGroupId, $accountId, $note, $page, $pageSize) { $query = AdqAccountBindPidConf::getBinPidListQuery($sysGroupId, $accountId, $note); $countQuery = clone $query; $count = $countQuery->count(); $list = $query->orderBy('id', 'desc')->offset(($page - 1) * $pageSize)->limit($pageSize)->get(); return [$list, $count]; } public static function editStatus($id, $status) { $updateData = ['status' => $status, 'update_time' => date('Y-m-d H:i:s')]; $res = AdqAccountBindPidConf::updateDataById($id, $updateData); if(!$res) { return ['程序异常', 500]; } return ['成功', 0]; } public static function getAccountIdByPid($sysGroupId, $pid, $status = null, $debarAccountId = null) { $params['sys_group_id'] = $sysGroupId; $params['pid'] = $pid; if(!is_null($status)) $params['status'] = $status; if(!empty($debarAccountId)) $params['debar_account_id'] = $debarAccountId; $confDataList = AdqAccountBindPidConf::search($params); if($confDataList->isEmpty()) { return null; } $confDataList = $confDataList->toArray(); return array_column($confDataList, 'account_id'); } public static function checkBindType($sysGroupId, $accountId, $type) { $data = []; if(1 == $type) { // 企微投放,检测之前是否有开启状态的推广计划绑定关系 $params = ['sys_group_id' => $sysGroupId, 'status' => 1, 'account_id' => $accountId]; $result = AdqAccountBindPidConf::search($params); $count = $result->count(); $bindStatus = $count > 0; $data = [ 'bind_status' => $bindStatus, 'msg' => $bindStatus ? '已绑定推广计划,请将已绑定计划的状态全部关闭后再执行本操作' : '', ]; } else if(2 == $type) { // 直接投放,检测之前是否有未删除的企微客服绑定关系 $params = ['account_id' => $accountId]; $result = AdqUser::search($params); $count = $result->count(); $bindStatus = $count > 0; $data = [ 'bind_status' => $bindStatus, 'msg' => $bindStatus ? '已绑定企微客服,请将企微客服绑定关系全部删除后再执行本操作' : '', ]; } return $data; } }