Ejemplo n.º 1
0
 /**
  * 更新e_commission表
  * @param $dataoh
  * add by xiongjianxu
  */
 private function _updataECommission($data)
 {
     $commissionInfo = Model_House_Commission::data_access()->filter('houseId', $data['houseId'])->filter('brokerId', $data['brokerId'])->find_only();
     if (!$commissionInfo) {
         return false;
     }
     switch ($data['status']) {
         case Model_House_CommissionSaleLog::STATUS_ROB:
             break;
         case Model_House_CommissionSaleLog::STATUS_PUBLISH:
             $commissionInfo->brokerHouseId = $data['brokerHouseId'];
             $commissionInfo->publishTime = date('Y-m-d h-i-s', $data['createTime']);
             break;
         case Model_House_CommissionSaleLog::STATUS_ALTER:
             break;
         case Model_House_CommissionSaleLog::STATUS_DELETE_HOUSE:
             $commissionInfo->deleteTime = date('Y-m-d h-i-s', $data['createTime']);
             break;
         case Model_House_CommissionSaleLog::STATUS_DELETE_RELATION:
             $commissionInfo->isDelete = Model_House_Commission::DELETE_YES;
             break;
         default:
     }
     return $commissionInfo->save();
 }
Ejemplo n.º 2
0
 /**
  * 查询房东信息
  * @param $proId
  * @param $brokerId
  * @return bool
  * add by xiongjianxu
  */
 private function getCommissionHouseInfo($proId, $brokerId)
 {
     $commissionInfo = Model_House_Commission::data_access()->filter('brokerHouseId', $proId)->filter('brokerId', $brokerId)->load_field('houseId')->find_only();
     if (!$commissionInfo) {
         return false;
     }
     $houseId = $commissionInfo->houseId;
     $houseInfo = Model_House_CommissionHouse::data_access()->filter('id', $houseId)->find_only();
     return $houseInfo;
 }
Ejemplo n.º 3
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $propertyId = $this->_params['propertyId'];
     $comeFrom = $this->_params['comeFrom'];
     //读取经纪人信息
     $BrokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId);
     //城市是否开通房源库
     $cityInfo = Bll_Fyk_Prop_Manage::getInstance()->getCityConfig($BrokerInfo['BaseInfo']['CITYID']);
     if ($cityInfo) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '已开通房源库,不可抢~', 'errcode' => Const_APIStatus::E_COMMISSION_INVALID);
     }
     //读取房源信息
     $houses = Model_House_CommissionHouse::getEntrustsPro($propertyId);
     $house = $houses[0];
     //获取委托房源关系
     $eEntrust = Model_House_Commission::getInfoByBrokerIdAndHouseId($brokerId, $propertyId, $house->commissionType);
     if ($house['commissionType'] == Model_House_CommissionHouse::COMMISSION_TYPE_SALE) {
         //是否收费
         $isToll = Bll_Broker_EntrustPrice::getInstance()->checkCityConsumeStatus($BrokerInfo['BaseInfo']['CITYID']);
         $isConsume = false;
         if ($isToll) {
             $isConsume = true;
         }
         $data = Bll_Broker_EntrustQuery::getInstance()->saleRush($propertyId, $brokerId, $BrokerInfo['BaseInfo']['TRUENAME'], $BrokerInfo['BaseInfo']['USERMOBILE'], $BrokerInfo['BaseInfo']['CITYID'], $comeFrom, $isConsume);
     } else {
         $isConsume = false;
         //租房免费
         $data = Bll_Broker_EntrustQuery::getInstance()->rentRush($propertyId, $brokerId, $BrokerInfo['BaseInfo']['TRUENAME'], $BrokerInfo['BaseInfo']['USERMOBILE'], $BrokerInfo['BaseInfo']['CITYID'], $comeFrom, $isConsume);
     }
     $ownerinfo = $this->formatdate($house, $eEntrust);
     if ($data['status'] == 1) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $ownerinfo, 'message' => '抢委托成功');
     } elseif ($data['status'] == 15) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '15天之内已抢房源中有3套未发,禁止经纪人继续抢房', 'errcode' => Const_APIStatus::E_COMMISSION_MAX);
     } elseif ($data['status'] == 8) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '账户余额不足', 'errcode' => Const_APIStatus::E_COMMISSION_BALANCE);
     } elseif ($data['status'] == 9) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '房东已删除', 'errcode' => Const_APIStatus::E_COMMISSION_DEL);
     } elseif ($data['status'] == 10) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '违规已删除', 'errcode' => Const_APIStatus::E_COMMISSION_ILLEGAL);
     } elseif ($data['status'] == 5) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '已过期~', 'errcode' => Const_APIStatus::E_COMMISSION_EXPIRED);
     } elseif ($data['status'] == 7) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '抢过了~', 'errcode' => Const_APIStatus::E_COMMISSION_RUSHED);
     } elseif ($data['status'] == 6) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '抢完了~', 'errcode' => Const_APIStatus::E_COMMISSION_FULL);
     } else {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '不可抢~', 'errcode' => Const_APIStatus::E_COMMISSION_INVALID);
     }
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 /**
  * 开始处理数据
  * @return bool
  */
 protected function proccessData()
 {
     if (empty($this->jobData)) {
         //没有数据
         if ($this->jobYmd != $this->currentYmd) {
             //如果job年月不等于当前年月日,则将job年月初始化为当前年月日
             $this->jobYmd = $this->currentYmd;
             $this->id = 0;
         }
         return false;
     }
     foreach ($this->jobData as $jobData) {
         $this->id = $jobData->id;
         //查询委托关系
         $commissionInfo = Model_House_Commission::getInfoByBrokerIdAndBrokerHouseId($jobData->houseId, 1);
         if (!empty($commissionInfo)) {
             $brokerHouseId = $commissionInfo->brokerHouseId;
             $commissionInfo->brokerHouseId = 0;
             $commissionInfo->deleteTime = '0000-00-00 00:00:00';
             if ($commissionInfo->save()) {
                 //插入委托删除日志
                 $deleDb = new Model_House_CommissionSaleLog();
                 $deleDb->cityId = $jobData->cityId;
                 $deleDb->ownerId = $commissionInfo->ownerId;
                 $deleDb->houseId = $commissionInfo->houseId;
                 $deleDb->brokerId = $commissionInfo->brokerId;
                 $deleDb->brokerHouseId = $brokerHouseId;
                 $deleDb->dateindex = $this->jobYmd;
                 $deleDb->status = Model_House_CommissionSaleLog::STATUS_PROP_DEL;
                 $deleDb->origin = $commissionInfo->origin;
                 $deleDb->createTime = time();
                 $deleDb->save();
                 var_dump('LOG:' . $jobData->id . ' commissionInfo done!' . "\n");
                 unset($commissionInfo);
                 unset($deleDb);
             }
         }
         var_dump('LOG:' . $jobData->id . ' is done!' . "\n");
     }
     return true;
 }
