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"));
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Cat::find()->orderBy('id DESC');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $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, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'created_at', $this->created_at])->andFilterWhere(['like', 'updated_at', $this->updated_at]);
     return $dataProvider;
 }
Example #3
0
 public function actionMain()
 {
     Utils::ensureOpenId();
     $openId = Yii::$app->request->get('open_id');
     if (($usermodel = UcenterMember::findOne(['openid' => $openId])) !== null) {
         Yii::$app->user->login($usermodel);
     }
     if (!\yii::$app->user->isGuest) {
         $income_yesterday = Income::find()->where(['member_id' => $uid, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->smoney;
         $model_asset = Info::find()->where(['member_id' => Yii::$app->user->id])->one();
         $balance = $model_asset->balance;
         //当前余额
         //在投收益
         $invest_income = $model_asset->profit;
         //昨日年化收益率
         $income_rate = income::find()->where(['member_id' => $uid, 'created_at' => strtotime(date('Y-m-d', time()))])->one()->rate;
         //投资总额
         $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;
             }
         }
     }
     //幻灯片
     try {
         $cat_id = Cat::find()->where(['name' => '幻灯片', 'status' => Cat::STATUS_ACTIVE])->one()->id;
         $sliders = Link::find()->where(['cat_id' => $cat_id, 'status' => Link::STATUS_ACTIVE])->asArray()->all();
     } catch (ErrorException $e) {
         $sliders = "";
     }
     //$products = Product::find()->limit(4)->orderBy('start_at DESC')->all();
     $products = Invest::product_list(4, 1);
     $products_pages = Product::find()->andwhere(['<>', 'status', Product::STATUS_LOCK])->andWhere(['>', 'create_at', 1441641600])->count();
     $products_pages = ceil($products_pages / 4);
     return $this->view('main', compact('products', 'sliders', 'balance', 'invest_income', 'invest_total', 'income_yesterday', 'income_rate', 'products', 'products_pages'));
 }
Example #4
0
 public function actionGuarantee()
 {
     $left = About::find()->asArray()->all();
     try {
         $cat_id = Cat::findOne(['name' => '担保机构', 'status' => 1])->id;
         $infos = Link::find()->where(['cat_id' => $cat_id, 'status' => 1])->all();
     } catch (ErrorException $e) {
         $infos = '';
     }
     return $this->render('guarantee', ['infos' => $infos, 'left' => $left]);
 }
Example #5
0
 /**
  * Finds the Cat model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Cat the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Cat::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #6
0
/* @var $model common\models\base\cms\Cat */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="cat-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(Cat::getArrayStatus());
?>



    <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>
