예제 #1
0
 public function handle_request_internal()
 {
     $userId = $this->_params['userId'];
     $type = $this->_params['type'];
     $source = $this->_params['source'];
     $amount = $this->_params['amount'];
     //$amount = 1;
     $userAccoutId = Bll_Fyk_Payment_User::getInstance()->getUserAccountId($userId);
     if (empty($userAccoutId)) {
         return array("status" => "error", "errcode" => Const_APIStatus::E_FYK_PROP_ACTION_ACCOUNT_IS_NULL, "message" => "支付中心账户创建失败");
     }
     /*****************创建充值订单**********/
     $addArr = array('userId' => $userId, 'accountId' => $userAccoutId, 'price' => $amount, 'payType' => $type, 'status' => Model_Fyk_RechargeOrder::STATUS_NODEAL, 'source' => $source, 'createTime' => time());
     $id = Bll_Fyk_Payment_Recharge::getInstance()->insertRechargeOrder($addArr);
     $tmpData = Bll_Fyk_Payment_Recharge::getInstance()->getRechargeOrderDataById($id);
     if (empty($id) || empty($tmpData)) {
         return array("status" => "error", "errcode" => Const_APIStatus::E_UNKNOWN, "message" => "充值插入数据库失败");
     }
     $rechargeOrder = $tmpData[0];
     $requestId = Bll_Fyk_Payment_Common::getInstance()->createRequsetId("recharge", $id);
     $orderNo = Bll_Fyk_Payment_Common::getInstance()->createOrderNo("recharge", $requestId);
     $this->updateRechargeOrderTable($rechargeOrder, array('orderNo' => $orderNo, 'status' => Model_Fyk_RechargeOrder::STATUS_DEALING));
     /*****************生成支付中心充值参数**********/
     // 获取ack
     $tmpAckResult = Bll_Fyk_Payment_Common::getInstance()->getAckValue($userAccoutId);
     $ack = $tmpAckResult['status'] ? $tmpAckResult['sessionkey'] : "";
     $userData = Bll_Broker_User::getBrokerInfoByUserId($userId);
     $apps = APF::get_instance()->get_config('apps', 'acenter');
     $userName = !empty($userData) ? $userData['trueName'] : '';
     $orderName = "移动经纪人钱包充值";
     $appId = $apps['fyk']['appId'];
     $backUrl = $this->getBackUrl($id, $userId, $amount);
     $cityId = !empty($userData) ? $userData['cityId'] : '';
     $mobile = !empty($userData) ? $userData['userMobile'] : '';
     if (empty($userAccoutId) || empty($ack) || empty($userName) || empty($cityId) || empty($mobile)) {
         return array('status' => "error", "errcode" => Const_APIStatus::E_PARAM_MISS, "message" => "参数不正确");
     }
     $objApi = new Uri_PayCenterAPI();
     $acUrl = $objApi->redirectWabPayCenter($amount / 100, $userAccoutId, $ack, $userName, $orderName, $appId, $backUrl, $orderNo, $cityId, $mobile, $orderNo);
     return array('status' => "ok", 'data' => array('acUrl' => $acUrl), "message" => "成功");
 }
 function getBalance($accountinfo)
 {
     $propSpread = APF::get_instance()->get_config("propSpread", 'app');
     $result = array();
     $PayCenter = new Uri_PayCenterAPI();
     $account_3w = array($accountinfo['accountidAjk'], $accountinfo['accountidHz'], $accountinfo['accountidJp'], $accountinfo['userId']);
     $payResp = $PayCenter->check3WMoney($propSpread['paycenter_id'], $propSpread['paycenter_key'], $account_3w, $accountinfo['userId']);
     if ($payResp) {
         // 成功
         if ($payResp['code'] == '0') {
             $result['status'] = 'ok';
             $result['data'] = array('balance' => $payResp['balance'], 'frozen' => $payResp['frozen'], 'accesslogid' => $payResp['accesslogid']);
             foreach ($payResp['sites'] as $acid => $val) {
                 if ($acid == $account_3w[0]) {
                     $result['data']['ajk_data'] = $val;
                 } elseif ($acid == $account_3w[1]) {
                     $result['data']['hz_data'] = $val;
                 } elseif ($acid == $account_3w[2]) {
                     $result['data']['jp_data'] = $val;
                 }
             }
         } else {
             $result['status'] = 'error';
             $result['data'] = array('error' => $payResp['error'], 'code' => $payResp['code']);
         }
     } else {
         $result['status'] = 'error';
         $result['data'] = array('error' => 'server error', 'code' => '500');
     }
     return $result;
 }