Ejemplo n.º 7
0
 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';
 }
Ejemplo n.º 8
0
 /**
  * @param $brokerId
  * @param null $type
  * @return array
  */
 private function getPublishButNotFixHouse($brokerId, $type = null)
 {
     $result = array();
     if (empty($brokerId)) {
         return array();
     }
     $startTimeStr = strtotime('-60 day');
     $endTimeStr = strtotime("-150 day");
     $startTime = date('Y-m-d H:i:s', $startTimeStr);
     $endTime = date('Y-m-d H:i:s', $endTimeStr);
     $res = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter_by_op('brokerHouseId', '>', 0);
     if (!empty($type)) {
         $res->filter('type', $type);
     }
     $data = $res->filter('isDelete', Model_House_Commission::DELETE_NO)->filter_by_op('createTime', '>', $endTime)->filter_by_op('createTime', '<', $startTime)->load_field('houseId')->load_field('brokerHouseId')->find();
     foreach ($data as $key => $value) {
         $result[$value->houseId] = $value;
     }
     return $result;
 }
Ejemplo n.º 9
0
 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';
 }
Ejemplo n.º 10
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $per = isset($this->_params['per']) ? $this->_params['per'] : 20;
     $per = $per + 1;
     //判断是否有下一页
     $moreFlag = 1;
     //读取经纪人信息
     $BrokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId);
     //城市是否开通房源库
     $cityInfo = Bll_Fyk_Prop_Manage::getInstance()->getCityConfig($BrokerInfo['BaseInfo']['CITYID']);
     if ($cityInfo) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'canGrabNum' => 0, 'msg' => '亲!房源已转至房源库,快去开通吧!', 'data' => array(), 'nextPage' => 0);
     }
     // 获取已推送委托
     $pushedCommissionHouses = Model_House_CommissionHousePushed::pushedCommissionHouses($brokerId, $per, $this->_params['maxId'], $this->_params['sinceId']);
     $countPushedCommissionHouses = count($pushedCommissionHouses);
     if ($countPushedCommissionHouses < $per) {
         $moreFlag = 0;
     } else {
         unset($pushedCommissionHouses[$countPushedCommissionHouses - 1]);
     }
     // 排序(按ID倒序)
     uasort($pushedCommissionHouses, function ($a, $b) {
         return $a['id'] < $b['id'];
     });
     // 获取房源数据
     $houses = array();
     $rushedHouses = array();
     if (!empty($pushedCommissionHouses)) {
         // 获取房源ID
         $houseIds = array();
         foreach ($pushedCommissionHouses as $pushedCommissionHouse) {
             $houseIds[] = $pushedCommissionHouse['propertyId'];
         }
         // 获取房源信息
         $houses = Model_House_CommissionHouse::getEntrustsPro($houseIds);
         $indexedHouses = array();
         foreach ($houses as $house) {
             $indexedHouses[$house['id']] = $house;
         }
         $houses = $indexedHouses;
         // 获取已抢房源数据
         $rushedCommissions = Model_House_Commission::getEntrustInfos($houseIds);
         foreach ($rushedCommissions as $rushedCommission) {
             if ($brokerId == $rushedCommission->brokerId) {
                 $rushedHouses[$rushedCommission->houseId] = $rushedCommission->id;
             }
         }
         // 是否存在实拍图片
         $imagesInfos = Model_Image_SaleEntrustImage::getImagesByProIds($houseIds);
         foreach ($imagesInfos as $imagesInfo) {
             $isImages[$imagesInfo->proId] = 1;
         }
     }
     // 拼装结果
     $data = array();
     $rushableCount = 0;
     foreach ($pushedCommissionHouses as $pushedCommissionHouse) {
         if (!isset($houses[$pushedCommissionHouse['propertyId']])) {
             continue;
         }
         $house = $houses[$pushedCommissionHouse['propertyId']];
         $row = array();
         $row['id'] = $pushedCommissionHouse['id'];
         $row['propertyId'] = $house['id'];
         $row['commName'] = $house['commName'];
         $row['ownerName'] = $house['userName'];
         if ($house->getPhone()) {
             $row['ownerPhone'] = substr_replace($house->getPhone(), '*****', 3, 5);
         } else {
             $row['ownerPhone'] = '';
         }
         $row['type'] = $house['commissionType'];
         $row['room'] = $house['roomNum'];
         $row['hall'] = $house['hallNum'];
         $row['toilet'] = $house['toiletNum'];
         $row['area'] = $house['areaNum'];
         $row['price'] = $house['proPrice'];
         switch ($house['commissionType']) {
             case Model_House_CommissionHouse::COMMISSION_TYPE_RENT:
                 $row['priceUnit'] = '元/月';
                 break;
             case Model_House_CommissionHouse::COMMISSION_TYPE_SALE:
                 $row['priceUnit'] = '万元';
                 break;
         }
         $row['publishTime'] = date('Y-m-d H:i:s', $house['created']);
         $row['rushable'] = 1;
         $row['showStatus'] = 4;
         $row['rushableInfo'] = '抢委托';
         $row['rushed'] = 0;
         if ($house['proStatus'] == Model_House_CommissionHouse::STATUS_ONGOING && $house['openBrokerCnt'] < Model_House_CommissionHouse::allowedMaxCommissionCount()) {
             $rushableCount++;
         }
         if (!($house['proStatus'] == Model_House_CommissionHouse::STATUS_ONGOING && $house['openBrokerCnt'] < Model_House_CommissionHouse::allowedMaxCommissionCount()) && empty($rushedHouses[$house['id']])) {
             $row['rushable'] = 0;
             $row['showStatus'] = 3;
             $row['rushableInfo'] = '抢完了';
         }
         if ($house['proStatus'] == Model_House_CommissionHouse::STATUS_STOP && $house['openBrokerCnt'] < Model_House_CommissionHouse::allowedMaxCommissionCount()) {
             $row['rushable'] = 0;
             $row['showStatus'] = 9;
             $row['rushableInfo'] = '房东停止委托';
         }
         if (isset($rushedHouses[$house['id']])) {
             $row['rushable'] = 0;
             $row['rushableInfo'] = '抢过了';
             $row['rushed'] = 1;
         }
         $row['isRealityPats'] = $isImages[$house['id']] ? 1 : 0;
         $row['timestate'] = Bll_Common_Format::formatTime($house['created']);
         //抢过不显示
         if (empty($rushedHouses[$house['id']])) {
             $data[] = $row;
         }
     }
     // 重置可抢房源数
     $daCommissionHousePushedCount = Model_House_CommissionHousePushedCount::data_access()->filter('brokerId', $brokerId)->find_only();
     if (!empty($daCommissionHousePushedCount)) {
         $daCommissionHousePushedCount->resetCommissionHousePushedCount();
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'canGrabNum' => $rushableCount, 'msg' => '仅展示15天以内房源', 'data' => $data, 'nextPage' => $moreFlag);
 }
