public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $num = Bll_Fyk_Prop_Manage::getInstance()->getUnReadInvalidPropNum($userId);
     $result = array("status" => "ok", "noReadNum" => $num);
     return $result;
 }
Esempio n. 2
0
 /**
  * 添加房源备注
  * @param $userId
  * @param $propId
  * @param $comment
  * @return bool
  */
 public function insertPropRemark($userId, $propId, $comment)
 {
     $result = array('status' => false, 'errcode' => '', 'msg' => '');
     if (empty($userId) || empty($propId) || empty($comment)) {
         $result['errcode'] = Const_APIStatus::E_UNKNOWN;
         $result['msg'] = '参数不完整';
         return $result;
     }
     // 验证内容长度
     if (mb_strlen($comment, 'utf-8') > 100) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_TOO_MANY_CONTENT;
         $result['msg'] = '内容过多';
         return $result;
     }
     // 验证经纪人是否有此房源
     $userPropData = Bll_Fyk_Prop_Manage::getInstance()->getUserPropByUserIdAndPropId($userId, $propId);
     if (empty($userPropData)) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_NOT_OWN;
         $result['msg'] = '经纪人无此房源';
         return $result;
     }
     $addArr = array('userId' => $userId, 'propId' => $propId, 'status' => 1, 'body' => json_encode($comment), 'createTime' => time(), 'updateTime' => date("Y-m-d H:i:s"));
     Model_Fyk_UserPropsRemark::getInstance()->insertData($addArr);
     $result['status'] = true;
     return $result;
 }
Esempio n. 3
0
 public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $type = $this->_params['type'];
     $per = isset($this->_params['per']) ? $this->_params['per'] : 20;
     $sinceId = isset($this->_params['sinceId']) ? $this->_params['sinceId'] : 0;
     $tmpPer = $per + 1;
     if ($type == 'my') {
         $status = array(Const_Fyk::PROPSTATUS_SELLING, Const_Fyk::PROPSTATUS_NOSELL);
         $orderBy = "id";
     } elseif ($type == 'invalid') {
         $status = array(Const_Fyk::PROPSTATUS_SELLED, Const_Fyk::PROPSTATUS_FALSE);
         $orderBy = "updateTime";
         // 更新失效房源未读数目为0
         Bll_Fyk_Prop_Manage::getInstance()->updateUnReadInvalidPropNum($userId);
     }
     $list = Bll_Fyk_Prop_Manage::getInstance()->getUserPropsByUserIdAndSinceId($userId, $status, $orderBy, 'desc', $tmpPer, $sinceId);
     if (count($list) > $per) {
         array_splice($list, -1);
         $hasNextPage = 1;
     } else {
         $hasNextPage = 0;
     }
     $data = array('propList' => $list, 'hasNextPage' => $hasNextPage, 'per' => $per);
     $result = array("status" => "ok", "data" => $data);
     return $result;
 }
Esempio n. 4
0
 public static function getFykStatus($userId, $cityId)
 {
     $userInfo = Model_Fyk_Users::data_access()->filter(Model_Fyk_Users::USER_ID, $userId)->get_row();
     $isOpen = 0;
     $status = -1;
     $message = '未开通房源库功能';
     //判断城市开关
     $cityInfo = Bll_Fyk_Prop_Manage::getInstance()->getCityConfig($cityId);
     if (empty($cityInfo)) {
         $data = array('isOpen' => 0, 'status' => -1, 'message' => '未开通房源库功能');
         return $data;
     }
     if (!empty($userInfo)) {
         $isOpen = 1;
         $openDate = intval($userInfo['openDate']);
         $today = intval(date('Ymd', time()));
         if ($userInfo['status'] == Model_Fyk_Users::INIT) {
             $message = '房源库功能尚未激活';
             $status = $userInfo['status'];
         }
         if ($userInfo['status'] == Model_Fyk_Users::INVITATION) {
             if ($today >= $openDate) {
                 $message = '房源库功能已经激活';
                 $status = $userInfo['status'];
             } else {
                 $message = '您已被关入小黑屋,暂不能使用房源库功能';
                 $status = Model_Fyk_Users::BLACK;
             }
         }
     }
     //4.3版本 对之前版本做的兼容处理
     if ($status == -1) {
         $brokerInfo = Bll_Broker_User::getBrokerInfoByUserId($userId);
         if (!empty($brokerInfo)) {
             $companyId = intval($brokerInfo['companyId']);
             if (!empty($_SERVER['PG_TEST'])) {
                 //如果是PG
                 $blackList = APF::get_instance()->get_config('pg_blacklist_company_ids');
                 $userBlackList = array();
             } else {
                 $blackList = APF::get_instance()->get_config('blacklist_company_ids');
                 $userBlackList = APF::get_instance()->get_config('blacklist_user_ids');
             }
             if (!in_array($companyId, $blackList) && !in_array($userId, $userBlackList)) {
                 //若不在黑名单公司,则显示房源库入口
                 $isOpen = 1;
                 $status = 0;
                 $message = '房源库功能尚未激活';
             }
         }
     }
     // TODO 获取用户激活状态
     $data = array('isOpen' => $isOpen, 'status' => $status, 'message' => $message);
     return $data;
 }
