Example #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.');
     }
 }
Example #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)));
         }
     }
 }
Example #3
0
 public function actionInformation()
 {
     if (($moneyModel = Invest::findByLately(Invest::TYPE_MONEY)) !== null) {
         $inverstOfMoney = Utils::timeCut($moneyModel->buy_time_start, time());
     } else {
         $inverstOfMoney = '未发布';
     }
     if (($emoneyModel = Invest::findByLately(Invest::TYPE_EXPERIENCE_MONEY)) !== null) {
         $inverstOfeMoney = Utils::timeCut($emoneyModel->buy_time_start, time());
     } else {
         $inverstOfeMoney = '未发布';
     }
     try {
         $jiuxinInfo = JiuxinApi::jiuxinGet();
         $row = wanhunet::app()->member->getOtherInfo(MemberOther::TABLE_JIUXIN)->row;
         $jiuxinInfo['j_user_name'] = current(explode('=|=', $row));
     } catch (\Exception $e) {
         $jiuxinInfo = [];
         //
         //            if ($e->getCode() == ErrorCode::Jiuxin_auth) {
         //                $jiuxinInfo = [];
         //            } else {
         //            }
     }
     return $this->view('information', ['inverstOfMoney' => $inverstOfMoney, 'inverstOfeMoney' => $inverstOfeMoney, 'jiuxinInfo' => $jiuxinInfo, 'actives' => Post::find()->where(['status' => Post::STATUS_ACTIVE])->orderBy('id desc')->all()]);
 }
Example #4
0
 private function makeView(&$investList)
 {
     $investList['created_at'] = Utils::dateFormat('Y-m-d H:i:s', $investList['created_at']);
     $investList['updated_at'] = Utils::dateFormat('Y-m-d H:i:s', $investList['updated_at']);
     $investList['interest_time'] = Utils::dateFormat('Y-m-d H:i:s', $investList['interest_time']);
     $investList['pay_time'] = Utils::dateFormat('Y-m-d H:i:s', $investList['pay_time']);
     $investList['status'] = InvestList::get_status($investList['status']);
     $investList['interest_status'] = InvestList::get_status($investList['interest_status']);
     if ($investList['status'] == '终审通过') {
         $investList['interest_status'] = '已返息';
     }
     if (isset($investList['member'])) {
         $investList['member']['idcard_status'] = Member::get_auth_status($investList['member']['idcard_status']);
         $investList['member']['email_status'] = Member::get_auth_status($investList['member']['email_status']);
         $investList['member']['status'] = Member::get_record_status($investList['member']['status']);
         $investList['member']['created_at'] = Utils::dateFormat('Y-m-d', $investList['member']['created_at']);
         foreach ($investList['member'] as $key => &$memberInfo) {
             $investList['member_' . $key] = $memberInfo;
         }
         unset($investList['member']);
     }
     if (isset($investList['invest'])) {
         $investList['invest']['invest_status'] = InvestList::get_record_status($investList['invest']['invest_status']);
         $investList['invest']['created_at'] = Utils::dateFormat('Y-m-d', $investList['invest']['created_at']);
         $investList['invest']['updated_at'] = Utils::dateFormat('Y-m-d', $investList['invest']['updated_at']);
         $investList['invest']['buy_time_start'] = Utils::dateFormat('Y-m-d', $investList['invest']['buy_time_start']);
         $investList['invest']['buy_time_end'] = Utils::dateFormat('Y-m-d', $investList['invest']['buy_time_end']);
         $investList['invest']['type'] = Invest::get_type($investList['invest']['type']);
         foreach ($investList['invest'] as $key => &$investInfo) {
             $investList['invest_' . $key] = $investInfo;
         }
         unset($investList['invest']);
     }
 }
Example #5
0
 public function actionSignupFinish()
 {
     try {
         $member = wanhunet::app()->member;
         $wechat_id = $member->getOtherInfo(MemberOther::TABLE_WECHAT);
         /** @var ShareGift $shateGift */
         $shateGift = ShareGift::find()->where(['wechat_id' => $wechat_id->row])->one();
         $limit = $shateGift->gift_limit;
         /** @var Invest $invest */
         $invest = Invest::find()->where(["type" => Invest::TYPE_REG])->one();
         if (InvestList::hasBuy($member->getId(), $invest->id)) {
             $investOrder = InvestList::find()->where(["member_id" => $member->getId()])->andWhere(['invest_id' => $invest->id])->andWhere(['status' => self::STATUS_PAYED])->one();
         } else {
             $investOrder = new InvestList();
             $investOrder->investment_sum = $limit;
             $investOrder->invest_id = $invest->id;
             $order = $invest->markOrderReg($investOrder);
             $investOrder->finishPay(new Event());
             $shateGift->has_gift = ShareGift::HAS_GIFT;
             $shateGift->user_id = $member->id;
             $shateGift->save();
         }
         return $this->view("signup_finish", ['info' => $investOrder]);
     } catch (\Exception $e) {
         //            throw $e;
         return $this->redirect(Url::to(['site/signin']));
     }
 }
Example #6
0
 public function getInvest()
 {
     return $this->hasOne(Invest::className(), ['id' => 'invest_id']);
 }