Ejemplo n.º 11
0
 /**
  *该经济人该区域下的可抢房源数
  */
 private function getCanCommissionNum($brokerId, $cityId, $areaCode, $type)
 {
     // 獲取本區域下所有可搶房源
     $commissions = $this->getCommissionsByAreaCode($cityId, $areaCode, $type);
     if (empty($commissions)) {
         return 0;
     }
     $houseIds = array();
     foreach ($commissions as $val) {
         $houseIds[] = $val['id'];
     }
     // 判斷房源经纪人是否已经抢过
     $res = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('houseId', $houseIds);
     if (!empty($type)) {
         $res->filter('type', $type);
     }
     $data = $res->load_field('houseId')->load_field('brokerId')->find();
     $tmpHouseIds = array();
     if (empty($data)) {
         return count($houseIds);
     } else {
         foreach ($data as $val) {
             if (!in_array($val->houseId, $tmpHouseIds)) {
                 $tmpHouseIds[] = $val->houseId;
             }
         }
         $num = count($houseIds) - count($data);
         return $num > 0 ? $num : 0;
     }
 }
Ejemplo n.º 12
0
 /**
  * 查询该房源是否为委托房源
  * @param $proId
  * @param $brokerId
  * @return mixed
  * add by xiongjianxu
  */
 public static function isCommissionHouse($proId, $brokerId, $type = Model_House_Commission::TYPE_SALE)
 {
     $res = Model_House_Commission::data_access()->filter('brokerHouseId', $proId)->filter('brokerId', $brokerId)->filter('type', $type)->count();
     return $res;
 }
Ejemplo n.º 13
0
 protected function getCommissionDataById($id)
 {
     $id = intval($id);
     if (!$id) {
         return array();
     }
     return Model_House_Commission::data_access()->filter('id', $id)->find_only();
 }
Ejemplo n.º 14
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $per = isset($this->_params['per']) ? $this->_params['per'] : 20;
     $per = $per + 1;
     //判断是否有下一页
     $moreFlag = 1;
     //读取经纪人信息
     $BrokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId);
     //城市是否开通房源库
     $cityInfo = Bll_Fyk_Prop_Manage::getInstance()->getCityConfig($BrokerInfo['BaseInfo']['CITYID']);
     if ($cityInfo) {
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array(), 'nextPage' => 0);
     }
     //是否收费
     $isToll = Bll_Broker_EntrustPrice::getInstance()->checkCityConsumeStatus($BrokerInfo['BaseInfo']['CITYID']);
     if ($isToll) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_PROMPT_UPDATE, 'message' => '你的版本太老了,快更新到新版本吧!');
     }
     // 获取已推送委托
     $daPushedCommissionHouses = Model_House_CommissionHousePushed::data_access()->filter('brokerId', $brokerId)->filter('propertyStatus', Model_House_CommissionHouse::STATUS_ONGOING)->limit($per);
     if (isset($this->_params['maxId'])) {
         $daPushedCommissionHouses->filter_by_op('id', '>', $this->_params['maxId'])->sort('id', 'asc');
     } elseif (isset($this->_params['sinceId'])) {
         $daPushedCommissionHouses->filter_by_op('id', '<', $this->_params['sinceId'])->sort('id', 'desc');
     } else {
         // maxId和sinceId均不存在时,返回当前最新的记录
         $daPushedCommissionHouses->sort('id', 'desc');
     }
     $pushedCommissionHouses = $daPushedCommissionHouses->find_all();
     $countPushedCommissionHouses = count($pushedCommissionHouses);
     if ($countPushedCommissionHouses < $per) {
         $moreFlag = 0;
     } else {
         unset($pushedCommissionHouses[$countPushedCommissionHouses - 1]);
     }
     // 排序(按ID倒序)
     uasort($pushedCommissionHouses, function ($a, $b) {
         return $a['id'] < $b['id'];
     });
     // 获取房源数据
     $houses = array();
     $rushedHouses = array();
     if (!empty($pushedCommissionHouses)) {
         // 获取房源ID
         $houseIds = array();
         foreach ($pushedCommissionHouses as $pushedCommissionHouse) {
             $houseIds[] = $pushedCommissionHouse['propertyId'];
         }
         // 获取房源信息
         $houses = Model_House_CommissionHouse::data_access()->filter('id', $houseIds)->find_all();
         // 索引
         $indexedHouses = array();
         foreach ($houses as $house) {
             $indexedHouses[$house['id']] = $house;
         }
         $houses = $indexedHouses;
         // 获取已抢房源数据
         $rushedCommissions = Model_House_Commission::data_access()->filter('houseId', $houseIds)->filter('brokerId', $brokerId)->find_all();
         foreach ($rushedCommissions as $rushedCommission) {
             $rushedHouses[$rushedCommission->houseId] = $rushedCommission->id;
         }
     }
     // 拼装结果
     $data = array();
     foreach ($pushedCommissionHouses as $pushedCommissionHouse) {
         if (!isset($houses[$pushedCommissionHouse['propertyId']])) {
             continue;
         }
         $house = $houses[$pushedCommissionHouse['propertyId']];
         $row = array();
         $row['id'] = $pushedCommissionHouse['id'];
         $row['propertyId'] = $house['id'];
         $row['commName'] = $house['commName'];
         $row['type'] = $house['commissionType'];
         $row['room'] = $house['roomNum'];
         $row['hall'] = $house['hallNum'];
         $row['toilet'] = $house['toiletNum'];
         $row['area'] = $house['areaNum'];
         $row['price'] = $house['proPrice'];
         switch ($house['commissionType']) {
             case Model_House_CommissionHouse::COMMISSION_TYPE_RENT:
                 $row['priceUnit'] = '元/月';
                 break;
             case Model_House_CommissionHouse::COMMISSION_TYPE_SALE:
                 $row['priceUnit'] = '万元';
                 break;
         }
         $row['publishTime'] = date('Y-m-d H:i:s', $house['created']);
         $row['rushable'] = 1;
         $row['rushableInfo'] = '抢委托';
         $row['rushed'] = 0;
         if (!($house['proStatus'] == Model_House_CommissionHouse::STATUS_ONGOING && $house['openBrokerCnt'] < Model_House_CommissionHouse::allowedMaxCommissionCount())) {
             $row['rushable'] = 0;
             $row['rushableInfo'] = '抢完了';
         }
         if (isset($rushedHouses[$house['id']])) {
             $row['rushable'] = 0;
             $row['rushableInfo'] = '抢过了';
             $row['rushed'] = 1;
         }
         $data[] = $row;
     }
     // 重置可抢房源数
     $daCommissionHousePushedCount = Model_House_CommissionHousePushedCount::data_access()->filter('brokerId', $brokerId)->find_only();
     if (!empty($daCommissionHousePushedCount)) {
         $daCommissionHousePushedCount->resetCommissionHousePushedCount();
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data, 'nextPage' => $moreFlag);
 }
