Пример #1
0
 public function handle_request_internal()
 {
     $brokerId = $this->_params['brokerId'];
     $skuId = $this->_params['skuId'];
     $password = $this->_params['password'];
     //经纪人信息
     $brokerInfo = Model_Broker_AjkBrokerExtend::findWithBrokerId($brokerId);
     if (!$brokerInfo) {
         throw new Exception_BrokerNotFoundException('经纪人不存在', Const_APIStatus::E_BROKER_NOT_EXISTS);
     }
     $userId = $brokerInfo->userId;
     if ($brokerInfo->payType != 9999) {
         return Util_MobileAPI::error(Const_APIStatus::E_BROKER_IS_NOT_COMBO);
         //非套餐经纪人不能购买套餐
     }
     //购买
     $md5_password = md5($password);
     //密码加密
     $baseencode_password = base64_encode($md5_password);
     $userInfo = Model_Broker_Member::getAjkMembersByUserId($userId);
     //验证密码
     if ($userInfo->userPwd == $baseencode_password) {
         $result = Bll_Combo_Broker_BrokerComboInfo::brokerBuyCombo($userId, $skuId);
         if ($result['status'] == 'ok') {
             return array('status' => Const_APIStatus::RETURN_CODE_OK, 'data' => array('message' => '购买成功'));
         } else {
             switch ($result['code']) {
                 case '400539':
                 case '400015':
                 case '400540':
                 case '400545':
                 case '400498':
                 case '400541':
                 case '505008':
                 case '398489':
                 case '398491':
                 case '402205':
                 case '404086':
                     throw new Exception_JavaApiException($result['info']);
                     break;
                 case '398490':
                     throw new Exception_SameComboException('不支持再购买同类型套餐');
                     break;
                 case '402207':
                     throw new Exception_Account_BalanceNotEnough('余额不足');
                     break;
                 case '505007':
                     throw new Exception_Broker_NotPassCheck('您的双证审核未通过');
                     break;
                 default:
                     return Util_MobileAPI::error(Const_APIStatus::E_COMBO_BUY_COMBO_FAILED);
                     //购买失败
             }
         }
     } else {
         return Util_MobileAPI::error(Const_APIStatus::E_BROKER_PASSWORD_DIFFERENT);
         //密码错误
     }
 }
Пример #2
0
 /**
  * 根据邮箱获取经纪人信息
  * @param $eMail
  * @return array|mixed|null
  */
 public static function getAjkMemberByEmail($eMail)
 {
     $data = array();
     if (empty($eMail)) {
         return $data;
     }
     $data = Model_Broker_Member::data_access()->filter('userEmail', $eMail)->get_row();
     return $data;
 }
Пример #3
0
 /**
  * 微信授权登陆
  * @return array
  */
 public static function checkAuthLogin()
 {
     //根据code获取经纪人的openid
     $WechatMbroker = new Bll_Wechat_Mbroker_WechatMbroker();
     $wechatUserInfo = $WechatMbroker->getAuthUserInfo();
     //判断openid是否存在
     if (!$wechatUserInfo['openid']) {
         return self::getMsg(array('msg' => '未获取到openid'));
     }
     //获取绑定信息
     $wechatUser = Model_Wechat_WechatUsers::getUserIdByOpenId($wechatUserInfo['openid']);
     if (!$wechatUser || !$wechatUser['userId']) {
         return self::getMsg(array('msg' => '微信未绑定', 'openid' => $wechatUserInfo['openid']));
     }
     //查询用户信息
     $userInfo = Model_Broker_Member::getAjkMembersByUserId($wechatUser['userId']);
     if (empty($userInfo)) {
         return self::getMsg(array('msg' => '微信未绑定', 'openid' => $wechatUserInfo['openid']));
     }
     //返回用户信息
     return self::getMsg($userInfo, true);
 }
Пример #4
0
 /**
  * author hukan
  * 根据UserId获取经纪人的CityId
  */
 public static function getCityIdByUserId($userId)
 {
     $info = Model_Broker_Member::data_access()->load_field('cityId')->filter('userId', $userId)->get_row();
     return !empty($info) ? $info['cityId'] : '';
 }
