Esempio n. 1
0
 public static function prepareYearlyFeeRecord($member_id, $total)
 {
     $data = array('member_id' => $member_id, 'type' => 4, 'fee' => 0, 'amount' => System::loadConfig('annual_fee'), 'total' => $total, 'account_type' => 1, 'note' => '年费: ' . date('Y-m-d H:i:s'));
     $model = new OutRecord();
     $model->load($data, '');
     return $model;
 }
Esempio n. 2
0
 public function actionApprove($id)
 {
     $model = $this->findModel($id);
     $data = array('Member' => array('approved_at' => date('Y-m-d h:i:s', time()), 'role_id' => 3));
     $model->load($data);
     $model->finance_fund -= System::loadConfig('annual_fee');
     $outRecord = OutRecord::prepareYearlyFeeRecord($model->id, $model->finance_fund);
     $connection = Yii::$app->db;
     try {
         $transaction = $connection->beginTransaction();
         if ($model->save() && $outRecord->save()) {
             $transaction->commit();
             Yii::$app->session->setFlash('success', '会员(' . $model->username . ')审核成功');
             return $this->redirect(['approvedindex']);
         } else {
             $transaction->rollBack();
             Yii::$app->session->setFlash('danger', '会员(' . $model->username . ')审核失败, 请稍后再试或联系管理员');
             return $this->redirect(['unapprovedindex']);
         }
     } catch (Exception $e) {
         $transaction->rollBack();
         Yii::$app->session->setFlash('danger', '会员(' . $model->username . ')审核失败, 请稍后再试或联系管理员');
         return $this->redirect(['unapprovedindex']);
     }
 }
 public function actionCharge()
 {
     $model = new Cash();
     $data = Yii::$app->request->post();
     if ($model->load(Yii::$app->request->post()) && isset($data['Cash']) && isset($data['Cash']['password2'])) {
         $validate = true;
         if (!Yii::$app->user->identity->validatePassword2($data['Cash']['password2'])) {
             $validate = false;
             $model->addError('password2', '第二密码错误,请确认后重新输入');
         }
         if ($model->amount > Yii::$app->user->identity->finance_fund) {
             $validate = false;
             $model->addError('amount', '账户余额不足, 理财账户:' . Yii::$app->user->identity->finance_fund);
         }
         if ($validate) {
             $member = Yii::$app->user->identity;
             $member->finance_fund -= $model->amount;
             $model->fee = round(System::loadConfig('cash_factorage'), 2);
             $model->real_amount = $model->amount - $model->fee;
             $member->save();
             $model->save();
             $outRecord = new OutRecord();
             $data = array('member_id' => Yii::$app->user->identity->id, 'account_type' => 1, 'amount' => $model->amount, 'fee' => $model->fee, 'total' => $member->finance_fund, 'type' => 1, 'note' => '会员提现(含银行转账手续费)');
             $outRecord->load($data, '');
             $outRecord->save();
             Yii::$app->session->setFlash('success', '提现申请提交成功');
             $this->redirect(['cashlist']);
         } else {
             Yii::$app->session->setFlash('danger', '提现申请失败,清输入正确的信息');
         }
     }
     return $this->render('charge', ['model' => $model]);
 }
Esempio n. 4
0
 /**
  * @inheritdoc
  */
 protected function matchRole($user)
 {
     if (System::loadConfig('enable_memmber_login')) {
         return parent::matchRole($user);
     } else {
         Yii::$app->user->logout();
         Yii::$app->getResponse()->redirect('/site/login');
     }
 }
Esempio n. 5
0
 static function loadConfig($name = '')
 {
     $configs = unserialize(Yii::$app->cache->get('SYSTEM_CONFIG'));
     if (!count($configs) || true) {
         $configs = array();
         $values = System::find()->all();
         foreach ($values as $val) {
             $configs[$val['name']] = $val['value'];
         }
         Yii::$app->cache->set('SYSTEM_CONFIG', serialize($configs));
     }
     return $name ? isset($configs[$name]) ? $configs[$name] : '' : $configs;
 }
Esempio n. 6
0
 protected function dealSellAction($transaction)
 {
     $transaction->status = 1;
     $memberStack = $transaction->getMemberStack()->one();
     $memberStack->lock_volume -= $transaction->volume;
     $member = $transaction->getMember()->one();
     $fee = round($transaction->total_price * System::loadConfig('sell_fee_rate'), 2);
     $member->finance_fund += $transaction->total_price - $fee;
     $stackOutRecord = InRecord::prepareModelForSellStack($transaction->member_id, $transaction->total_price - $fee, $member->finance_fund, $fee);
     $stackOutRecord->note = '系统解锁[' . $transaction->created_at . ']出售[' . $transaction->stack->code . ']' . $transaction->volume . '股';
     $stackOutRecord->save();
     $member->save();
     $memberStack->save();
     $transaction->save();
 }
Esempio n. 7
0
 public function behaviors()
 {
     return [['class' => TimestampBehavior::className(), 'value' => new Expression('NOW()')], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'status'], 'value' => function ($event) {
         if ($this->status) {
             return $this->status;
         } else {
             return 0;
         }
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'charge'], 'value' => function ($event) {
         if ($this->type) {
             return round($this->total_price * System::loadConfig('sell_fee_rate'), 2);
         } else {
             return 0;
         }
     }]];
 }
