Пример #1
0
 public function handle_request_internal()
 {
     header("Access-Control-Allow-Origin: *");
     $userMobile = $this->_params['userMobile'];
     //检测电话号码格式是否正确
     if (strlen($userMobile) != 11) {
         throw new Exception_Broker_BrokerMobileFormatError('电话号码格式错误', Const_APIStatus::E_BROKER_MOBILE_FORMAT_ERROR);
     }
     $brokerInfo = Model_Broker_AjkBrokerExtend::getBrokerInfoByMobile($userMobile);
     if (!$brokerInfo) {
         throw new Exception_Broker_BrokerNotVerified('经纪人不存在', Const_APIStatus::E_BROKER_MOBILE_SEARCH_ERROR);
     }
     if ($brokerInfo->checkState != 1) {
         throw new Exception_BrokerNotFoundException('经纪人审核未通过', Const_APIStatus::E_BROKER_MOBILE_SEARCH_NOT_VERIFIED);
     }
     //查询微聊信息
     $chatInfo = Bll_Mobile_ChatInfoBll::getInstance()->onlyGetChatInfo($brokerInfo->brokerId);
     $re = array();
     $re['brokerId'] = $brokerInfo->brokerId;
     $re['companyInfo'] = $brokerInfo->company;
     $re['trueName'] = $brokerInfo->trueName;
     $re['userMobile'] = $brokerInfo->userMobile;
     $re['userPhoto'] = Util_ImageUtils::get_broker_photo_url($brokerInfo->userPhoto, '200x200');
     $re['chatId'] = $chatInfo['data']['chatId'];
     $re['twoCodeIcon'] = $chatInfo['data']['twoCodeIcon'];
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $re);
 }
