Пример #1
0
 protected function findModel($id)
 {
     if (($model = Invest::findOne($id)) !== null) {
         /** @var Invest $model */
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #2
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)));
         }
     }
 }
Пример #3
0
 /**
  * @return Invest
  */
 public function getInvestModel()
 {
     return Invest::findOne($this->invest_id);
 }