/** * 获取经纪人我的房源 * @param $userId * @param $status * @param $orderBy * @param $sort * @param int $limit * @param int $sinceId * @param string $upOrDown * @return mixed */ public function getUserPropsByUserIdAndSinceId($userId, $status, $orderBy, $sort, $limit = 20, $sinceId = 0, $upOrDown = 'down') { $list = Model_Fyk_UserProps::getInstance()->getDataByUserIdAndSinceId($userId, $status, $orderBy, $sort, $limit, $sinceId, $upOrDown); $result = array(); if (!empty($list)) { $propIds = array(); foreach ($list as $val) { $propIds[] = $val['propId']; } $propInfos = $this->getPropInfo($propIds); // 获取房源信息 $propExtendInfos = Bll_Fyk_Prop_Extend::getInstance()->getPropExtendInfo($propIds); // 获取房源扩展信息 $cInfo = array(); foreach ($list as $val) { $propInfo = $propInfos[$val['propId']]; // 单个房源信息 $propExtendInfo = $propExtendInfos[$val['propId']]; // 单个房源扩展信息 if (empty($propInfo)) { continue; } if (empty($cInfo[$propInfo['commId']])) { $cInfo[$propInfo['commId']] = Bll_Community_APIComm::getInstance()->getInfoById($propInfo['commId']); } //print_r($cInfo[$propInfo['commId']]);exit; $commInfo = $cInfo[$propInfo['commId']]; $result[] = array('id' => $val['id'], 'fPropId' => $propInfo['id'], 'commId' => $propInfo['commId'], 'commName' => $commInfo['name'], 'buildNum' => $propInfo['buildNum'], 'houseNum' => $propInfo['roomNum'], 'roomNum' => $propInfo['cell'], 'hallNum' => $propInfo['hall'], 'toiletNum' => $propInfo['toilet'], 'area' => $propInfo['acreage'], 'price' => intval($propInfo['totalPrices']), 'priceUnit' => '万元', 'ownerName' => $propInfo['ownerName'], 'ownerMobile' => $propInfo['mobile'], 'is400' => 0, 'owner400host' => '', 'owner400' => '', 'isUserRush' => $val['comeFrom'] == 1 ? 1 : 0, 'houseStatus' => $propInfo['status'], 'houseStatusName' => $this->getPropStatusName($propInfo['status']), 'createTime' => date("Y-m-d H:i:s", $val['createTime'])); } } return $result; }
public static function &getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
public function handle_request_internal() { $fPropId = $this->_params['fPropId']; $userId = $this->_params['userId']; //获取房源库房源数据 $fpropObj = Model_Fyk_PropLibrary::getDataById($fPropId); $fPropInfo = $fpropObj[0]; $fPropInfoExtend = Bll_Fyk_Prop_Extend::getInstance()->getPropExtendInfo($fPropId); //查询用户是否购买这套房源 $isBuy = $this->isBuyProp($userId, $fPropId); //组装数据 $data = $this->dataCheck($fPropInfo, $fPropInfoExtend[$fPropId], $isBuy); $result = array('status' => 'ok', 'data' => $data); return $result; }
/** * 纠正房源和变更房源状态时,添加数据 * @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; } }