protected function invoke($arrInput) { $arrResult = array(); $arrResult['errno'] = 0; //用于登录 try { $this->objServiceDataMessage = new Service_Data_Message_V2_Message(); $messageTypeDataService = new Service_Data_Message_V2_MessageType(); $type_list = $messageTypeDataService->getList(100); //大于100的运营消息 $data = $this->objServiceDataMessage->get_operation_message_details($arrInput['id']); $arrResult['data'] = $data[0]; $arrResult['type_list'] = $type_list; $opt = $data[0]['opt'] ? json_decode($data[0]['opt'], true) : array(); $arrResult['data']['opt'] = $opt; $linkInfo['id'] = $arrInput['id']; $linkInfo['type'] = $data[0]['type']; $linkInfo['origin'] = 'share'; $arrResult['data']['articleLink'] = Net_Util::getMessageLink($linkInfo); $arrResult['data']['old_city_list'] = $opt['city_list'] ? json_encode($opt['city_list']) : '[]'; $arrResult['data']['pic_cover'] = $arrResult['data']['pic_cover'] ? $arrResult['data']['pic_cover'] : $type_list[$arrResult['data']['type']]['pic_url']; } catch (Exception $e) { Bd_Log::warning($e->getMessage(), $e->getCode()); $arrResult['errno'] = $e->getCode(); } return $arrResult; }
public function invoke($arrInput) { //用于登录 $row = array(); $row['type'] = $arrInput['type']; $row['title'] = $arrInput['title']; $cids = $arrInput['cids']; if ($arrInput['content']) { $row['content'] = stripslashes($arrInput['content']); } if ($arrInput['ria_content']) { $row['ria_content'] = stripslashes($arrInput['ria_content']); } if (is_numeric($arrInput['start_time'])) { $row['start_time'] = intval($arrInput['start_time']); } else { $row['start_time'] = strtotime($arrInput['start_time']); } if (is_numeric($arrInput['stop_time'])) { $row['stop_time'] = intval($arrInput['stop_time']); } else { $row['stop_time'] = strtotime($arrInput['stop_time']); } if (isset($arrInput['is_push'])) { $row['is_push'] = $arrInput['is_push']; } else { $row['is_push'] = 0; } $row['push_title'] = $arrInput['push_title'] ? $arrInput['push_title'] : ''; $row['cid'] = 0; $row['os'] = isset($arrInput['os']) ? $arrInput['os'] : -1; if (isset($arrInput['push_cond']) && $arrInput['push_cond'] == 0 && $arrInput['app_version']) { //按版本推送 $row['app_version'] = $arrInput['app_version']; } else { //按城市推送 $city_ids = array(); if ($cids) { //过略重复,避免重复推送 foreach ($cids as $k => $v) { $v = intval($v); if ($v == 0) { //全国 $city_ids = array(); break; } $city_ids[$v] = $v; } } if ($city_ids) { sort($city_ids); $opt['city_list'] = $city_ids; $row['opt'] = json_encode($opt); } } $row['position'] = $arrInput['position'] ? $arrInput['position'] : 0; if ($arrInput['link']) { $row['link'] = $arrInput['link']; } if ($arrInput['from_title']) { $row['from_type'] = 1; $row['from_title'] = $arrInput['from_title']; } foreach ($_FILES as $k => $v) { if ($v['error'] === 0) { //文件上传成功 if (strpos($v['type'], 'image') !== 0) { return array('errno' => 1, "errmsg" => '上传文件不是图片'); } $imgurl = Net_Util::uploadPic($v); if ($imgurl === false) { return array('errno' => 1, "errmsg" => "图片上传百度云失败"); } $row[$k] = $imgurl; } } $row['status'] = isset($arrInput['status']) ? $arrInput['status'] : 0; $dataService = new Service_Data_Message_V2_Message(); $ret = $dataService->addMessage($row); if ($ret) { // 如果是来自情报系统,则需要反调其接口通知状态 if ($arrInput['timestamp']) { $callRet = Net_Util::updateIntelligenceStatus($arrInput['timestamp'], 2); if (!$callRet) { $errmsg = "\\n通知情报系统失败"; } } //获取短连接 $lastId = $dataService->getInsertId(); $linkInfo['id'] = $lastId; $linkInfo['type'] = $row['type']; $linkInfo['origin'] = 'share'; $messgeLink = Net_Util::getMessageLink($linkInfo); $update['opt'] = $opt['shortUrl'] = Net_Util::shortUrl($messgeLink); $ret = $dataService->updateMessage($lastId, $update); return array('errno' => 0, 'errmsg' => '添加成功' . $errmsg); } return array('errno' => 1, 'errmsg' => '添加失败' . $errmsg); }
public function invoke($arrInput) { //用于登录 $row = array(); $row['type'] = $arrInput['type']; $row['title'] = $arrInput['title']; $id = $arrInput['id']; $cids = $arrInput['cids']; $dataService = new Service_Data_Message_V2_Message(); $Message = $dataService->get_operation_message_details($id); $Message = $Message[0]; $allow_column = array('title', 'content', 'ria_content', 'stop_time', 'from_type', 'from_title', 'link'); //发布之后只能修改的列 $opt = $Message['opt'] ? json_decode($Message['opt'], true) : array(); if (empty($Message)) { return array('errno' => 1, 'errmsg' => '运营消息不存在'); } if ($arrInput['content']) { $row['content'] = stripslashes($arrInput['content']); } if ($arrInput['ria_content']) { $row['ria_content'] = stripslashes($arrInput['ria_content']); } if (is_numeric($arrInput['start_time'])) { $row['start_time'] = intval($arrInput['start_time']); } else { $row['start_time'] = strtotime($arrInput['start_time']); } if (is_numeric($arrInput['stop_time'])) { $row['stop_time'] = intval($arrInput['stop_time']); } else { $row['stop_time'] = strtotime($arrInput['stop_time']); } if (isset($arrInput['is_push'])) { $row['is_push'] = $arrInput['is_push']; } else { $row['is_push'] = 0; } $row['push_title'] = $arrInput['push_title'] ? $arrInput['push_title'] : ''; $row['os'] = isset($arrInput['os']) ? $arrInput['os'] : -1; if (isset($arrInput['push_cond']) && $arrInput['push_cond'] == 0 && $arrInput['app_version']) { //按版本推送 $row['app_version'] = $arrInput['app_version']; $row['cid'] = 0; $opt['city_list'] = array(); $row['opt'] = json_encode($opt); } else { //按城市推送 $row['app_version'] = ''; $city_ids = array(); if ($cids) { //过略重复,避免重复推送 foreach ($cids as $k => $v) { $v = intval($v); if ($v == 0) { //全国 $city_ids = array(); break; } $city_ids[$v] = $v; } } if ($city_ids) { sort($city_ids); $opt['city_list'] = $city_ids; $row['opt'] = json_encode($opt); } } $row['position'] = $arrInput['position'] ? $arrInput['position'] : 0; if ($arrInput['link']) { $row['link'] = $arrInput['link']; } if ($arrInput['from_type'] && $arrInput['from_title']) { $row['from_type'] = 1; $row['from_title'] = $arrInput['from_title']; } else { $row['from_type'] = 0; $row['from_title'] = '百度导航'; } foreach ($_FILES as $k => $v) { if ($v['error'] === 0) { //文件上传成功 if (strpos($v['type'], 'image') !== 0) { return array('errno' => 1, "errmsg" => '上传文件不是图片'); } $imgurl = Net_Util::uploadPic($v); if ($imgurl === false) { return array('errno' => 1, "errmsg" => "图片上传百度云失败"); } $row[$k] = $imgurl; $allow_column[] = $k; } } $row['status'] = isset($arrInput['status']) ? $arrInput['status'] : 0; if ($Message['status'] == 1) { //发布状态只能修改标题和内容 $allow_row = array(); foreach ($allow_column as $v) { $allow_row[$v] = $row[$v]; } $row = $allow_row; $exat_message = "\\n[发布状态只能修改标题,内容,图片,来源]"; } if (isset($arrInput['shortUrl']) && strpos($arrInput['shortUrl'], 'http') === 0) { $opt['shortUrl'] = trim($arrInput['shortUrl']); } else { $linkInfo['id'] = $id; $linkInfo['type'] = $row['type']; $linkInfo['origin'] = 'share'; $messgeLink = Net_Util::getMessageLink($linkInfo); $shortUrl = Net_Util::shortUrl($messgeLink); if ($shortUrl == false) { $shortUrl = Net_Util::thirdShortUrl($messgeLink); } $opt['shortUrl'] = $shortUrl; } $row['opt'] = json_encode($opt); $ret = $dataService->updateMessage($id, $row); if ($ret) { return array('errno' => 0, 'errmsg' => '修改成功' . $exat_message); } return array('errno' => 1, 'errmsg' => '没有修改' . $exat_message); }