Ejemplo n.º 15
0
 /**
  * 构造房源数据。
  * @param array $info
  * @return array
  */
 public static function gen_prop_info($info)
 {
     $params["broker_id"] = $info["brokerId"];
     //经纪人ID
     $params["fileNo"] = $info["fileNo"];
     //房源档案号
     //委托房源
     if (isset($info['ownerPropId']) && !empty($info['ownerPropId'])) {
         $commission = Model_House_Commission::rushedCommissions($info['ownerPropId'], $info['brokerId']);
         if (!empty($commission)) {
             $params['relationId'] = $commission[0]['id'];
             //房源委托关系id
         }
     }
     $params["comm_id"] = $info["commId"];
     //小区ID
     $params["rooms"] = $info["rooms"];
     //户型(选择)
     $params["area"] = $info["area"];
     //产证面积(输入)
     $params["price"] = $info["price"];
     //价格(输入)
     $params["fitment"] = $info["fitment"];
     //装修(默认+选择)装修情况,1毛坯 ;2普通装修;3精装修;4豪华装修; 9其它。
     $params["exposure"] = $info["exposure"];
     //朝向(默认+选择)
     $params["floor"] = $info["floor"];
     //楼层(选择)
     $params["title"] = $info["title"];
     //房源标题(输入)
     $params["description"] = $info["description"];
     //房源描述(输入)
     $params["trade_type"] = 1;
     //交易类型-售房
     $params["publish"] = '';
     $params["stype"] = 1;
     //发布类型
     $params["for_lease"] = 2;
     // 仅对二手房(trade_type==1:售)1:带租约;2:不带租约
     $params['from'] = APF::get_instance()->get_config('java_api_from');
     // 房屋类型(读取) 读取所选择小区的“物业类型”
     $params["style"] = $info["style"] ? $info["style"] : 1;
     //房屋类型 (1公寓;2别墅;3新里洋房;4其它;5老公房 ;6普通住宅;7四合院 8平房 9排屋)
     //新增3个字段 最低首付(万元) 是否满5年(1:是;0:否) 是否是唯一住房(1:是;0:否)
     if (isset($info['minDownPay'])) {
         $params["minDownPay"] = round($info['minDownPay'], 2);
     }
     if (isset($info['isFullFive'])) {
         $params["isFullFive"] = intval($info['isFullFive']);
     }
     if (isset($info['isOnly'])) {
         $params["isOnly"] = intval($info['isOnly']);
     }
     // 建造年代(读取) 读取所选择小区的“竣工时间”
     $api_url = '/service-ppc/rest/cache/commInfo?commuId=' . $params["comm_id"] . '&rsl=111';
     //获取小区信息
     $comminfo = Util_CallAPI::get_data_from_java_api($api_url);
     if ($comminfo['data']['status'] == 'ok') {
         $usetype = Dao_Broker_AjkProp::get_prop_usetype($info["cityId"], intval($comminfo['data']['commBaseInfo']['USETYPE']));
         $usetype_name_id = array('公寓' => 1, '别墅' => 2, '新里洋房' => 3, '其它' => 4, '老公房' => 5, '普通住宅' => 6, '四合院' => 7, '平房' => 8, '排屋' => 9);
         $usetype_id = $usetype_name_id[$usetype['TYPENAME']];
         //$params["style"] = $usetype_id ? $usetype_id : intval($params["style"]); //物业类型
         if (2 == $params["style"]) {
             $pos = strpos($params["floor"], ',');
             $params["floor"] = '0' . substr($params["floor"], $pos);
         }
         $params["year"] = $comminfo['data']['commExtInfo']['SENDDATE'] ? date("Y", strtotime($comminfo['data']['commExtInfo']['SENDDATE'])) : date("Y");
         //竣工日期
         if ($params["year"] > date('Y')) {
             $params["year"] = date('Y');
         }
         //删除该经纪人房源缓存
         $key = self::MEMCACHE_KEY_ANJUKE_CHAT_GETCOMMPROPS . '_' . $info["brokerId"] . '_' . $info["commId"] . '_' . date("Ymd");
         $memcache = APF_Cache_Factory::get_instance()->get_memcache();
         $memcache->delete($key);
     } else {
         return Util_MobileAPI::error(Const_APIStatus::E_CALL_API_ERROR);
     }
     return $params;
 }
Ejemplo n.º 16
0
 /**
  * 添加委托房源日志
  *
  * @param int $brokerId
  * @param int $cityId
  * @param int $commissionId
  * @param int $houseId
  * @return bool
  */
 public static function insertCommissionSaleLog($brokerId, $cityId, $commissionId, $houseId)
 {
     $commissionInfo = static::getCommission($commissionId, $brokerId);
     if (empty($commissionInfo)) {
         return false;
     }
     /** 更新委托房源发布时间 */
     if (!Model_House_Commission::updateCommissionById($commissionId, $brokerId, $houseId)) {
         return false;
     }
     $status = 2;
     if ($commissionInfo['publishTime'] != '0000-00-00 00:00:00') {
         $status = 5;
     }
     $propertySales = Model_House_PropertySale::getPropertySales($houseId);
     if (!empty($propertySales)) {
         $saleId = $propertySales['saleId'];
         $ownerMobile = $commissionInfo['house']['owner400'] ? $commissionInfo['house']['owner400'] : $commissionInfo['house']['ownerMobile'];
         $data = array('ownerName' => $commissionInfo['house']['userName'], 'ownerMobile' => $ownerMobile);
         Model_House_PropertySale::updatePropertyBySaleId($saleId, $data);
     }
     /** 更新房源的委托类型 */
     Bll_House_EsfHouse::updateCommissionType($cityId, $houseId);
     /** 更新经纪人 已处理委托数 */
     Model_Broker_BrokerExt::incrementDealCommissionCnt($brokerId);
     $data = array('cityId' => $cityId, 'ownerId' => $commissionInfo['ownerId'], 'houseId' => $commissionInfo['houseId'], 'brokerId' => $brokerId, 'brokerHouseId' => $houseId, 'dateindex' => date('Ymd'), 'status' => $status, 'createTime' => time());
     return 1 == Model_House_CommissionSaleLog::create($data)->save();
 }
