public function handle_request_internal() { //$stime=microtime(true); $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $params = $this->request->get_parameters(); $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; // TODO 替换为其他的方式 $result = array('status' => 0, 'data' => array(), 'errorMsg' => ""); // 必须使用POST请求 if (!$this->request->is_post_method()) { $result['errorMsg'] = "请使用POST请求。"; } $houseId = $params['id']; $brokerName = self::$BrokerInfo['BaseInfo']['TRUENAME']; $brokerPhone = self::$BrokerInfo['BaseInfo']['USERMOBILE']; $cityId = self::$BrokerInfo['BaseInfo']['CITYID']; /* if($cityId == 11){ APF::get_instance()->get_response()->redirect('/ajkbroker/commissions/mysale'); return false; } */ $isComboCity = Bll_Combo_HouseRelation::ifComboCity($cityId); $saleRushResult = Bll_Broker_EntrustQuery::getInstance()->saleRush($houseId, $brokerId, $brokerName, $brokerPhone, $cityId, Const_Entrust::RUSH_FROM_PC, true, $isComboCity); $result = array('status' => $saleRushResult['status'], 'data' => $saleRushResult['data'], 'errorMsg' => $saleRushResult['errorMsg']); echo json_encode($result); exit; /* $etime=microtime(true);//获取程序执行结束的时间 $total=$etime-$stime; //计算差值 echo "<br />{$total} times";*/ }
public function handle_request_internal() { $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $this->params = $this->request->get_parameters(); $act = trim($this->params['act']); $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; $cityId = self::$BrokerInfo['BaseInfo']['CITYID']; /* if($cityId == 11){ APF::get_instance()->get_response()->redirect('/ajkbroker/commissions/mysale'); return false; } */ switch ($act) { case 'checkConsume': $this->checkConsume($brokerId, $cityId); break; default: echo json_encode("非法请求"); exit; break; } }
private function initEnv() { $this->objAPF = $objAPF = APF::get_instance(); $this->request = $this->objAPF->get_request(); $this->params = $this->request->get_parameters(); $this->brokerId = $this->request->getBrokerId(); $this->cityId = $this->request->getBrokerCityId(); //设置租房、金铺的经纪人id $MainBusiness = Model_Broker_MainBusiness::getMainBusinessByAjkBrokerId($this->brokerId, false); $this->hzBrokerId = $MainBusiness['hzBrokerid']; $this->jpBrokerId = $MainBusiness['jpBrokerid']; $this->debug = isset($_GET['debug']) ? true : false; }
public function handle_request_internal() { if (!Bll_City::isShowCaseCity(static::$intBrokerCityID)) { $this->outData(array(), 0); exit; } $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $this->params = $this->request->get_parameters(); $this->brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; $this->userId = self::$BrokerInfo['BaseInfo']['USERID']; $this->getBrokerMoney(); }
public function handle_request_internal() { $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $params = $this->request->get_parameters(); $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; // TODO 替换为其他的方式 try { // 必须使用POST请求 if (!$this->request->is_post_method()) { throw new Exception('请使用POST请求。'); } // 判断委托ID $id = isset($params['id']) & intval($params['id']) > 0 ? intval($params['id']) : 0; if ($id <= 0) { throw new Exception('非法的委托编号。'); } // 判断委托是否存在 $commission = Model_House_Commission::data_access()->filter('id', $id)->find_only(); if (!$commission) { throw new Exception('委托不存在。'); } // 确认委托的经纪人和当前经纪人是同一人 if ($commission->brokerId != $brokerId) { throw new Exception('非法的委托编号。'); } // 删除委托 $commission->isDelete = Model_House_Commission::DELETE_YES; $commission->deleteTime = date('Y-m-d H:i:s'); $commission->save(); // 如果是出售,记录到commission_sale_log日志表 if (Model_House_CommissionHouse::COMMISSION_TYPE_SALE == $commission->type) { $this->insertCommissionSaleLog($commission); } // 返回结果 $result = array('code' => 0, 'message' => 'Delete successfully.'); } catch (Exception $e) { $result = array('code' => $e->getCode() ? $e->getCode() : 1, 'message' => $e->getMessage()); } $this->response->add_header('Content-type', 'application/json'); // $response->add_header(); // todo no cache echo json_encode($result); die; }
public function handle_request_internal() { $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $params = $this->request->get_parameters(); $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; // TODO 替换为其他的方式 try { // 必须使用POST请求 if (!$this->request->is_post_method()) { throw new Exception('请使用POST请求。'); } // 判断委托ID $id = isset($params['id']) & intval($params['id']) > 0 ? intval($params['id']) : 0; if ($id <= 0) { throw new Exception('非法的委托编号。'); } // 判断委托是否存在 $commission = Model_House_Commission::data_access()->filter('id', $id)->find_only(); if (!$commission) { throw new Exception('委托不存在。'); } // 确认委托的经纪人和当前经纪人是同一人 if ($commission->brokerId != $brokerId) { throw new Exception('非法的委托编号。'); } // 获取委托房源信息 $house = Model_House_CommissionHouse::data_access()->filter('id', $commission->houseId)->find_only(); if (!$house) { throw new Exception('房源不存在'); } // 返回结果 $result = array('code' => 0, 'data' => array('phone' => $house->getPhone())); } catch (Exception $e) { $result = array('code' => $e->getCode() ? $e->getCode() : 1, 'message' => $e->getMessage()); } $this->response->add_header('Content-type', 'application/json'); // $response->add_header(); // todo no cache echo json_encode($result); die; }
public function handle_request_internal() { $type = "sale"; $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $baseDomain = APF::get_instance()->get_config('base_domain', 'common'); $baseUri = defined('BASE_URI') ? BASE_URI : ''; $baseUrl = "http://my.{$baseDomain}"; $commissionsPageUrl = "http://my.{$baseDomain}{$baseUri}/commissions"; $myCommissionsPageUrl = "http://my.{$baseDomain}{$baseUri}/commissions/mysale"; $myRentCommissionsPageUrl = "http://my.{$baseDomain}{$baseUri}/commissions/my"; $cityId = $this->request->getBrokerCityId(); if ($cityId == 11) { $this->request->set_attribute('propCheck', 0); } else { $this->request->set_attribute('propCheck', 1); } $params = $this->request->get_parameters(); $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; // TODO 替换为其他的方式 $per = 10; $page = isset($params[Const_Listing::PARAM_N_PAGE]) && intval($params[Const_Listing::PARAM_N_PAGE]) > 0 ? intval($params[Const_Listing::PARAM_N_PAGE]) : 1; // 获取经纪人的委托 $daCommissions = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('type', 1)->filter('isDelete', Model_House_Commission::DELETE_NO); $daTotal = clone $daCommissions; $commissions = $daCommissions->limit($per)->offset(($page - 1) * $per)->sort('id', 'desc')->find_all(); // 获取委托关联的房源 if (!empty($commissions)) { $houseIds = array(); $brokerHouseIds = array(); foreach ($commissions as $commission) { $houseIds[] = $commission->houseId; if (!empty($commission->brokerHouseId)) { $brokerHouseIds[] = $commission->brokerHouseId; } } $houses = Model_House_CommissionHouse::data_access()->filter('id', $houseIds)->sort('id', 'asc')->find_all(); $this->request->set_attribute('houses', $houses); // 获取小区默认图片 和 区域板块名称 $communityIds = array(); $areaCodes = array(); foreach ($houses as $house) { $communityIds[] = $house->commId; $areaCodes[] = $house->areaCode; } // 房东房源图片 $propImageUrls = Bll_Image_UtilsImage::getCommissionProImage($houseIds); $this->request->set_attribute('propImageUrls', $propImageUrls); // 小区默认图片 $communityImageUrls = $this->getCommunityImageUrls($communityIds); $this->request->set_attribute('communityImageUrls', $communityImageUrls); // 区域板块 $areaCodesNames = $this->getAreaCodeNames($areaCodes); $this->request->set_attribute('areaCodeNames', $areaCodesNames); // 是否推广数据 $staticPro = Bll_House_EsfHouse::getHouseOnLineInfo(self::$BrokerInfo['BaseInfo']['CITYID'], $brokerId, $brokerHouseIds); if (!empty($brokerHouseIds)) { $publishedProInfo = Bll_House_EsfHouse::getHouseInfo($brokerHouseIds, self::$BrokerInfo['BaseInfo']['CITYID']); } // 分页 $total = $daTotal->count(); $pager = Util_MultiPage::multiPage($params, '', $total, $per, 10, $myCommissionsPageUrl); $this->request->set_attribute('page', $page); $this->request->set_attribute('pager', $pager); $this->request->set_attribute('showPager', $total > $per); } $proSpreadUrl1 = "http://my." . $baseDomain . "/user/ajax/ppclimit"; $proSpreadUrl2 = "http://my." . $baseDomain . "/user/ajax/sale/staticplan/"; // 立即推广地址 $isCombo = Bll_Combo_HouseRelation::ifComboCity(self::$BrokerInfo['BaseInfo']['CITYID']); if ($isCombo == true) { $tgUrl = $baseUrl . "/ajkbroker/combo/broker/manage/ajk"; } else { $tgUrl = $baseUrl . "/user/broker/sale/homepage"; } $this->request->set_attribute('commissions', $commissions); $this->request->set_attribute('commissionsPageUrl', $commissionsPageUrl); $this->request->set_attribute('myCommissionsPageUrl', $myCommissionsPageUrl); $this->request->set_attribute('type', $type); $this->request->set_attribute('staticPro', $staticPro); $this->request->set_attribute('publishedProInfo', $publishedProInfo); $this->request->set_attribute('myRentCommissionsPageUrl', $myRentCommissionsPageUrl); $this->request->set_attribute('proSpreadUrl1', $proSpreadUrl1); $this->request->set_attribute('proSpreadUrl2', $proSpreadUrl2); $this->request->set_attribute('baseUrl', $baseUrl); $this->request->set_attribute('tgUrl', $tgUrl); return 'House_Commission_MySale'; }
public function handlePost() { $this->request = APF::get_instance()->get_request(); $brokerId = $this->request->getBrokerId(); $cityId = $this->request->getBrokerCityId(); $params = $this->request->get_parameters(); $params['broker_id'] = $brokerId; $result = array(); try { if ($this->action == 'edit') { $houseInfo = Bll_House_EsfEdit::getHouseBaseInfo($this->houseId); /** 违规房源不可以编辑 */ if (isset($houseInfo['isIllegal']) && $houseInfo['isIllegal']) { $this->redirect2Result(Const_PublishCode::UNKNOWN_ERROR, 'ajk', 'edit', $this->houseId, '已违规房源不可编辑'); } $result = Bll_House_EsfEdit::saveHouseInfo($brokerId, $cityId, $this->houseId, $params); } if ($this->action == 'publish') { $result = Bll_House_EsfPublish::saveHouseInfo($brokerId, $params, $this->isComboBroker); if ($result['status'] == 'ok') { $this->houseId = $result['houseId']; } } /** 委托房源发布 */ if ($this->action == 'commission') { $result = Bll_House_EsfCommission::saveHouseInfo($brokerId, $cityId, $this->commissionId, $params, $this->isComboBroker); if ($result['status'] == 'ok') { $this->houseId = $result['houseId']; } } if ($result['status'] != 'ok') { $this->redirect2Result(Const_PublishCode::PUBLISH_PROP_ERROR, 'ajk', $this->action, $this->houseId, $result['info']); } } catch (Exception $e) { $params['brokerId'] = self::$intBrokerID; APF::get_instance()->get_nlogger()->log(__CLASS__, $params); $this->redirect2Result(Const_PublishCode::PUBLISH_PROP_ERROR, 'ajk', $this->action, $this->houseId, $e->getMessage()); } /** 立即推广 */ if (isset($params['broker_action']) && $params['broker_action'] == 'publish') { /** 套餐推广 */ if ($this->isComboBroker) { $spreadResult = Bll_Combo_HouseRelation::houseStartComboSpreadV2($brokerId, $cityId, array($this->houseId), Bll_Combo_HouseRelation::SITE_TYPE_AJK); if ($spreadResult['status'] != 1) { switch ($spreadResult['status']) { /** 没有套餐 */ case -1: case -2: $this->redirect2Result(Const_PublishCode::SPREAD_PROP_NO_COMBO, 'ajk', $this->action, $this->houseId, $spreadResult['msg']); break; /** 套餐未生效 */ /** 套餐未生效 */ case -3: $this->redirect2Result(Const_PublishCode::SPREAD_PROP_COMBO_ACTIVE, 'ajk', $this->action, $this->houseId, $spreadResult['msg']); break; /** 推广房源数已满 */ /** 推广房源数已满 */ case -4: case -5: $this->redirect2Result(Const_PublishCode::SPREAD_PROP_COMBO_LIMIT, 'ajk', $this->action, $this->houseId, $spreadResult['msg']); break; default: $this->redirect2Result(Const_PublishCode::SPREAD_PROP_COMBO_FAIL, 'ajk', $this->action, $this->houseId, $spreadResult['msg']); } } } else { /** 定价推广 */ if ($this->action == 'edit') { /** 定价推广失败 房源已经推广 */ if (BLL_Plan_EsfPropFixedPlanRelation::isHouseOnline($cityId, $this->houseId)) { $this->redirect2Result(Const_PublishCode::SPREAD_PROP_PLAN_IN, 'ajk', $this->action, $this->houseId, '房源已经推广'); } } $fixPlanList = BLL_Plan_EsfPropFixedPlanRelation::getBrokerValidPlan($brokerId); if (empty($fixPlanList)) { $this->redirect2Result(Const_PublishCode::UNKNOWN_ERROR, 'ajk', $this->action, $this->houseId, '获取定价计划信息失败'); } $fixPlan = $fixPlanList[0]; /** 定价推广失败 已经超出推广房源上限 */ if (!Bll_Broker_HzBroker::ajkPpcBrokerCanSpreadHouse($cityId, $brokerId)) { $this->redirect2Result(Const_PublishCode::SPREAD_PROP_OUT_LIMIT, 'ajk', $this->action, $this->houseId, '已经超出推广房源上限'); } $spreadResult = Bll_Ppc_ServiceAPI::fixPlanAddHouse($brokerId, $this->houseId, $fixPlan['id'], '23532'); if (isset($spreadResult['status'])) { if ($spreadResult['status'] != 'ok') { $this->redirect2Result(Const_PublishCode::API_ERROR, 'ajk', $this->action, $this->houseId, $spreadResult['info']); } } else { $this->redirect2Result(Const_PublishCode::API_ERROR, 'ajk', $this->action, $this->houseId, '系统繁忙(推广房源超时)'); } /** 定价推广失败 计划已经手动停止 */ if ($fixPlan['viewTime'] == 1861891200) { /** 定价推广失败 认证未通过 */ $brokerCheckState = Bll_Broker_BrokerCheckInfo::getCheckStateByBrokerId($brokerId); if ($brokerCheckState != 1) { $this->redirect2Result(Const_PublishCode::SPREAD_PROP_AUDITED_ERROR, 'ajk', $this->action, $this->houseId, '认证未通过'); } $this->redirect2Result(Const_PublishCode::SPREAD_PROP_HANDLE_STOP, 'ajk', $this->action, $this->houseId, '计划已经手动停止'); } /** 定价推广失败 账户余额不足,充值后自动推广 */ if ($fixPlan['viewTime'] == 1893427200) { $this->redirect2Result(Const_PublishCode::SPREAD_PROP_BALANCE_ERROR, 'ajk', $this->action, $this->houseId, '账户余额不足,充值后自动推广'); } } /** 推广成功 */ $this->redirect2Result(Const_PublishCode::HOUSE_SPREAD_SUCCESS, 'ajk', $this->action, $this->houseId); } /** 发布成功 */ $this->redirect2Result(Const_PublishCode::HOUSE_SAVE_SUCCESS, 'ajk', $this->action, $this->houseId); }
public function handle_request_internal() { $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $baseDomain = APF::get_instance()->get_config('base_domain', 'common'); $baseUri = defined('BASE_URI') ? BASE_URI : ''; $pageUrl = "http://my.{$baseDomain}{$baseUri}/commissions"; /* * 1.参数获取 */ $params = $this->request->get_parameters(); $type = isset($params['type']) && in_array($params['type'], array('rent', 'sale')) ? $params['type'] : ''; // 房源类型:不限、出粗、出售 // $room = (isset($params['room']) && in_array($params['room'], array('1', '2', '3', '4'))) ? $params['room'] : ''; // 房源房型:不限、一室、二室、三室、三室以上 //$areaId = (isset($params['area']) && is_numeric($params['area'])) ? intval($params['area']) : 0; // 房源区域:主版块 //$subAreaId = ($areaId && isset($params['subArea']) && is_numeric($params['subArea'])) ? intval($params['subArea']) : 0; // 房源区域:子版块 $cityId = $this->request->getBrokerCityId(); //如果是审核直接跳到我得房源库 /* if($cityId == 11){ APF::get_instance()->get_response()->redirect($pageUrl.'/mysale'); return false; } */ $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; // TODO 替换为其他的方式 $per = 10; $page = isset($params[Const_Listing::PARAM_N_PAGE]) && intval($params[Const_Listing::PARAM_N_PAGE]) > 0 ? intval($params[Const_Listing::PARAM_N_PAGE]) : 1; /* * 2.获取经纪人主营板块下的所有委托房源(按照创建时间排序) */ $rushedHouses = array(); $daHouse = Model_House_CommissionHouse::data_access()->filter('cityId', $cityId)->filter('proStatus', Model_House_CommissionHouse::STATUS_ONGOING)->filter_by_op('openBrokerCnt', '<', Model_House_CommissionHouse::allowedMaxCommissionCount()); // 房源区域 /*$areas = $this->getCityAreas($cityId); $subAreas = array(); if ($areaId) { $subAreas = $this->getSubAreas($areaId); if ($subAreas) { $subAreaIds = array(); $subAreaCodes = array(); foreach ($subAreas as $subArea) { $subAreaIds[$subArea->typeId] = $subArea->typeId; $subAreaCodes[$subArea->typeId] = $subArea->typeCode; } if ($subAreaId && isset($subAreaCodes[$subAreaId])) { $daHouse->filter('areaCode', $subAreaCodes[$subAreaId]); } else { $daHouse->filter('areaCode', $subAreaCodes); } } else { $daHouse->filter('areaCode', 0); } } */ // 房源类型 if ($type) { switch ($type) { case 'rent': $daHouse->filter('commissionType', Model_House_CommissionHouse::COMMISSION_TYPE_RENT); break; case 'sale': $daHouse->filter('commissionType', Model_House_CommissionHouse::COMMISSION_TYPE_SALE); break; } } /* // 房源房型 if ($room) { switch ($room) { case '1': case '2': case '3': $daHouse->filter('roomNum', $room); break; case '4': $daHouse->filter_by_op('roomNum', '>=', $room); break; } } */ // 获取经纪人的区域id $brokerAreaCode = $this->getBrokerAreaCode(self::$BrokerInfo['BaseInfo']); if (!empty($brokerAreaCode)) { $daHouse->filter_by_op('areaCode', 'like', "{$brokerAreaCode}%"); } else { $daHouse->filter('id', 0); // 没有区域id,则不显示数据 } // 获取满足条件的总量 $daTotal = clone $daHouse; $total = $daTotal->count(); // 分页 $pager = Util_MultiPage::multiPage($params, '', $total, $per, 10, $pageUrl); $this->request->set_attribute('page', $page); $this->request->set_attribute('pager', $pager); $this->request->set_attribute('showPager', $total > $per); // 当前页面的个人房源 $houses = $daHouse->limit($per)->offset(($page - 1) * $per)->sort('created', 'desc')->find_all(); //print_r($daHouse->get_last_sql()); $overHouses = $this->getHasOverHouses($cityId); // 获取小区默认图片 和 区域板块名称 $houseIds = array(); $communityIds = array(); $areaCodes = array(); foreach ($houses as $house) { $houseIds[] = $house->id; $communityIds[] = $house->commId; $areaCodes[] = $house->areaCode; } // 判断已经抢完的数据是否存在 if (!empty($overHouses)) { foreach ($overHouses as $house) { $houseIds[] = $house->id; $communityIds[] = $house->commId; $areaCodes[] = $house->areaCode; } } // 房东房源图片 $propImageUrls = Bll_Image_UtilsImage::getCommissionProImage($houseIds); $this->request->set_attribute('propImageUrls', $propImageUrls); // 小区默认图片 $communityImageUrls = $this->getCommunityImageUrls($communityIds); $this->request->set_attribute('communityImageUrls', $communityImageUrls); // 区域板块 $areaCodesNames = $this->getAreaCodeNames($areaCodes); $this->request->set_attribute('areaCodeNames', $areaCodesNames); // 获取当前经纪人房源委托情况,如果已经委托,提示已委托 if ($houseIds) { $rushedCommissions = Model_House_Commission::data_access()->filter('houseId', $houseIds)->filter('brokerId', $brokerId)->find_all(); $rushedHouses = array(); foreach ($rushedCommissions as $rushedCommission) { $rushedHouses[$rushedCommission->houseId] = $rushedCommission->id; } } $rechargeUrl = "http://my.{$baseDomain}/user/broker/hpsupplement"; $isCombo = Bll_Combo_HouseRelation::ifComboCity(self::$BrokerInfo['BaseInfo']['CITYID']); if ($isCombo == ture) { // 获取经纪人套餐房源数 $conbosProNum = Bll_Combo_Broker_BrokerComboInfo::getTotalCombosProNum($brokerId); $this->request->set_attribute('conbosProNum', $conbosProNum); } $this->request->set_attribute('isCombo', $isCombo); $this->request->set_attribute('type', $type); //$this->request->set_attribute('room', $room); //$this->request->set_attribute('area', $areaId); //$this->request->set_attribute('subArea', $subAreaId); //$this->request->set_attribute('areas', $areas); //$this->request->set_attribute('subAreas', $subAreas); $this->request->set_attribute('pageUrl', $pageUrl); $this->request->set_attribute('houses', $houses); $this->request->set_attribute('rushedHouses', $rushedHouses); $this->request->set_attribute('overHouses', $overHouses); $this->request->set_attribute('rechargeUrl', $rechargeUrl); return 'House_Commission_All'; }
public function handle_request_internal() { $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $params = $this->request->get_parameters(); $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; // TODO 替换为其他的方式 $cityId = self::$BrokerInfo['BaseInfo']['CITYID']; try { // 必须使用POST请求 if (!$this->request->is_post_method()) { throw new Exception('请使用POST请求。'); } /* if($cityId == 11){ APF::get_instance()->get_response()->redirect('/ajkbroker/commissions/my'); return false; } */ // 判断是否套餐城市 $isComboCity = Bll_Combo_HouseRelation::ifComboCity($cityId); if ($isComboCity == true) { // 判断经纪人是否购买了租房套餐 $conbosProNum = Bll_Combo_Broker_BrokerComboInfo::getTotalCombosProNum($brokerId); if ($conbosProNum['totalRentPropNum'] <= 0) { $isPlan = 0; throw new Exception('经纪人无租房套餐。'); } else { $isPlan = 1; } } else { $isPlan = 1; } // 判断房源ID $id = isset($params['id']) & intval($params['id']) > 0 ? intval($params['id']) : 0; if ($id <= 0) { throw new Exception('无效的房源编号。'); } // 判断委托房源是否存在 $house = Model_House_CommissionHouse::data_access()->filter('id', $id)->find_only(); if (!$house) { throw new Exception('房源不可委托:房源不存在或已被业主删除。'); } // 判断类型是否是出租 if ($house->commissionType != Model_House_CommissionHouse::COMMISSION_TYPE_RENT) { throw new Exception('房源类型不是出租'); } // 判断委托房源状态 if ($house->proStatus != Model_House_CommissionHouse::STATUS_ONGOING) { throw new Exception('房源不可委托:已过期或已被删除。'); } // 判断委托房源已委托数量 if ($house->openBrokerCnt >= Model_House_CommissionHouse::allowedMaxCommissionCount()) { throw new Exception('委托已满。', 37); } // 判断是否已抢过委托 $commission = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('houseId', $house->id)->find_only(); if ($commission) { throw new Exception('你已经委托了该房源。', 77); } // 防并发(先插入,再检测(超出,删除),最后更新) // TODO 该方案层使用在2013圣诞活动“找锤子,砸金蛋”,并导致数据库多次TMC,但是在该业务场景中瞬时并发并没有那么多,暂定使用 by 胡言言 2014.02.28 $commission = Model_House_Commission::create(array('type' => $house->commissionType, 'ownerId' => $house->userId, 'houseId' => $house->id, 'brokerId' => $brokerId, 'createTime' => date('Y-m-d H:i:s'), 'updateTime' => date('Y-m-d H:i:s'))); $commission->save(); $rank = Model_House_Commission::data_access()->filter_by_op('houseId', '=', $house->id)->filter_by_op('id', '<=', $commission->id)->sort('id', 'asc')->count(); if ($rank > Model_House_CommissionHouse::allowedMaxCommissionCount()) { $commission->delete(); throw new Exception('委托已满。', 37); } // 更新房源的委托数量 $house->incrCommissionCount(); // 更新推送房源状态 $pushedHouse = Model_House_CommissionHousePushed::data_access()->filter('brokerId', $brokerId)->filter('propertyId', $house->id)->find_only(); if ($pushedHouse) { $pushedHouse->propertyStatus = Model_House_CommissionHousePushed::STATUS_RUSHED; $pushedHouse->save(); } // 拼装返回数据 $result = array('isPlan' => $isPlan, 'code' => 0, 'data' => array('owner' => $house->userName, 'phone' => $house->getPhone(), 'title' => '', 'summary' => '')); $area = '[' . implode('-', $house->getAreaCodeNames()) . '] '; $houseModel = "{$house->roomNum}室{$house->hallNum}厅{$house->toiletNum}卫,{$house->areaNum}平方米,"; switch ($house->commissionType) { case Model_House_CommissionHouse::COMMISSION_TYPE_SALE: // 记录到commission_sale_log日志表 $this->insertCommissionSaleLog($house, $brokerId); $result['data']['title'] = '[出售] ' . $house->commName; $result['data']['summary'] = $area . $houseModel . $house->proPrice . '万元'; break; case Model_House_CommissionHouse::COMMISSION_TYPE_RENT: $result['data']['title'] = '[出租] ' . $house->commName; $result['data']['summary'] = $area . $houseModel . $house->proPrice . '元/月'; break; } } catch (Exception $e) { $result = array('code' => $e->getCode() ? $e->getCode() : 1, 'message' => $e->getMessage(), 'isPlan' => $isPlan); } $baseDomain = APF::get_instance()->get_config('base_domain', 'common'); $baseUri = defined('BASE_URI') ? BASE_URI : ''; $result['data']['manageUrl'] = "http://my.{$baseDomain}{$baseUri}/commissions/my"; $this->response->add_header('Content-type', 'application/json'); echo json_encode($result); die; }
/** * @param User_Statistics_BrokerStatisticsController $controller * @param AJKRequest $request * @param AJKResponse $response * * @return array */ public static function getBrokerStatistics($controller, $request, $response) { $brokerId = $request->getBrokerId(); $cityId = $request->getBrokerCityId(); $params = $request->get_parameters(); $pageParams = static::setSearchDay($params); $isChoiceCity = Bll_City::isChoiceCity($cityId); $isBidCity = Bll_City::isChoiceCity($cityId); $isShowCaseCity = Bll_City::isShowCaseCity($cityId); $pageParams['isChoiceCity'] = $isChoiceCity; $pageParams['isBidCity'] = $isBidCity; $pageParams['isShowCaseCity'] = $isShowCaseCity; $startDate = date('Ymd', $pageParams['beginDateUnix']); $endDate = date('Ymd', $pageParams['endDateUnix']); if ($startDate > $endDate) { return $pageParams; } /** 非精选城市 */ if ($isBidCity) { $pageParams['bidMessage'] = '竞价'; } if ($isChoiceCity) { $pageParams['bidMessage'] = '精选'; } $tempBrokerStatisticsInfoList = Model_Broker_AjkComboBrokerDay::getBrokerStatistics($brokerId, $startDate, $endDate); if (empty($tempBrokerStatisticsInfoList)) { return $pageParams; } $total = array('TotalPropNum' => 0, 'TotalClickNum' => 0, 'TotalAmount' => 0, 'saleProp' => 0, 'saleGoodProp' => 0, 'saleNewProp' => 0, 'saleNewGoodProp' => 0, 'saleVppv' => 0, 'saleBidProp' => 0, 'saleBidGoodProp' => 0, 'saleBidNewProp' => 0, 'saleBidNewGoodProp' => 0, 'saleBidCost' => 0, 'saleBidVppv' => 0); $dateList = static::getDateList($pageParams['beginDateUnix'], $pageParams['endDateUnix']); if ($isShowCaseCity) { $adPriceInfo = static::getBrokerPriceInfo($brokerId, $startDate, $endDate); $adClickInfo = static::getBrokerAdClickInfo($brokerId, $startDate, $endDate); } $brokerStatisticsInfoList = array(); foreach ($dateList as $key => $date) { $brokerStatisticsInfoList[$key] = array('_DayDate' => $date); } foreach ($tempBrokerStatisticsInfoList as $brokerStatisticsInfo) { $date = $brokerStatisticsInfo['dayDate']; $brokerStatisticsInfo['_DayDate'] = $dateList[$date]; $brokerStatisticsInfo['TotalPropNum'] = $brokerStatisticsInfo['saleProp']; $brokerStatisticsInfo['TotalClickNum'] = $brokerStatisticsInfo['saleVppv']; $brokerStatisticsInfo['TotalAmount'] = $brokerStatisticsInfo['saleBidCost']; if ($isBidCity || $isChoiceCity) { $brokerStatisticsInfo['TotalPropNum'] += $brokerStatisticsInfo['saleBidProp']; $brokerStatisticsInfo['TotalClickNum'] += $brokerStatisticsInfo['saleBidVppv']; } /** * 总计 */ $total['TotalPropNum'] += $brokerStatisticsInfo['TotalPropNum']; $total['TotalClickNum'] += $brokerStatisticsInfo['TotalClickNum']; $total['TotalAmount'] += $brokerStatisticsInfo['TotalAmount']; $total['saleProp'] += $brokerStatisticsInfo['saleProp']; $total['saleGoodProp'] += $brokerStatisticsInfo['saleGoodProp']; $total['saleNewProp'] += $brokerStatisticsInfo['saleNewProp']; $total['saleNewGoodProp'] += $brokerStatisticsInfo['saleNewGoodProp']; $total['saleVppv'] += $brokerStatisticsInfo['saleVppv']; if ($isBidCity || $isChoiceCity) { $total['saleBidProp'] += $brokerStatisticsInfo['saleBidProp']; $total['saleBidVppv'] += $brokerStatisticsInfo['saleBidVppv']; $total['saleBidCost'] += $brokerStatisticsInfo['saleBidCost']; $total['saleBidNewProp'] += $brokerStatisticsInfo['saleBidNewProp']; $total['saleBidGoodProp'] += $brokerStatisticsInfo['saleBidGoodProp']; $total['saleBidNewGoodProp'] += $brokerStatisticsInfo['saleBidNewGoodProp']; } /** * 橱窗 */ if ($isShowCaseCity) { $brokerStatisticsInfo['props_sum'] = $adPriceInfo[$date]['propsSum']; $brokerStatisticsInfo['quantity_count'] = $adClickInfo[$date]['quantity_count']; $brokerStatisticsInfo['price'] = $adPriceInfo[$date]['price']; $total['props_sum'] += $adPriceInfo[$date]['propsSum']; $total['quantity_count'] += $adClickInfo[$date]['quantity_count']; $total['price'] += $adPriceInfo[$date]['price']; } $brokerStatisticsInfoList[$date] = $brokerStatisticsInfo; } $BrokerWorkLogInfo = array('data' => array_reverse($brokerStatisticsInfoList), 'total' => $total); $pageParams['BrokerWorkLogInfo'] = $BrokerWorkLogInfo; return $pageParams; }
public function handle_request_internal() { $type = "rent"; $this->apf = APF::get_instance(); $this->request = $this->apf->get_request(); $this->response = $this->apf->get_response(); $baseDomain = APF::get_instance()->get_config('base_domain', 'common'); $baseUri = defined('BASE_URI') ? BASE_URI : ''; $pageUrl = "http://my.{$baseDomain}{$baseUri}/commissions/my"; $commissionsPageUrl = "http://my.{$baseDomain}{$baseUri}/commissions"; $myCommissionsPageUrl = "http://my.{$baseDomain}{$baseUri}/commissions/mysale"; $myRentCommissionsPageUrl = "http://my.{$baseDomain}{$baseUri}/commissions/my"; // *** *** *** *** *** *** *** $params = $this->request->get_parameters(); $brokerId = self::$BrokerInfo['BaseInfo']['BROKERID']; // TODO 替换为其他的方式 $per = 5; $page = isset($params[Const_Listing::PARAM_N_PAGE]) && intval($params[Const_Listing::PARAM_N_PAGE]) > 0 ? intval($params[Const_Listing::PARAM_N_PAGE]) : 1; $cityId = $this->request->getBrokerCityId(); if ($cityId == 11) { $this->request->set_attribute('propCheck', 0); } else { $this->request->set_attribute('propCheck', 1); } // 获取经纪人的所有委托 $daCommissions = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('type', 2)->filter('isDelete', Model_House_Commission::DELETE_NO); $daTotal = clone $daCommissions; $commissions = $daCommissions->limit($per)->offset(($page - 1) * $per)->sort('id', 'desc')->find_all(); // 获取委托关联的房源 if (!empty($commissions)) { $houseIds = array(); foreach ($commissions as $commission) { $houseIds[] = $commission->houseId; } $houses = Model_House_CommissionHouse::data_access()->filter('id', $houseIds)->sort('id', 'asc')->find_all(); $this->request->set_attribute('houses', $houses); // 获取小区默认图片 和 区域板块名称 $communityIds = array(); $areaCodes = array(); foreach ($houses as $house) { $communityIds[] = $house->commId; $areaCodes[] = $house->areaCode; } // 房东房源图片 $propImageUrls = Bll_Image_UtilsImage::getCommissionProImage($houseIds); $this->request->set_attribute('propImageUrls', $propImageUrls); // 小区默认图片 $communityImageUrls = $this->getCommunityImageUrls($communityIds); $this->request->set_attribute('communityImageUrls', $communityImageUrls); // 区域板块 $areaCodesNames = $this->getAreaCodeNames($areaCodes); $this->request->set_attribute('areaCodeNames', $areaCodesNames); // 分页 $total = $daTotal->count(); $pager = Util_MultiPage::multiPage($params, '', $total, $per, 5, $pageUrl); $this->request->set_attribute('page', $page); $this->request->set_attribute('pager', $pager); $this->request->set_attribute('showPager', $total > $per); } $this->request->set_attribute('commissions', $commissions); $this->request->set_attribute('commissionsPageUrl', $commissionsPageUrl); $this->request->set_attribute('myCommissionsPageUrl', $myCommissionsPageUrl); $this->request->set_attribute('type', $type); $this->request->set_attribute('myRentCommissionsPageUrl', $myRentCommissionsPageUrl); return 'House_Commission_My'; }