Пример #5
0
 public function handle_request_internal()
 {
     $apf = APF::get_instance();
     $response = $apf->get_response();
     $request = APF::get_instance()->get_request();
     $params = $request->get_parameters();
     //加密公钥
     $member_key = $apf->get_config("member_key");
     //加密字符串
     $key = $params['key'];
     //用户ID
     $uid = $params['uid'];
     //用户NAME
     $username = $params['name'];
     //用户类型
     $usertype = $params['utype'];
     //$response->set_cookie("uid",$uid);
     $response->set_cookie("usertype", $usertype);
     //成功跳转页面
     $location = base64_decode(urldecode($params['location']));
     if (strpos($location, chr(13))) {
         $location = substr($location, 0, strpos($location, chr(13)));
     }
     if (strpos($location, '?') !== false) {
         $location .= '&_r=' . mt_rand(0, time());
     } else {
         $location .= '?_r=' . mt_rand(0, time());
     }
     //用户登录时间
     $time = $params['time'];
     //key的过期时间
     $keytime = $params['keytime'];
     //是否来自经纪人登陆
     $frombroker = $params['frombroker'];
     $errmsg = htmlspecialchars(urldecode($params['errmsg']));
     //错误代码
     $error = $params['error'];
     //来源
     $sid = @APF::get_instance()->get_request()->get_parameter("sid");
     //登陆成功
     if ($uid && Bll_Security_Member::check_key($key, $uid, $username, $member_key, $time, $keytime)) {
         $user = Model_Broker_Member::getAjkMembersByUserId($uid);
         if ($user->userType > 1) {
             $broker = Model_Broker_AjkBrokerExtend::getBrokerInfoByUserId($user->userId);
         }
         if ($user) {
             header("P3P: CP=CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR");
             $brokerid = 0;
             $cookietime = 86400 * 365;
             $ucity = APF::get_instance()->get_request()->getCityId();
             if ($user->userType == 2) {
                 // 自动创建三网支付中心账号
                 /*$bll_account = new BLL_Acenter_AccountUser();
                   $bll_account->create_three_account_must($uid);*/
                 if (intval($broker->checkState) == 2) {
                     // 被业务经理关闭的帐号
                     $errorMess = Const_Verify::CLOSE_ERROR;
                 }
                 if (intval($broker->accountType) == 10000) {
                     // 被业务经理冻结帐号
                     $errorMess = Const_Verify::FREEZE_ERROR;
                 }
                 if ($broker->isLogin == 0 && $broker->punish == 2) {
                     //黑名单经纪人不管是免费的还是续费的,立即关闭。
                     $errorMess = Const_Verify::BLACK_ERROR;
                 }
                 if ($errorMess) {
                     $backurl = strpos($location, '?') ? $location . '&errorMess=' . $errorMess : $location . '?errmsg=' . $errorMess;
                     Uri_Http::redirect_header($backurl, 302);
                     return;
                 }
                 $ucity = @$broker->cityId;
                 $brokerid = @$broker->brokerId;
                 $cookietime = 0;
                 $userTypeNew = Const_Verify::BROKER_USER;
             } else {
                 //查询是用户是否门店
                 $AgcyInfo = Model_Broker_AgcyAccount::getAgcyByUserId($user->userId);
                 if (is_array($AgcyInfo) && count($AgcyInfo)) {
                     $userTypeNew = Const_Verify::COMPANY_USER;
                 } else {
                     $userTypeNew = Const_Verify::COMMON_USER;
                 }
             }
             $userid = $user->userId;
             $username = $user->userName;
             $usertype = $user->userType;
             $fuid = $user->fuid;
             $emailpass = 1;
             if ($brokerid > 0) {
                 Model_Log_BrokerLogin::insertLoginLog(date('Ym'), $brokerid);
             }
             $anjuke_secques = APF::get_instance()->get_config("AnjukeSecques");
             $this->setLoginDataCookie($userid, $username, $usertype, $emailpass, $anjuke_secques, 0, $fuid, $ucity, $brokerid, $cookietime, $afutype = 0, $sid, $userTypeNew);
             $this->setLastLoinUserName($username, 86400 * 365);
         }
         //跳转用户原访问页面
         if (!$params['no_redirect']) {
             Uri_Http::redirect_header($location, 302);
         }
     } else {
         //登陆失败
         $backurl = strpos($location, '?') ? $location . '&errorMess=' . $errmsg . '&errorCode=' . $error : $location . '?errorMess=' . $errmsg . '&errorCode=' . $error;
         Uri_Http::redirect_header($backurl, 302);
         return;
     }
 }
