Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AssetConfig::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     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;
     }
     $query->andFilterWhere(['id' => $this->id, 'deposit_num' => $this->deposit_num, 'deposit_min' => $this->deposit_min, 'deposit_max' => $this->deposit_max, 'invest_num' => $this->invest_num, 'invest_min' => $this->invest_min, 'invest_max' => $this->invest_max, 'withdraw_num' => $this->withdraw_num, 'withdraw_min' => $this->withdraw_min, 'withdraw_max' => $this->withdraw_max, 'ransom_num' => $this->ransom_num, 'ransom_min' => $this->ransom_min, 'ransom_max' => $this->ransom_max, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     return $dataProvider;
 }
Example #2
0
 /**
  *Auther:langxi
  *
  * 获取系统规定的用户每日允许的最大赎回次数
  * @return string
  */
 private static function redeemkTime()
 {
     $result = AssetConfig::find()->select(['ransom_num'])->asArray()->one();
     if ($result) {
         $result = $result['ransom_num'];
     } else {
         $result = array('errorNum' => '1', 'errorMsg' => '获取允许用户每日的最大赎回次数失败', 'data' => null);
         return $result;
     }
     return $result;
 }
 /**
  * Finds the AssetConfig model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return AssetConfig the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = AssetConfig::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #4
0
 /**
  * 获取用户的详细信息--认证信息--账户信息
  * @param $uid
  * @return array|null|\yii\db\ActiveRecord
  */
 public static function getUserInfo($uid)
 {
     $year_rate = '0.08';
     //活动期间利率调整TODO
     date_default_timezone_set('PRC');
     //活动开始时间
     $begin_time = strtotime('2015-9-24');
     //活动结束时间
     $end_time = strtotime('2015-9-30');
     //当前时间
     $now_time = time();
     if ($now_time > $begin_time && $now_time < $end_time) {
         $year_rate = '0.0815';
     }
     $yes_money = 0;
     $info = UcenterMember::find()->joinWith('info')->select(['id', 'ucenter_member.status', 'lock', 'invitation_code', 'phone', 'idcard', 'real_name', 'bank_card', 'bank_card_phone', 'balance', 'total_invest', 'invest', 'profit', 'total_revenue'])->where(['id' => $uid])->asArray()->one();
     if ($info == null) {
         $return = array('errorNum' => '1', 'errorMsg' => '用户不存在', 'data' => null);
         return $return;
     }
     //获取网站配置信息
     $config = AssetConfig::find()->select(['id', 'deposit_num', 'deposit_min', 'deposit_max', 'deposit_time', 'invest_num', 'invest_min', 'invest_max', 'invest_time', 'withdraw_num', 'withdraw_min', 'withdraw_max', 'withdraw_time', 'ransom_num', 'ransom_min', 'ransom_max', 'ransom_time'])->where(['id' => '2'])->asArray()->one();
     //获取用户昨日收益金额
     //今日零时时间
     $zero_time = strtotime(date("Y-m-d"));
     //获取昨日收益
     $get_yes_money = Income::find()->where(['>', 'created_at', $zero_time])->andWhere(['member_id' => $uid])->one();
     //获取昨日收益金额--利率
     $yes_experience_money = 0;
     if ($get_yes_money) {
         $yes_money = $get_yes_money->smoney ? $get_yes_money->smoney : 0;
         $year_rate = $get_yes_money->rate ? $get_yes_money->rate : 0;
         $yes_experience_money = $get_yes_money->goldincome ? $get_yes_money->goldincome : 0;
     }
     //获取体验金
     $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);
     }
     //获取活动红包可用金额
     $red_packet_money = 0;
     $red_money = member::get_user_red_packet($uid);
     if (!$red_money['errorNum']) {
         $red_packet_money = $red_money['data']['red_sum'];
     }
     $activity_invite = '';
     //用户再投资金大于一元,可以进行分享
     //        $invest = $info['invest'] ? $info['invest'] : 0;
     //        if($invest >= 1){
     //            $activity_invite = AloneMethod::encrypt($info['phone']);
     //        }
     $activity_invite = AloneMethod::encrypt($info['phone']);
     $data = array('phone' => $info['phone'], 'idcard' => $info['idcard'], 'real_name' => $info['real_name'], 'status' => $info['status'], 'lock' => $info['lock'], 'invitation_code' => $info['invitation_code'], 'bank_card' => $info['bank_card'], 'bank_card_phone' => $info['bank_card_phone'], 'balance' => $info['balance'], 'total_invest' => $info['total_invest'], 'total_revenue' => $info['total_revenue'], 'invest' => $info['invest'], 'profit' => $info['profit'], 'yesterday_rate' => sprintf("%.4f", $year_rate), 'yesterday_money' => $yes_money, 'experience_money' => $experience_money, 'yes_experience_money' => $yes_experience_money, 'red_packet_money' => $red_packet_money, 'activity_invite' => $activity_invite, 'config' => $config);
     $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
     return $return;
 }
Example #5
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'));
 }
Example #6
0
 /**
  *Auther:langxi
  *
  * 获取系统规定的用户每日允许的最大投资次数
  * @return string
  */
 private static function investkTime()
 {
     $result = AssetConfig::find()->select(['invest_num'])->asArray()->one();
     if ($result) {
         $result = $result['invest_num'];
     } else {
         throw new ErrorException('获取允许用户每日的最大投资次数失败', 6002);
     }
     return $result;
 }
Example #7
0
 /**
  *Auther:langxi
  *
  * 获取系统规定的用户每日允许的最大赎回次数
  * @return string
  */
 private static function redeemkTime()
 {
     $result = AssetConfig::find()->select(['ransom_num'])->asArray()->one();
     if ($result) {
         $result = $result['ransom_num'];
     } else {
         throw new ErrorException('获取允许用户每日的最大赎回次数失败', 1004);
     }
     return $result;
 }