Esempio n. 5
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);
     }
 }
 public function handle_request()
 {
     $this->mailAddress = array('*****@*****.**', '*****@*****.**');
     $this->mobile = array(15618590702.0, 18817325945.0);
     //计算处理延迟
     $fykCursor = $this->getFlag('Mobile_NewPropsPush_flag.log');
     $newestHouse = Bll_Fyk_Prop_Manage::getInstance()->getNewPropsPushNewestHouseInfo();
     $nowId = intval($fykCursor['id']);
     $newestId = intval($newestHouse['id']);
     $threshold = $newestId - $nowId;
     if ($threshold > $this->mailThreshold) {
         //延迟超过邮件报警的阀值
         $mailSubject = '房源库推送--推送job延迟报警';
         $mailBody = '您的job:房源库推送job(Mobile_NewPropsPush),数据处理延迟过高,有可能运行异常。当前最新ID为:' . $newestId . ',目前处理中的ID为:' . $nowId . '。';
         $this->sentMail($mailSubject, $mailBody);
     }
     if ($threshold > $this->messageThreshold) {
         //延迟超过短信报警的阀值
         $message = '您的job:房源库推送job(Mobile_NewPropsPush),数据处理延迟过高,有可能运行异常。当前最新ID为:' . $newestId . ',目前处理中的ID为:' . $nowId . '。';
         $this->sentMessage($message);
     }
     $this->setShStopFlag();
 }
Esempio n. 7
0
 /**
  * 获取本组中
  * @param $tasks
  *
  * @return array
  */
 protected function propMaxTaskIds($tasks)
 {
     $propMaxTaskIds = array();
     $propIds = array();
     foreach ($tasks as $task) {
         $propMaxTaskIds[$task->propId] = $task->id;
         $propIds[$task->propId] = $task->propId;
     }
     //过滤测试小区的房源
     if (!empty($_SERVER['PG_TEST'])) {
         //PG
         $testCommIds = APF::get_instance()->get_config('fyk_pg_test_commIds');
     } else {
         //GA
         $testCommIds = APF::get_instance()->get_config('fyk_ga_test_commIds');
     }
     $commIdInfos = Bll_Fyk_Prop_Manage::getInstance()->getCommIdsByPropIds($propIds);
     foreach ($commIdInfos as $commIdInfo) {
         if (in_array($commIdInfo['commId'], $testCommIds)) {
             unset($propMaxTaskIds[$commIdInfo['id']]);
         }
     }
     return $propMaxTaskIds;
 }
Esempio n. 8
0
 public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $propId = $this->_params['fPropId'];
     $source = $this->_params['source'];
     // 关闭购买房源
     $tmpTime = APF::get_instance()->get_config('fyk_onoff_time', 'fyk_common');
     if (time() >= strtotime($tmpTime)) {
         return array('status' => 'error', 'message' => "现在无法购买房源");
     }
     //判断用户是否有使用房源库的资格
     $hasAccess = Bll_Fyk_Prop_Action::getInstance()->hasFykAccess($userId);
     if ($hasAccess === false) {
         $ary = array("status" => "error", "errcode" => Const_APIStatus::E_FYK_USER_NO_ACCESS, "message" => '该用户没有权限');
         return $ary;
     }
     $result = Bll_Fyk_Prop_Manage::getInstance()->addUserProp($userId, $propId, $source);
     if ($result['status'] == true) {
         $ary = array("status" => "ok", "message" => "购买成功");
     } else {
         $ary = array("status" => "error", "errcode" => $result['errcode'], "message" => $result['msg']);
     }
     return $ary;
 }