Ejemplo n.º 17
0
 /**
  * 更新委托房源
  * @param $commissionId
  * @param $proId
  * @return int
  */
 public static function updateCommission($commissionId, $proId)
 {
     return Model_House_Commission::updateCommission(array('id' => $commissionId), array('brokerHouseId' => $proId, 'publishTime' => date('Y-m-d H:i:s'), 'updateTime' => date('Y-m-d H:i:s')));
 }
Ejemplo n.º 18
0
 /**
  * 开始处理数据
  * @return bool
  */
 protected function proccessData()
 {
     if (empty($this->jobData)) {
         //没有数据
         return false;
     }
     $tDate = date('Ymd');
     foreach ($this->jobData as $jobData) {
         $this->id = $jobData->id;
         //查询委托关系
         $commissionInfo = Model_House_Commission::getInfoByBrokerIdAndBrokerHouseId($jobData->proId, 1, '');
         if (!empty($commissionInfo)) {
             if (empty($this->cPropInfo[$commissionInfo->houseId])) {
                 //房东房源具体信息
                 try {
                     $this->cPropInfo[$commissionInfo->houseId] = Model_House_CommissionHouse::data_access()->find_by_pk($commissionInfo->houseId);
                 } catch (Exception $e) {
                     $this->cPropInfo[$commissionInfo->houseId] = false;
                 }
             }
             $commissionProp = $this->cPropInfo[$commissionInfo->houseId];
             if (empty($commissionProp)) {
                 //房东信息没有,跳过处理下一跳
                 continue;
             }
             //写入委托房源被推广日志
             $spreadObj = new Model_House_CommissionSaleLog();
             $spreadObj->cityId = $commissionProp->cityId;
             $spreadObj->ownerId = $commissionInfo->ownerId;
             $spreadObj->houseId = $commissionInfo->houseId;
             $spreadObj->brokerId = $commissionInfo->brokerId;
             $spreadObj->brokerHouseId = $jobData->proId;
             $spreadObj->dateindex = $tDate;
             $spreadObj->status = $jobData->type == 1 ? Model_House_CommissionSaleLog::STATUS_PROP_FS : Model_House_CommissionSaleLog::STATUS_PROP_BS;
             $spreadObj->origin = $commissionInfo->origin;
             $spreadObj->createTime = time();
             $spreadObj->save();
             unset($spreadObj);
             $firstSmsInfo = Model_House_CommissionFirstAction::getBrokerHouseInfo($commissionInfo->brokerId, $commissionInfo->houseId);
             if (!empty($firstSmsInfo)) {
                 //如果已经发过短信,无需再处理
                 continue;
             }
             if (empty($this->brokerInfo[$commissionInfo->brokerId])) {
                 //经纪人信息
                 $this->brokerInfo[$commissionInfo->brokerId] = Model_Broker_AjkBrokerExtend::data_access()->find_by_pk($commissionInfo->brokerId);
             }
             $bInfo = $this->brokerInfo[$commissionInfo->brokerId];
             if (empty($bInfo) || empty($commissionProp)) {
                 continue;
             }
             if (mb_strlen($commissionProp->commName, 'UTF-8') > 12) {
                 //小区名称
                 $commName = mb_substr($commissionProp->commName, 0, 12, 'UTF-8') . '...';
             } else {
                 $commName = $commissionProp->commName;
             }
             //短信内容
             $content = $commissionProp->userName . '您好,' . $bInfo->trueName . ' ' . $bInfo->userMobile . ' 已将您在' . $commName . '的房源在安居客网站上挂牌';
             $smsInfo = array('userid' => $commissionProp->userId, 'brokerid' => $commissionInfo->brokerId, 'mobile' => $commissionProp->ownerMobile, 'content' => $content, 'status' => '0', 'createtime' => date('Y-m-d H:i:s'), 'bizid' => 1010);
             Model_Notice_AjkSmsTask::insertLayer($smsInfo);
             //插入发短信信息表
             $smsObj = new Model_House_CommissionFirstAction();
             $smsObj->brokerId = $commissionInfo->brokerId;
             $smsObj->houseId = $commissionInfo->houseId;
             $smsObj->type = $jobData->type;
             $smsObj->dateIndex = $tDate;
             $smsObj->createTime = time();
             $smsObj->save();
             //给app推送消息
             $this->senfAppMsg($commissionInfo->brokerId, $jobData->proId, $commissionInfo->houseId, $commissionProp->userId);
             var_dump('LOG:' . $jobData->id . ' send sms done!' . "\n");
         }
         var_dump('LOG:' . $jobData->id . ' is done!' . "\n");
     }
     return true;
 }
