Esempio n. 1
0
 /**
  * Job执行逻辑
  */
 public function handle_request()
 {
     //读取公告列表数据
     $queueList = $this->readAnnounceQueueInfo($this->announceId);
     if (!empty($queueList)) {
         $broker_queue = $this->brokerId;
         //从ajk_dw_stats库里读取本次操作的经纪人信息
         $DwStatsBll = Bll_DwStatsBiz::get_instance();
         $where = " broker_id>{$broker_queue} order by broker_id asc limit 1";
         $DwStats_broker = $DwStatsBll->get_distinct_broker($where);
         if (!empty($DwStats_broker)) {
             //添加逻辑判断待发送信息的经纪人是否开通微聊
             $activeBorker = Model_Mobile_BrokerChatInfo::getActiveBroker($DwStats_broker[0]['broker_id'], array('chatId'));
             $chatId = $activeBorker['chatId'];
             foreach ($queueList as $list) {
                 if (!empty($activeBorker)) {
                     //发送公众号信息
                     $msg_map = APF::get_instance()->get_config('msg_conf', 'mobile_api');
                     $text = $msg_map['ANNOUNCE_PUSH'] . $list['announce_content'];
                     $result = Bll_Chat::sendPublicMsg($chatId, $text);
                 } else {
                     $this->write_redis($DwStats_broker[0]['broker_id'], 'ANNOUNCE_PUSH', $list['announce_content'], 'mobile-ajk-broker');
                     $this->writeLog($this->log_dir . 'broker_queue.id', $DwStats_broker[0]['broker_id']);
                 }
             }
         } else {
             $this->writeLog($this->log_dir . 'broker_queue.id', 0);
             foreach ($queueList as $list) {
                 //更新公告队列
                 Dao_Msgpush_Announce::update($list['announce_id']);
                 $this->writeLog($this->log_dir . 'announce_queue.id', $list['announce_id']);
             }
         }
     }
 }
Esempio n. 2
0
 public static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 3
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;
 }