/** * 组装竞价列表 * @param $out * @return array */ private static function prepareBidList(&$out) { $out['bidList'] = array(); $out['bidProIds'] = array(); // 获取计划 $validBidPlans = Model_Plan_HzPlanBasic::getBidPlansByBrokerId($out['hzBrokerId']); if (empty($validBidPlans)) { return array(); } $planIds = array(); $allPlanIds = array(); foreach ($validBidPlans as $plan) { if ($plan['flag'] == 1 && $plan['status'] != Const_HzPlan::DELETE) { $planIds[] = $plan['id']; } $allPlanIds[] = $plan['id']; } // 获取关系 $bidPlannings = Model_Plan_HzPlanning::getPlanningByPlanIds($planIds); // 获取竞价消费信息 //$out['bidComsume'] = Bll_Plan_Bid_HzBid::getBidPlanConsumeAndClickInfos($allPlanIds, date('Ymd')); $out['bidComsume'] = Model_Stats_PropClick::getBillingInfo($out['hzBrokerId'], $out['cityId'], date('Ymd')); if (empty($bidPlannings)) { return array(); } // 组装 foreach ($validBidPlans as $plan) { $planId = $plan['id']; // 拼接关系 foreach ($bidPlannings as $bidPlanning) { $proId = $bidPlanning['proid']; if ($planId != $bidPlanning['plan_id']) { continue; } $out['bidList'][$planId] = $plan; $out['bidList'][$planId]['planning'] = $bidPlanning; // 拼接房子 $prop = isset($out['props'][$proId]) ? $out['props'][$proId] : array(); if (empty($prop)) { unset($out['bidList'][$planId]); continue; } $out['bidList'][$planId]['prop'] = $prop; // 算竞价排名 if ($plan['status'] == Const_HzPlan::SPREAD) { $rank = Bll_Plan_Bid_HzBid::getBidRank($prop['proid'], $prop['commid'], $prop['pricenum'], $bidPlanning['unit_price'], $out['cityId']); } else { $rank = '已暂停'; } $out['bidList'][$planId]['rank'] = $rank; $out['bidProIds'][] = $proId; } } // 排序 前5名 排队 停止 usort($out['bidList'], function ($a, $b) { return is_numeric($a['rank']) && !is_numeric($b['rank']) ? -1 : 1; }); usort($out['bidList'], function ($a, $b) { return $a['rank'] == '已暂停' && $b['rank'] != '已暂停' ? 1 : -1; }); foreach ($out['bidList'] as $k => $v) { $out['bidList'][$v['id']] = $v; unset($out['bidList'][$k]); } // 获取房源竞价点击 if (count($out['bidProIds']) > 0) { $out['bidClicks'] = Bll_Plan_Bid_HzBid::getPropsBidClick($out['bidProIds'], $out['cityId'], $out['hzBrokerId']); } }
/** * 组装竞价列表 * @param $out * @return array */ private static function prepareBidList(&$out) { $bidList = array(); $out['bidProIds'] = array(); // 获取计划 $validBidPlans = Model_Plan_HzPlanBasic::getValidBidPlans($out['hzBrokerId']); if (empty($validBidPlans)) { return array(); } $planIds = array(); foreach ($validBidPlans as $plan) { $planIds[] = $plan['id']; } // 获取关系 $bidPlannings = Model_Plan_HzPlanning::getPlanningByPlanIds($planIds); if (empty($bidPlannings)) { return array(); } // 组装 foreach ($validBidPlans as $plan) { $planId = $plan['id']; // 拼接关系 foreach ($bidPlannings as $bidPlanning) { $proId = $bidPlanning['proid']; if ($planId != $bidPlanning['plan_id']) { continue; } $bidList[$planId] = $plan; $bidList[$planId]['planning'] = $bidPlanning; // 拼接房子 $prop = isset($out['props'][$proId]) ? $out['props'][$proId] : array(); if (empty($prop)) { unset($bidList[$planId]); continue; } $bidList[$planId]['prop'] = $prop; // 算竞价排名 if ($plan['status'] == Const_HzPlan::SPREAD) { $rank = Bll_Plan_Bid_HzBid::getBidRank($prop['proId'], $prop['commId'], $prop['priceNum'], $bidPlanning['unit_price'], $out['cityId']); } else { $rank = '已暂停'; } $bidList[$planId]['rank'] = $rank; $out['bidProIds'][] = $proId; } } // 获取房源竞价点击 if (count($out['bidProIds']) > 0) { $out['bidClicks'] = Bll_Plan_Bid_HzBid::getPropsBidClick($out['bidProIds'], $out['cityId'], $out['hzBrokerId']); } return $bidList; }