예제 #1
0
 public function handle_request_internal()
 {
     $isAllowIp = self::is_allow_call_api();
     if (!$isAllowIp) {
         $ret = Util_MobileAPI::error(Const_APIStatus::E_CALL_API_ERROR);
     }
     if (!isset($this->_params["toPhone"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PARAM_MISS);
     }
     if (!isset($this->_params["msg"])) {
         return Util_MobileAPI::error(Const_APIStatus::E_PARAM_MISS);
     }
     $mobile = (int) $this->_params["toPhone"];
     $msg = Util_StringUtils::truncate($this->_params["msg"], 18, '...');
     $ret = array('status' => 'ok', 'data' => 'success');
     if (1 == $this->_params["chatFlag"]) {
         if (!isset($this->_params["userMobile"])) {
             return Util_MobileAPI::error(Const_APIStatus::E_PARAM_MISS);
         }
         $downloadUrl = 'http://t.anjuke.com/swzZMCV';
         $msg = '"' . $msg . '",安居客用户' . substr($this->_params["userMobile"], 0, 3) . '****' . substr($this->_params["userMobile"], 7) . '找您,与TA聊天,请安装经纪人APP:' . $downloadUrl;
         //更新经纪人微聊表发送短信数目
         $chatInfo = Model_Mobile_BrokerChatInfo::getBrokerByPhone($mobile, array('brokerId', 'phone', 'sendMsgNum', 'isActived'));
         if ($chatInfo) {
             $brokerId = $chatInfo['brokerId'];
             if ($chatInfo['sendMsgNum'] < 10 && 0 == $chatInfo['isActived']) {
                 //更新经纪人微聊信息表的数据
                 $updateData['brokerId'] = $chatInfo['brokerId'];
                 $updateData['sendMsgNum'] = $chatInfo['sendMsgNum'] + 1;
                 $updateData['updateTime'] = time();
                 Model_Mobile_BrokerChatInfo::updateChatInfo($chatInfo['brokerId'], $updateData);
             } else {
                 return $ret;
             }
         } else {
             return Util_MobileAPI::error(Const_APIStatus::E_BROKER_CHAT_NOT_EXISIT);
         }
     }
     //发送短信
     $business_id = SMS_API::BROKER_APP_MSG_CODE;
     $sms_api = SMS_API::get_instance();
     $sms_api->send($mobile, $msg, $business_id, $brokerId);
     return $ret;
 }
예제 #2
0
 public static function setBrokerSms($brokerid, $usermobile, $content)
 {
     apf_require_class("SMS_API");
     $sms_api = SMS_API::get_instance();
     $is_ok = $sms_api->send($usermobile, $content);
     return $is_ok;
 }