コード例 #1
0
ファイル: AjkLibrary.php プロジェクト: emilymwang8/ajk-broker
 public function handle_request_internal()
 {
     $request = APF::get_instance()->get_request();
     $params = $request->get_parameters();
     $fields = array('commId', 'roomNum', 'hallNum', 'toiletNum', 'houseOri');
     $apiParams = array();
     foreach ($fields as $field) {
         if (!isset($params[$field])) {
             $this->responseJSON('error', array(), '参数不全');
             return;
         }
         $apiParams[$field] = $params[$field];
     }
     $data = array('MODELPIC' => array(), 'COMMPIC' => array());
     $apiParams['houseOri'] = Bll_House_EsfPublish::getPropOrigin($apiParams['houseOri']);
     try {
         /**
          * @var $result Bll_Service_Client_HttpResponse
          */
         $result = Bll_Service_Image::esfGetImgInfo($apiParams);
         if ($result->isFailed()) {
             $this->responseJSON('error', $data, '调用API超时');
             return;
         }
         if ($result['status'] != 'ok') {
             $this->responseJSON('error', $data, '调用API失败');
             return;
         }
         /** 房型图 */
         $modelPicAIds = array();
         if (isset($result['publicPicResult']['fineImg']['count']) && isset($result['publicPicResult']['fineImg']['list'])) {
             foreach ($result['publicPicResult']['fineImg']['list'] as $imageInfo) {
                 $modelPicAIds[] = $imageInfo['Aid'];
             }
         }
         if (isset($result['publicPicResult']['readyImg']['count']) && isset($result['publicPicResult']['readyImg']['list'])) {
             foreach ($result['publicPicResult']['readyImg']['list'] as $imageInfo) {
                 $modelPicAIds[] = $imageInfo['Aid'];
             }
         }
         if (!empty($modelPicAIds)) {
             $modelImageList = Model_Community_Attachment::getImageInfoById($modelPicAIds, array('aid', 'fileName', 'hostId'));
             foreach ($modelImageList as $imageInfo) {
                 $imageInfo['AID'] = intval($imageInfo['aid']);
                 $imageInfo['commPicId'] = intval($imageInfo['aid']);
                 $imageInfo['IMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['fileName'], $imageInfo['hostId'], 100, 75);
                 $imageInfo['BIGIMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['fileName'], $imageInfo['hostId'], 600, 600);
                 $data['MODELPIC'][] = $imageInfo;
             }
         }
         if (isset($result['publicPicResult']['othResult']['count']) && isset($result['publicPicResult']['othResult']['attachmentsComm'])) {
             foreach ($result['publicPicResult']['othResult']['attachmentsComm'] as $imageInfo) {
                 $imageInfo['AID'] = intval($imageInfo['Aid']);
                 $imageInfo['commPicId'] = intval($imageInfo['Aid']);
                 $imageInfo['IMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 100, 75);
                 $imageInfo['BIGIMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 600, 600);
                 $data['MODELPIC'][] = $imageInfo;
             }
         }
         /** 小区图 */
         if (isset($result['publicPicResult']['commPic']['count']) && isset($result['publicPicResult']['commPic']['attachmentsComm'])) {
             foreach ($result['publicPicResult']['commPic']['attachmentsComm'] as $imageInfo) {
                 $imageInfo['AID'] = intval($imageInfo['Aid']);
                 $imageInfo['commPicId'] = intval($imageInfo['Aid']);
                 $imageInfo['IMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 100, 75);
                 $imageInfo['BIGIMGURL'] = Util_ImageUtils::getResizeURL($imageInfo['FileName'], $imageInfo['host_id'], 600, 600);
                 $data['COMMPIC'][] = $imageInfo;
             }
         }
         $data['MODELPIC'] = array_slice($data['MODELPIC'], 0, 10);
         $data['COMMPIC'] = array_slice($data['COMMPIC'], 0, 20);
         $this->responseJSON('ok', $data, '');
     } catch (Exception $e) {
         $this->responseJSON('error', $data, $e->getMessage());
     }
 }