Esempio n. 8
0
 /**
  * Lists all System models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = new System();
     $postData = Yii::$app->request->post('System');
     if (count($postData)) {
         foreach ($postData as $key => $da) {
             if ($key == 'lowest_cash_amount') {
                 $da = $da * 100;
             }
             $system = System::findOne(['name' => $key]);
             if ($system && $system->id) {
                 $oldValue = $system->value;
                 $system->value = $da;
                 if ($system->save() && $da != $oldValue) {
                     Yii::$app->systemlog->add('管理员', '修改系统参数', '成功', $key . ': 从 (' . $oldValue . ')改为(' . $da . ')');
                 } else {
                     if ($da != $oldValue) {
                         Yii::$app->systemlog->add('管理员', '修改系统参数', '失败', $key . ': 从 (' . $oldValue . ')改为(' . $da . ')');
                     }
                 }
             } else {
                 $system = new System();
                 $system->name = $key;
                 $system->value = $da;
                 $system->save();
             }
             Yii::$app->session->setFlash('success', '保存成功.');
         }
         Yii::$app->cache->set('SYSTEM_CONFIG', null);
     }
     $data = System::loadConfig();
     if ($data && count($data)) {
         foreach ($data as $key => $da) {
             $model->{$key} = $da;
         }
     }
     return $this->render('index', ['model' => $model]);
 }
Esempio n. 9
0
                </li>
                <li>
                    股票账户余额: <?php 
echo Yii::$app->user->identity->stack_fund;
?>
                </li>
            </ul>
        </div>
    </div>
    <div class="header">
        <div class="container">
            <h2 class="site-name">QC(启程)股票在线交易平台</h2>
            
            <?php 
NavBar::begin();
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-left'], 'items' => [['label' => '首页', 'url' => ['/news/index']], ['label' => '业务中心', 'url' => ['/member/create'], 'items' => [\common\models\System::loadConfig('show_add_member') ? ['label' => '注册会员', 'url' => ['/member/create']] : '', ['label' => '我的注册', 'url' => ['/member/index']]]], ['label' => '基金资产', 'url' => ['/account/fund']], ['label' => '股票管理', 'url' => ['/stack/index'], 'items' => [['label' => '交易中心', 'url' => ['/stack/index']], ['label' => '股价动态', 'url' => ['/stack/trends']], ['label' => '股票交易记录', 'url' => ['/stack/transactions']], ['label' => '股票资产', 'url' => ['/stack/fund']]]], ['label' => '财务管理', 'url' => ['/blank'], 'items' => [['label' => '入账明细', 'url' => ['/account/inlist']], ['label' => '出账明细', 'url' => ['/account/outlist']], ['label' => '提现记录', 'url' => ['/account/cashlist']], ['label' => '申请提现', 'url' => ['/account/charge']]]], ['label' => '系统公告', 'url' => ['/news/index'], 'items' => [['label' => '新闻公告', 'url' => ['/news/index']], ['label' => '留言列表', 'url' => ['/message/index', 'user_id' => Yii::$app->user->identity->id]], ['label' => '添加留言', 'url' => ['/message/create']]]], ['label' => '会员管理', 'url' => ['/member/view', 'id' => Yii::$app->user->identity->id], 'items' => [['label' => '修改密码', 'url' => ['/member/changepassword']], ['label' => '会员资料', 'url' => ['/member/view', 'id' => Yii::$app->user->identity->id]]]], Yii::$app->user->isGuest ? ['label' => '安全退出', 'url' => ['/site/login']] : ['label' => '安全退出 (' . Yii::$app->user->identity->username . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]);
NavBar::end();
?>
        </div>
    </div>
    <div class="container">
        <?php 
echo Alert::widget();
?>
        <?php 
echo $content;
?>
    </div>
</div>

<?php 
Esempio n. 10
0
 public function actionUnlock()
 {
     $id = Yii::$app->request->get('id');
     $stackTransaction = StackTransaction::findOne($id);
     $connection = Yii::$app->db;
     try {
         $transaction = $connection->beginTransaction();
         if ($stackTransaction->type == 0) {
             $stackTransaction->status = 1;
             $memberStack = $stackTransaction->getMemberStack()->one();
             $memberStack->sell_volume += $stackTransaction->volume;
             $memberStack->lock_volume -= $stackTransaction->volume;
             if ($memberStack->save() && $stackTransaction->save()) {
                 $transaction->commit();
                 Yii::$app->session->setFlash('success', '交易自主解锁成功');
             } else {
                 $transaction->rollBack();
                 Yii::$app->session->setFlash('danger', '交易自主解锁失败, 请稍后再试或联系管理员');
             }
         } else {
             $stackTransaction->status = 1;
             $memberStack = $stackTransaction->getMemberStack()->one();
             $memberStack->lock_volume -= $stackTransaction->volume;
             $member = $stackTransaction->getMember()->one();
             $fee = round($stackTransaction->total_price * System::loadConfig('sell_fee_rate'), 2);
             $member->stack_fund += $stackTransaction->total_price - $fee;
             $stackOutRecord = InRecord::prepareModelForSellStack($stackTransaction->member_id, $stackTransaction->total_price - $fee, $member->stack_fund, $fee);
             $stackOutRecord->account_type = 2;
             $stackOutRecord->note = '自主解锁[' . $stackTransaction->created_at . ']出售股票[' . $stackTransaction->stack->code . ']' . $stackTransaction->volume . '股';
             if ($memberStack->save() && $stackTransaction->save() && $member->save() && $stackOutRecord->save()) {
                 $transaction->commit();
                 Yii::$app->session->setFlash('success', '交易自主解锁成功');
             } else {
                 $transaction->rollBack();
                 Yii::$app->session->setFlash('danger', '交易自主解锁失败, 请稍后再试或联系管理员');
             }
         }
     } catch (Exception $e) {
         $transaction->rollBack();
     }
     $this->redirect(Yii::$app->request->referrer);
     return;
 }