Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Rule::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, 'money' => $this->money, 'time' => $this->time, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'start_at', $this->start_at])->andFilterWhere(['like', 'end_at', $this->end_at])->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
Esempio n. 2
0
 /**
  * Creates a new Gold model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Gold();
     if ($model->load(Yii::$app->request->post())) {
         $rule = Rule::find()->andWhere(['id' => 6, 'status' => Rule::STATUS_ACTIVE])->one();
         if ($rule) {
             $model->money = \App::$app->request->post()['Gold']['money'];
             $model->uid = \App::$app->request->post()['Gold']['uid'];
             $model->rid = 6;
             $model->end_at = $rule->time * 3600 * 24 + strtotime(date('Y-m-d H:i:s', time()));
             $model->title = '系统赠送体验金';
             $model->save();
             return $this->redirect(['index']);
         } else {
             return $this->redirect(['index']);
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Esempio n. 3
0
 /**
  * Finds the Rule model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Rule the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Rule::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
                            <a id="share" href="javascript:;">去完成</a>
                        </td>
                    </tr>
                </table>
            </li>
            <li class="experience4-li">
                <img src="<?php 
echo Yii::getAlias('@web') . '/';
?>
rq-images/Experience42.jpg" alt="">
                <table class="experience4-tab">
                    <tr>
                        <td>
                            <p class="experience4-tabT">好友投资</p>
                            <p class="experience4-tabP">获取<?php 
echo $rule = Rule::find()->where(['title' => '好友投资'])->one()->money;
?>
元体验金</p>
                        </td>
                        <td class="experience4-tabCome">

                        </td>
                    </tr>
                </table>
            </li>
            <p class="experienct4-BOT"><a href="#">活动详情</a></p>
        </ul>

    </div>
    <section id="wh_cover"></section>
    <p class="share"><img width="100%" src="<?php 
Esempio n. 5
0
 public function getRule()
 {
     return $this->hasOne(Rule::className(), ['id' => 'rid']);
 }
Esempio n. 6
0
$form = ActiveForm::begin();
?>
    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'money')->textInput();
?>

    <?php 
echo $form->field($model, 'time')->textInput();
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(\common\models\base\experience\Rule::labels());
?>


    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Esempio n. 7
0
 public static function goldtwo($member_id, $money)
 {
     //获取举办活动
     $holdactivity = HoldActivity::find()->where(['id' => 7])->asArray()->one();
     //获取使用的规则
     $ridearray = array();
     $ridearray = explode(',', $holdactivity['rid_list']);
     //获取应该得到的体验金数量
     $experience_gold = 0;
     $experience_gold = $holdactivity['gold_money'];
     //体验金的有效时间
     $gold_day = 0;
     $gold_day = $holdactivity['gold_day'];
     //活动开始时间
     $activity_begin = time();
     $activity_begin = $holdactivity['activity_begin'];
     //活动结束时间
     $activity_end = time();
     $activity_end = $holdactivity['activity_end'];
     //首次投资送体验金规则
     if (in_array('3', $ridearray)) {
         //获取规则情况
         $flag = Rule::find()->where(['id' => '3', 'status' => Rule::STATUS_ACTIVE])->asArray()->one();
         //存在规则
         if ($flag) {
             $info = Info::find()->where(['member_id' => $member_id])->one();
             //获取再投资金
             $invest = $info->invest;
             //用户注册时间
             $create_at = $info->create_at;
             //再投资金大于1元
             if ($invest >= 1 && $create_at > $activity_begin && $create_at < $activity_end) {
                 //判断规则是否生效
                 $now = time();
                 if ($now > $activity_begin && $now < $activity_end) {
                     //判定用户是否领取了体验金
                     $is_get = Gold::find()->where(['rid' => 3, 'uid' => $member_id, 'title' => '国庆佳节新用户投资送体验金'])->asArray()->one();
                     if (!$is_get) {
                         //计算体验金截止时间
                         $end_at = time() + $gold_day * 24 * 3600;
                         //给用户发体验金
                         $gold = new Gold();
                         $gold->uid = $member_id;
                         $gold->rid = '3';
                         $gold->money = $experience_gold;
                         $gold->end_at = $end_at;
                         $gold->status = Gold::STATUS_ACTIVE;
                         $gold->title = '国庆佳节新用户投资送体验金';
                         $gold->save();
                     }
                 }
                 //判断是否有邀请人
                 $member = UcenterMember::find()->where(['id' => $member_id])->asArray()->one();
                 if ($member['invitation_id']) {
                     if (in_array('5', $ridearray)) {
                         $rule = Rule::find()->where(['id' => '5', 'status' => Rule::STATUS_ACTIVE])->asArray()->one();
                         //规则启用
                         if ($rule) {
                             //判断规则是否在时间内
                             $now = time();
                             if ($now > $activity_begin && $now < $activity_end) {
                                 //判定用户是否领取了体验金
                                 $is_get = Gold::find()->where(['rid' => 3, 'uid' => $member_id, 'title' => '国庆佳节推荐用户投资送体验金'])->asArray()->one();
                                 if (!$is_get) {
                                     //计算体验金截止时间
                                     $end_at = time() + $gold_day * 24 * 3600;
                                     //给用户发体验金
                                     $gold = new Gold();
                                     $gold->uid = $member_id;
                                     $gold->rid = '3';
                                     $gold->money = $experience_gold;
                                     $gold->end_at = $end_at;
                                     $gold->status = Gold::STATUS_ACTIVE;
                                     $gold->title = '国庆佳节推荐用户投资送体验金';
                                     $gold->save();
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 8
0
 public function actionSignup()
 {
     //判断注册URL中是否包含邀请码参数
     if (isset($_GET['code'])) {
         $code = $_GET['code'];
         //$_code_source = UcenterMember::find()->where(['invitation_code'=>$code])->one();
         //if(count($_code_source) != 1)
         $flag = \frontend\actions\app\member::verify_code($code);
         if (!$flag) {
             header("Content-type: text/html; charset=utf-8");
             echo "<script>alert('来源链接不合法!')</script>";
             echo "<script>window.location.href='" . \yii\helpers\Url::to(['site/signup']) . "'</script>";
             exit;
         }
     }
     $model = new SignupForm();
     //是否邀请注册
     $test_invite = 1;
     if ($model->load(Yii::$app->request->post())) {
         if ($_POST['SignupForm']['username'] && $_POST['SignupForm']['validate_code'] && $_POST['SignupForm']['password'] && $_POST['SignupForm']['password_repeat']) {
             $invite_code = $_POST["SignupForm"]['invitation_code'];
             //使用测试邀请码
             if ($test_invite) {
                 //使用测试邀请
                 $flag = \frontend\actions\app\member::verify_code($invite_code);
                 //验证码通过
                 if (!$flag) {
                     echo "<script>alert('" . '邀请码错误' . "')</script>";
                 }
             }
             $_phone = $_POST['SignupForm']['username'];
             $_code = $_POST['SignupForm']['validate_code'];
             try {
                 $result = Port::checkPhnoe($_phone, $_code);
                 if (is_bool($result)) {
                 }
             } catch (ErrorException $e) {
                 header("Content-type: text/html; charset=utf-8");
                 echo "<script>alert('" . $e->getMessage() . "')</script>";
                 echo "<script>location.href='" . \yii\helpers\Url::to(['site/signup']) . "'</script>";
                 exit;
             }
             $user = new UcenterMember();
             $user->username = $_POST["SignupForm"]['username'];
             $user->phone = $_POST["SignupForm"]['username'];
             $user->invitation_code = $_POST["SignupForm"]['invitation_code'];
             $password = $_POST["SignupForm"]['password'];
             $user->setPassword($password);
             $user->create_ip = Yii::$app->request->userIp;
             $app_pwd = md5(sha1($password) . time());
             $user->app_pwd = $app_pwd;
             try {
                 $area = self::get_area(Yii::$app->request->userIp);
                 $user->create_area = $area;
             } catch (ErrorException $e) {
             }
             $user->generateAuthKey();
             if ($user->save()) {
                 $uid = $user['id'];
                 if ($test_invite) {
                     //使用验证码
                     $flag = \frontend\actions\app\member::verify_code($invite_code);
                     $invite_flag = \frontend\actions\app\member::use_code($flag, $uid);
                     if (!$invite_flag) {
                         $return = array('errorNum' => '1', 'errorMsg' => '注册失败', 'data' => null);
                         return $return;
                     }
                 }
                 if (Yii::$app->getUser()->login($user)) {
                     $newModel = UcenterMember::find()->where(['id' => Yii::$app->user->id])->one();
                     //$newModel->invitation_id= \yii::$app->params['invitation_id'];
                     $invitation_code = Utils::createcode();
                     $newModel->invitation_code = $invitation_code;
                     $newModel->person_face = Setting::find()->where("code='img'")->one()->value;
                     if ($_POST['url_code']) {
                         $code_source = UcenterMember::find()->where(['invitation_code' => $_POST["url_code"]])->asArray()->one();
                         if ($code_source) {
                             $newModel->invitation_id = $code_source['id'];
                         }
                         //好友注册领取体验金
                         $rule = Rule::find()->where(['title' => '好友注册', 'status' => Rule::STATUS_ACTIVE])->one();
                         if ($rule) {
                             $rid = $rule->id;
                             $r_money = $rule->money;
                             $model_gold = new Gold();
                             $model_gold->rid = $rid;
                             $model_gold->money = $r_money;
                             $model_gold->uid = $code_source['id'];
                             $model_gold->created_at = strtotime("now");
                             $model_gold->save();
                         }
                     } elseif ($_POST['SignupForm']['invitation_code']) {
                         $code_source = UcenterMember::find()->where(['invitation_code' => $_POST["SignupForm"]["invitation_code"]])->asArray()->one();
                         if ($code_source) {
                             $newModel->invitation_id = $code_source['id'];
                         }
                         //好友注册领取体验金
                         $rule = Rule::find()->where(['title' => '好友注册', 'status' => Rule::STATUS_ACTIVE])->one();
                         if ($rule) {
                             $rid = $rule->id;
                             $r_money = $rule->money;
                             $model_gold = new Gold();
                             $model_gold->rid = $rid;
                             $model_gold->money = $r_money;
                             $model_gold->uid = $code_source['id'];
                             $model_gold->created_at = strtotime("now");
                             $model_gold->save();
                         }
                     }
                     $newModel->save(false);
                     $model_asset_info = new Info();
                     $model_asset_info->member_id = yii::$app->user->id;
                     $model_asset_info->create_at = strtotime("now");
                     $model_asset_info->save(false);
                     //手机号注册领取体验金
                     $rule = Rule::find()->where(['title' => '手机号注册', 'status' => Rule::STATUS_ACTIVE])->one();
                     if ($rule) {
                         $rid = $rule->id;
                         $r_money = $rule->money;
                         $model_gold = new Gold();
                         $model_gold->rid = $rid;
                         $model_gold->money = $r_money;
                         $model_gold->uid = $code_source['id'];
                         $model_gold->created_at = strtotime("now");
                         $model_gold->save();
                     }
                     return $this->goHome();
                 }
             }
         }
     }
     return $this->render('signup', compact("model", "code"));
 }
Esempio n. 9
0
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\base\experience\RuleSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', '体验金');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="rule-index">
    <p>
        <?php 
echo Html::a('创建', ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', 'money', 'time', ['attribute' => 'created_at', 'format' => ['date', 'php:Y-m-d']], ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    if ($model->status === \common\models\base\experience\Rule::STATUS_ACTIVE) {
        $class = 'label-success';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', \common\models\base\experience\Rule::labels(), ['class' => 'form-control', 'prompt' => '请筛选'])], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'buttons' => ['delete' => function ($url, $model, $key) {
    return '';
}, 'view' => function ($url, $model, $key) {
    return '';
}]]]]);
?>

</div>
Esempio n. 10
0
 public function actionBindcard()
 {
     $model = UcenterMember::find()->where('id=' . Yii::$app->user->id)->one();
     $uid = yii::$app->user->id;
     $is_bind = sinapay::isBinding($uid);
     if ($is_bind['errorNum'] == 0) {
         $result_bind = $is_bind['data'];
         $logo_bind = self::BankInfos();
     }
     $result = member::isAuthentic($uid);
     //接收验证码后进行银行卡绑定
     try {
         if (isset($_POST['bankcard']) && isset($_POST['idcard']) && isset($_POST['username']) && isset($_POST['phone']) && isset($_POST['code']) && isset($_POST['ticket']) && isset($_POST['request_no'])) {
             $valid_code = $_POST['code'];
             $request_no = $_POST['request_no'];
             $ticket = $_POST['ticket'];
             $info = sinapay::bankCardAdvance($request_no, $ticket, $valid_code);
             if ($info['errorNum'] == 0) {
                 //领取体验金
                 $rid = Rule::find()->where(['title' => '绑定银行卡', 'status' => 1])->one()->id;
                 $r_money = Rule::find()->where(['title' => '绑定银行卡', 'status' => 1])->one()->money;
                 $model_gold = new Gold();
                 $model_gold->rid = $rid;
                 $model_gold->money = $r_money;
                 $model_gold->uid = yii::$app->user->id;
                 $model_gold->created_at = strtotime("now");
                 $model_gold->save();
                 echo "绑卡成功";
                 exit;
             } elseif ($info['errorNum'] != 0) {
                 echo $info['errorMsg'];
                 exit;
             }
         }
     } catch (ErrorException $e) {
         echo $e->getMessage();
         exit;
     }
     //发送验证码和请求ID
     try {
         if (isset($_POST['bankcard']) && isset($_POST['idcard']) && isset($_POST['username']) && isset($_POST['phone'])) {
             $cardno = $_POST['bankcard'];
             $idcardno = $_POST['idcard'];
             $username = $_POST['username'];
             $phone = $_POST['phone'];
             try {
                 $info = sinapay::bindingBankCard($uid, $cardno, $phone);
                 echo json_encode($info);
                 exit;
             } catch (ErrorException $e) {
                 echo $e->getMessage();
                 exit;
             }
         }
     } catch (ErrorException $e) {
         echo $e->getMessage();
         exit;
     }
     if (isset($_POST['bankcard']) && isset($_POST['phone'])) {
         $cardno = $_POST['bankcard'];
         $phone = $_POST['phone'];
         $info = Balance::bindbankcard2($uid, $cardno, $phone);
         if ($info) {
             echo '绑卡成功';
             exit;
         }
     }
     $infos_rar = $this->Ucenter();
     //用户数据包
     return $this->render('bindcard', compact("infos_rar", "result", "result_bind", "model", "logo_bind"));
 }
Esempio n. 11
0
 /**
  * Auther:langxi
  *
  *体验金
  */
 public static function gold($member_id, $money)
 {
     $order = Order::find()->select(['id'])->where(['member_id' => $member_id])->andWhere(['>=', 'start_money', '1000'])->asArray()->all();
     $is_order = count($order);
     //投资金额不小于1000且只有一个金额不小于1000的订单(含刚生成的订单):首次投资大于1000
     if ($money >= 1000 && $is_order == 1) {
         $rule = Rule::find()->where(['id' => '3', 'status' => Rule::STATUS_ACTIVE])->asArray()->one();
         //判断规则是否生效
         if ($rule['time']) {
             $rul_money = $rule['money'];
             $end_at = time() + $rule['time'] * 24 * 3600;
             $gold = new Gold();
             $gold->uid = $member_id;
             $gold->rid = '3';
             $gold->money = $rul_money;
             $gold->end_at = $end_at;
             $gold = $gold->save();
         }
         //判断是否有邀请人
         $member = UcenterMember::find()->where(['id' => $member_id])->asArray()->one();
         if ($member['parent_member_id']) {
             $rule = Rule::find()->where(['id' => '5', 'status' => Rule::STATUS_ACTIVE])->asArray()->one();
             //判断规则是否生效
             if ($rule['time']) {
                 $rul_money = $rule['money'];
                 $end_at = time() + $rule['time'] * 24 * 3600;
                 $gold = new Gold();
                 $gold->uid = $member['parent_member_id'];
                 $gold->rid = '5';
                 $gold->money = $rul_money;
                 $gold->end_at = $end_at;
                 $gold = $gold->save();
             }
         }
     }
 }
