Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Log::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, 'step' => $this->step, 'status' => $this->status, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     $query->andFilterWhere(['like', 'action', $this->action])->andFilterWhere(['like', 'bankcard', $this->bankcard])->andFilterWhere(['like', 'remark', $this->remark]);
     return $dataProvider;
 }
 public function actionInvesting()
 {
     //TODO
     //累计金额
     $money_total = Log::find()->select("sum(step) as step")->where(['action' => 'Invest/invest', 'status' => Log::STATUS_INVEST_SUC])->andWhere(['>', 'create_at', 1441641600])->asArray()->one()['step'];
     //累计收益
     $income_total = (new Query())->select("sum(smoney) as smoney")->from("fund_income")->where('created_at >= 1441641600 ')->one();
     //累计人数
     $people_total = UcenterMember::find()->where('created_at >= 1441641600 ')->count();
     //项目数量
     $product_total = Product::find()->where('create_at >= 1441641600 ')->count();
     //担保机构
     $cat_id = Cat::find()->where("name='担保机构'")->one()->id;
     $guarantee = Link::find()->where('cat_id=' . $cat_id)->limit(4)->asArray()->all();
     //投资项目列表
     //    	$invest_query = (new Query())
     //		->select("*")
     //		->from("fund_product")
     //		->orderBy('start_at DESC');
     //TODO
     $invest_query = (new Query())->select("*")->where('create_at >= 1441641600 ')->from("fund_product")->orderBy('start_at DESC');
     //分页
     $pages = new Pagination(['totalCount' => $invest_query->count(), 'pageSize' => 5]);
     $invest_datas = $invest_query->offset($pages->offset)->limit($pages->limit)->all();
     //最新投资记录
     $query = (new Query())->select("C.real_name,A.money,A.start_at")->from("fund_orders AS A")->where('A.start_at >= 1441641600 ')->join("left join", "ucenter_member AS C", "A.member_id = C.id")->orderBy("start_at DESC");
     $pages_new = new Pagination(['totalCount' => $query->count(), 'pageSize' => '8']);
     $invest_new = $query->offset($pages_new->offset)->limit($pages_new->limit)->all();
     return $this->render('investing', compact("pages", "invest_datas", "invest_new", "pages_new", "income_total", "people_total", "product_total", "guarantee", "money_total"));
 }
Esempio n. 3
0
 public function actionIndex()
 {
     $uid = Yii::$app->user->id;
     Utils::ensureOpenId();
     $openId = Yii::$app->request->get('open_id');
     if (($usermodel = UcenterMember::findOne(['openid' => $openId])) !== null) {
         Yii::$app->user->login($usermodel);
     } elseif (empty(Yii::$app->user->id)) {
         return $this->redirect(['site/signin']);
     }
     $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;
     }
     //全部记录
     $logs = AloneMethod::total_log($uid, 1, 15);
     $logs_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid])->andWhere(['>', 'status', '0'])->andWhere(['<>', 'step', '0.00'])->asArray()->all();
     $logs_pages = ceil(count($logs_pages) / 15);
     //$logs = Log::find()->select(['step','create_at','status'])->where(['member_id'=>$uid])->andWhere(['in','status',[1,2,3,4]])->orderBy('id desc')->asArray()->all();
     //充值
     $recharge = AloneMethod::recharge_log($uid, 1, 15);
     $recharge_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_RECHAR_SUC])->asArray()->all();
     $recharge_pages = ceil(count($recharge_pages) / 15);
     //投资
     $invest = AloneMethod::invest_log($uid, 1, 15);
     $invest_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_INVEST_SUC])->asArray()->all();
     $invest_pages = ceil(count($invest_pages) / 15);
     //赎回
     $ransom = AloneMethod::redeem_log($uid, 1, 15);
     $ransom_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_REDEM_SUC])->asArray()->all();
     $ransom_pages = ceil(count($recharge_pages) / 15);
     //提现
     $withdraw = AloneMethod::withdrawals_log($uid, 1, 15);
     $withdraw_pages = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $uid, 'status' => Log::STATUS_WITHDRAW_SUC])->asArray()->all();
     $withdraw_pages = ceil(count($recharge_pages) / 15);
     return $this->view('index', compact('invest', 'recharge', 'withdraw', 'ransom', 'logs', 'logs_pages', 'recharge_pages', 'invest_pages', 'ransom_pages', 'withdraw_pages'));
 }
