public function afterPost() { // 推广 if ($this->ctx['html_action'] == 'publish') { //伪登陆不能推广 if ($this->ctx['isManagerCookie']) { $this->redirect2Result(Const_PublishCode::PSEUDO_ERROR, $this->site, $this->action, $this->ctx['proId']); } if (Bll_City::isComboCity($this->ctx['cityId'])) { // 套餐推广 $spreadResult = Bll_Combo_HouseRelation::houseStartComboSpreadV2($this->ctx['ajkBrokerId'], $this->ctx['cityId'], $this->ctx['proId'], Bll_Combo_HouseRelation::SITE_TYPE_HZ); } else { // 双证审核未通过 不能推广 // 获取经纪人信息 $brokerInfo = Model_Broker_HzUsersSearch::getUserInfoByUserId($this->ctx['hzBrokerId']); // 身份是否通过 $this->ctx['isPassVerify'] = $brokerInfo && Bll_Broker_HzBroker::isPassVerify($brokerInfo['profileVerify']); //if (!$isPassVerify) // $this->redirect2Result(Const_PublishCode::NOT_PASS_VERIFY, $this->site, $this->action, $this->ctx['proId']); // 获取账户余额 $balance = Bll_Broker_HzBroker::getAccountInfo($this->ctx['ajkBrokerId'], 'balance'); $this->ctx['validMoney'] = $balance && $balance['msg'] ? round($balance['msg'] / 100, 2) : 0; //if (!$validMoney) // $this->redirect2Result(Const_PublishCode::NOT_MONEY, $this->site, $this->action, $this->ctx['proId']); // ppc推广 $spreadResult = Bll_Plan_Fix_HzFix::addPropToPlan($this->ctx['planId'], $this->ctx['proId'], $this->ctx['cityId'], $this->ctx['ajkBrokerId']); } // 推广出错 if ($spreadResult['status'] <= 0) { $this->redirect2Result(Const_PublishCode::SPREAD_PROP_HANDLE_STOP, $this->site, $this->action, $this->ctx['proId'], $spreadResult['msg']); } } //++++++ others actions // 委托 if (isset($this->ctx['isCommission']) && $this->ctx['isCommission']) { // 房源发布成功,回写委托信息 if ($this->ctx['commission'] && $this->ctx['proId']) { Bll_House_HzHouse::updateCommission($this->ctx['commissionId'], $this->ctx['proId']); } } }
/** * 删除计划 * @return array */ public function do_deletePlan() { return Bll_Plan_Fix_HzFix::deletePlan($this->params['planId'], $this->cityId, $this->brokerId); }
/** * 公共计划非空判断 * @throws Exception_BllErrorException */ private function checkPlanIsEmpty() { $planInfo = Bll_Plan_Fix_HzFix::getPlan($this->params['plan_id']); if (!$planInfo['status']) { throw new Exception_BllErrorException($planInfo['msg']); } return $planInfo['msg']; }
/** * 根据经纪人获取有效计划 * @param $hzBrokerId * @return array */ public static function getValidPlansByBrokerId($hzBrokerId) { return Model_Plan_HzPlanBasic::getPlanByCondition($hzBrokerId, array('plan_type' => Const_HzPlan::SPREAD_TYPE, 'status' => Bll_Plan_Fix_HzFix::getValidStatus())); }
/** * 获取经纪人的发房房源houstIds * @param $ctx * @return array */ public static function getSpreadProIds($ctx) { $spreadProIds = array(); // ppc if ($ctx['isFixCity']) { $plannings = Bll_Plan_Fix_HzFix::getValidPlannings($ctx['hzBrokerId']); if ($plannings) { foreach ($plannings as $planning) { $spreadProIds[] = $planning->proid; } } } else { // 新套餐 $spreadHouses = Bll_Combo_HouseRelation::getHouseRelations($ctx['ajkBrokerId'], Bll_Combo_HouseRelation::SITE_TYPE_HZ, 1); if ($spreadHouses) { foreach ($spreadHouses as $spreadHouse) { $spreadProIds[] = $spreadHouse['houseId']; } } } return $spreadProIds; }
/** * 组装定价列表 * @param $out * @return array * @throws Exception */ private static function prepareFixList(&$out) { $fixList = array(); $out['planId'] = 0; $out['props'] = array(); $out['fixPropIds'] = array(); // 获取房源关系列表 $brokerProps = Bll_Broker_HzBroker::getBrokerProps($out['ajkBrokerId'], $out['cityId']); if (!$brokerProps['status']) { throw new Exception($brokerProps['msg']); } $brokerProps = $brokerProps['msg']; $plans = $brokerProps['plans']; $plannings = $brokerProps['plannings']; $propsTemp = $brokerProps['props']; if (empty($plans)) { // 没有有效计划 初始化一个 Bll_Plan_Fix_HzFix::createPlan($out['ajkBrokerId'], $out['cityId'], '定价推广组'); return $fixList; } $planIds = array(); foreach ($plans as $plan) { $planIds[] = $plan['planId']; } // 转换成proid下标方便索引 if (count($propsTemp) > 0) { foreach ($propsTemp as $prop) { $out['props'][$prop['proId']] = $prop; } } // 获取计划的消费 点击信息 $responseConsumClickInfos = Bll_Plan_Fix_HzFix::getPlanConsumClickInfo($planIds, $out['cityId'], $out['ajkBrokerId']); if (!$responseConsumClickInfos['status']) { throw new Exception($responseConsumClickInfos['msg']); } $responseConsumClickInfos = $responseConsumClickInfos['msg']; // 分组 $temProps = array(); foreach ($plans as $plan) { $planId = $plan['planId']; $fixList[$planId] = $plan; // 组装计划的消费 点击量信息 foreach ($responseConsumClickInfos[$planId] as $field => $value) { $fixList[$planId][$field] = $value; } // 非在线 获取停止信息 if ($plan['status'] != 1) { $fixList[$planId]['stopInfo'] = Bll_Plan_Fix_HzFix::getStopInfoByStatus($plan['status'], $out['isPassVerify']); } if (empty($plannings)) { $fixList[$planId]['plannings'] = array(); continue; } // 关系需要按照推广时间最新排在前面 usort($plannings, function ($a, $b) { return strtotime($a['lastUpdated']) > strtotime($b['lastUpdated']) ? -1 : 1; }); foreach ($plannings as $k => $planning) { $proId = $planning['proId']; // 非有效 过滤掉 if (!Bll_HzFixPlan::isValidPlanning($planning['isValid'])) { unset($out['props'][$proId]); continue; } if ($planning['planId'] != $planId) { continue; } // 组装关系 $fixList[$planId]['plannings'][$k] = $planning; // 组装房子 $fixList[$planId]['plannings'][$k]['prop'] = isset($out['props'][$proId]) ? $out['props'][$proId] : array(); // 获取剩余时间 $fixList[$planId]['plannings'][$k]['prop']['leftDays'] = Bll_House_HzHouse::getLeftDays($out['props'][$proId]['created']); $out['fixPropIds'][$proId] = $proId; $temProps[] = $fixList[$planId]['plannings'][$k]['prop']; } $out['planId'] = $planId; } // 获取定价房子可否精选状态 if ($out['isChoiceCity']) { $out['propChoiceStatus'] = Bll_HzProp::getPropChoiceStatus($temProps, $out['cityId']); } return $fixList; }