Esempio n. 12
0
 /**
  * 给予体验金
  * @param $title
  * @param $uid
  * @return bool
  */
 public static function give_experience_gold($title, $uid)
 {
     //获取体验金规则
     $rule = Rule::find()->where(['title' => $title, 'status' => Rule::STATUS_ACTIVE])->one();
     if ($rule) {
         $rid = $rule->id;
         $r_money = $rule->money;
         //加入体验金记录表
         $model_gold = new Gold();
         $model_gold->rid = $rid;
         $model_gold->money = $r_money;
         $model_gold->uid = $uid;
         return $model_gold->save();
     }
 }
Esempio n. 13
0
$upload = yii::$app->request->baseUrl . '/../../backend/web/upload/';
$user = UcenterMember::find()->where(['id' => $_GET['id']])->one();
?>

<section>
    <p><img class="d-block" width="100%" src="<?php 
echo Yii::getAlias('@web') . '/';
?>
rq-images/sign2-bg.jpg" alt="活琪王"></p>
    <div class="Invitat-top">
        <p class="Invitat-tp1 Experience-tp1">您的好友 <?php 
echo $user->real_name;
?>
 已经在活琪王赚翻了~</p>
        <p class="Invitat-tp2">新用户完成任务,最高可领<?php 
echo $rule = Rule::find()->where(['title' => '手机号注册'])->one()->money;
?>
元体验金~</p>
        <p class="Experience-tbtn"><a href="<?php 
echo Url::to(['gold/gsignup', 'code' => $user->invitation_code, 'id' => $user->id]);
?>
">立即购买体验</a></p>
    </div>
</section>
<section>
    <div class="Experience-bt">
        <p><img width="100%" src="<?php 
echo Yii::getAlias('@web') . '/';
?>
rq-images/Experience3.jpg" alt=""></p>
    </div>
Esempio n. 14
0
 /**
  * 给予体验金
  * @param $title
  * @param $uid
  * @return bool
  */
 public static function give_experience_gold($tid, $uid)
 {
     //获取体验金规则
     $rule = Rule::find()->where(['id' => $tid, 'status' => Rule::STATUS_ACTIVE])->one();
     if ($rule !== null) {
         $rid = $rule->id;
         //规则金额
         $r_money = $rule->money;
         //规则时间
         $rule_time = $rule->time;
         //规则标题
         $title = $rule->title;
         //加入体验金记录表
         $model_gold = new Gold();
         $model_gold->rid = $rid;
         $model_gold->money = $r_money;
         $model_gold->uid = $uid;
         $model_gold->title = $title;
         $model_gold->end_at = time() + $rule_time * 24 * 3600;
         $model_gold->save();
     }
 }