Пример #2
0
 public function handle_request_internal()
 {
     /**
      * 00:00
      *  获取前一天20:00 以后
      * 10:00
      *  获取10:00 以后
      * 15:00
      *  获取15:00 以后
      * 20:00
      *  获取20:00 以后
      *
      */
     // 获取参数;
     $commId = $this->_params['commId'];
     // 根据ID获取小区
     $community = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($commId, 2);
     if (!$community || !$community['sosolat'] || !$community['sosolng']) {
         throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $data = array();
     if (Bll_Broker_CommunitySign::isTopSignerActivityOngoing()) {
         $hour = intval(date('H'));
         if ($hour >= 0 && $hour < 10) {
             $theSignRange = array(date('Y-m-d 20:00:00', strtotime('-1 day')), date('Y-m-d 23:59:59', strtotime('-1 day')));
         } elseif ($hour >= 10 && $hour < 15) {
             $theSignRange = array(date('Y-m-d 10:00:00'), date('Y-m-d 14:59:59'));
         } elseif ($hour >= 15 && $hour < 20) {
             $theSignRange = array(date('Y-m-d 15:00:00'), date('Y-m-d 19:59:59'));
         } else {
             $theSignRange = array(date('Y-m-d 20:00:00'), date('Y-m-d 23:59:59'));
         }
         $brokerInfos = Bll_Commsign::getFirstThr($commId, $theSignRange[0]);
         //var_dump($data);exit;
         $data = array();
         if (!empty($brokerInfos)) {
             foreach ($brokerInfos as $k => $v) {
                 $brokerTmp = Bll_Commsign::getBrokerInfo($v['brokerId']);
                 if (!$brokerTmp) {
                     $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $v['brokerId'])->find_only();
                     $broker_photo = Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200');
                     $brokerTmp = array('brokerId' => $broker['brokerId'], 'username' => $broker['trueName'], 'userPhoto' => $broker_photo, 'cityId' => $broker['cityId']);
                     Bll_Commsign::redisBrokerInfo($v['brokerId'], $brokerTmp);
                 }
                 if (empty($brokerTmp['userPhoto'])) {
                     $brokerTmp['userPhoto'] = PageHelper::pure_static_url('/img/bknoimg.gif');
                 }
                 $dataTmp = array('brokerId' => $brokerTmp['brokerId'], 'brokerTrueName' => $brokerTmp['username'], 'brokerPhoto' => $brokerTmp['userPhoto']);
                 $data[] = $dataTmp;
             }
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
 }
Пример #3
0
 public function handle_request_internal()
 {
     header("Access-Control-Allow-Origin: *");
     $lng = $this->_params['lng'];
     $lat = $this->_params['lat'];
     $brokerId = $this->_params['brokerId'];
     $radius = isset($this->_params['radius']) ? $this->_params['radius'] : 3000;
     // 搜索半径,默认3000米
     $total = isset($this->_params['total']) ? $this->_params['total'] : 100;
     // 最大总数,默认500
     $days = isset($this->_params['days']) ? $this->_params['days'] : 3;
     // 查询天数,默认3天
     //获取附近经纪人Id
     $brokerLocations = Bll_Broker_Location::getRoundBrokerLocationsInThePastFewDays($lng, $lat, $radius, $total, $days);
     $brokerIds = array_keys($brokerLocations);
     //根据经纪人Id数组查询多个经纪人信息
     $brokerInfosTmp = Model_Broker_AjkBrokerExtend::findMultiBrokers($brokerIds);
     //提取经纪人ID
     $brokerIds = $brokerInfos = array();
     foreach ($brokerInfosTmp as $value) {
         if ($value->brokerId != $brokerId) {
             $brokerIds[] = $value->brokerId;
             $brokerInfos[$value->brokerId] = $value;
         }
     }
     //批量查询微聊信息
     $chatInfos = Bll_Mobile_ChatInfoBll::getInstance()->GetChatInfoByIds($brokerIds);
     //根据微聊信息筛选经纪人,去除微聊信息为空的经纪人
     $brokers = array();
     foreach ($chatInfos as $chatInfo) {
         $re = array();
         $distance = Util_Map::distance($lng, $lat, $brokerLocations[$chatInfo['brokerId']]['lng'], $brokerLocations[$chatInfo['brokerId']]['lat']);
         $distance = round($distance / 1000, 2);
         if ($distance > 3 || $brokerInfos[$chatInfo['brokerId']]->checkState != 1) {
             continue;
         }
         $re['brokerId'] = $chatInfo['brokerId'];
         $re['companyInfo'] = $brokerInfos[$chatInfo['brokerId']]->company;
         $re['trueName'] = $brokerInfos[$chatInfo['brokerId']]->trueName;
         $re['userMobile'] = $brokerInfos[$chatInfo['brokerId']]->userMobile;
         $disarr[] = $distance;
         $re['distance'] = $distance;
         $re['userPhoto'] = Util_ImageUtils::get_broker_photo_url($brokerInfos[$chatInfo['brokerId']]->userPhoto, '200x200');
         $re['chatId'] = $chatInfo['chatId'];
         $re['twoCodeIcon'] = $chatInfo['twoCodeIcon'];
         $brokers[] = $re;
     }
     //按距离排序
     array_multisort($disarr, $brokers);
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('brokerList' => $brokers));
 }
Пример #4
0
 public function handle_request_internal()
 {
     header("Access-Control-Allow-Origin: *");
     $brokerId = $this->_params['brokerId'];
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     //根据区域代码查询经纪人
     $brokerArea = $brokerInfo->areaCode;
     $brokerInfoTmp = Model_Broker_AjkBrokerExtend::getDataByAreaCodeAll($brokerArea);
     //提取经纪人ID
     $brokerIds = $brokerInfos = array();
     foreach ($brokerInfoTmp as $value) {
         if ($value->brokerId != $brokerId) {
             $brokerIds[] = $value->brokerId;
             $brokerInfos[$value->brokerId] = $value;
         }
     }
     //批量查询微聊信息
     $chatInfos = Bll_Mobile_ChatInfoBll::getInstance()->GetChatInfoByIds($brokerIds);
     //根据微聊信息筛选经纪人,去除微聊信息为空的经纪人
     $brokers = array();
     foreach ($chatInfos as $chatInfo) {
         if ($brokerInfos[$chatInfo['brokerId']]->checkState != 1) {
             continue;
         }
         $re = array();
         $re['brokerId'] = $chatInfo['brokerId'];
         $re['trueName'] = $brokerInfos[$chatInfo['brokerId']]->trueName;
         $re['userMobile'] = $brokerInfos[$chatInfo['brokerId']]->userMobile;
         $re['companyInfo'] = $brokerInfos[$chatInfo['brokerId']]->company;
         $re['userPhoto'] = Util_ImageUtils::get_broker_photo_url($brokerInfos[$chatInfo['brokerId']]->userPhoto, '200x200');
         $re['chatId'] = $chatInfo['chatId'];
         $re['twoCodeIcon'] = $chatInfo['twoCodeIcon'];
         $brokers[] = $re;
     }
     foreach ($brokers as $broker) {
         $brokerCompany[] = $broker['company'];
     }
     //按公司排序
     array_multisort($brokerCompany, $brokers);
     $keyReturn = array();
     foreach ($brokers as $broker) {
         $keyReturn[$broker['companyInfo']]['company'] = $broker['companyInfo'];
         $keyReturn[$broker['companyInfo']]['broker'][] = $broker;
     }
     $brokerList = array_values($keyReturn);
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('brokerList' => $brokerList));
 }
Пример #5
0
 public function handle_request_internal()
 {
     header("Access-Control-Allow-Origin: *");
     $brokerId = $this->_params['brokerId'];
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     //查询微聊信息
     $chatInfo = Bll_Mobile_ChatInfoBll::getInstance()->onlyGetChatInfo($brokerInfo->brokerId);
     $re = array();
     $re['brokerId'] = $brokerInfo->brokerId;
     $re['companyInfo'] = $brokerInfo->company;
     $re['trueName'] = $brokerInfo->trueName;
     $re['userMobile'] = $brokerInfo->userMobile;
     $re['userPhoto'] = Util_ImageUtils::get_broker_photo_url($brokerInfo->userPhoto, '200x200');
     $re['chatId'] = $chatInfo['data']['chatId'];
     $re['twoCodeIcon'] = $chatInfo['data']['twoCodeIcon'];
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $re);
 }