Example #7
0
 public function actionIndex()
 {
     $title = '';
     $reserve = '';
     try {
         $title = Setting::findOne(['code' => 'siteTitle'])->value;
         // 网站title
         $reserve = Setting::findOne(['code' => 'reserve'])->value;
         //储备金额
     } catch (ErrorException $e) {
     }
     //媒体报道
     try {
         $cat_id = Cat::find()->where(['name' => '媒体报道', 'status' => 1])->one()->id;
         if ($cat_id) {
             $media = Link::find()->where(['cat_id' => $cat_id, 'status' => 1])->asArray()->all();
         }
     } catch (ErrorException $e) {
         $media = "";
     }
     //合作伙伴
     try {
         $cat_id = Cat::find()->where(['name' => '合作伙伴', 'status' => 1])->one()->id;
         $partner = Link::find()->where(['cat_id' => $cat_id, 'status' => 1])->asArray()->all();
     } catch (ErrorException $e) {
         $partner = "";
     }
     //投资帮助
     /* try
       	{
       		$parent_id = Category::findOne(['title'=>'帮助中心','status'=>1])->id;
       		$category = Category::find()->where(['parent_id'=>$parent_id,'status'=>1])->asArray()->all();
       		$left = array();
       		foreach ($category as $K=>$V)
       		{
       			$left[] = Article::find()->where(['category_id'=>$V['id'],'status'=>1])->asArray()->all();
       		}
       	}
       	catch (ErrorException $e)
       	{
       		$left = array();
       	} */
     $hover = 'hover';
     //项目列表
     //TODO
     //		$model = Product::find()->limit(4)->orderBy('start_at DESC')->all();
     $model = Product::find()->limit(4)->orderBy('start_at DESC')->where('create_at >= 1441641600 ')->all();
     //是否签到
     $isCheckin = false;
     $checkin_total = count(SignIn::find()->where('create_at >=' . strtotime(date("Y-m-d")))->all());
     //本日签到总人数
     $yesterday_total = \frontend\actions\app\member::get_yesterday_sign_in()['data']['count'];
     //获取昨日签到情况 TODO
     $yesterday_sign_in = \frontend\actions\app\member::get_yesterday_sign_in();
     //获取今日签到情况 TODO
     $today_sign_in = \frontend\actions\app\member::get_today_sign_in();
     //昨日在投收益排名
     $command = (new \yii\db\Query())->select(['ucenter_member.real_name', 'fund_income.smoney as money'])->from('fund_income')->where("fund_income.created_at >=" . strtotime(date("Y-m-d")))->join('left join', 'ucenter_member', 'fund_income.member_id = ucenter_member.id')->limit(6)->groupBy('fund_income.member_id')->orderBy('money DESC')->createCommand();
     $rank = $command->queryAll();
     //近30天收益排名
     //TODO
     $test_time = strtotime("-1 month") > "1441641600" ? strtotime("-1 month") : '1441641600';
     $command_month = (new \yii\db\Query())->select(['ucenter_member.real_name', 'sum(fund_income.smoney) as money'])->from('fund_income')->where("fund_income.created_at >=" . $test_time)->join('left join', 'ucenter_member', 'fund_income.member_id = ucenter_member.id')->limit(6)->groupBy('fund_income.member_id')->orderBy('money DESC')->createCommand();
     $rank_month = $command_month->queryAll();
     if (!Yii::$app->user->isGuest) {
         $result = \frontend\actions\app\member::is_sign_today(yii::$app->user->id);
         if ($result['errorNum'] == 1) {
             $isCheckin = true;
         } elseif ($result['errorNum'] == 0) {
             $isCheckin = false;
         }
     }
     return $this->render('index', ['yesterday_sign_in' => $yesterday_sign_in, 'today_sign_in' => $today_sign_in, 'model' => $model, 'isCheckin' => $isCheckin, 'checkin_total' => $checkin_total, 'yesterday_total' => $yesterday_total, 'rank' => $rank, 'rank_month' => $rank_month, 'hover' => $hover, 'title' => $title, 'reserve' => $reserve, 'media' => $media, 'partner' => $partner]);
 }
Example #8
0
<?php

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use common\models\base\cms\Cat;
use common\models\base\cms\Link;
/* @var $this \yii\web\View */
/* @var $content string */
\www\assets\AppAsset::register($this);
$directoryAsset = Yii::$app->assetManager->getPublishedUrl('@almasaeed/');
//友情链接
try {
    $cat_id = Cat::find()->where(['name' => '友情链接', 'status' => 1])->one()->id;
    if ($cat_id) {
        $friendly_links = Link::find()->where(['cat_id' => $cat_id, 'status' => 1])->asArray()->all();
    }
} catch (ErrorException $e) {
    $friendly_links = "";
}
?>
<!-- footer -->

<div id="footer">
    <div class="foot_top main">
        <div class="dilb left">
            <ul>
                <h5>我要投资</h5>
                <li><a href="<?php 
echo yii\helpers\Url::to(['investment/investing']);
?>
Example #9
0
 public static function getArrayCats()
 {
     return ArrayHelper::map(Cat::find()->all(), 'id', 'name');
 }
Example #10
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="cat-index">

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

    <p>
        <?php 
echo Html::a(Yii::t('app', '创建'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    if ($model->status === $model::STATUS_ACTIVE) {
        $class = 'label-success';
    } elseif ($model->status === $model::STATUS_INACTIVE) {
        $class = 'label-warning';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', common\models\base\cms\Cat::getArrayStatus(), ['class' => 'form-control', 'prompt' => Yii::t('app', 'Please Filter')])], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'buttons' => ['delete' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => '删除', 'data' => ['confirm' => '你确定要删除吗?', 'method' => 'post']]);
}]]]]);
?>

</div>