Esempio n. 4
0
<div class="row">
<div class="log-index">


    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>



    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'member_id', 'value' => function ($model) {
    return $model->member ? $model->member->username : '******';
}], 'step', 'action', ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    if ($model->status === $model::STATUS_WITHDRAW_SUC) {
        $class = 'label-success';
    } elseif ($model->status === $model::STATUS_INVEST_SUC) {
        $class = 'label-success';
    } elseif ($model->status === $model::STATUS_REDEM_SUC) {
        $class = 'label-success';
    } elseif ($model->status === $model::STATUS_RECHAR_SUC) {
        $class = 'label-success';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', Log::getArrayStatus(), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], 'bankcard', 'remark', ['attribute' => 'create_at', 'format' => ['date', 'php:Y-m-d H:i:s']], ['attribute' => 'update_at', 'format' => ['date', 'php:Y-m-d H:i:s']]]]);
?>
</div>
</div>
Esempio n. 5
0
 private static function datas()
 {
     $uid = yii::$app->user->id;
     $model = UcenterMember::find()->where(['id' => Yii::$app->user->id])->one();
     //个人账户
     $model_asset = Info::find()->where(['member_id' => Yii::$app->user->id])->one();
     if (!isset($model_asset)) {
         //跳转至绑定银行卡
         echo "<script>alert('您还没有绑定银行卡');</script>";
         echo "<script>location.href='" . \yii\helpers\Url::to(['money/bindcard']) . "'</script>";
         exit;
     }
     //收益总额
     $income_total = $model_asset->total_revenue;
     //当前收益
     $income_current = $model_asset->profit;
     //昨日收益
     try {
         $income_yesterday = Income::find()->where(['member_id' => yii::$app->user->id, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->smoney;
     } catch (ErrorException $e) {
         $income_yesterday = 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);
     }
     //投资总额
     $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;
         }
     }
     //用户投资记录
     $query1 = (new Query())->select("A.step,A.create_at,B.title")->from("asset_log AS A")->where('A.member_id=' . Yii::$app->user->id . " AND A.action='Invest/invest' AND A.status=2 ")->join("left join", "fund_product AS B", "A.product_id=B.id")->orderBy("A.id DESC");
     $pages = new Pagination(['totalCount' => $query1->count(), 'pageSize' => '10']);
     $array_investlog = $query1->offset($pages->offset)->limit($pages->limit)->all();
     $pages_offset = $pages->offset;
     //用户交易记录
     $query2 = Log::find()->where(['member_id' => Yii::$app->user->id, 'status' => [1, 2, 3, 4]]);
     $pages_trade = new Pagination(['totalCount' => $query2->count(), 'pageSize' => '2']);
     $array_tradelog = $query2->offset($pages_trade->offset)->limit($pages_trade->limit)->orderBy("id DESC")->all();
     $pages_trade_offset = $pages_trade->offset;
     //当前投资记录
     $query3 = (new Query())->select("A.step,A.create_at,B.title")->from("asset_log AS A")->where('A.member_id=' . Yii::$app->user->id . " AND A.action='Invest/invest' AND A.status=2 ")->join("left join", "fund_product AS B", "A.product_id=B.id")->limit(4)->orderBy("A.id DESC")->createCommand();
     $invest_log = $query3->queryAll();
     //数据包变量
     $amount_total = $model_asset->balance + $invest_total + $income_current;
     $session = yii::$app->session;
     $session->open();
     if (isset($session['last_time'])) {
         $updated_at = $session['last_time'];
     } else {
         $updated_at = $model->updated_at;
     }
     $phone = $model->phone;
     $balance = $model_asset->balance;
     $freeze = $model_asset->freeze;
     return $infos_rar = compact("invest_total", "income_total", "amount_total", "updated_at", "phone", "balance", "freeze", "invest_log", "array_investlog", "array_tradelog", "pages", "pages_trade", "pages_offset", "pages_trade_offset", "income_current", "income_yesterday", "experience_money");
 }
Esempio n. 6
0
 /**
  * 获取用户错误操作日志
  * @param $mid
  * @param $action
  * @return static[]
  */
 public static function getErrorLog($mid, $action)
 {
     $log = Log::findAll(['status' => Balance::ERROR, 'member_id' => $mid, 'action' => $action]);
     return $log;
 }