Пример #6
0
 public function handle_request_internal()
 {
     header("Access-Control-Allow-Origin: *");
     $brokerId = $this->_params['brokerId'];
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     //根据公司ID查询经纪人,限制100个
     $comId = $brokerInfo['cstBrokerCompanyId'];
     $brokerInfoTmp = Model_Broker_AjkBrokerExtend::getSameMendianBrokerInfo($comId);
     $brokerIds = array();
     foreach ($brokerInfoTmp as $value) {
         if ($value->brokerId != $brokerId) {
             $brokerIds[] = $value->brokerId;
             $brokerInfos[$value->brokerId] = $value;
         }
     }
     $chatInfos = Bll_Mobile_ChatInfoBll::getInstance()->GetChatInfoByIds($brokerIds);
     foreach ($brokerInfoTmp as $brokerInfo) {
         $brokerInfos[$brokerInfo->brokerId] = $brokerInfo;
     }
     $brokerList = array();
     foreach ($chatInfos as $chatInfo) {
         if ($brokerInfos[$chatInfo['brokerId']]->checkState != 1) {
             continue;
         }
         $re = array();
         $re['brokerId'] = $chatInfo['brokerId'];
         $re['trueName'] = $brokerInfos[$chatInfo['brokerId']]->trueName;
         $re['userMobile'] = $brokerInfos[$chatInfo['brokerId']]->userMobile;
         $re['userPhoto'] = Util_ImageUtils::get_broker_photo_url($brokerInfos[$chatInfo['brokerId']]->userPhoto, '200x200');
         $re['chatId'] = $chatInfo['chatId'];
         $re['twoCodeIcon'] = $chatInfo['twoCodeIcon'];
         $brokerList[] = $re;
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('brokerList' => $brokerList));
 }
Пример #7
0
 public function handle_request_internal()
 {
     /**
      * 签到小区详情
      *
      * - 验证参数
      *
      *
      * - 获取经纪人
      *
      * - 获取小区(AjkCommunity)
      * -
      *
      * - 获取小区签到人数
      *
      * - 判断经纪人是否可签到(经纪人是否已签到、当前是否在签到时间段)
      * - 校验小区坐标和lat、lng的距离5公里,超出不可签到(如小区无坐标,不可签到)
      *
      * - 计算距离下一时间点的签到倒计时(单位:s)
      *
      * - 获取小区各个时间段签到前3名
      *
      * - 返回数据
      */
     // 获取参数
     $brokerId = $this->_params['brokerId'];
     $commId = $this->_params['commId'];
     $lat = $this->_params['lat'];
     $lng = $this->_params['lng'];
     // 根据ID获取经纪人
     $broker = Bll_Commsign::getBrokerInfo($brokerId);
     if (!$broker) {
         $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $brokerId)->find_only();
         if (!$broker) {
             throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
         }
         $broker_photo = Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200');
         $brokerInfo = array('brokerId' => $broker['brokerId'], 'username' => $broker['trueName'], 'userPhoto' => $broker_photo, 'cityId' => $broker['cityId']);
         Bll_Commsign::redisBrokerInfo($brokerId, $brokerInfo);
     }
     // 根据ID获取小区
     $community = Bll_Commsign::getCommInfo($commId);
     if (empty($community)) {
         $community = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($commId, 2);
         $commInfo = array();
         $commInfo['commId'] = $community['commId'];
         $commInfo['commName'] = $community['commName'];
         $commInfo['sosolng'] = $community['sosolng'];
         $commInfo['sosolat'] = $community['sosolat'];
         Bll_Commsign::setCommInfo($commId, $commInfo);
     }
     if (!$community || !$community['sosolat'] || !$community['sosolng']) {
         throw new Exception('小区不存在', Const_APIStatus::E_COMMUNITY_NOT_EXISTS);
     }
     // 获取小区签到人数
     $communitySignCount = Bll_Commsign::getCommCount($commId);
     // 判断经纪人是否可签到
     $signAble = true;
     $currentSignRange = Bll_Broker_CommunitySign::getCurrentSignRange();
     if (!$currentSignRange) {
         $signAble = false;
     } else {
         // 经纪人是否已经签过到
         if (Bll_Commsign::isSignedAlready($brokerId, $commId, $currentSignRange[0])) {
             $signAble = false;
         }
     }
     // 对比小区坐标和参数坐标两点的距离(5km)
     $distance = Util_Map::distance($lat, $lng, $community['sosolat'], $community['sosolng']);
     if ($distance > 5000) {
         $signAble = false;
     }
     $data = array();
     $data['signAble'] = intval($signAble);
     $data['signCount'] = $communitySignCount;
     $data['countDown'] = $signAble ? 0 : Bll_Broker_CommunitySign::nextSignCountDown();
     $data['signList'] = array();
     // 获取各时间段签到前三名
     if (Bll_Broker_CommunitySign::isTopSignerActivityOngoing()) {
         $data['signList'] = array(array('hour' => '10:00', 'brokers' => array()), array('hour' => '15:00', 'brokers' => array()), array('hour' => '20:00', 'brokers' => array()));
         foreach ($data['signList'] as &$theSignList) {
             $theHour = intval($theSignList['hour']);
             $hour = intval(date('H'));
             if ($hour >= 0 && $hour < 10) {
                 break;
             } elseif ($hour >= 10 && $hour < 20) {
                 if ($theHour > $hour) {
                     continue;
                 }
             }
             $theSignRange = array();
             switch ($theHour) {
                 case 10:
                     $theSignRange = array(date('Y-m-d 10:00:00'), date('Y-m-d 14:59:59'));
                     break;
                 case 15:
                     $theSignRange = array(date('Y-m-d 15:00:00'), date('Y-m-d 19:59:59'));
                     break;
                 case 20:
                     $theSignRange = array(date('Y-m-d 20:00:00'), date('Y-m-d 23:59:59'));
                     break;
             }
             $theSignList['brokers'] = Bll_Commsign::getFirstThr($commId, $theSignRange[0]);
             if (empty($theSignList['brokers'])) {
                 $theSignList['brokers'] = Model_Broker_CommunitySign::data_access(date('Ym', strtotime($currentSignRange[0])))->filter('communityId', $commId)->filter_by_op_multi(array(array('signTime', '>=', $theSignRange[0]), array('signTime', '<=', $theSignRange[1])))->sort('signTime', 'asc')->limit(3)->get_all();
             }
             $tmp = array();
             if (!empty($theSignList['brokers'])) {
                 foreach ($theSignList['brokers'] as $k => $v) {
                     $brokerTmp = Bll_Commsign::getBrokerInfo($v['brokerId']);
                     if (!$brokerTmp) {
                         $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $v['brokerId'])->find_only();
                         $broker_photo = Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200');
                         $brokerTmp = array('brokerId' => $broker['brokerId'], 'username' => $broker['trueName'], 'userPhoto' => $broker_photo, 'cityId' => $broker['cityId']);
                         Bll_Commsign::redisBrokerInfo($v['brokerId'], $brokerTmp);
                     }
                     if (empty($brokerTmp['userPhoto'])) {
                         $brokerTmp['userPhoto'] = PageHelper::pure_static_url('/img/bknoimg.gif');
                     }
                     $dataTmp = array('brokerId' => $brokerTmp['brokerId'], 'brokerTrueName' => $brokerTmp['username'], 'brokerPhoto' => $brokerTmp['userPhoto']);
                     $tmp[] = $dataTmp;
                 }
                 $theSignList['brokers'] = $tmp;
             }
         }
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => $data);
 }