Ejemplo n.º 19
0
 /**
  * 抢委托操作流程
  * @param $houseId 房源id
  * @param $brokerId 二手房经纪人Id
  * @param $brokerName 二手房经纪人真实姓名
  * @param $brokerPhone 经纪人手机电话
  * @param $cityId 经纪人城市id
  * @param $comeFrom 来源
  * @param $isConsume 是否扣费
  * @return array
  */
 public function rentRush($houseId, $brokerId, $brokerName, $brokerPhone, $cityId, $comeFrom = Const_Entrust::RUSH_FROM_PC, $isConsume = true)
 {
     $result = array('status' => 0, 'data' => array(), 'errorMsg' => "");
     if (empty($houseId) || empty($brokerId) || empty($cityId)) {
         $result['status'] = 99;
         $result['errorMsg'] = "输入的参数不正确";
         return $result;
     }
     // 判断房源ID
     $id = isset($houseId) & intval($houseId) > 0 ? intval($houseId) : 0;
     if ($houseId <= 0) {
         $result['status'] = 2;
         $result['errorMsg'] = "无效的房源编号。";
         return $result;
     }
     // 判断委托房源是否存在
     $house = Model_House_CommissionHouse::data_access()->filter('id', $id)->find_only();
     if (!$house) {
         $result['status'] = 3;
         $result['errorMsg'] = "房源不可委托:房源不存在。";
         return $result;
     }
     if ($house->commissionType != Model_House_CommissionHouse::COMMISSION_TYPE_RENT) {
         $result['status'] = 4;
         $result['errorMsg'] = "房源类型不是租房";
         return $result;
     }
     // 判断委托房源状态
     if ($house->proStatus != Model_House_CommissionHouse::STATUS_ONGOING) {
         $result['status'] = 5;
         $result['errorMsg'] = "房源不可委托:已过期或已被删除。";
         return $result;
     }
     // 判断委托房源已委托数量
     if ($house->openBrokerCnt >= Model_House_CommissionHouse::allowedMaxCommissionCount()) {
         $result['status'] = 6;
         $result['errorMsg'] = '委托已满。';
         return $result;
     }
     // 判断是否已抢过委托
     $commission = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('houseId', $house->id)->find_only();
     if ($commission) {
         $result['status'] = 7;
         $result['errorMsg'] = '你已经委托了该房源。';
         return $result;
     }
     // 更新commission_prop表的openBrokerCnt+1
     if (!$house->updateCommissionCount()) {
         $result['status'] = 6;
         $result['errorMsg'] = '委托已满。';
         return $result;
     }
     // 更新成功 插入e_commission表
     $commission = Model_House_Commission::create(array('type' => $house->commissionType, 'ownerId' => $house->userId, 'houseId' => $house->id, 'brokerId' => $brokerId, 'origin' => $comeFrom, 'createTime' => date('Y-m-d H:i:s'), 'updateTime' => date('Y-m-d H:i:s')));
     $commission->save();
     // 更新推送房源状态
     $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();
     }
     //给app房东推送消息,added by xiongjiewu at 2014-08-07
     $this->pushEntrustMsg($brokerId, $id);
     // 拼装返回数据
     $result['status'] = 1;
     // 抢委托成功
     $result['data'] = array('owner' => $house->userName, 'phone' => $house->getPhone(), 'title' => '', 'summary' => '', 'manageUrl' => '');
     $area = '[' . implode('-', $house->getAreaCodeNames()) . '] ';
     $houseModel = "{$house->roomNum}室{$house->hallNum}厅{$house->toiletNum}卫,{$house->areaNum}平方米,";
     $baseDomain = APF::get_instance()->get_config('base_domain', 'common');
     $baseUri = defined('BASE_URI') ? BASE_URI : '';
     $result['data']['title'] = '[出售] ' . $house->commName;
     $result['data']['summary'] = $area . $houseModel . $house->proPrice . '万元';
     $result['data']['manageUrl'] = "http://my.{$baseDomain}{$baseUri}/commissions/mysale";
     return $result;
 }
Ejemplo n.º 20
0
 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';
 }
Ejemplo n.º 21
0
 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;
 }
Ejemplo n.º 22
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $maxId = isset($this->_params['maxId']) ? $this->_params['maxId'] : null;
     $sinceId = isset($this->_params['sinceId']) ? $this->_params['sinceId'] : null;
     $per = isset($this->_params['per']) ? $this->_params['per'] : 20;
     $per = $per + 1;
     //判断是否有下一页
     $moreFlag = 1;
     $allData = array();
     $cacheCursorKey = md5($brokerId . 'commission');
     //游标key
     $cacheCommissionKey = md5($cacheCursorKey . $brokerId);
     //commissionInfo key
     $cache = APF_Cache_Factory::get_instance()->get_memcache();
     $cacheCursor = $cache->get($cacheCursorKey);
     $maxCommissionInfo = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('isDelete', Model_House_Commission::DELETE_NO)->sort('id', 'desc')->limit(1)->find_only();
     if ($maxCommissionInfo['id'] == $cacheCursor) {
         //没新数据则读缓存
         $allData = $cache->get($cacheCommissionKey);
     } elseif (!empty($maxCommissionInfo)) {
         //如果有新数据
         // 获取经纪人的所有委托
         $daCommissions = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('isDelete', Model_House_Commission::DELETE_NO)->sort('id', 'desc');
         $commissions = $daCommissions->find_all();
         // 获取委托关联的房源
         $houses = array();
         if (!empty($commissions)) {
             $houseIds = array();
             foreach ($commissions as $commission) {
                 $houseIds[] = $commission->houseId;
                 $brokerHouseIds[] = $commission->brokerHouseId;
             }
             // 获取房源信息
             $houses = Model_House_CommissionHouse::data_access()->filter('id', $houseIds)->sort('id', 'asc')->find_all();
             // 索引
             $indexedHouses = array();
             foreach ($houses as $house) {
                 $indexedHouses[$house['id']] = $house;
             }
             $houses = $indexedHouses;
             // 是否存在实拍图片
             $imagesInfos = Model_Image_SaleEntrustImage::getImagesByProIds($houseIds);
             $isImages = array();
             foreach ($imagesInfos as $imagesInfo) {
                 $isImages[$imagesInfo->proId] = 1;
             }
             $BrokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId);
             //房源推广状态(定价&套餐)
             $isOnLine = Bll_House_EsfHouse::getHouseOnLineInfo($BrokerInfo['BaseInfo']['CITYID'], $brokerId, $brokerHouseIds);
         }
         $houseAction = array();
         //可操作房源
         $houseUnAction = array();
         //不可操作房源
         foreach ($commissions as $commission) {
             if (!isset($houses[$commission['houseId']])) {
                 continue;
             }
             $house = $houses[$commission['houseId']];
             $row = array();
             $row['id'] = $commission['id'];
             $row['propertyId'] = $house['id'];
             $row['commName'] = $house['commName'];
             $row['type'] = $house['commissionType'];
             $row['room'] = $house['roomNum'];
             $row['hall'] = $house['hallNum'];
             $row['toilet'] = $house['toiletNum'];
             $row['area'] = $house['areaNum'];
             $row['price'] = $house['proPrice'];
             switch ($house['commissionType']) {
                 case Model_House_CommissionHouse::COMMISSION_TYPE_RENT:
                     $row['priceUnit'] = '元/月';
                     break;
                 case Model_House_CommissionHouse::COMMISSION_TYPE_SALE:
                     $row['priceUnit'] = '万元';
                     break;
             }
             $row['publishTime'] = date('Y-m-d H:i:s', $house['created']);
             $row['status'] = $house['proStatus'];
             $row['statusInfo'] = $this->statusMapping[$house['proStatus']];
             $row['ownerName'] = $house['userName'];
             $row['ownerPhone'] = $house->getPhone();
             $row['callable'] = intval($house['proStatus'] == Model_House_CommissionHouse::STATUS_ONGOING);
             $row['isRealityPats'] = $isImages[$house['id']] ? 1 : 0;
             $row['timestate'] = Bll_Common_Format::formatTime($house['created']);
             list($isExtension, $isExtensionInfo) = $this->isExtension($commission, $isOnLine, $house);
             if ($isExtension == 5 || $isExtension == 6) {
                 $row['isExtension'] = 7;
             } else {
                 $row['isExtension'] = $isExtension;
             }
             $row['isExtensionInfo'] = $isExtensionInfo;
             //1-违规已删除 2-已过期 5-待发布 6-待推广 7-已推广 8-房东删除
             if (in_array($isExtension, array(1, 2, 8))) {
                 //不可操作房源
                 $houseUnAction[] = $row;
             } else {
                 $houseAction[] = $row;
             }
         }
         $cacheCursorValue = $houseAction[0]['id'] > $houseUnAction[0]['id'] ? $houseAction[0]['id'] : $houseUnAction[0]['id'];
         $cache->set($cacheCursorKey, $cacheCursorValue, 0, 10);
         $allData = array_merge($houseAction, $houseUnAction);
         $cache->set($cacheCommissionKey, $allData, 0, 10);
     }
     $data = array();
     if ($allData) {
         $countAllCommissions = count($allData);
         $segmentation = array();
         //供分页用
         foreach ($allData as $value) {
             $segmentation[] = $value['id'];
         }
         /**
          * 以下是分页处理代码 略坑,勿踩
          *  add by xiongjianxu
          */
         if (isset($maxId)) {
             $max = array();
             $max = array_keys($segmentation, $maxId);
             if (!empty($max)) {
                 $offset = $countAllCommissions - $max[0];
                 krsort($allData);
                 $data = array_slice($allData, $offset, $per, false);
             }
         } elseif (isset($sinceId)) {
             $since = array();
             $since = array_keys($segmentation, $sinceId);
             if (!empty($since)) {
                 $offset = $since[0] + 1;
                 $data = array_slice($allData, $offset, $per, false);
             }
         } else {
             // maxId和sinceId均不存在时,返回当前最新的记录
             $data = array_slice($allData, 0, $per, false);
         }
         //判断有无下一页
         $countCommissions = count($data);
         if ($countCommissions < $per) {
             $moreFlag = 0;
         } else {
             unset($data[$countCommissions - 1]);
         }
     } else {
         $moreFlag = 0;
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data, 'nextPage' => $moreFlag);
 }
