public function dingdoneSetClickNum() { $click_num = intval($this->input['click_num']); $module_bundle = trim($this->input['module_bundle']); $app_bundle = trim($this->input['app_bundle']); $source_id = intval($this->input['source_id']); $publish_id = intval($this->input['publish_id']); include_once ROOT_PATH . 'lib/class/publishcontent.class.php'; $publishcontent_class = new publishcontent(); $ret = $publishcontent_class->get_content_by_other($source_id, $app_bundle, $module_bundle); $content_fromid = $ret[0]['content_fromid']; $cid = $ret[0]['content_id']; //对叮当旧数据需要做兼容 content_fromid 为0 $jianrong_sql = "select * from " . DB_PREFIX . "nums where module_bundle = '" . $module_bundle . "' and cid = " . $cid . " and content_fromid = 0"; $temp_info = $this->db->query_first($jianrong_sql); if ($temp_info) { $update_temp_sql = "update " . DB_PREFIX . "nums set content_fromid = " . $source_id . " where cid = " . $cid; $this->db->query($update_temp_sql); } //验证消息是否正确 //source source_id publish_id $select_sql = "select * from " . DB_PREFIX . "nums where module_bundle = '" . $module_bundle . "' and content_fromid = " . $source_id; $now_nums = $this->db->query_first($select_sql); $content_info = $publishcontent_class->get_content_by_cid($cid); $title = $content_info[$cid]['title']; if (!$ret) { $this->errorOutput(FAILED); } if ($now_nums) { //更新nums表 $update_sql = "update " . DB_PREFIX . "nums set access_nums = " . $click_num . " where module_bundle = '" . $module_bundle . "' and content_fromid = " . $source_id; $this->db->query($update_sql); } else { $insert_sql = 'INSERT INTO ' . DB_PREFIX . "nums (app_bundle, module_bundle, content_fromid,cid, title, access_nums, last_sync_time, is_sync, url, create_time, update_time) VALUES\r\n\t\t\t('{$app_bundle}', '{$module_bundle}', '{$content_fromid}', '{$cid}' ,'{$title}', " . $click_num . ", " . TIMENOW . ", '0', '', " . TIMENOW . ", " . TIMENOW . ")"; $this->db->query($insert_sql); } //更新发布库和对应的source库 include_once ROOT_PATH . 'lib/class/curl.class.php'; $settings = $this->settings['App_' . $app_bundle]; if ($settings) { if (empty($this->pub_content_bundle)) { $this->publishcontent = new publishcontent(); $content_type = $this->publishcontent->get_all_content_type(); $this->pub_content_bundle = array(); foreach ((array) $content_type as $k => $v) { $this->pub_content_bundle[] = $v['bundle_id']; } } //取原始内容id if ($app_bundle && in_array($app_bundle, (array) $this->pub_content_bundle)) { //去文稿、图集等应用同步访问数时 随便把统计库标题更新调 防止发布库统计库不一致(依然有时间差) $title = $ret[0]['title']; $curl = new curl($settings['host'], $settings['dir'] . 'admin/'); $curl->setSubmitType('post'); $curl->setReturnFormat('json'); $curl->initPostData(); $curl->addRequestData('a', 'access_sync'); $curl->addRequestData('id', $content_fromid); switch ($app_bundle) { case 'livmedia': $filename = 'vod'; break; default: $filename = $app_bundle; break; } $curl->addRequestData('click_num', $click_num); $q = $curl->request($filename . '_update.php'); //同步到发布库 $this->publishcontent = new publishcontent(); //get_content_by_cid把$this->curl更改 需要重新实例化 $data = array('click_num' => $click_num); $this->publishcontent->update_content_by_cid($ret[0]['content_id'], $data); } } $this->addItem(array('return' => 1)); $this->output(); }