Пример #8
0
 private function getUpdateData($broker, $chatInfo)
 {
     $updateData = array();
     if ($chatInfo['phone'] != $broker['userMobile']) {
         $updateData['phone'] = $broker['userMobile'];
     }
     if ($chatInfo['nick_name'] != $broker['trueName']) {
         $updateData['nick_name'] = $broker['trueName'];
     }
     $userIcon = Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200') ? Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200') : "";
     if ($chatInfo['icon'] != $userIcon) {
         $updateData['icon'] = $userIcon;
     }
     if ($chatInfo['desc'] != $broker['aphorism']) {
         $updateData['desc'] = $broker['aphorism'];
     }
     if ($chatInfo['corp'] != $broker['company']) {
         $updateData['corp'] = $broker['company'];
     }
     return $updateData;
 }
Пример #9
0
 public function handle_request_internal()
 {
     /**
      * 小区签到逻辑
      *
      * - 验证参数
      *
      * - 获取经纪人
      *
      * - 获取小区(AjkCommunity)
      * - 校验小区坐标和lat、lng的距离5公里(如小区无坐标,直接拒绝)
      *
      * - 添加签到记录
      *  - 添加签到记录
      *  - 更新签到按日统计信息(incr)
      *
      * - 更新经纪人坐标
      *  - 添加经纪人坐标日志
      *  - 更新经纪人坐标
      *
      * - 返回数据
      */
     $result = array('status' => 'error', 'errcode' => '', 'message' => '');
     // 获取参数
     $brokerId = $this->_params['brokerId'];
     $commId = $this->_params['commId'];
     $lat = $this->_params['lat'];
     $lng = $this->_params['lng'];
     if (empty($lat) || empty($lng)) {
         $result['message'] = '获取定位数据失败,请重新定位';
         return $result;
     }
     // 根据ID获取经纪人
     $broker = Bll_Commsign::getBrokerInfo($brokerId);
     if (!$broker) {
         $broker = Model_Broker_AjkBrokerExtend::data_access()->filter('brokerId', $brokerId)->find_only();
         if (!$broker) {
             throw new Exception('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
         }
         $broker_photo = Util_ImageUtils::get_broker_photo_url($broker['userPhoto'], '200x200');
         $brokerInfo = array('brokerId' => $broker['brokerId'], 'username' => $broker['trueName'], 'userPhoto' => $broker_photo, 'cityId' => $broker['cityId']);
         Bll_Commsign::redisBrokerInfo($brokerId, $brokerInfo);
     }
     // 根据ID获取小区
     $community = Bll_Commsign::getCommInfo($commId);
     if (empty($community)) {
         $community = Bll_Community_APIComm::getInstance()->getInfoByIdMapping($commId, 2);
         $commInfo = array();
         $commInfo['commId'] = $community['commId'];
         $commInfo['commName'] = $community['commName'];
         $commInfo['sosolng'] = $community['sosolng'];
         $commInfo['sosolat'] = $community['sosolat'];
         Bll_Commsign::setCommInfo($commId, $commInfo);
     }
     // 小区不存在或小区经纬租表不存在时,返回小区不存在
     if (!$community || !$community['sosolat'] || !$community['sosolng']) {
         $result['errcode'] = Const_APIStatus::E_COMMUNITY_NOT_EXISTS;
         $result['message'] = '小区暂未开通签到功能';
         return $result;
     }
     // 对比小区坐标和参数坐标两点的距离(5km)
     $distance = Util_Map::distance($lat, $lng, $community['sosolat'], $community['sosolng']);
     if ($distance > 5000) {
         $result['errcode'] = Const_APIStatus::E_BROKER_COMMSIGN_FAR_AWAY;
         $result['message'] = '签到失败!你跑得太远了,请返回重新定位';
         return $result;
     }
     // 获取当前所处签到时间(10:00 15:00 20:00)
     $currentSignRange = Bll_Broker_CommunitySign::getCurrentSignRange();
     if (!$currentSignRange) {
         $result['errcode'] = Const_APIStatus::E_BROKER_COMMSIGN_NOT_IN_RANGE;
         $result['message'] = '不在签到时间范围';
         return $result;
     }
     // 判断是否已经签到
     if (Bll_Commsign::isSigned($brokerId, $commId, $currentSignRange[0])) {
         $result['errcode'] = Const_APIStatus::E_BROKER_COMMSIGN_ALREADY_SIGNED;
         $result['message'] = '已经签到!';
         return $result;
     }
     try {
         // 新建签到,
         $sign = array('brokerId' => $brokerId, 'communityId' => $commId, 'lat' => $lat, 'lng' => $lng, 'signTime' => date('Y-m-d H:i:s'), 'currentSignRange' => $currentSignRange[0]);
         Bll_Commsign::Signed($brokerId, $commId, $currentSignRange[0], $sign);
         //缓存‘签到信息’到同步数据库的redis中
         Bll_RedisToDb::writeBrokerCommunitySign($sign);
         // 缓存经纪人位置
         $locationInfo = array('brokerId' => $brokerId, 'lng' => $lng, 'lat' => $lat, 'updateTime' => date('Y-m-d H:i:s'));
         Bll_Commsign::setLocationInfo($brokerId, $locationInfo);
         //缓存‘位置信息’到同步数据库的redis中
         Bll_RedisToDb::writeBrokerLocation($locationInfo);
         //记录每日签到情况
         Bll_Commsign::dailySignedRecord($brokerId);
         // 获取签到排名
         $rank = Bll_Commsign::getSignRank($commId, $currentSignRange[0]);
         //连续签到统计
         $SignStatistics = Bll_Commsign::getSignStatistics($brokerId);
         $sendFlag = false;
         if ($SignStatistics) {
             if (date('Y-m-d', strtotime($SignStatistics['updateTime'])) == date('Y-m-d', strtotime('yesterday'))) {
                 $SignStatistics['signCount'] = $SignStatistics['signCount'] + 1;
                 $sendFlag = true;
             } elseif (date('Y-m-d', strtotime($SignStatistics['updateTime'])) == date('Y-m-d', time())) {
             } else {
                 $SignStatistics['signCount'] = 1;
                 $sendFlag = true;
             }
             if ($SignStatistics['signCount'] > $SignStatistics['maxSignCount']) {
                 $SignStatistics['maxSignCount'] = $SignStatistics['signCount'];
             }
             $SignStatistics['updateTime'] = date('Y-m-d H:i:s');
             Bll_Commsign::setSignStatistics($brokerId, $SignStatistics);
             //缓存‘签到统计信息’到同步数据库的redis中
             $SignStatistics = array_merge($SignStatistics, array('sendFlag' => $sendFlag));
             Bll_RedisToDb::writeCommSignStatistics($SignStatistics);
         } else {
             $SignStatistics = array('brokerId' => $brokerId, 'signCount' => 1, 'maxSignCount' => 1, 'createTime' => date('Y-m-d H:i:s'));
             Bll_Commsign::setSignStatistics($brokerId, $SignStatistics);
             $sendFlag = true;
             //缓存‘签到统计信息’到同步数据库的redis中
             $SignStatistics = array_merge($SignStatistics, array('sendFlag' => $sendFlag));
             Bll_RedisToDb::writeCommSignStatistics($SignStatistics);
         }
     } catch (Exception $e) {
         $result['message'] = '签到人太多,系统繁忙,请稍后再试~';
         return $result;
     }
     return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('signRank' => $rank, 'countDown' => Bll_Broker_CommunitySign::nextSignCountDown()));
 }