Ejemplo n.º 23
0
 /**
  * 数据整理
  * @param $data
  * @param $brokerId
  * @param $showStatus
  * @param $commLocal
  * @param $rushBrokerId
  * @param $propertyId
  * @return array
  */
 private function formatdate($data, $eBrokers, $showStatus, $commLocal, $rushBrokerId, $propertyId, $imgInfos)
 {
     if (empty($data)) {
         return '';
     }
     $business = APF::get_instance()->get_config("choice_business", "multicity");
     $row = array();
     $row['entrustId'] = $data['id'];
     //委托ID
     $row['cityId'] = $data['cityId'];
     //房源所属城市
     $row['ownerId'] = $data['userId'];
     //房东ID
     $row['ownerName'] = $data['userName'];
     //房东姓名
     if ($data['owner400'] != 0) {
         $is400 = 1;
     } else {
         $is400 = 0;
     }
     $row['is400'] = $is400;
     if ($rushBrokerId) {
         $row['ownerMobile'] = $rushBrokerId ? $data['ownerMobile'] : substr_replace($data['ownerMobile'], '*****', 3, 5);
         //手机. 规则抢到显示
         $row['owner400'] = $rushBrokerId ? $data['owner400'] : ($is400 == 1 ? substr_replace($data['owner400'], '*****', 0, strlen($data['owner400'])) : 0);
         //是否绑定400。0-否;是-具体号码
     } else {
         $row['ownerMobile'] = substr_replace($data['ownerMobile'], '*****', 3, 5);
         $row['owner400'] = $is400 == 1 ? substr_replace($data['owner400'], '*****', 0, strlen($data['owner400'])) : 0;
         //是否绑定400。0-否;是-具体号码
     }
     $row['owner400Host'] = APF::get_instance()->get_config("400_host");
     if ($data['fromType'] != 0) {
         $houseExt = Model_House_CommissionHouseExtend::getHouseExtByPk($data['id']);
         $chatId = $houseExt ? $houseExt->chatId : '';
     } else {
         $chatId = '';
     }
     if ($rushBrokerId) {
         $row['ownerChatId'] = $rushBrokerId ? $chatId : '';
         //新增微聊id。
     } else {
         $row['ownerChatId'] = '';
     }
     $row['commId'] = $data['commId'];
     //对应的小区ID
     $row['commName'] = $data['commName'];
     //小区名称
     $row['commLocal'] = $commLocal;
     //小区地址
     $row['roomNum'] = $data['roomNum'];
     //房间数量
     $row['hallNum'] = $data['hallNum'];
     //客厅的数量x
     $row['toiletNum'] = $data['toiletNum'];
     //卫生间的数量
     $row['areaNum'] = $data['areaNum'];
     //房源的建筑面积;单位”平米”
     $row['areaUnit'] = '平米';
     //房源的建筑面积;单位”平米”
     $row['propPrice'] = $data['proPrice'];
     //房源价格(万元)/房源租金(元/月)
     $row['priceUnit'] = $data['commissionType'] == 1 ? '万元' : '元/月';
     //房源价格(万元)/房源租金(元/月)
     $row['entrustType'] = $data['commissionType'];
     //1-出售,2-出租
     if (!empty($imgInfos) && $data['commissionType'] == 1) {
         foreach ($imgInfos as $imginfo) {
             $img = array();
             $img['id'] = $imginfo['id'];
             $img['smallImageUrl'] = Util_Image::getInstance()->getResizeURL($imginfo['imageId'], $imginfo['hostId'], 100, 75);
             //(拼好小图)
             $img['bigImageUrl'] = Util_Image::getInstance()->getResizeURL($imginfo['imageId'], $imginfo['hostId'], 600, 600);
             //(拼好大图)
             $img['hostId'] = $imginfo['hostId'];
             $img['width'] = $imginfo['width'] ? $imginfo['width'] : 1280;
             $img['height'] = $imginfo['height'] ? $imginfo['height'] : 1500;
             $img['hash'] = $imginfo['imageId'];
             $img['type'] = 2;
             //图片类型 1:小区图 2: 室内图 3: 户型图
             $img['entry'] = 4;
             //图片来源 1:系统默认 2:相机拍摄 3:相册选取 4: 在线图库
             $img['exists'] = 1;
             //图片是否已存在
             $img['format'] = 'JPEG';
             $imgs[] = $img;
         }
         $row['imagesInfo'] = $imgs;
     } else {
         $row['imagesInfo'] = array();
     }
     if ($showStatus == 5 || $showStatus == 6) {
         $row['showStatus'] = 7;
     } else {
         $row['showStatus'] = $showStatus;
     }
     //房源状态 0-非法数据暂时没用 1-违规删除 2-已过期 3-抢完了 4-可以抢 5-抢到未发布;6-抢到已发布未推广;7-抢到已发布已推广;8-房东已删除;9-房东停止委托;
     $row['propertyId'] = $propertyId;
     $row['created'] = $data['created'];
     //创建时间
     $row['lastModifyDate'] = $data['lastModifyDate'];
     //最后更改时间
     $row['brokerIds'] = $eBrokers ? implode(',', $eBrokers) : '';
     //该套委托二手房源的所有经纪人id
     $row['isRealityPats'] = empty($imgs) ? 0 : 1;
     //实拍icon 1:显示实拍 0:不显示
     if (!empty($business)) {
         $row['isChoiceCity'] = in_array($data['cityId'], $business) ? 1 : 0;
         //1:精选城市 0:非精选城市
     } else {
         $row['isChoiceCity'] = 0;
     }
     $row['timeState'] = Bll_Common_Format::formatTime($data['created']);
     //倒计时
     $row['brokerImages'] = array();
     if ($showStatus == 3) {
         //已抢完,加入经纪人头像
         $commissionInfo = Model_House_Commission::getCommissionsOrderById(intval($data['id']));
         $brokerIds = array();
         foreach ($commissionInfo as $comm) {
             $brokerIds[] = $comm['brokerId'];
         }
         $brokerInfo = array();
         $brokers = array();
         $brokerInfo = Model_Broker_AjkBrokerExtend::findMultiBrokers($brokerIds);
         foreach ($brokerInfo as $broInfo) {
             $brokers[$broInfo['brokerId']] = $broInfo;
         }
         if (!empty($brokerIds)) {
             foreach ($brokerIds as $broId) {
                 $photo = Util_ImageUtils::get_broker_photo_url($brokers[$broId]['userPhoto'], '200x200');
                 $row['brokerImages'][] = $photo ? $photo : APF::get_instance()->get_config("broker_image_url");
             }
         } else {
             for ($i = 0; $i < 5; $i++) {
                 $row['brokerImages'][$i] = APF::get_instance()->get_config("broker_image_url");
             }
         }
     }
     return $row;
 }
 /**
  * 获取job数据
  * @return array
  */
 protected function getJobData()
 {
     return Model_House_Commission::getEntrustData($this->id, 1, $this->limit);
 }