Esempio n. 9
0
 public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $sinceId = isset($this->_params['sinceId']) ? $this->_params['sinceId'] : 0;
     $per = isset($this->_params['per']) ? $this->_params['per'] : 20;
     $per += 1;
     $hasNextPage = 0;
     $fPropId = array();
     $amountList = array();
     $logInfo = Bll_Fyk_Payment_Log::getInstance()->getLogInfoByUserIdOrderByIdDesc($userId, $per, $sinceId);
     if (!empty($logInfo)) {
         //判断是否有下一页
         if (isset($logInfo[$per - 1])) {
             $hasNextPage = 1;
             unset($logInfo[$per - 1]);
         }
         //房源数据获取
         foreach ($logInfo as $log) {
             $fPropId[] = $log['propId'];
         }
         $fPropId = array_unique($fPropId);
         $fPropInfo = Bll_Fyk_Prop_Manage::getInstance()->getPropInfo($fPropId);
         //获取app版本号
         $cv = 4.2;
         $chatInfos = Model_Mobile_BrokerChatInfo::getActiveBrokerIdsCV(array($this->_params['brokerId']));
         if (!empty($chatInfos)) {
             $chatInfo = $chatInfos[0];
             $response = Bll_Mobile_ChatInfoBll::getInstance()->apiGetChatInfoByCV($chatInfo['chatId']);
             $cv = $response['data']['result']['cv'];
         }
         //组装数据
         foreach ($logInfo as $log) {
             $list = array();
             $createTime = date('Y-m-d', $log['createTime']);
             list($comment, $content, $symbol, $clickAble) = $this->_loadingLogConfig(intval($log['type']));
             $amount = $this->_assemblyAmount($log['price'], $symbol);
             $type = $log['type'];
             $typeArr = array(Const_Fyk::THE_THIRD_PARTY_RECHARGE, Const_Fyk::THE_THIRD_PARTY_WITHDRAWAL, Const_Fyk::THE_THIRD_PARTY_WITHDRAWAL_FAILED);
             //4.3版本以下,做兼容处理 (支付宝提现,支付宝充值,支付宝提现失败,全部并入type=8)
             if ($cv < 4.3 && in_array($log['type'], $typeArr)) {
                 $type = 8;
             }
             $list['id'] = $log['id'];
             $list['amountType'] = $type;
             $list['comment'] = $comment;
             $list['content'] = $content;
             $list['amount'] = $amount;
             $list['amountUnit'] = '元';
             $list['fPropId'] = $log['propId'];
             $list['createTime'] = $createTime;
             $list['clickAble'] = $clickAble;
             $list['commName'] = '';
             $list['roomNum'] = '';
             $list['price'] = '';
             $list['priceUnit'] = '';
             $list['area'] = '';
             //获取房源基本信息
             if (empty($content)) {
                 if (!empty($fPropInfo[$log['propId']])) {
                     $commInfo = Bll_Community_APIComm::getInstance()->getInfoById($fPropInfo[$log['propId']]['commId']);
                     $list['commName'] = $commInfo['name'];
                     $list['roomNum'] = $fPropInfo[$log['propId']]['cell'];
                     $list['price'] = intval($fPropInfo[$log['propId']]['totalPrices']);
                     $list['priceUnit'] = '万';
                     $list['area'] = $fPropInfo[$log['propId']]['acreage'];
                 }
             }
             $amountList[] = $list;
         }
         //更新未读账户日志
         Bll_Fyk_Payment_Amount::getInstance()->updateUnReadNewAmountNum($userId);
     }
     $result = array('status' => 'ok', 'data' => array('amountList' => $amountList, 'hasNextPage' => $hasNextPage));
     return $result;
 }