Пример #10
0
 public function handle_request_internal()
 {
     $params["j_username"] = trim($this->_params["username"]);
     $params["j_password"] = trim($this->_params["password"]);
     $params["channel"] = 3;
     $api_url = '/service-internal/rest/brokers/login';
     $broker = Util_CallAPI::get_data_from_java_api($api_url, $params);
     if ($broker['data']['status'] != 'ok') {
         if ($broker['data']['code'] == 398213) {
             return Util_MobileAPI::error(Const_APIStatus::E_BROKER_USERPWD_ERR);
         } else {
             return Util_MobileAPI::error(Const_APIStatus::E_CALL_API_ERROR);
         }
     }
     $broker_id = $broker['data']['broker']['brokerId'];
     //获取经纪人信息
     $api_url = "/service-internal/rest/brokers/{$broker_id}";
     $broker_info = Util_CallAPI::get_data_from_java_api($api_url);
     if (empty($broker_info)) {
         $broker_info = array();
     }
     if ($broker_info['data']['status'] == 'error') {
         return Util_MobileAPI::error(Const_APIStatus::E_CALL_API_ERROR);
     }
     $broker_info = $broker_info['data'];
     $cityId = isset($broker_info['broker']['cityId']) ? $broker_info['broker']['cityId'] : "";
     if ($cityId > 229) {
         return array('status' => 'error', 'errcode' => "", 'message' => "您所在的城市暂不支持APP服务");
     }
     $broker_return = array('id' => isset($broker_info['broker']['brokerId']) ? $broker_info['broker']['brokerId'] : "", 'city_id' => isset($broker_info['broker']['cityId']) ? $broker_info['broker']['cityId'] : "", 'email' => isset($broker_info['broker']['userEmail']) ? $broker_info['broker']['userEmail'] : "", 'last_log_date' => isset($broker_info['broker']['lastLogDate']) ? $broker_info['broker']['lastLogDate'] : "", 'name' => isset($broker_info['broker']['trueName']) ? $broker_info['broker']['trueName'] : "", 'username' => isset($broker_info['broker']['userName']) ? $broker_info['broker']['userName'] : "", 'phone' => isset($broker_info['broker']['userMobile']) ? $broker_info['broker']['userMobile'] : "", 'use_photo' => isset($broker_info['broker']['userPhoto']) ? $broker_info['broker']['userPhoto'] : "", 'user_type' => isset($broker_info['broker']['userType']) ? $broker_info['broker']['userType'] : "", 'user_id' => isset($broker_info['broker']['userId']) ? $broker_info['broker']['userId'] : "");
     $sid = APF::get_instance()->get_config("sid", "login");
     //单点登录
     $registerBll = new Bll_Register();
     $registerBll->singleSignon($broker_return['user_id'], $broker_return['username'], $sid, $broker_return['user_type']);
     // 生成token
     $token = self::createToken(array($broker_return["id"], $broker_return['username'], time()));
     $broker_return['use_photo'] = Util_ImageUtils::get_broker_photo_url($broker_return['use_photo']);
     $insert_data["token"] = $token;
     $insert_data["user_id"] = $broker_return["id"];
     $insert_data["expired"] = Bll_TokenBiz::get_instance()->get_expire_time();
     $insert_data["app"] = APF::get_instance()->get_config('java_api_from');
     Bll_TokenBiz::get_instance()->insert($insert_data);
     $device_data = array();
     $device_data["user_id"] = $broker_return["id"];
     $device_data["app"] = APF::get_instance()->get_config('java_api_from');
     $device_data["device"] = "";
     $device_data["ismi"] = trim(@$this->_params["imsi"]);
     $device_data["ip"] = APF::get_instance()->get_request()->get_client_ip();
     $device_data["i"] = "";
     $device_data["m"] = "";
     $device_data["o"] = "";
     $device_data["v"] = "";
     $device_data["cv"] = "";
     $device_data["cid"] = "";
     $device_data["pm"] = "";
     $device_data["created"] = date("Y-m-d H:i:s");
     Bll_DeviceBiz::get_instance()->save($device_data);
     $dwStatsBiz = new Bll_DwStatsBiz();
     if (!empty($this->_params["macid"])) {
         $guid = md5(trim($this->_params["macid"]));
         $dwStatsBiz->saveGuid($guid);
     }
     if (!empty($this->_params["uuid"])) {
         $guid = md5(trim($this->_params["uuid"]));
         $dwStatsBiz->saveGuid($guid);
     }
     if (!empty($this->_params["i"])) {
         $guid = md5(trim($this->_params["i"]));
         $dwStatsBiz->saveGuid($guid);
     }
     if (!empty($this->_params["uuid2"])) {
         //ios7兼容
         $guid = md5(trim($this->_params["uuid2"]));
         $dwStatsBiz->saveGuid($guid);
     }
     if (!empty($this->_params["udid2"])) {
         //ios7兼容
         $guid = md5(trim($this->_params["udid2"]));
         $dwStatsBiz->saveGuid($guid);
     }
     $return = array();
     $return["status"] = "ok";
     $return['data']["token"] = $token;
     $return['data']['broker'] = $broker_return;
     //缓存信息到redis
     $redisInfo = array('brokerId' => $broker_info['broker']['brokerId'], 'username' => $broker_info['broker']['trueName'], 'userPhoto' => $broker_return['use_photo'], 'cityId' => $broker_info['broker']['cityId']);
     Bll_Commsign::redisBrokerInfo($broker_info['broker']['brokerId'], $redisInfo);
     return $return;
 }
