public function invoke($arrInput) { //用于登录 $id = $arrInput['id']; $dataService = new Service_Data_Message_V2_Message(); $data = $dataService->get_operation_message_details($id); $message = $data[0]; $out['title'] = $message['title']; $out['content'] = $message['ria_content']; $out['from_title'] = $message['from_title']; if ($message['link']) { $out['link'] = $message['link']; if (strpos($out['link'], 'http') !== 0) { $out['link'] = "http://{$message['link']}"; } } $out['publish_time'] = date('m月d日 H:i', $message['start_time']); $out['out_date_tips'] = $message['stop_time'] < time() ? '已过期' : ''; $out['showType'] = $arrInput['showType'] ? intval($arrInput['showType']) : 0; return $out; }
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) { //用于登录 $id = (int) $arrInput['id']; $dataService = new Service_Data_Message_V2_Message(); $data = $dataService->get_operation_message_details($id); $message = $data[0]; if (!$message) { return array('errno' => '1', 'errmsg' => 'message not found'); } $cid = $message['cid']; $opt = json_decode($message['opt'], true); $app_version = $message['app_versiont']; if (!$opt['push_response']) { return array('errno' => 1, 'errmsg' => '暂无统计'); } // push_reponse 是以city_code 作为键值 // "push_response":{"131":{"3":["msgid#8452819436143893891"],"4":["msgid#1259143845097668564"]},"289":{"3":["msgid#7402617256944954515"],"4":["msgid#2232901761059640260"]},"340":{"3":["msgid#7206400091464665875"],"4":["msgid#4420386400034273812"]}} // {"3":["msgid#3386917452281572931"],"4":["msgid#2528194748361896020"]} 全国推或者按照版本推 $broadcast = array(); $group = array(); $reponses = $opt['push_response']; foreach ($reponses as $k => $v) { if ($k == 0 && !$app_version) { //广播 $broadcast = $v; } if ($k == 0 && $app_version) { //按版本号推送 $group['ver_' . $app_version] = $v; } if ($k > 0) { //按城市的组播 $group[$k] = $v; } } $rebroadcast = $regroup = array(); if ($broadcast) { // 查询广播绑定人数 // 广播成功接收用户数,只有android数据 foreach ($broadcast as $os => $msids) { //目前只有一个 foreach ($msids as $msgid) { $id = $this->stripMsgid($msgid); $ret = Net_Util::getMsgCountByResourceId($id); foreach ($ret['ack_counts'] as $t => $cnt) { $rebroadcast['detail'][$os]['count'] += $cnt; $rebroadcast['sum'] += $cnt; } } } } //组播 if ($group) { foreach ($group as $tag => $msgids) { $ret = Net_Util::getUserCountByTag($tag); if ($ret) { // ios and android foreach ($msgids as $os => $srcIDs) { //其实只有一个msgid foreach ($srcIDs as $oneID) { $msgid = $this->stripMsgid($oneID); $tagCntReturn = Net_Util::getGroupMesageArriveCount($ret['tid'], $msgid); $regroup['tags'][$tag]['os'][$os]['usercount'] += $tagCntReturn['usercount']; $regroup['tags'][$tag]['os'][$os]['success_count'] += $tagCntReturn['success_count']; $regroup['tags'][$tag]['sum']['usercount'] = $tagCntReturn['usercount']; $regroup['tags'][$tag]['sum']['success_count'] += $tagCntReturn['success_count']; //其实 ios 和 android 返回的usercount是一样的,表示tag的绑定用户数 $regroup['sum']['usercount'] += $tagCntReturn['usercount']; $regroup['sum']['success_count'] += $tagCntReturn['success_count']; } } } } $regroup['sum']['usercount'] = $regroup['sum']['usercount'] >> 1; //算重了 } $return['errno'] = 0; $return['data']['broadcast'] = $rebroadcast; $return['data']['group'] = $regroup; return $return; }
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); }