Esempio n. 7
0
 public function actionExportuser()
 {
     $users = UcenterMember::find()->asArray()->all();
     $data = array();
     if ($users !== null) {
         foreach ($users as $key => $value) {
             $data[$key]['id'] = $value['id'];
             $data[$key]['phone'] = $value['phone'];
             $data[$key]['real_name'] = $value['real_name'];
             $data[$key]['created_at'] = date('Y-m-d :H-m-s', $value['created_at']);
             $data[$key]['create_area'] = $value['create_area'];
             $status = $value['status'];
             if ($status == UcenterMember::STATUS_ACTIVE) {
                 $data[$key]['status'] = '注册用户';
             } elseif ($status == UcenterMember::STATUS_REAL) {
                 $data[$key]['status'] = '实名用户';
             } elseif ($status == UcenterMember::STATUS_BIND) {
                 $data[$key]['status'] = '绑卡用户';
             }
             //账户信息
             $info = Info::find()->where(['member_id' => $value['id']])->one();
             //账户余额
             $data[$key]['balance'] = $info['balance'];
             //在投资金
             $data[$key]['invest'] = $info['invest'];
             //可用收益
             $data[$key]['profit'] = $info['profit'];
             //累计收益
             $data[$key]['total_revenue'] = $info['total_revenue'];
             //充值--投资--赎回--提现
             //首次充值
             $rechar_at = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_RECHAR_SUC])->orderBy('id asc')->one();
             //充值总金额
             $rechar_sum = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_RECHAR_SUC])->sum('step');
             //首次投资时间
             $invest_at = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_INVEST_SUC])->orderBy('id asc')->one();
             //投资总额
             $invest_sum = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_INVEST_SUC])->sum('step');
             //赎回总额
             $redem_sum = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_REDEM_SUC])->sum('step');
             //提现总额
             $withdraw_sum = Log::find()->where(['member_id' => $value['id'], 'status' => Log::STATUS_WITHDRAW_SUC])->sum('step');
             //首次充值时间
             $data[$key]['rechar_at'] = $rechar_at ? date('Y-m-d :H-m-s', $rechar_at['create_at']) : 0;
             $data[$key]['rechar_sum'] = $rechar_sum;
             //首次投资时间
             $data[$key]['invest_at'] = $invest_at ? date('Y-m-d :H-m-s', $invest_at['create_at']) : 0;
             $data[$key]['invest_sum'] = $invest_sum;
             //赎回
             $data[$key]['redem_sum'] = $redem_sum;
             //提现
             $data[$key]['withdraw_sum'] = $withdraw_sum;
             //未领取红包奖励
             $red = member::get_user_red_packet($value['id']);
             $data[$key]['red_usable'] = $red['data']['red_sum'];
             //总的红包奖励
             $red1 = member::get_rad_list($value['id']);
             $data[$key]['red_sum'] = $red1['data']['sum'];
         }
         return Utils::exportExcel($data, array('用户id', '用户手机号', '用户真实姓名', '用户注册时间', '用户注册地区', '用户状态', '用户账户余额', '在投资金', '可用收益', '累计收益', '首次充值时间', '充值总金额', '首次投资时间', '投资总额', '赎回总额', '提现总额', '未领取红包', '红包奖励总额'), '数据分析' . date('Y-m-d-H-m-s'));
     }
 }
Esempio n. 8
0
 /**
  * Finds the Log model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Log the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Log::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 9
0
 /**
  *Auther:langxi
  *
  * 用户一日内投资次数
  * @param $member_id
  * @return int|string
  */
 private static function investTimes($member_id)
 {
     $min_time = strtotime(date('Y-m-d'));
     $max_time = strtotime(date('Y-m-d', strtotime('+1 day')));
     return Log::find()->andWhere(['member_id' => $member_id, 'status' => Log::STATUS_INVEST_SUC, 'action' => 'Invest/invest'])->andWhere(['>=', 'create_at', $min_time])->andWhere(['<', 'create_at', $max_time])->count('member_id');
 }
Esempio n. 10
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"));
 }
Esempio n. 11
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'));
 }
Esempio n. 12
0
 /**
  * 获取用户今日提现次数
  * @param $uid
  * @return bool|int|string
  */
 public static function get_ransom_num($uid)
 {
     //今日零时时间
     $zero_time = strtotime(date("Y-m-d"));
     //明日零时时间
     $tom_zero_time = $zero_time + 86400;
     $log = \common\models\base\asset\Log::find()->where(['member_id' => $uid, 'status' => \common\models\base\asset\Log::STATUS_WITHDRAW_SUC])->andWhere(['between', 'create_at', $zero_time, $tom_zero_time])->count();
     if ($log) {
         return $log;
     } else {
         return false;
     }
 }