Пример #6
0
 public function handle_request_internal()
 {
     if (!$this->isBrokerLogin()) {
         $this->redirect_to_login();
     }
     /**
      * @var $request AJKRequest
      */
     $request = APF::get_instance()->get_request();
     $objResponse = APF::get_instance()->get_response();
     $params = $request->get_parameters();
     $brokerId = $request->getBrokerId();
     $cityId = $request->getBrokerCityId();
     $userId = $request->getUserId();
     $sukId = $params['combo'];
     $password = $params['brokerPassword'];
     $act = $params['act'];
     $brokerInfo = self::$BrokerInfo['BaseInfo'];
     //非套餐经纪人不能进入该页面,跳转到首页
     if ($brokerInfo['PAYTYPE'] != 9999) {
         $this->redirect('/user/broker/brokerhome');
     }
     //查询账户余额
     $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId));
     $UserAccountAll = $balance['data']['balance'] / 100.0;
     //账户余额
     $UserAccountPerson = $balance['data']['personBalance'] / 100.0;
     //账户余额(个人)
     $UserAccountCompany = $balance['data']['companyBalance'] / 100.0;
     //账户余额(公司)
     $companyId = intval($brokerInfo['COMPANYID']);
     if ($companyId > 0) {
         /** 通过配置文件配置那些城市的非独立经纪人不可以购买月套餐 */
         $canNotBuyMonthlyComboCitySet = APF::get_instance()->get_config('can_not_buy_monthly_combo_city_set');
         if (is_array($canNotBuyMonthlyComboCitySet) && in_array($cityId, $canNotBuyMonthlyComboCitySet)) {
             $companyId = 0;
         }
     }
     //经纪人能否购买
     $buyComboInfo = Bll_Combo_Broker_BrokerComboInfo::getBrokerallowBuy($brokerId, $cityId, $sukId, $companyId);
     $this->setAttribute('buyComboInfo', $buyComboInfo);
     $this->setAttribute('UserAccountAll', number_format($UserAccountAll, 2));
     $request->set_attribute("UserAccountPerson", number_format($UserAccountPerson, 2));
     $request->set_attribute("UserAccountCompany", number_format($UserAccountCompany, 2));
     $this->setAttribute('params', $params);
     //看能不能购买
     if (!$buyComboInfo['allowBuy']) {
         return 'Combo_Buy_Result';
     }
     //购买
     if ($act == 'pay') {
         //密码加密
         $md5_password = md5($password);
         $baseencode_password = base64_encode($md5_password);
         //查询经纪人信息
         $userInfo = Model_Broker_Member::getAjkMembersByUserId($userId);
         //验证密码
         if ($userInfo->userPwd == $baseencode_password) {
             //购买
             $buySuccess = Bll_Combo_Broker_BrokerComboInfo::buyCombo($userId, $sukId);
             //购买是否成功
             $this->setAttribute('buySuccess', $buySuccess);
             return 'Combo_Buy_Result';
         } else {
             //密码错误
             $this->setAttribute('pwdErr', 1);
         }
     }
     return 'Combo_Buy_Pay';
 }
