Example #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);
         //密码错误
     }
 }