Пример #11
0
 /**
  * 数据整理
  * @param $data
  * @param $brokerId
  * @param $showStatus
  * @param $commLocal
  * @param $rushBrokerId
  * @param $propertyId
  * @return array
  */
 private function formatdate($data, $eBrokers, $showStatus, $commLocal, $rushBrokerId, $propertyId, $imgInfos)
 {
     if (empty($data)) {
         return '';
     }
     $business = APF::get_instance()->get_config("choice_business", "multicity");
     $row = array();
     $row['entrustId'] = $data['id'];
     //委托ID
     $row['cityId'] = $data['cityId'];
     //房源所属城市
     $row['ownerId'] = $data['userId'];
     //房东ID
     $row['ownerName'] = $data['userName'];
     //房东姓名
     if ($data['owner400'] != 0) {
         $is400 = 1;
     } else {
         $is400 = 0;
     }
     $row['is400'] = $is400;
     if ($rushBrokerId) {
         $row['ownerMobile'] = $rushBrokerId ? $data['ownerMobile'] : substr_replace($data['ownerMobile'], '*****', 3, 5);
         //手机. 规则抢到显示
         $row['owner400'] = $rushBrokerId ? $data['owner400'] : ($is400 == 1 ? substr_replace($data['owner400'], '*****', 0, strlen($data['owner400'])) : 0);
         //是否绑定400。0-否;是-具体号码
     } else {
         $row['ownerMobile'] = substr_replace($data['ownerMobile'], '*****', 3, 5);
         $row['owner400'] = $is400 == 1 ? substr_replace($data['owner400'], '*****', 0, strlen($data['owner400'])) : 0;
         //是否绑定400。0-否;是-具体号码
     }
     $row['owner400Host'] = APF::get_instance()->get_config("400_host");
     if ($data['fromType'] != 0) {
         $houseExt = Model_House_CommissionHouseExtend::getHouseExtByPk($data['id']);
         $chatId = $houseExt ? $houseExt->chatId : '';
     } else {
         $chatId = '';
     }
     if ($rushBrokerId) {
         $row['ownerChatId'] = $rushBrokerId ? $chatId : '';
         //新增微聊id。
     } else {
         $row['ownerChatId'] = '';
     }
     $row['commId'] = $data['commId'];
     //对应的小区ID
     $row['commName'] = $data['commName'];
     //小区名称
     $row['commLocal'] = $commLocal;
     //小区地址
     $row['roomNum'] = $data['roomNum'];
     //房间数量
     $row['hallNum'] = $data['hallNum'];
     //客厅的数量x
     $row['toiletNum'] = $data['toiletNum'];
     //卫生间的数量
     $row['areaNum'] = $data['areaNum'];
     //房源的建筑面积;单位”平米”
     $row['areaUnit'] = '平米';
     //房源的建筑面积;单位”平米”
     $row['propPrice'] = $data['proPrice'];
     //房源价格(万元)/房源租金(元/月)
     $row['priceUnit'] = $data['commissionType'] == 1 ? '万元' : '元/月';
     //房源价格(万元)/房源租金(元/月)
     $row['entrustType'] = $data['commissionType'];
     //1-出售,2-出租
     if (!empty($imgInfos) && $data['commissionType'] == 1) {
         foreach ($imgInfos as $imginfo) {
             $img = array();
             $img['id'] = $imginfo['id'];
             $img['smallImageUrl'] = Util_Image::getInstance()->getResizeURL($imginfo['imageId'], $imginfo['hostId'], 100, 75);
             //(拼好小图)
             $img['bigImageUrl'] = Util_Image::getInstance()->getResizeURL($imginfo['imageId'], $imginfo['hostId'], 600, 600);
             //(拼好大图)
             $img['hostId'] = $imginfo['hostId'];
             $img['width'] = $imginfo['width'] ? $imginfo['width'] : 1280;
             $img['height'] = $imginfo['height'] ? $imginfo['height'] : 1500;
             $img['hash'] = $imginfo['imageId'];
             $img['type'] = 2;
             //图片类型 1:小区图 2: 室内图 3: 户型图
             $img['entry'] = 4;
             //图片来源 1:系统默认 2:相机拍摄 3:相册选取 4: 在线图库
             $img['exists'] = 1;
             //图片是否已存在
             $img['format'] = 'JPEG';
             $imgs[] = $img;
         }
         $row['imagesInfo'] = $imgs;
     } else {
         $row['imagesInfo'] = array();
     }
     if ($showStatus == 5 || $showStatus == 6) {
         $row['showStatus'] = 7;
     } else {
         $row['showStatus'] = $showStatus;
     }
     //房源状态 0-非法数据暂时没用 1-违规删除 2-已过期 3-抢完了 4-可以抢 5-抢到未发布;6-抢到已发布未推广;7-抢到已发布已推广;8-房东已删除;9-房东停止委托;
     $row['propertyId'] = $propertyId;
     $row['created'] = $data['created'];
     //创建时间
     $row['lastModifyDate'] = $data['lastModifyDate'];
     //最后更改时间
     $row['brokerIds'] = $eBrokers ? implode(',', $eBrokers) : '';
     //该套委托二手房源的所有经纪人id
     $row['isRealityPats'] = empty($imgs) ? 0 : 1;
     //实拍icon 1:显示实拍 0:不显示
     if (!empty($business)) {
         $row['isChoiceCity'] = in_array($data['cityId'], $business) ? 1 : 0;
         //1:精选城市 0:非精选城市
     } else {
         $row['isChoiceCity'] = 0;
     }
     $row['timeState'] = Bll_Common_Format::formatTime($data['created']);
     //倒计时
     $row['brokerImages'] = array();
     if ($showStatus == 3) {
         //已抢完,加入经纪人头像
         $commissionInfo = Model_House_Commission::getCommissionsOrderById(intval($data['id']));
         $brokerIds = array();
         foreach ($commissionInfo as $comm) {
             $brokerIds[] = $comm['brokerId'];
         }
         $brokerInfo = array();
         $brokers = array();
         $brokerInfo = Model_Broker_AjkBrokerExtend::findMultiBrokers($brokerIds);
         foreach ($brokerInfo as $broInfo) {
             $brokers[$broInfo['brokerId']] = $broInfo;
         }
         if (!empty($brokerIds)) {
             foreach ($brokerIds as $broId) {
                 $photo = Util_ImageUtils::get_broker_photo_url($brokers[$broId]['userPhoto'], '200x200');
                 $row['brokerImages'][] = $photo ? $photo : APF::get_instance()->get_config("broker_image_url");
             }
         } else {
             for ($i = 0; $i < 5; $i++) {
                 $row['brokerImages'][$i] = APF::get_instance()->get_config("broker_image_url");
             }
         }
     }
     return $row;
 }