Esempio n. 13
0
 /**
  * Auther:langxi
  *
  * 交易记录(充值,投资,提现,赎回)
  */
 public static function total_log($member_id, $page, $num)
 {
     $page = ($page - 1) * $num;
     $info_log = Log::find()->select(['step', 'remark', 'status', 'create_at'])->where(['member_id' => $member_id])->andWhere(['>', 'status', '0'])->andWhere(['<>', 'step', '0.00'])->orderBy('id desc')->limit($num)->offset($page)->asArray()->all();
     $info_log_count = Log::find()->where(['member_id' => $member_id])->andWhere(['>', 'status', '0'])->andWhere(['<>', 'step', '0.00'])->count();
     if ($info_log) {
         $result = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => array('data' => $info_log));
     } elseif (!$info_log && $info_log_count) {
         $result = array('errorNum' => '1', 'errorMsg' => '没有更多交易记录', 'data' => null);
     } else {
         $result = array('errorNum' => '1', 'errorMsg' => '暂无交易记录', 'data' => null);
     }
     return $result;
 }
Esempio n. 14
0
 /**
  *Auther:langxi
  *
  * 用户一日内赎回次数
  * @param $member_id
  * @return int|string
  */
 private static function redeemTimes($member_id)
 {
     $min_time = strtotime(date('Y-m-d'));
     $max_time = strtotime(date('Y-m-d', strtotime('+1 day')));
     return Log::find()->andWhere(['member_id' => $member_id, 'status' => Log::STATUS_REDEM_SUC, 'action' => 'Withdrawals/Redeem'])->andWhere(['>=', 'create_at', $min_time])->andWhere(['<', 'create_at', $max_time])->count('member_id');
 }
Esempio n. 15
0
 public function findDepositResult($out_trade_no, $uid)
 {
     $log = Log::find()->where(['member_id' => $uid, 'trade_no' => $out_trade_no])->one();
     $errnum = '2';
     $msg = '未果';
     if ($log) {
         if ($log->status == Log::STATUS_RECHAR_SUC) {
             $msg = "充值成功";
             $errnum = '0';
         } elseif ($log->status == Log::STATUS_RECHAR_ERR) {
             $msg = "充值失败";
             $errnum = '1';
         } else {
             $msg = '处理中';
         }
     }
     return array('errorNum' => $errnum, 'errorMsg' => $msg, 'data' => null);
 }
Esempio n. 16
0
 /**
  * 保存用户的账户操作记录
  * @param $member_id
  * @param $step
  * @param $action
  * @param $status
  * @param $bankcard
  * @param $remark
  * @return bool
  */
 public static function logSave($member_id, $step, $action, $status, $bankcard, $remark)
 {
     $log = new Log();
     $log->member_id = $member_id;
     $log->step = $step;
     $log->action = $action;
     $log->status = $status;
     $log->bankcard = $bankcard;
     $log->remark = $remark;
     $res = $log->save();
     return $res;
 }
Esempio n. 17
0
 /**
  * 获取活动链接中邀请者身份
  * 判定邀请次数
  * @param $invite_code
  * @return array
  */
 public static function get_invite_info($invite_code)
 {
     if ($invite_code == '0') {
         $return = array('errorNum' => '1', 'errorMsg' => '活动链接来源不合法', 'data' => null);
         return $return;
     } else {
         //解析链接中的手机号
         $invite_phone = \frontend\actions\App\AloneMethod::decrypt($invite_code);
         //验证邀请者身份
         $invitation_id = self::phoneIsRegister($invite_phone);
         if (!$invitation_id) {
             $return = array('errorNum' => '1', 'errorMsg' => '邀请者不存在', 'data' => null);
             return $return;
         }
         //判定邀请者资格--一定要有投资行为--防止链接伪造
         $invite_code = \common\models\base\asset\Log::find()->where(['member_id' => $invitation_id, 'action' => 'Invest/invest', 'status' => \common\models\base\asset\Log::STATUS_INVEST_SUC])->count();
         if (!$invite_code) {
             $return = array('errorNum' => '1', 'errorMsg' => '邀请者不合法', 'data' => null);
             return $return;
         }
         //可以邀请
         $invite_count = ActivityLog::find()->where(['invite_id' => $invitation_id, 'invite_phone' => $invite_phone, 'status' => ActivityLog::STATUS_ACTIVITY])->count();
         //存在邀请记录
         $invite_test = ActivityLog::find()->where(['invite_id' => $invitation_id, 'invite_phone' => $invite_phone, 'status' => ActivityLog::STATUS_SUCCESS])->count();
         if ($invite_count == 0 && $invite_test) {
             $data = array('invite_phone' => $invite_phone, 'invitation_id' => $invitation_id);
             $return = array('errorNum' => '2', 'errorMsg' => '红包已经被抢完', 'data' => $data);
             return $return;
         } else {
             $data = array('invite_phone' => $invite_phone, 'invitation_id' => $invitation_id);
             $return = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
             return $return;
         }
     }
 }