Esempio n. 1
0
 public function actionPay()
 {
     $member = wanhunet::app()->member;
     $request = wanhunet::$app->request;
     $investOrder = new InvestList();
     /** @var Invest $invest */
     $invest = Invest::findOne($request->post('invest_id'));
     $investOrder->investment_sum = $request->post('investment_sum');
     $investOrder->invest_id = $request->post('invest_id');
     if (empty($investOrder->investment_sum) or empty($investOrder->invest_id)) {
         $urlr = wanhunet::$app->request->post('return_url', 'list');
         $url = ['invest/' . $urlr];
         if ($urlr === 'view') {
             $url = ['invest/' . $urlr, 'id' => $request->post('invest_id')];
         }
         return $this->goBack(["info" => "请填写所有内容"], Url::to($url));
     }
     try {
         $order = $invest->markOrder($investOrder);
     } catch (\ErrorException $e) {
         $urlr = wanhunet::$app->request->post('return_url', 'list');
         $url = ['invest/' . $urlr];
         if ($urlr === 'view') {
             $url = ['invest/' . $urlr, 'id' => $request->post('invest_id')];
         }
         return $this->goBack(['info' => $e->getMessage()], Url::to($url));
     }
     if ($request->post('pay_style') == 'balance') {
         try {
             /** @var InvestList $order */
             $order = InvestList::findOne($investOrder->id);
             return $member->payOrderWithBalance($order);
         } catch (\ErrorException $e) {
             if ($e->getCode() == ErrorCode::Pay_pass_empty) {
                 wanhunet::$app->getSession()->set('order', $investOrder->id);
                 return $this->redirect(Url::to(['pay/pay-pass']));
             } else {
                 return $this->goBack(['info' => $e->getMessage()], Url::to(['invest/list']));
             }
         }
     } else {
         $bankCard = $member->getBankCard();
         if (count($bankCard) <= 0) {
             return $this->goBack(['info' => '请先绑定银行卡'], Url::to(['site/setup']));
         } else {
             $urlManager = wanhunet::$app->urlManager;
             $order->setUrl($urlManager->createAbsoluteUrl(['pay/return']), $urlManager->createAbsoluteUrl(['pay/notify']));
             die($member->payOrderWithBankCard($order, reset($bankCard)));
         }
     }
 }
Esempio n. 2
0
 public function actionPayWithBalance()
 {
     try {
         $pass = wanhunet::app()->member->validatePayPass(wanhunet::$app->request->post('paypass'));
         if (!$pass) {
             throw new ErrorException('密码验证错误', ErrorCode::Pay_pass_empty);
         }
         /** @var InvestList $order */
         $order = InvestList::findOne(wanhunet::$app->getSession()->get("order"));
         wanhunet::app()->member->payOrderWithBalance($order);
         wanhunet::$app->getSession()->remove('order');
         return $this->view('/invest/pay_return');
     } catch (\ErrorException $e) {
         if ($e->getCode() == ErrorCode::Pay_pass_empty) {
             return $this->goBack(['info' => $e->getMessage()], Url::to(['pay/pay-pass']));
         } else {
             return $this->goBack(['info' => $e->getMessage()], Url::to(['pay/pay-pass']));
         }
     }
 }
Esempio n. 3
0
<?php

/** @var \wanhunet\base\View $this */
if (($order = \wanhunet\wanhunet::$app->getSession()->get('order')) !== null) {
    if (is_array($order)) {
        $price = \modules\asset\models\AssetMoney::findOne($order[1])->getPrice();
        $action = \yii\helpers\Url::to(['pay/mention']);
    } else {
        $price = \modules\invest\models\InvestList::findOne($order)->getPrice();
        $action = \yii\helpers\Url::to(['pay/pay-with-balance']);
    }
}
?>
    <section class="login_bt divoi wh-addpage" style="padding:20px 8px 0;">
        <form class="wh-addform" id="form" action="<?php 
echo $action;
?>
" method="post">
            <div class="divoi_odi">
                <div class="login_td login-fall">
                    <input style="text-align:center;" type="password" name="paypass" placeholder="请输入交易密码"/>
                </div>
            </div>
            <p class="font-s16 wh-addptop mb10">为了保证资金安全,请输入您的交易密码,默认为登录密码</p>

            <p class="font-s16 mt20 mb10">支付金额:<span
                    class="hui8">
                <?php 
echo $price;
?>
                    元</span></p>