Пример #12
0
 /**
  * 注册微聊账号
  *
  * @param int|Model_Broker_AjkBrokerExtend $brokerInfo
  * @param $pushType
  *
  * @return array
  * @throws Exception
  */
 public function register($brokerInfo, $pushType)
 {
     if (is_numeric($brokerInfo)) {
         $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerInfo);
         if (is_null($brokerInfo)) {
             throw new Exception_BrokerNotFoundException();
         }
     } else {
         if (!$brokerInfo instanceof Model_Broker_AjkBrokerExtend) {
             throw new Exception_InvalidParameterException();
         }
     }
     $brokerId = $brokerInfo['brokerId'];
     $phone = $brokerInfo['userMobile'];
     $isActive = $pushType == 1 ? 1 : 0;
     // 验证手机号码是否合法
     if (!preg_match('/^1((3[0-9])|(4[0-9])|(5[0-9])|(7[0-9])|(8[0-9]))[0-9]{8}$/', $phone)) {
         throw new Exception_InvalidPhoneException();
     }
     // 调用微聊接口注册
     $path = "/user/register/{$phone}";
     $params = array('phone' => $phone, 'user_type' => 2, 'broker_id' => $brokerId, 'nick_name' => $brokerInfo['trueName'], 'icon' => Util_ImageUtils::get_broker_photo_url($brokerInfo['userPhoto'], '200x200') ? Util_ImageUtils::get_broker_photo_url($brokerInfo['userPhoto'], '200x200') : "", 'desc' => $brokerInfo['aphorism'], 'corp' => $brokerInfo['company'], 'is_active' => $isActive);
     $response = Util_CallAPI::get_data_from_chat_api($path, json_encode($params));
     // 注册成功,回写数据,发送欢迎消息
     if ($response && $response['data']['status'] == 'OK') {
         $chatId = $response['data']['result']['user_id'];
         Model_Mobile_BrokerChatInfo::addChatInfo(array('brokerId' => $brokerInfo['brokerId'], 'chatId' => $chatId, 'phone' => $phone, 'pushType' => $pushType, 'isPushed' => 1, 'sendMsgNum' => 0, 'isActived' => $isActive, 'createTime' => time(), 'updateTime' => time()));
         // 发送欢迎信息
         Bll_Chat::sendPublicMsg($chatId, '欢迎使用微聊!从此客户可以通过微聊轻松找到你。新渠道,带来更多的客户。不用担心通话不便,客户不真实,准备好开始微聊了吗?');
     }
     return $response;
 }