Esempio n. 10
0
 /**
  * 纠正房源和变更房源状态时,添加数据
  * @param $userId
  * @param $propId
  * @param $updateData
  * @param $type
  * @param $source
  * @return array
  */
 public function addPropActionDataByEdit($userId, $propId, $updateData, $type, $source)
 {
     $result = array('status' => false, 'errcode' => '', 'msg' => '');
     if (empty($userId) || empty($propId) || empty($updateData) || empty($type) || empty($source)) {
         $result['errcode'] = Const_APIStatus::E_UNKNOWN;
         $result['msg'] = "参数不正确";
         return $result;
     }
     // 验证是否是我的房源
     $userPropData = Bll_Fyk_Prop_Manage::getInstance()->getUserPropByUserIdAndPropId($userId, $propId);
     if (empty($userPropData)) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_NOT_OWN;
         $result['msg'] = '无权限操作,不是经纪人房源';
         return $result;
     }
     //验证指定类型的操作是否已被他人提交过
     $typeModify = array(Const_Fyk::PROPTYPE_REPORT, Const_Fyk::PROPTYPE_NOSELL, Const_Fyk::PROPTYPE_SELLED);
     if (in_array($type, $typeModify)) {
         $hasBeenSubmitted = $this->getActionInfoByPropIdAndType($propId, $type);
         if (!empty($hasBeenSubmitted)) {
             $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_HAS_BEEN_SUBMITTED;
             $result['msg'] = '已经有人提交过了';
             return $result;
         }
     }
     // 获取房源基本信息
     $tmpPropData = Bll_Fyk_Prop_Manage::getInstance()->getPropInfo($propId);
     $propData = $tmpPropData[$propId];
     if (empty($tmpPropData) || empty($propData)) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_INFO_IS_NULL;
         $result['msg'] = '该房源不存在';
         return $result;
     }
     $updateArr = array();
     if ($updateData['status'] && $updateData['status'] != $propData['status']) {
         // 房源状态
         $updateArr['status'] = $updateData['status'];
     }
     if ($updateData['totalPrices'] && $updateData['totalPrices'] != $propData['totalPrices']) {
         $updateArr['totalPrices'] = $updateData['totalPrices'];
     }
     if ($updateData['cell'] && $updateData['cell'] != $propData['cell']) {
         $updateArr['cell'] = $updateData['cell'];
     }
     if ($updateData['acreage'] && $updateData['acreage'] != $propData['acreage']) {
         $updateArr['acreage'] = $updateData['acreage'];
     }
     if ($updateData['hall'] && $updateData['hall'] != $propData['hall']) {
         $updateArr['hall'] = $updateData['hall'];
     }
     if ($updateData['toilet'] && $updateData['toilet'] != $propData['toilet']) {
         $updateArr['toilet'] = $updateData['toilet'];
     }
     if ($updateData['orientation'] && $updateData['orientation'] != $propData['orientation']) {
         $updateArr['orientation'] = $updateData['orientation'];
     }
     if ($updateData['certificate'] && $updateData['certificate'] != $propData['certificate']) {
         $updateArr['certificate'] = $updateData['certificate'];
     }
     if ($updateData['isOnly'] && $updateData['isOnly'] != $propData['isOnly']) {
         $updateArr['isOnly'] = $updateData['isOnly'];
     }
     if ($updateData['floor'] && $updateData['floor'] != $propData['floor']) {
         $updateArr['floor'] = $updateData['floor'];
     }
     if ($updateData['totalFloor'] && $updateData['totalFloor'] != $propData['totalFloor']) {
         $updateArr['totalFloor'] = $updateData['totalFloor'];
     }
     if (empty($updateArr)) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_NO_CHANGE;
         $result['msg'] = '房源信息没有变化';
         return $result;
     }
     // 获取房源扩展信息
     $tmpPropExtendData = Bll_Fyk_Prop_Extend::getInstance()->getPropExtendInfo($propId);
     $propData['wish'] = '';
     $propData['saleReason'] = '';
     $propData['houseImages'] = array();
     if (!empty($tmpPropExtendData)) {
         $propExtendData = !empty($tmpPropExtendData[$propId]) ? $tmpPropExtendData[$propId] : array();
         if (!empty($propExtendData)) {
             $propData['wish'] = !empty($propExtendData['sale_desire']) ? $propExtendData['sale_desire'] : '';
             $propData['saleReason'] = !empty($propExtendData['sale_reason']) ? $propExtendData['sale_reason'] : '';
             $houseImages = array();
             if (!empty($propExtendData['image'])) {
                 foreach ($propExtendData['image'] as $val) {
                     if ($val) {
                         $tmp = explode("_", $val);
                         $houseImages[] = array('hash' => $tmp[0], 'host' => $tmp[1]);
                     }
                 }
             }
             $propData['houseImages'] = $houseImages;
         }
     }
     $body = array('base' => $propData, 'edit' => $updateArr);
     $addArr = array('cityId' => !empty($propData['cityId']) ? $propData['cityId'] : 0, 'userId' => $userId, 'propId' => $propId, 'status' => 0, 'source' => $source, 'type' => $type, 'body' => json_encode($body), 'createTime' => time(), 'updateTime' => date("Y-m-d H:i:s", time()));
     $addResult = $this->insertData($addArr);
     if (empty($addResult)) {
         $result['errcode'] = Const_APIStatus::E_FYK_PROP_ACTION_ADD_FAILURE;
         $result['msg'] = '添加失败';
         return $result;
     } else {
         $result['status'] = true;
         return $result;
     }
 }
Esempio n. 11
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);
 }
Esempio n. 12
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);
 }
Esempio n. 13
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' => '抢成功!快去联系业主吧');
 }