Esempio n. 1
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $usrCardState = $brokerInfo->usrCardState;
     $usrPhotoState = $brokerInfo->usrPhotoState;
     $photoFileJson = json_decode($this->_params['photoFile'], true);
     $size = $photoFileJson['size'];
     $format = $photoFileJson['format'];
     if ($size > 1048576) {
         throw new Exception_Broker_UpLoadFailed('头像图片不得大于1M');
     } elseif (!in_array($format, array('JPEG', 'JPG', 'GIF', 'PNG'))) {
         throw new Exception_Broker_UpLoadFailed('图片限jpg、jpeg、gif、png格式');
     }
     $photoFile = 'display/' . $photoFileJson['hash'] . '_' . $photoFileJson['host'];
     //调用上传头像的接口
     $setNewPhoto = Bll_BrokerBaseBll::setNewPhoto($brokerId, $photoFile);
     if ($setNewPhoto == 1) {
         if ($usrCardState == 1 || $usrCardState == 2) {
             Bll_Broker_BrokerCheckInfo::autoSendPass($brokerId);
         }
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('status' => 1));
     } else {
         throw new Exception_Broker_UpLoadApiFailed($setNewPhoto['message']);
     }
 }