/** * 执行流程: * 1. 从 broker_ppc_ceiling_log 获取到 封顶的经纪人ID, * 2. 根据经纪人ID获取到经纪人当前有效的推广计划 * 3. 根据推广计划和城市ID 获取到计划里的房源列表 * 4. 将有效的房源推送到SOLAR队列 */ public function handle_request() { if (file_exists($this->logFile) && is_readable($this->logFile)) { $this->lastUpdateTime = intval(file_get_contents($this->logFile)); } while (true) { /** 从封顶经纪人对列表里获取经纪人ID */ $brokerList = $this->getTopLimitBrokerList($this->lastUpdateTime); if (empty($brokerList)) { break; } foreach ($brokerList as $broker) { $this->lastUpdateTime = $broker['upd_time']; /** 根据经纪人ID 获取经纪人有效的推广计划列表 */ $planList = $this->getStaticPricePlanByBrokerId($broker['broker_id']); if (empty($planList)) { printf('[%s] 经纪人ID【%d】没有获取到推广信息!' . PHP_EOL, date('Y-m-d H:i:s'), $broker['broker_id']); continue; } foreach ($planList as $plan) { /** 根据推广计划ID和城市ID,获取计划下对应的房源 */ $propList = $this->getPropListSpreadRelation($plan['id'], $plan['cityId']); if (empty($propList)) { printf('[%s] 计划ID【%d】没有获取到房源信息!' . PHP_EOL, date('Y-m-d H:i:s'), $plan['Id']); continue; } /** 批量添加 Solar队列 */ // $this->batchInsertLogRankPropUpdate($broker['broker_id'], $propList, $plan['cityId']); //调用api // $url = APF::get_instance()->get_config("ajk_prop_pricing_updown"); // $url .= 'publish?tunnel=esf_prop_state_update'; // // $fields['city_id'] = $plan['cityId']; // $fields['broker_id'] = $plan['brokerId']; // $fields['flag'] = 1; // //$fields['hpstarttime'] = $plan['viewTime']; // //$fields['hpendtime'] = 0; // //$fields['hpplanid'] = $plan['id']; // $fields['update_time'] = time(); // $fields['from_type'] = 102; foreach ($propList as $prop) { $fields['pro_id'][] = $prop['ProId']; } // $post_data = json_encode($fields); // // $curl = new Util_Http_Curl(); // $res = $curl->setDefaults() // ->addOption(CURLOPT_POSTFIELDS, $post_data) // ->post($url); // // $res = json_decode($res,true); $res = Bll_Combo_NoticeSolrUpDown::noticePpcUpdateAjkAPI($plan['cityId'], $plan['brokerId'], $fields['pro_id'], 1, Bll_Combo_NoticeSolrUpDown::HLSFromProDownGrade); if ($res['status'] == 'ok') { //输出 日志,这边可能会导致调度程序内存溢出 printf("[%s] 计划id: %s 房源Id: %s 经纪人: %s 城市: %s 动作: 1 solar更新成功\n", date('Y-m-d H:i:s'), $plan['id'], json_encode($fields['pro_id']), $plan['brokerId'], $plan['cityId']); } else { printf("[%s] 计划id: %s 房源Id: %s 经纪人: %s 城市: %s 动作: 1 solar更新失败\n", date('Y-m-d H:i:s'), $plan['id'], json_encode($fields['pro_id']), $plan['brokerId'], $plan['cityId']); } // printf("[%s] %s\n", date('Y-m-d H:i:s'), $post_data); } } } }
public function addPriceQueueByAPI($brokerId, $cityId, $propIds, $flag) { // $fields = array( // 'city_id' => $cityId, // 'broker_id' => $brokerId, // 'pro_id' => $propIds, // 'flag' => $flag, // //'hpstarttime' => $hpStartTime, // //'hpendtime' => 0, // //'hpplanid' => $hpPlanId, // 'update_time' => time(), // 'from_type' => 106, // ); // // //调用api // $url = APF::get_instance()->get_config("ajk_prop_pricing_updown"); // $url .= 'publish?tunnel=esf_prop_state_update'; // $curl = new Util_Http_Curl(); // $res = $curl->setDefaults() // ->addOption(CURLOPT_POSTFIELDS, json_encode($fields)) // ->post($url); // return $res; return Bll_Combo_NoticeSolrUpDown::noticePpcUpdateAjkAPI($cityId, $brokerId, $propIds, $flag, Bll_Combo_NoticeSolrUpDown::HLSFromProRecoverGrade); }