Пример #7
0
 public function handle_request_internal()
 {
     if (!$this->isBrokerLogin()) {
         $this->redirect_to_login();
     }
     $request = APF::get_instance()->get_request();
     $params = $request->get_parameters();
     $userId = $request->getUserId();
     $orderId = $params['orderId'];
     $sukId = $params['upDateComboName'];
     $orderName = $params['orderName'];
     $password = $params['brokerPassword'];
     $act = $params['act'];
     $brokerInfo = self::$BrokerInfo['BaseInfo'];
     //非套餐经纪人不能进入该页面,跳转到首页
     if ($brokerInfo['PAYTYPE'] != 9999) {
         $this->redirect('/user/broker/brokerhome');
     }
     //查询账户余额
     $balance = Bll_Service_Payment::balance(Bll_Service_Payment::SITE_ANJUKE, array('userId' => $userId));
     $UserAccountAll = $balance['data']['balance'] / 100.0;
     //账户余额
     $UserAccountPerson = $balance['data']['personBalance'] / 100.0;
     //账户余额(个人)
     $UserAccountCompany = $balance['data']['companyBalance'] / 100.0;
     //账户余额(公司)
     //升级需要的金额
     $result = Bll_Combo_Broker_BrokerComboInfo::getUpdatePrice($sukId, $orderId);
     //假数据
     //$result['data'] = array('price' => 1000, 'startTime' => '2014-10-30 00:00:00.0', 'endTime' => '2014-12-30 00:00:00.0');
     $errorInfo = '';
     if ($result['result'] === false) {
         $errorInfo = '套餐升级api获取失败';
     }
     if ($result['status'] == 'error') {
         $errorInfo = $result['info'];
     }
     if (!empty($errorInfo)) {
         $this->setAttribute('errorInfo', $errorInfo);
     }
     $buyComboInfo['price'] = round($result['data']['price'] / 100, 2);
     $buyComboInfo['startTime'] = date('Y.m.d', strtotime($result['data']['startTime']));
     $buyComboInfo['endTime'] = date('Y.m.d', strtotime($result['data']['endTime']));
     $buyComboInfo['day'] = floor((strtotime(date('Y-m-d', strtotime($result['data']['endTime']))) - strtotime(date('Y-m-d', strtotime($result['data']['startTime'])))) / 86400) + 1;
     $buyComboInfo['orderName'] = $orderName;
     if ($act != 'pay') {
         $str = '';
         if ($params['AjkNum'] > 0) {
             $str .= '二手房' . $params['AjkNum'] . '套';
         }
         if ($params['HzNum'] > 0) {
             $str .= ($str ? ',' : '') . '租房' . $params['HzNum'] . '套';
         }
         if ($params['JpNum'] > 0) {
             $str .= ($str ? ',' : '') . '金铺' . $params['JpNum'] . '套';
         }
     } else {
         $str = $params['NumStr'];
     }
     $buyComboInfo['propStr'] = $str;
     $buyComboInfo['sukId'] = $sukId;
     $buyComboInfo['orderId'] = $orderId;
     $buyComboInfo['AjkNum'] = $params['AjkNum'];
     $buyComboInfo['HzNum'] = $params['HzNum'];
     $buyComboInfo['JpNum'] = $params['JpNum'];
     $this->setAttribute('buyComboInfo', $buyComboInfo);
     $this->setAttribute('UserAccountAll', number_format($UserAccountAll, 2));
     $request->set_attribute("UserAccountPerson", number_format($UserAccountPerson, 2));
     $request->set_attribute("UserAccountCompany", number_format($UserAccountCompany, 2));
     $this->setAttribute('params', $params);
     //购买
     if ($act == 'pay') {
         //密码加密
         $md5_password = md5($password);
         $baseencode_password = base64_encode($md5_password);
         //查询经纪人信息
         $userInfo = Model_Broker_Member::getAjkMembersByUserId($userId);
         //验证密码
         if ($userInfo->userPwd == $baseencode_password) {
             //升级
             $buySuccess = Bll_Combo_Broker_BrokerComboInfo::upgradeCombo($userId, $sukId, $orderId);
             //升级是否成功
             $this->setAttribute('buySuccess', $buySuccess['status']);
             $this->setAttribute('buyMessage', $buySuccess['errMsg']);
             return 'Combo_Update_Result';
         } else {
             //密码错误
             $this->setAttribute('pwdErr', 1);
         }
     }
     return 'Combo_Update_Pay';
 }