/** * 获取租房房源的推广状态 * * @param int|array $houseId * @return array */ private function getHouseSpreadStateHz($houseId) { $result = array('spread_house' => array(), 'not_spread_house' => array()); try { $dataAccess = Model_Plan_HzPlanning::data_access(''); $dataAccess->filter('proid', $houseId); $dataAccess->filter('is_valid', 1); $dataAccess->filter('plan_type', Model_Plan_HzPlanning::BID_OR_CHOICE_PLAN); $housePlanRelationList = $dataAccess->get_all(); } catch (Exception $e) { return $result; } if (empty($housePlanRelationList)) { $result['not_spread_house'] = is_array($houseId) ? $houseId : array($houseId); return $result; } $planHouseMapping = array(); foreach ($housePlanRelationList as $housePlanRelation) { $planHouseMapping[$housePlanRelation['plan_id']] = $housePlanRelation['proid']; } try { $dataAccess = Model_Plan_HzPlanBasic::data_access(''); $dataAccess->filter('id', array_keys($planHouseMapping)); $dataAccess->filter('flag', 1); $dataAccess->filter('plan_type', Model_Plan_HzPlanning::BID_OR_CHOICE_PLAN); $dataAccess->filter('bid_version', 2); $dataAccess->filter('status', 1); $planList = $dataAccess->get_all(); } catch (Exception $e) { $result['not_spread_house'] = is_array($houseId) ? $houseId : array($houseId); return $result; } if (empty($planList)) { $result['not_spread_house'] = is_array($houseId) ? $houseId : array($houseId); return $result; } foreach ($planList as $planInfo) { $result['spread_house'][] = $planHouseMapping[$planInfo['id']]; } if (!is_array($houseId)) { $houseId = array($houseId); } $result['not_spread_house'] = array_diff($houseId, $result['spread_house']); return $result; }
public function get_plan_by_proid($proid) { return Model_Plan_HzPlanning::data_access()->filter('proid', $proid)->filter('plan_type', 2)->find_only(); }
/** * 警告:未得到授权,不能使用。所有者:caoyang * 本方法为租房架构变更,房源状态维护的过渡期中临时方法。有效到2014-10-01。 * * 根据当前定价、竞价(精选)的状态维护房源的状态 * 1.房源的状态为:违规-6,删除-99、100的时候房源的状态不被更新 * 2.定价、竞价(精选)任意一个推广时房源状态为1 * 3.房源不在定价计划中的时候状态需要维护成2、4 * * @param $hzProId * @return mixed */ public static function bulidHzProStatu($hzProId) { /** 房源信息初步判断 */ //查询房源信息 $proInfo = Model_House_HzProp::get_prop_info_by_prop_id($hzProId); if (empty($proInfo)) { //房源信息不存在 return ''; } if (in_array($proInfo['contentBasic']['status'], array(Const_HzStatus::VERIFY, Const_HzStatus::REMOVE, Const_HzStatus::EXPIRED))) { //房源状态为违规的、删除的不能更新房源状态 return ''; } /** 定价、竞价(精选)数据准备 */ //查询租房定价、竞价(精选)关系数据 $fixPlanning = array(); //定价关系数据 $bidPlanning = array(); //竞价(精选)关系数据 $comboRelation = array(); // 套餐关系数据 //$isComboBroker = Bll_Broker_HzBroker::isComboBroker($proInfo['contentBasic']['user_id']); $planning = Model_Plan_HzPlanning::data_access()->filter('proid', $hzProId)->get_all(); foreach ($planning as $list) { //定价 if ($list['plan_type'] == Const_HzPlan::SPREAD_TYPE) { $fixPlanning = $list; } //竞价(精选) if ($list['plan_type'] == Const_HzPlan::BID_TYPE) { $bidPlanning = $list; } } //查询租房竞价(精选)计划状态 if (empty($bidPlanning)) { $bidPlanInfo = array(); } else { $bidPlanInfo = Model_Plan_HzPlanBasic::get_plan_by_id($bidPlanning['plan_id']); } //查询租房定价计划状态 if (empty($fixPlanning)) { $fixPlanInfo = array(); } else { $fixPlanInfo = Model_Plan_HzPlanBasic::get_plan_by_id($fixPlanning['plan_id']); } //查询套餐关系 $comboRelation = Bll_Combo_HouseRelation::getRelationByHouseId($hzProId); /** 计算出房源状态应该更新成什么样 */ /** * 1. 非定价推广(计划删除、或房源不在计划里面)proStatus=2 * 2. 定价推广:proStatus=1 * 3. 定价非推广(房源在计划中) * 3.1 竞价(精选)非推广 * 3.1.1 定价计划没钱 proStatus=13 * 3.1.1 定价其他 proStatus=9 * 3.2 竞价(精选)推广 proStatus=1 */ if ($comboRelation) { return Dao_Broker_HzProp::change_prop_status($hzProId, Bll_Combo_HouseRelation::isRelationOnline($comboRelation['state']) ? Const_HzStatus::ONLINE : Const_HzStatus::OUTLINE); } else { //定价计划不存在、计划标记为删除、计划不是正常状态(1、2、5、7、9) if (empty($fixPlanInfo) || $fixPlanInfo['flag'] == 0 || !in_array($fixPlanInfo['status'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE))) { return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::OUTLINE); //房源不在计划里面 } //定价房源不在计划里面、非有效的关系(1、2、5、7、9) if (empty($fixPlanning) || !in_array($fixPlanning['is_valid'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE))) { return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::OUTLINE); //房源不在计划里面 } //定价计划推广中 if ($fixPlanInfo['status'] == Const_HzPlan::SPREAD) { return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::ONLINE); //房源正在推广 } //竞价(精选)计划不存在、计划标记为删除、计划不是正常状态(1、2、5、7、9、13) //竞价(精选)房源不在计划里面、非有效的关系(1、2、5、7、9、13) if (empty($bidPlanInfo) || $bidPlanInfo['flag'] == 0 || !in_array($bidPlanInfo['status'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE, Const_HzPlan::WAITING)) || empty($bidPlanning) || !in_array($bidPlanning['is_valid'], array(Const_HzPlan::SPREAD, Const_HzPlan::AUTOOVER, Const_HzPlan::AWAIT, Const_HzPlan::UPPERLIMIT, Const_HzPlan::MANUALLY_PAUSE, Const_HzPlan::WAITING))) { if ($fixPlanInfo['status'] == Const_HzPlan::UPPERLIMIT) { //计划没钱 return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::NOCASH); //房源没钱 } else { return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::MANUALLY); //房源状态更新为9手动停止 } } //竞价(精选)推广 if ($bidPlanInfo['status'] == Const_HzPlan::SPREAD) { return Dao_Broker_HzProp::change_prop_status($hzProId, Const_HzStatus::ONLINE); //房源正在推广 } } //以上逻辑都没走到,记录当时错误情况 file_put_contents("/data1/logs/bulidHzProStatu.log", date('Y-m-d H:i:s') . " " . $hzProId . " " . json_encode($fixPlanInfo) . " " . json_encode($fixPlanning) . " " . json_encode($bidPlanInfo) . " " . json_encode($bidPlanning) . "\n", FILE_APPEND); return false; }
/** * 获取计划单个房源关系 * * @param int $userId * @param int $planId * @return array */ public static function getOneHouseFixPlanRelation($userId, $planId) { try { return Model_Plan_HzPlanning::data_access()->filter('plan_id', $planId)->filter('plan_type', self::FIX_PLAN)->filter('user_id', $userId)->get_row(); } catch (Exception $e) { return array(); } }
/** * 获取经纪人精选推广的房源Id * * @param int $brokerId * @return array */ private function getHouseSpreadStateResultHz($brokerId) { $result = array('spread_house' => array(), 'not_spread_house' => array()); /** 获取状态发生变更的计划Id */ try { $dataAccess = Model_Plan_HzPlanBasic::data_access(''); $dataAccess->filter('ajkBrokerId', $brokerId); $dataAccess->filter('status', Const_HzPlan::SPREAD); $dataAccess->filter('plan_type', 2); $dataAccess->filter('flag', 1); $dataAccess->load_field(array('id', 'status', 'ajkBrokerId')); $houseSpreadPlanList = $dataAccess->get_all(); } catch (Exception $e) { return $result; } if (empty($houseSpreadPlanList)) { return $result; } $spreadPlanIds = array(); foreach ($houseSpreadPlanList as $houseSpreadPlan) { if ($houseSpreadPlan['status'] == 1) { $spreadPlanIds[] = $houseSpreadPlan['id']; } } /** 获取房源Id */ try { $dataAccess = Model_Plan_HzPlanning::data_access(''); $dataAccess->filter('plan_id', $spreadPlanIds); $dataAccess->filter('plan_type', Model_Plan_HzPlanning::BID_OR_CHOICE_PLAN); $dataAccess->load_field(array('plan_id', 'proid')); $promotionPropPlanningList = $dataAccess->get_all(); } catch (Exception $e) { return $result; } if (empty($promotionPropPlanningList)) { return $result; } foreach ($promotionPropPlanningList as $promotionPropPlanning) { if (in_array($promotionPropPlanning['plan_id'], $spreadPlanIds)) { $result['spread_house'][] = $promotionPropPlanning['proid']; } } return $result; }
/** * 获取租房 精选状态发生变更的房源 * * @param int $startTime * @param int $endTime * @param int $startId * @return array */ private function getHouseSpreadStateChangeResultHz($startTime, $endTime, $startId) { $result = array('spread_house' => array(), 'not_spread_house' => array(), 'last_id' => 0); /** 获取状态发生变更的计划Id */ try { $dataAccess = Model_Plan_HzPlanBasic::data_access(''); $dataAccess->filter_by_op('last_update', '>=', date('Y-m-d H:i:s', $startTime)); $dataAccess->filter_by_op('last_update', '<=', date('Y-m-d H:i:s', $endTime)); if ($startId > 0) { $dataAccess->filter_by_op('id', '>', $startId); } $dataAccess->load_field(array('id', 'status', 'ajkBrokerId')); $dataAccess->sort('id', 'asc'); $dataAccess->limit(1000); $stateChangePlanList = $dataAccess->get_all(); } catch (Exception $e) { return $result; } if (empty($stateChangePlanList)) { return $result; } $spreadPlanIds = array(); $notSpreadPlanIds = array(); foreach ($stateChangePlanList as $stateChangePlan) { $result['last_id'] = $stateChangePlan['id']; if ($stateChangePlan['status'] == 1) { $spreadPlanIds[] = $stateChangePlan['id']; } else { $notSpreadPlanIds[] = $stateChangePlan['id']; } } /** 获取房源Id */ try { $dataAccess = Model_Plan_HzPlanning::data_access(''); $dataAccess->filter('plan_id', array_merge($spreadPlanIds, $notSpreadPlanIds)); $dataAccess->filter('plan_type', Model_Plan_HzPlanning::BID_OR_CHOICE_PLAN); $dataAccess->load_field(array('plan_id', 'proid')); $promotionPropPlanningList = $dataAccess->get_all(); } catch (Exception $e) { return $result; } if (empty($promotionPropPlanningList)) { return $result; } foreach ($promotionPropPlanningList as $promotionPropPlanning) { if (in_array($promotionPropPlanning['plan_id'], $spreadPlanIds)) { $result['spread_house'][] = $promotionPropPlanning['proid']; } elseif (in_array($promotionPropPlanning['plan_id'], $notSpreadPlanIds)) { $result['not_spread_house'][] = $promotionPropPlanning['proid']; } } return $result; }
public static function get_check_planning($proid, $plan_id, $plan_type = Const_HzPlan::SPREAD_TYPE) { if (empty($proid) || empty($plan_id)) { return array(); } $is_valid = $plan_type == Const_HzPlan::SPREAD_TYPE ? array(1, 2, 5, 7, 9) : array(1, 3, 7); $broker_planning = Model_Plan_HzPlanning::data_access()->filter('proid', $proid)->filter('plan_id', $plan_id)->filter_by_op('is_valid', 'in', $is_valid)->filter('plan_type', $plan_type)->get_all(); return $broker_planning; }