Ejemplo n.º 25
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $propertyId = $this->_params['propertyId'];
     //读取经纪人信息
     $BrokerInfo = Bll_BrokerBaseBll::get_instance()->get_broker_info($brokerId);
     //城市是否开通房源库
     $cityInfo = Bll_Fyk_Prop_Manage::getInstance()->getCityConfig($BrokerInfo['BaseInfo']['CITYID']);
     if ($cityInfo) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'message' => '已开通房源库,不可抢~', 'errcode' => Const_APIStatus::E_COMMISSION_INVALID);
     }
     //是否收费
     $isToll = Bll_Broker_EntrustPrice::getInstance()->checkCityConsumeStatus($BrokerInfo['BaseInfo']['CITYID']);
     if ($isToll) {
         // 不能再抢了请升级
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => Const_APIStatus::E_PROMPT_UPDATE, 'message' => '你的版本太老了,快更新到新版本吧!');
     }
     // 判断是否是推送房源
     $pushedHouse = Model_House_CommissionHousePushed::data_access()->filter('brokerId', $brokerId)->filter('propertyId', $propertyId)->filter('propertyStatus', array(Model_House_CommissionHouse::STATUS_ONGOING, Model_House_CommissionHousePushed::STATUS_RUSHED))->find_only();
     if (!$pushedHouse) {
         throw new Exception('来晚了,房源已删除', Const_APIStatus::E_COMMISSION_INVALID);
     }
     // 判断委托房源是否存在
     $house = Model_House_CommissionHouse::data_access()->filter('id', $propertyId)->find_only();
     if (!$house || $house->proStatus != Model_House_CommissionHouse::STATUS_ONGOING) {
         throw new Exception('来晚了,房源已删除', Const_APIStatus::E_COMMISSION_INVALID);
     }
     // 判断是否已抢过委托
     $commission = Model_House_Commission::data_access()->filter('brokerId', $brokerId)->filter('houseId', $propertyId)->find_only();
     if ($commission) {
         // 更新推送房源状态
         if ($pushedHouse->propertyStatus != Model_House_CommissionHousePushed::STATUS_RUSHED) {
             $this->pushedHouseRushed($pushedHouse);
         }
         // 如果已抢,仍然返回成功状态
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'message' => '抢过了!去“我的委托”里看看');
     }
     if ($house->openBrokerCnt >= Model_House_CommissionHouse::allowedMaxCommissionCount()) {
         throw new Exception('抢完了~', Const_APIStatus::E_COMMISSION_FULL);
     }
     // 防并发(先插入,再检测(超出,删除),最后更新)
     // TODO 该方案层使用在2013圣诞活动“找锤子,砸金蛋”,并导致数据库多次TMC,但是在该业务场景中瞬时并发并没有那么多,暂定使用 by 胡言言 2014.02.28
     $commission = Model_House_Commission::create(array('type' => $house->commissionType, 'ownerId' => $house->userId, 'houseId' => $house->id, 'brokerId' => $brokerId, 'origin' => Model_House_Commission::ORIGIN_APP, '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('抢完了~', Const_APIStatus::E_COMMISSION_FULL);
     }
     // 更新房源的委托数量
     $house->incrCommissionCount();
     // 更新推送房源状态
     $this->pushedHouseRushed($pushedHouse);
     // 通知到API用户端提示信息(消息推送)
     try {
         $userCheckInPushUrl = 'http://api.anjuke.com/mobile/v5/broker/checkin/notice?is_nocheck=1';
         $curl = new Util_Http_Curl();
         $curl->setDefaults()->post($userCheckInPushUrl, array('broker_id' => $brokerId, 'prop_id' => $propertyId, 'updated' => time(), 'owner_id' => $house['userId'], 'owner_name' => $house['userName']));
     } catch (Exception $e) {
         // 暂时忽略请求
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'message' => '抢成功!快去联系业主吧');
 }