Example #1
0
 public function actionList($id)
 {
     $data = Order::find()->andWhere(['product_id' => $id]);
     $pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => '10']);
     $model = $data->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('list', ['model' => $model, 'pages' => $pages]);
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Order::find()->orderBy('id DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $this->load($params);
     if (\App::$app->request->post()) {
         $time = \App::$app->request->post()['time'];
         if ($time) {
             $arr = explode('至', \App::$app->request->post()['time']);
             //var_dump($arr);
             //            var_dump(strtotime($arr[0].' 00:00:00'));
             //            var_dump(strtotime($arr[1].' 23:59:59'));
             $query->andWhere(['between', 'create_at', strtotime($arr[0] . ' 00:00:00'), strtotime($arr[1] . ' 23:59:59')]);
         }
     }
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $ucmember = new UcenterMember();
     $ucmember = $ucmember->find()->andWhere(['username' => $this->member_id])->one();
     $uid = $ucmember ? $ucmember->id : '';
     $query->andFilterWhere(['id' => $this->id, 'member_id' => $uid, 'product_id' => $this->product_id, 'money' => $this->money, 'status' => $this->status, 'start_at' => $this->start_at, 'end_at' => $this->end_at, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     return $dataProvider;
 }
Example #3
0
 public function actionInfoview()
 {
     $uid = Yii::$app->user->id;
     $info = Info::find()->where(['member_id' => $uid])->one();
     //投资总额
     $invest_total = 0;
     $model_order = Order::find()->where(['member_id' => Yii::$app->user->id, 'status' => 1])->all();
     if (count($model_order) > 0) {
         foreach ($model_order as $K => $V) {
             $invest_total += $V->money;
         }
     }
     return $this->view('infoview', compact('info', 'invest_total'));
 }
Example #4
0
 public function actionIndex()
 {
     $uid = Yii::$app->user->id;
     $isAuthentic = member::isAuthentic(yii::$app->user->id);
     if ($isAuthentic['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有实名制认证')</script>";
         echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/step2']) . "'</script>";
         exit;
     }
     //判断用户是否绑定银行卡
     $is_bind = sinapay::isBinding($uid);
     $model = UcenterMember::find()->where(['id' => $uid])->one();
     if ($is_bind['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有绑定银行卡');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['site/bindcard']) . "'</script>";
         exit;
     }
     $limitConfig = sinapay::getsiteConfig();
     if ($limitConfig) {
         $ransom_max = $limitConfig->ransom_max;
         $ransom_min = $limitConfig->ransom_min;
         $ransom_times = $limitConfig->ransom_num;
     }
     $collect = AloneMethod::user_collect($uid)[data];
     //在投金额和在投收益
     $red_packet = member::get_user_red_packet($uid)[data];
     //个人账户
     $model_asset = Info::find()->where('member_id=' . Yii::$app->user->id)->one();
     //投资总额
     $invest_total = 0;
     $model_order = Order::find()->where('member_id=' . Yii::$app->user->id . " AND status=1")->all();
     if (count($model_order) > 0) {
         foreach ($model_order as $K => $V) {
             $invest_total += $V->money;
         }
     }
     $invest_total += $model_asset->profit;
     return $this->view('index', compact('invest_total', 'ransom_max', 'ransom_min', 'ransom_times', 'collect', 'red_packet'));
 }
Example #5
0
 public function actionIndex()
 {
     $betime = strtotime(date('Y-m-d' . ' 00:00:00', time()));
     $endtime = strtotime(date('Y-m-d' . ' 23:59:59', time()));
     $order = Order::find()->andWhere(['between', 'start_at', $betime, $endtime])->asArray()->count();
     $payment = SinaDeposit::find()->andWhere(['status' => SinaDeposit::STATUS_SUCCESS])->andWhere(['between', 'create_at', $betime, $endtime])->asArray()->count();
     $withdraw = SinaWithdraw::find()->andWhere(['status' => SinaWithdraw::STATUS_SINA_SUCCESS])->andWhere(['between', 'create_at', $betime, $endtime])->asArray()->count();
     $product = Thirdproduct::find()->andWhere(['status' => Thirdproduct::STATUS_ACTIVE])->andWhere(['intent' => Thirdproduct::INTENT_CHECK])->andWhere(['create_user_id' => Yii::$app->user->identity->getId()])->asArray()->all();
     $user = UcenterMember::find()->andWhere(['between', 'created_at', $betime, $endtime])->asArray()->count();
     $log = TradeLog::find()->orderBy('t_date desc');
     $pages = new Pagination(['totalCount' => $log->count(), 'pageSize' => '10']);
     $log = $log->offset($pages->offset)->limit($pages->limit)->all();
     AloneMethod::trade_log();
     $cur_recharge = TradeLog::find()->sum('t_recharge');
     $cur_invest = TradeLog::find()->sum('t_invest');
     $cur_redeem = TradeLog::find()->sum('t_redeem');
     $cur_withdraw = TradeLog::find()->sum('t_withdraw');
     $cur_profit = TradeLog::find()->sum('t_profit');
     $cur_glod = TradeLog::find()->sum('t_gold');
     $cur_red = TradeLog::find()->sum('t_red');
     $ret_msg = '当前总额: 充值【' . $cur_recharge . '】 投资【' . $cur_invest . '】 赎回【' . $cur_redeem . '】 提现【' . $cur_withdraw . '】 在投【' . $cur_profit . '】 体验金收益【' . $cur_glod . '】 红包【' . $cur_red . '】';
     return $this->render('index', ['withdraw' => $withdraw, 'payment' => $payment, 'order' => $order, 'user' => $user, 'product' => $product, 'log' => $log, 'pages' => $pages, 'ret_msg' => $ret_msg]);
 }
Example #6
0
 /**
  * Auther:langxi
  * 根据赎回债权字典进行赎回操作
  * @param $Redeem
  */
 private static function Set_redeem($Redeem)
 {
     foreach ($Redeem as $k => $v) {
         //order表金额赎回
         $order = Order::findOne($v['order_id']);
         $order->money = $order['money'] - $v['thirdmoney'];
         if ($order['money'] == '0') {
             $order->status = Order::STATUS_DELETE;
         }
         $order = $order->save();
         if (!$order) {
             $result = array('errorNum' => '1', 'errorMsg' => '转让债权赎回失败', 'data' => null);
             return $result;
         }
         //thirdorder表金额赎回
         $thirdorder = Thirdorder::findOne($v['thirdorder_id']);
         $thirdorder->money = $thirdorder['money'] - $v['thirdmoney'];
         if ($thirdorder['money'] == '0') {
             $thirdorder->status = Thirdorder::STATUS_DELETED;
         }
         $thirdorder->mcmoney = $thirdorder['mcmoney'] + $v['thirdmoney'];
         //记录最大债权增加
         $thirdorder->ocmoney = $thirdorder['ocmoney'] - $v['thirdmoney'];
         //记录原始债权金额减少
         $thirdorder = $thirdorder->save();
         if (!$thirdorder) {
             $result = array('errorNum' => '1', 'errorMsg' => '第三方转让债权失败', 'data' => null);
             return $result;
         }
         //thirdproduct第三方债权已投金额减少
         $thirdproduct = Thirdproduct::findOne($v['thirdproduct_id']);
         $thirdproduct->invest_sum = $thirdproduct['invest_sum'] - $v['thirdmoney'];
         $thirdproduct->mcmoney = $thirdproduct['mcmoney'] + $v['thirdmoney'];
         //赎回导致最大债权人金额增加
         $thirdproduct = $thirdproduct->save();
         if (!$thirdproduct) {
             $result = array('errorNum' => '1', 'errorMsg' => '赎回第三方债权已投金额失败', 'data' => null);
             return $result;
         }
         //获取债权的最大债权人id,将用户赎回的钱从最大债权人的账户中减去
         $maxcreditor = Thirdproduct::find()->select(['maxcreditor'])->where(['id' => $v['thirdproduct_id']])->asArray()->one();
         $maxcreditor = $maxcreditor['maxcreditor'];
         $is_max = Catmiddle::find()->where(['cid' => '1', 'uid' => $maxcreditor])->asArray()->one();
         if (!$is_max) {
             $result = array('errorNum' => '1', 'errorMsg' => '最大债权人异常', 'data' => null);
             return $result;
         }
         $max_info = Info::findOne($maxcreditor);
         $max_info->balance = $max_info['balance'] - $v['thirdmoney'];
         $max_info = $max_info->save();
         if (!$max_info) {
             $result = array('errorNum' => '1', 'errorMsg' => '消减最大债权人账户金额失败', 'data' => null);
             return $result;
         }
         //写入职员账户记录表中
         $member_id = Order::find()->select(['member_id'])->where(['id' => $v['order_id']])->asArray()->one();
         $member_id = $member_id['member_id'];
         $clerk = new ClerkLog();
         $clerk->member_id = $member_id;
         $clerk->clerk_id = $maxcreditor;
         $clerk->behav = ClerkLog::CLERK_BEHAV_TWO;
         $clerk->step = $v['thirdmoney'];
         $clerk->remark = '最大债权人';
         $clerk = $clerk->save();
         if (!$clerk) {
             throw new ErrorException('写入职员账户记录失败');
         }
     }
     return true;
 }
Example #7
0
 public function actionInvestinfos()
 {
     if (\yii::$app->user->isGuest) {
         $this->redirect(['site/login']);
     }
     $pid = $_GET['id'];
     $uid = yii::$app->user->id;
     $model = Product::find()->where('id=' . $pid)->one();
     $model_asset = Info::find()->where(['member_id' => Yii::$app->user->id])->one();
     $model_orders = Order::find()->where('product_id=' . $pid)->asArray()->all();
     //本期投资记录
     $query = (new Query())->select("C.real_name,A.start_money,A.start_at")->from("fund_orders AS A")->where("product_id=" . $pid)->join("left join", "ucenter_member AS C", "A.member_id = C.id")->orderBy('start_at DESC');
     $rows = $query;
     $pages = new Pagination(['totalCount' => $rows->count(), 'pageSize' => '8']);
     $array_investlog = $rows->offset($pages->offset)->limit($pages->limit)->all();
     //最大投资限额——(后台设置里取值)
     $limitConfig = sinapay::getsiteConfig();
     $invest_max = 10000;
     $invest_min = 5;
     $invest_times = 3;
     if ($limitConfig) {
         $invest_max = $limitConfig->invest_max;
         $invest_min = $limitConfig->invest_min;
         $invest_times = $limitConfig->invest_num;
         //当日投资次数
         $today_num = Log::find()->where('member_id = ' . $uid . '  AND create_at > ' . strtotime(date("Y-m-d")) . ' AND status=2')->count();
     }
     $k_money = Invest::kmoney($pid);
     return $this->render('investinfos', compact("invest_max", "invest_min", "invest_times", "today_num", "model", "k_money", "model_orders", "array_investlog", "pages", "model_asset"));
 }
Example #8
0
 public function actionMember()
 {
     Utils::ensureOpenId();
     $openId = Yii::$app->request->get('open_id');
     if (($usermodel = UcenterMember::findOne(['openid' => $openId])) !== null) {
         Yii::$app->user->login($usermodel);
     } elseif (yii::$app->user->isGuest) {
         return $this->redirect(['site/signin']);
     }
     $uid = yii::$app->user->id;
     /* $datas = AloneMethod::user_collect(118);
        var_dump($datas);exit;*/
     $model = UcenterMember::find()->where(['id' => $uid])->one();
     //个人账户
     $income_yesterday = Income::find()->where(['member_id' => $uid, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->smoney;
     //体验金收益
     $experience_income = Income::find()->where(['member_id' => $uid, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->goldincome;
     //红包收益
     $railscard = Income::find()->where(['member_id' => $uid, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->railscard;
     $model_asset = Info::find()->where(['member_id' => Yii::$app->user->id])->one();
     $balance = $model_asset->balance;
     //当前余额
     $income_total = $model_asset->total_revenue;
     //累计收益
     //投资总额
     $invest_total = 0;
     $model_order = Order::find()->where(['member_id' => Yii::$app->user->id, 'status' => 1])->all();
     if (count($model_order) > 0) {
         foreach ($model_order as $K => $V) {
             $invest_total += $V->money;
         }
     }
     // 体验金
     $experience_money = 0;
     $money = Gold::find()->where(['<', 'created_at', time()])->andWhere(['>', 'end_at', time()])->andWhere(['uid' => $uid, 'status' => Gold::STATUS_ACTIVE])->sum('money');
     if ($money) {
         $experience_money = sprintf("%.2f", $money);
     }
     return $this->view('member', compact("model", 'income_yesterday', 'balance', 'income_total', 'invest_total', 'experience_money', 'experience_income', 'railscard'));
 }
Example #9
0
 public function actionIndex()
 {
     error_reporting(0);
     //取出后台设置最大红包
     $maxincome = Setting::getCode('maxincome');
     //取出后台设置的每人最大红白
     $maxpeople = Setting::getCode('maxpeople');
     //后台设置体验金利率
     $goldrate = Setting::getCode('goldrate');
     //设定时区
     date_default_timezone_set('PRC');
     //取出当前时间
     $btime = date('Y-m-d' . '00:00:00', time());
     //转换成“开始”的时间戳
     $btimestr = strtotime($btime);
     //
     //判定今日是否已经计算了收益---防止收益被多次计算
     $count = Income::find()->where(['>', 'created_at', $btimestr])->count();
     if ($count) {
         return '收益已经计算过了';
     }
     //查询昨天以前所有的投资订单,查询order表
     $order = Order::find()->select('member_id,sum(money) as smoney,product_id')->andWhere(['<', 'start_at', Utils::alldaytostr($btimestr)[1]])->andWhere(['status' => 1])->groupBy(['member_id', 'product_id'])->asArray()->all();
     $arrnew = array();
     //循环所有投资
     //        $test = 0;
     foreach ($order as $k => $v) {
         //查询订单下对应项目
         $product = Product::findOne($v['product_id']);
         //查询昨天的生成的利息
         $income = Income::find()->andWhere(['member_id' => $v['member_id']])->andWhere(['between', 'created_at', Utils::alldaytostr($btimestr)[0], Utils::alldaytostr($btimestr)[1]])->one();
         //查询增值卡昨天信息
         //            $railscard = RaiseCard::find()
         //                ->select('member_id,sum(rate) as srate')
         //                ->andWhere(['member_id'=>$v['member_id']])
         //                ->andWhere(['<', 'use_at',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['>', 'use_end_time',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['status'=>RaiseCard::STATUS_USE])
         //                ->groupBy(['member_id'])
         //                ->asArray()
         //                ->one();
         //昨日签到人数
         $count = SignIn::find()->joinWith(['info' => function ($query) {
             /** @var \yii\db\ActiveQuery $query */
             $query->andWhere(['>', 'asset_info.invest', '1000']);
         }])->andWhere(['between', 'sign_in.sign_in_time', Utils::alldaytostr($btimestr)[0], Utils::alldaytostr($btimestr)[1]])->asArray()->count();
         //每人赠送利息,如果每人分的利息大于设置的每人获得的最大利息,就用设置的每人利息,如果小于就用分的利息
         $everyincome = 0;
         if ($count) {
             $everyincome = $maxincome / $count > $maxpeople ? $maxpeople : $maxincome / $count;
         }
         //取出昨天这个人有没有签到
         $rails = SignIn::find()->andWhere(['uid' => $v['member_id']])->andWhere(['between', 'sign_in_time', Utils::alldaytostr($btimestr)[0], Utils::alldaytostr($btimestr)[1]])->asArray()->one();
         //判断订单是否有总金额
         $smoney = isset($v['smoney']) ? $v['smoney'] : 0;
         //查询该用户体验金
         //            $all = Gold::find()->select('experience_gold.id,experience_gold.rid,sum(experience_gold.money) as gmoney')->andWhere(['uid'=>$v['member_id']])->joinWith(['rule' => function ($query) {
         //                /** @var \yii\db\ActiveQuery $query */
         //                $query->andWhere(['experience_rule.status'=>Rule::STATUS_ACTIVE]);
         //            }])->asArray()->all();
         //
         //            //查询发放给该用户体验金昨天信息
         //            $sendgold = RaiseCard::find()
         //                ->select('member_id,sum(rate) as srate')
         //                ->andWhere(['member_id'=>$v['member_id']])
         //                ->andWhere(['<', 'validity_start_at',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['>', 'validity_out_at',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['status'=>RaiseCard::STATUS_USE])
         //                ->asArray()
         //                ->one();
         //查询该用户体验金-----TODO
         $all = Gold::find()->select('uid,sum(money) as smoney')->andWhere(['uid' => $v['member_id'], 'status' => Gold::STATUS_ACTIVE])->andWhere(['<', 'created_at', time()])->andWhere(['>', 'end_at', time()])->asArray()->one();
         //            $summoney = 0;
         //            foreach($all as $kmmy=>$vmmy){
         //                $newbetime = strtotime(date('Y-m-d'.' 00:00:00',time()));
         //                $endtime = $vmmy['created_at'] + 3600 * 24 * $vmmy['time'];
         //                if($vmmy['created_at']<$newbetime && $endtime>$newbetime){
         //                    $summoney +=$all[$kmmy]['money'];
         //                }
         //            }
         //            var_dump($summoney);
         //            var_dump($all);
         //查询发放给该用户体验金昨天信息
         //            $sendgold = RaiseCard::find()
         //                ->select('member_id,sum(rate) as srate')
         //                ->andWhere(['member_id'=>$v['member_id']])
         //                ->andWhere(['<', 'validity_start_at',Utils::alldaytostr($btimestr)[1]])
         //                ->andWhere(['>', 'validity_out_at',Utils::alldaytostr($btimestr)[1]])
         //                ->groupBy(['member_id'])
         //                ->asArray()
         //                ->one();
         //计算利率,增息卡的利率+项目的利率
         //            $railscardrate = isset($railscard)? $railscard['srate']+$product->rate/365:$product->rate/365;
         //TODO
         $railscardrate = isset($railscard) ? $railscard['srate'] + $product->rate : $product->rate;
         //活动期间利率调整TODO
         date_default_timezone_set('PRC');
         //活动开始时间
         $begin_time = strtotime('2015-10-1');
         //活动结束时间
         $end_time = strtotime('2015-10-7');
         //当前时间
         $now_time = time();
         if ($now_time > $begin_time && $now_time < $end_time) {
             $railscardrate = '0.101';
         }
         $railscardrate = '0.08';
         //组成新数组,用户的id
         $arrnew[$v['member_id']]['member_id'] = $v['member_id'];
         //用户昨日利息,因利息也会产生利息,所以昨日利息乘以利率
         // $arrnew[$v['member_id']]['smoney'] += isset($income)?($smoney+$income->smoney)*Utils::moneyFormat($railscardrate) :$smoney*Utils::moneyFormat($railscardrate);
         //投资总额---记录当前再投资金
         $arrnew[$v['member_id']]['money'] += $v['smoney'];
         //计算收益--TODO
         $arrnew[$v['member_id']]['smoney'] += ceil($smoney * $railscardrate * 100 / 365) / 100;
         //取不包含红包体验金收益
         $arrnew[$v['member_id']]['iincome'] += ceil($smoney * $railscardrate * 100 / 365) / 100;
         //用户的昨日之前的累计利息
         // isset($income)? $arrnew[$v['member_id']]['newmoney'] = $arrnew[$v['member_id']]['smoney']+$income->newmoney : $arrnew[$v['member_id']]['newmoney'] += $smoney*Utils::moneyFormat($railscardrate);
         // TODO
         isset($income) ? $arrnew[$v['member_id']]['newmoney'] = $arrnew[$v['member_id']]['smoney'] + $income->newmoney : ($arrnew[$v['member_id']]['newmoney'] += ceil($smoney * $railscardrate * 100 / 365) / 100);
         //签到获取的利息
         $arrnew[$v['member_id']]['railscard'] = $rails ? $everyincome : 0;
         //在投金额大于1元--计算体验金收益
         if ($smoney >= 1) {
             //计算该用户体验金获取的利息
             $arrnew[$v['member_id']]['goldincome'] = ceil($all['smoney'] * $railscardrate * 100 / 365) / 100;
         }
         //每人的利率
         $arrnew[$v['member_id']]['rate'] = $railscardrate;
     }
     foreach ($arrnew as $k => &$v) {
         //求出每个用户的昨日利率
         $v['rate'] = Utils::moneyFormat(($v['smoney'] + $v['railscard']) * 365 / $v['money']);
         //总利息加上签到获取的利息
         $v['newmoney'] = $v['railscard'] + $v['newmoney'] + $v['goldincome'];
         //利息加上签到获取的利息
         $v['smoney'] = $v['railscard'] + $v['smoney'] + $v['goldincome'];
         //利息计算时的投资---
         //            $v['money'] = $v['money']  + $v['goldincome'] + $v['railscard'];
         // -- 计算在投金额不应该增加利息产生的金额
         $v['money'] = $v['money'];
     }
     //循环数组
     foreach ($arrnew as $vs) {
         $_model = new Income();
         //查出用户表的余额
         $Info = Info::find()->where(['member_id' => $vs['member_id']])->one();
         if ($Info) {
             $Info->profit = $Info->profit + $vs['smoney'];
             $Info->total_revenue = $Info->total_revenue + $vs['smoney'];
             $Info->save();
         }
         //取出昨天这个人有没有签到
         $signin = SignIn::find()->andWhere(['uid' => $vs['member_id']])->andWhere(['between', 'sign_in_time', Utils::alldaytostr($btimestr)[0], Utils::alldaytostr($btimestr)[1]])->one();
         if ($signin && $vs['money'] >= 1000) {
             $signin->sign_in_money = $vs['railscard'];
             $signin->status = SignIn::STATUS_FINISH;
             $signin->save();
             $_model->railscard = $vs['railscard'];
         }
         $_model->member_id = $vs['member_id'];
         $_model->smoney = $vs['smoney'];
         $_model->money = $vs['money'];
         $_model->rate = $vs['rate'];
         $_model->newmoney = $vs['newmoney'];
         $_model->goldincome = $vs['goldincome'];
         $_model->iincome = $vs['iincome'];
         //生成每日利息表的数据
         $_model->save();
     }
     //推荐大师活动
     //获取所有用户信息
     $users = UcenterMember::find()->select(['id'])->asArray()->all();
     if ($users !== null) {
         //获取所有用户id值
         foreach ($users as $key => $value) {
             //循环用户信息--判定其推荐人中是否有符合奖励规则的人--有进行推荐表中状态更改
             AloneMethod::produce_red_packet($value['id']);
         }
     }
     //判定推荐表中用户是否符合拿取奖励规则
     if ($users !== null) {
         foreach ($users as $key => $value) {
             AloneMethod::send_red_packet($value['id']);
         }
     }
     echo "成功";
 }
Example #10
0
 public function actionRedemption()
 {
     $uid = yii::$app->user->id;
     $isAuthentic = member::isAuthentic(yii::$app->user->id);
     if (!$isAuthentic) {
         echo "<script>alert('您还没有实名制认证')</script>";
         echo "<script>window.location.href='" . \yii\helpers\Url::to(['setting/setting']) . "'</script>";
         exit;
     }
     $is_bind = sinapay::isBinding($uid);
     if ($is_bind['errorNum'] == 0) {
         $result_bind = $is_bind['data'];
         $logo_bind = self::BankInfos();
     } elseif ($is_bind['errorNum'] != 0) {
         header("Content-type: text/html; charset=utf-8");
         echo "<script>alert('您还没有绑定银行卡');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['money/bindcard']) . "'</script>";
         exit;
     }
     //最大赎回限额——(后台设置里取值)
     $limitConfig = sinapay::getsiteConfig();
     $redemption_max = 10000;
     $redemption_min = 5;
     $redemption_times = 3;
     if ($limitConfig) {
         $redemption_max = $limitConfig->ransom_max;
         $redemption_min = $limitConfig->ransom_min;
         $redemption_times = $limitConfig->ransom_num;
         //当日充值次数
         $today_num = Log::find()->where('member_id = ' . $uid . '  AND create_at > ' . strtotime(date("Y-m-d")) . ' AND status=3')->count();
     }
     $model = UcenterMember::find()->where('id=' . Yii::$app->user->id)->one();
     $uid = Yii::$app->user->id;
     //个人账户
     $model_asset = Info::find()->where('member_id=' . Yii::$app->user->id)->one();
     //用户投资记录
     $model_income = Income::find()->where('member_id=' . Yii::$app->user->id)->all();
     //投资总额
     $invest_total = 0;
     $model_order = Order::find()->where('member_id=' . Yii::$app->user->id . " AND status=1")->all();
     if (count($model_order) > 0) {
         foreach ($model_order as $K => $V) {
             $invest_total += $V->money;
         }
     }
     $invest_total += $model_asset->profit;
     $bank_card = Withdrawals::showCard($uid);
     //银行卡号
     $balance = Withdrawals::showBlance($uid);
     //显示余额
     //赎回操作
     if (isset($_POST['money'])) {
         $money = $_POST['money'];
         try {
             $result = Withdrawals::User_redeem($uid, $money);
             if ($result) {
                 echo '赎回成功';
                 exit;
             }
         } catch (ErrorException $e) {
             echo $e->getMessage();
             exit;
         }
     }
     $config = AssetConfig::find()->select(['id', 'ransom_num', 'ransom_min', 'ransom_max'])->where(['id' => '2'])->asArray()->one();
     $infos_rar = $this->Ucenter();
     //用户数据包
     return $this->render('redemption', compact("bank_card", "balance", "infos_rar", "amount_total", "invest_total", "model", "result_bind", "logo_bind", "redemption_max", "redemption_min", "today_num", "redemption_times", 'config'));
 }