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);
             }
         }
     }
 }
Beispiel #2
0
 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' => '导入成功'));
 }