public function handle_request_internal() { header("Access-Control-Allow-Origin: *"); $propId = $this->_params['propId']; //好丑陋。。。。。。好无奈。。。。。。 //委托房源自动转发停用,为了app能够展示报错信息。。。 if (empty($propId)) { $this->_params['apiDebug'] = 1; return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => '0000', 'message' => '委托房源自动转发功能已停用;若要发布请手动发布'); } $propInfo = Bll_Ppc_ServiceAPI::getHouseInfo($propId); $brokerId = $this->_params['brokerId']; $houseInfo = Model_House_EsfHouseElementFactory::getHouseBaseInfo($propId); if (empty($houseInfo)) { $cityId = Model_Broker_AjkBrokerExtend::getCityIdByBrokerId($this->_params['brokerId']); $houseInfo = Bll_House_EsfHouse::getHouseBaseInfo($propId, $cityId); } if (!empty($houseInfo)) { $result['status'] = 'ok'; $areaCode = $houseInfo['areaCode']; $block = Bll_Commtype_Api::getInfoByTypeCode($areaCode); $area = Bll_Commtype_Api::getInfoByTypeId($block['parentId']); $area_name = $area['typeName']; $block_name = $block['typeName']; $data['title'] = $houseInfo['proName']; $data['commId'] = $houseInfo['commId']; $data['commName'] = $houseInfo['commName']; //小区信息 $commInfo = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($data['commId'], 2); $data['commLocation'] = $commInfo['commLocal']; $data['sosolat'] = $commInfo['sosolat']; //纬度 $data['sosolng'] = $commInfo['sosolng']; //经度 $data['floor'] = $propInfo['property']['ProFloor']; $data['totalFloor'] = $propInfo['property']['FloorNum']; $propDescription = $propInfo['property']['sale']['AddExplan']; $propDescription = str_replace('<p>', "", $propDescription); $propDescription = str_replace('</p>', "", $propDescription); $propDescription = trim($propDescription); $data['propDescription'] = $propDescription; $data['areaname'] = $area_name; $data['blockname'] = $block_name; $data['roomNum'] = $houseInfo['roomNum']; $data['hallNum'] = $houseInfo['hallNum']; $data['toiletNum'] = $houseInfo['toiletNum']; $data['area'] = $houseInfo['areaNum']; $data['areaUnit'] = '平米'; $data['price'] = $houseInfo['proPrice']; $data['priceUnit'] = '万'; $data['isMoreImg'] = $houseInfo['isHighQulity']; $data['isVisible'] = $houseInfo['isVisible']; $data['isPhonePub'] = $houseInfo['uriCode'] == 'mobile.asyn' || $houseInfo['uriCode'] == 'mobile-ajk-broker.asyn' ? 1 : 0; $data['propImagesUrl'] = array(); $data['propImages'] = $data['outdoorImage'] = array(); if ($propInfo['attachments']['attachments']) { $propImageNum = 0; $outdoorImageNum = 0; $images = $propInfo['attachments']['attachments']; foreach ($images as $image) { if ($image['DataType'] == 2) { if ($propImageNum >= 8) { continue; } $imageInfo = array(); $url = Util_ImageUtils::getResizeURL($image['FileName'], $image['host_id'], 600, 600); $url = str_replace("display", "display/e", $url); $imageInfo['bigImageUrl'] = $url; $data['propImages'][] = $imageInfo; $propImageNum += 1; } else { if ($image['DataType'] == 3) { if ($outdoorImageNum >= 1) { continue; } $imageInfo = array(); $url = Util_ImageUtils::getResizeURL($image['FileName'], $image['host_id'], 600, 600); $url = str_replace("display", "display/e", $url); $imageInfo['bigImageUrl'] = $url; $data['outdoorImage'][] = $imageInfo; $outdoorImageNum += 1; } } } } $spread = Model_Plan_AjkPropspread::getAjkPropSpreadByIds($propId); $data['isChoice'] = $data['isBid'] = 0; if (!empty($spread)) { if ($spread[0]['bidVersion'] == 1 && $spread[0]['status'] == 1) { $data['isBid'] = 1; } elseif ($spread[0]['bidVersion'] == 2 && ($spread[0]['status'] == 1 || $spread[0]['status'] == 11)) { $data['isChoice'] = 1; } } //计算出房源推广天数 $timeFixStr = strtotime(date("Ymd", $houseInfo['postDate'])); $leftDay = floor((time() - $timeFixStr) / 86400); $data['publishDaysMsg'] = $leftDay > 0 ? $leftDay . '天前发布' : '今天发布'; $imgBll = Bll_Image_EsfHouseImage::getInstance(); $data['imgUrl'] = $imgBll->getThumbImageUrl($propId, $houseInfo['commId']); $mobileBaseDomain = APF::get_instance()->get_config("mobile_base_domain"); $data['url'] = 'http://' . $mobileBaseDomain . '/sale/x/' . $houseInfo['cityId'] . '/' . $houseInfo->proId; //增加委托房源标签 if ($houseInfo['commitionType'] == 2) { $data['isEntrust'] = 1; } else { $data['isEntrust'] = 0; } } else { $data['status'] = 'error'; $data['message'] = '房源信息不存在'; } $result['data'] = $data; return $result; }
public function handle_request() { //取任务 weshop_prop_queue 表中status 为0; $props = Model_Weshop_PropQueue::getProps($this->per); //处理任务 foreach ($props as $prop) { //weshop_prop_queue 表中status 为1; Model_Weshop_PropQueue::updatePropStatus($prop, Model_Weshop_PropQueue::PROP_START); $propInfo = Bll_Ppc_ServiceAPI::getHouseInfo($prop['propId']); $params = array(); $params['cityId'] = $prop['cityId']; $params['commId'] = $propInfo['property']['CommId']; $params['brokerId'] = $prop['brokerId']; $params['areaId'] = substr($propInfo['property']['AreaCode'], 0, 8); $params['blockId'] = $propInfo['property']['AreaCode']; $params['price'] = $propInfo['property']['ProPrice']; $params['acreage'] = $propInfo['property']['AreaNum']; $params['room'] = $propInfo['property']['RoomNum']; $params['hall'] = $propInfo['property']['HallNum']; $params['toilet'] = $propInfo['property']['ToiletNum']; $propDescription = $propInfo['property']['sale']['AddExplan']; $propDescription = str_replace('<p>', "", $propDescription); $propDescription = str_replace('</p>', "", $propDescription); $propDescription = trim($propDescription); $params['description'] = json_encode($propDescription); $params['title'] = $propInfo['property']['ProName']; $params['floor'] = $propInfo['property']['ProFloor']; $params['totalFloor'] = $propInfo['property']['FloorNum']; $params['status'] = 1; $params['createTime'] = date('Y-m-d H:i:s', time()); $params['updateTime'] = date('Y-m-d H:i:s', time()); $result = Model_Weshop_Props::insertWeshopProps($params); //更新weshop_prop_queue 表中status; if (!$result) { Model_Weshop_PropQueue::updatePropStatus($prop, Model_Weshop_PropQueue::PROP_FAILED); //导入失败 } else { Model_Weshop_PropQueue::updatePropStatus($prop, Model_Weshop_PropQueue::PROP_SUCCESS); //导入成功 $tmp = array('weshopPropId' => $result->id, 'brokerId' => $prop['brokerId'], 'propId' => $prop['propId']); Model_Weshop_PropsFilter::insertRecord($tmp); } //存储图片 默认图 区分 室内图8张 户型图 1张 if ($propInfo['attachments']['attachments']) { $propImageNum = 0; $outdoorImageNum = 0; $images = $propInfo['attachments']['attachments']; foreach ($images as $image) { if ($image['DataType'] == 2) { if ($propImageNum >= 8) { continue; } if ($propImageNum == 0) { $img_params['isDefault'] = 1; } else { $img_params['isDefault'] = 0; } $img_params['imageType'] = 1; //室内图 $propImageNum += 1; } else { if ($image['DataType'] == 3) { if ($outdoorImageNum >= 1) { continue; } $img_params['imageType'] = 2; //户型图 $outdoorImageNum += 1; } } $img_params['propId'] = $result->id; $img_params['imageHostId'] = $image['host_id']; $img_params['imageHash'] = $image['FileName']; $img_params['isDelete'] = 0; $img_params['createTime'] = date('Y-m-d H:i:s', time()); $img_params['updateTime'] = date('Y-m-d H:i:s', time()); //存储图片 Model_Weshop_PropImages::insertWeshopPropImages($img_params); } } } }
public function handle_request_internal() { if (Bll_Weshop::weshopPropsIsMaintain()) { return array('status' => 'error', 'message' => "系统维护中,请稍后再试!"); } header("Access-Control-Allow-Origin: *"); $brokerId = $this->_params['brokerId']; $propIds = explode(',', $this->_params['propIds']); $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId); if (!$brokerInfo) { throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS); } //房源表查寻后 添加到队列表 $propsInfos = Bll_House_EsfHouse::getHouseBaseInfo($propIds, $brokerInfo->cityId); if (count($propIds) == 1) { //插入 房源列表 并返回 $propInfo = Bll_Ppc_ServiceAPI::getHouseInfo($propIds[0]); if ($propInfo) { $params = array(); $params['cityId'] = $propInfo['property']['CityId']; $params['commId'] = $propInfo['property']['CommId']; $params['brokerId'] = $brokerId; $params['areaId'] = substr($propInfo['property']['AreaCode'], 0, 8); $params['blockId'] = $propInfo['property']['AreaCode']; $params['price'] = $propInfo['property']['ProPrice']; $params['acreage'] = $propInfo['property']['AreaNum']; $params['room'] = $propInfo['property']['RoomNum']; $params['hall'] = $propInfo['property']['HallNum']; $params['toilet'] = $propInfo['property']['ToiletNum']; $propDescription = $propInfo['property']['sale']['AddExplan']; $propDescription = str_replace('<p>', "", $propDescription); $propDescription = str_replace('</p>', "", $propDescription); $propDescription = trim($propDescription); $params['description'] = json_encode($propDescription); $params['title'] = $propInfo['property']['ProName']; $params['floor'] = $propInfo['property']['ProFloor']; $params['totalFloor'] = $propInfo['property']['FloorNum']; $params['status'] = 1; $params['createTime'] = date('Y-m-d H:i:s', time()); $params['updateTime'] = date('Y-m-d H:i:s', time()); $result = Model_Weshop_Props::insertWeshopProps($params); //存储图片 默认图 区分 室内图8张 户型图 1张 $imageUrl = ''; if ($propInfo['attachments']['attachments']) { $propImageNum = 0; $outdoorImageNum = 0; $images = $propInfo['attachments']['attachments']; foreach ($images as $image) { if ($image['DataType'] == 2) { if ($propImageNum >= 8) { continue; } if ($propImageNum == 0) { $img_params['isDefault'] = 1; //默认图 $url = Util_ImageUtils::getResizeURL($image['FileName'], $image['host_id'], 290, 240); //(拼好小图) $imageUrl = str_replace("240", "240c", $url); //无水印格式 } else { $img_params['isDefault'] = 0; } $img_params['imageType'] = 1; //室内图 $propImageNum += 1; } else { if ($image['DataType'] == 3) { if ($outdoorImageNum >= 1) { continue; } $img_params['imageType'] = 2; //户型图 $outdoorImageNum += 1; } } $img_params['propId'] = $result->id; $img_params['imageHostId'] = $image['host_id']; $img_params['imageHash'] = $image['FileName']; $img_params['isDelete'] = 0; $img_params['createTime'] = date('Y-m-d H:i:s', time()); $img_params['updateTime'] = date('Y-m-d H:i:s', time()); //存储图片 Model_Weshop_PropImages::insertWeshopPropImages($img_params); } } if ($result) { //插入 weshop_prop_ext表 $tmp = array('weshopPropId' => $result->id, 'brokerId' => $brokerId, 'propId' => $propIds[0]); Model_Weshop_PropsFilter::insertRecord($tmp); //区域板块 $areaAndBlockIds = array(); $areaId = $params['areaId']; $blockId = $params['blockId']; $areaAndBlockIds[] = $areaId; $areaAndBlockIds[] = $blockId; $commTypeInfos = Bll_Community_CommunityGardener::getCommTypeInfo($areaAndBlockIds); $previewUrl = Bll_Weshop::getPropPreviewUrl(array('brokerId' => $brokerId, 'propId' => $result->id)); return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('propId' => $result->id, 'title' => $propInfo['property']['ProName'], 'areaName' => $commTypeInfos[$areaId], 'blockName' => $commTypeInfos[$blockId], 'commId' => $propInfo['property']['CommId'], 'commName' => $propInfo['property']['CommName'], 'room' => $propInfo['property']['RoomNum'], 'hall' => $propInfo['property']['HallNum'], 'toilet' => $propInfo['property']['ToiletNum'], 'price' => $propInfo['property']['ProPrice'], 'priceUnit' => '万', 'area' => $propInfo['property']['AreaNum'], 'areaUnit' => '平米', 'propDescription' => $propDescription, 'previewUrl' => $previewUrl, 'imageUrl' => $imageUrl)); } } } //插入队列表 foreach ($propsInfos as $propsInfo) { if ($propsInfo['brokerId'] == $brokerId) { $params = array(); $params['brokerId'] = $brokerId; $params['propId'] = $propsInfo['proId']; $params['cityId'] = $brokerInfo->cityId; $params['status'] = 0; $params['addTime'] = date('Y-m-d H:i:s', time()); $params['updateTime'] = date('Y-m-d H:i:s', time()); Model_Weshop_PropQueue::insertWeshopPropQueue($params); } } return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('message' => '导入成功')); }