コード例 #1
0
 public function handle_request_internal()
 {
     $bll = new Bll_Customer_RobUser();
     $deviceId = $this->_params['device_id'];
     $brokerId = $this->_params['broker_id'];
     if (($status = $bll->getAppUserStatus($deviceId, $brokerId)) < 0) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => $status, 'message' => $bll->errorMsg);
     }
     switch ($status) {
         case Const_RobUser::USER_STATUS_NO_ROBED:
             $messgae = Const_RobUser::USER_STATUS_MSG_NO_ROBED;
             break;
         case Const_RobUser::USER_STATUS_SELF_ROBED:
             $messgae = Const_RobUser::USER_STATUS_MSG_SELF_ROBED;
             break;
         case Const_RobUser::USER_STATUS_OTHER_ROBED:
             $messgae = Const_RobUser::USER_STATUS_MSG_OTHER_ROBED;
             break;
         case Const_RobUser::USER_STATUS_LOCKED:
             $messgae = Const_RobUser::USER_STATUS_MSG_LOCKED;
             break;
         case Const_RobUser::BROKER_STATUS_FULL:
             $messgae = Const_RobUser::BROKER_STATUS_MSG_FULL;
             break;
         default:
             $messgae = '已抢完';
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('device_id' => $deviceId, 'status' => $status, 'message' => $messgae));
 }
コード例 #2
0
ファイル: UserDetail.php プロジェクト: emilymwang8/ajk-broker
 public function handle_request_internal()
 {
     $bll = new Bll_Customer_RobUser();
     $deviceId = $this->_params['device_id'];
     $brokerId = $this->_params['broker_id'];
     if (($data = $bll->getAppUserDetail($deviceId, $brokerId)) == false) {
         return array('status' => Const_APIStatus::RETURN_CODE_ERROR, 'errcode' => $bll->errorCode, 'message' => $bll->errorMsg);
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
 }
コード例 #3
0
ファイル: SendProp.php プロジェクト: emilymwang8/ajk-broker
 public function handle_request_internal()
 {
     $brokerId = $this->_params['broker_id'];
     $deviceId = $this->_params['device_id'];
     $houseBody = $this->_params['house_body'];
     $modelBody = $this->_params['model_body'];
     $authToken = $this->_params['auth_token'];
     $sendPropMsgFault = array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('status' => self::SEND_PROP_MESSAGE_FAULT, 'house' => array('status' => 'error', 'msg_id' => 0, 'error_code' => 0, 'error_message' => '发送消息失败'), 'model' => array('status' => 'error', 'msg_id' => 0, 'error_code' => 0, 'error_message' => '发送消息失败')));
     if (false === Bll_Customer_Parallel::lockBroker($brokerId)) {
         $sendPropMsgFault['data']['description'] = '经纪人并发锁失败';
         return $sendPropMsgFault;
     }
     if (false == Bll_Customer_Parallel::lockUser($deviceId)) {
         Bll_Customer_Parallel::unlockBroker($deviceId);
         $sendPropMsgFault['data']['description'] = '用户并发锁失败';
         return $sendPropMsgFault;
     }
     $this->needReleaseLock = true;
     $brokerUserRelationInfo = Bll_Customer_BrokerUserRelation::getBrokerUserRelationInfo($deviceId, $brokerId);
     if ($brokerUserRelationInfo['status'] != Model_Mobile_BrokerUserRelation::STATUS_TMP_LOCKED) {
         $sendPropMsgFault['data']['description'] = '经纪人和用户不是锁定关系';
         return $sendPropMsgFault;
     }
     $brokerCanSendMsg = false;
     $tempLockTime = strtotime($brokerUserRelationInfo['tempLockTime']);
     if ($tempLockTime >= time() - Bll_Customer_Lock::BROKER_LOCK_EXPIRE) {
         $brokerCanSendMsg = true;
     } else {
         /** 这一段走不到这个状态 */
         $sendPropMsgFault['data']['status'] = self::SEND_PROP_MESSAGE_USER_EXPIRE;
         $sendPropMsgFault['data']['description'] = '用户锁定已过期';
     }
     /** TODO 判断用户是否设置了不可以打招呼 */
     $oRobUser = new Bll_Customer_RobUser();
     if (false == $oRobUser->checkIfUserChat($brokerUserRelationInfo['appName'], $brokerUserRelationInfo['userDeviceId2'], $brokerUserRelationInfo['guid'], $brokerUserRelationInfo['macId'])) {
         $sendPropMsgFault['data']['status'] = self::SEND_PROP_MESSAGE_USER_HAS_MAX_LOCK;
         $sendPropMsgFault['data']['description'] = '用户已被抢完';
         return $sendPropMsgFault;
     }
     /** 临时锁定过期以后,如果用户还没有被抢走且经纪人还可以抢 则发布房源成功 */
     if ($brokerCanSendMsg == false) {
         if (false == Bll_Customer_Lock::checkUserCanBind($deviceId)) {
             $sendPropMsgFault['data']['status'] = self::SEND_PROP_MESSAGE_USER_HAS_MAX_LOCK;
             $sendPropMsgFault['data']['description'] = '用户已被抢完';
             return $sendPropMsgFault;
         }
         if (false == Bll_Customer_Lock::checkBrokerCanBind($brokerId)) {
             $sendPropMsgFault['data']['status'] = self::SEND_PROP_MESSAGE_BROKER_HAS_MAX_LOCK;
             $sendPropMsgFault['data']['description'] = '今天您已抢满3次';
             return $sendPropMsgFault;
         }
         $brokerCanSendMsg = true;
     }
     /** 更新经纪人用户关系状态成功,对经纪人和用户的永久绑定次数做+1成功则 发送房源 */
     if ($brokerCanSendMsg && $this->lockCustomer($deviceId, $brokerId)) {
         /** TODO 发布房源 只要房源发送成功就OK 不管系统消息发送是否成功 */
         $sendPropMsgResult = $this->sendHouseMsg($authToken, $houseBody);
         if (strcasecmp($sendPropMsgResult['data']['status'], 'error') == 0) {
             $this->unlockCustomer($deviceId, $brokerId);
             $sendPropMsgFault['data']['description'] = '发送房源失败';
             $sendPropMsgFault['data']['status'] = self::SEND_PROP_MESSAGE_FAULT;
             $sendPropMsgFault['data']['house']['message_id'] = $sendPropMsgResult['data']['result']['msg_id'];
             $sendPropMsgFault['data']['house']['error_code'] = $sendPropMsgResult['data']['errorCode'];
             $sendPropMsgFault['data']['house']['error_message'] = $sendPropMsgResult['data']['errorMessage'];
             return $sendPropMsgFault;
         }
         $sendModelMsgResult = $this->sendHouseMsg($authToken, $modelBody);
         return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('status' => self::SEND_PROP_MESSAGE_SUCCESS, 'house' => array('status' => 'ok', 'message_id' => $sendPropMsgResult['data']['result']['msg_id'], 'error_code' => $sendPropMsgResult['data']['errorCode'], 'error_message' => $sendPropMsgResult['data']['errorMessage']), 'model' => array('status' => strtolower($sendModelMsgResult['data']['status']), 'message_id' => $sendModelMsgResult['data']['result']['msg_id'], 'error_code' => $sendModelMsgResult['data']['errorCode'], 'error_message' => $sendModelMsgResult['data']['errorMessage'])));
     }
     return $sendPropMsgFault;
 }