Exemplo n.º 1
0
 /**
  * 验证用户是否有足够资金发布项目
  */
 public function logisfeeRight()
 {
     $oneAccount = Account::find()->where("user_id=:user_id", [':user_id' => $this->publis_user_id])->one();
     if ($this->logis_fee > $oneAccount->use_money) {
         $this->addError('logis_fee', '您的可用资金不足以支付佣金。');
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * 用户登录
  * @param $post
  * @return array
  */
 public static function login($post)
 {
     $passport = static::findByPhone($post['phone']);
     if (isset($passport)) {
         if ($passport->password === $passport->md5($post['password'])) {
             if (\Yii::$app->user->login($passport, isset($post['rememberMe']) ? 3600 * 24 * 30 : 0)) {
                 $account = Account::find()->where(['passport_id' => $passport->id])->one();
                 \Yii::$app->session['passport_id'] = $passport->id;
                 \Yii::$app->session['account_id'] = $account->id;
                 return ['code' => 1, 'msg' => '登录成功'];
             }
         } else {
             return ['code' => 0, 'msg' => '密码错误'];
         }
     } else {
         return ['code' => 0, 'msg' => '手机号不存在'];
     }
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Account::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'fullname_changed' => $this->fullname_changed, 'email_verified' => $this->email_verified, 'role' => $this->role, 'status' => $this->status, 'updated_at' => $this->updated_at, 'DATE(FROM_UNIXTIME(`created_at`))' => $this->created_at]);
     $query->andFilterWhere(['like', 'seo_name', $this->seo_name])->andFilterWhere(['like', 'fullname', $this->fullname])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'password_reset_token', $this->password_reset_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'new_email', $this->new_email])->andFilterWhere(['like', 'change_email_token', $this->change_email_token])->andFilterWhere(['like', 'language', $this->language])->andFilterWhere(['like', 'timezone', $this->timezone]);
     //$query->andFilterWhere([
     //    'DATE(FROM_UNIXTIME(`created_at`))' => $this->created_at,
     //]);
     return $dataProvider;
 }
Exemplo n.º 4
0
<?php

/* @var $this yii\web\View */
$this->title = '会员中心';
use yii\helpers\Url;
use common\models\Account;
$user_id = Yii::$app->user->getId();
$thisuserAccount = Account::find()->where(":user_id=user_id", [':user_id' => $user_id])->one();
?>
<div class="container no-bottom" style="background-color: #fae0ca;">              
    <p class="p_member_t">
        可用资金(元)    
    </p>
    <p class="p_member_m">
        <?php 
echo ceil($thisuserAccount->use_money * 100) / 100;
?>
   
    </p>
    <div class="one-half">
        <p class="qys_member_center">
            今日收益<br>
            0.00
        </p>
    </div>
    <div class="two-half last-column">
        <p class="qys_member_center">
            总收益<br>
            100.00元 
        </p>        
    </div>
Exemplo n.º 5
0
 /**
  * 显示可用资金
  */
 public function actionBook()
 {
     $user_id = \Yii::$app->user->getId();
     #获得用户的可用资金
     $p_param = Yii::$app->request->get();
     if (!isset($p_param['id'])) {
         echo 1;
         Yii::$app->end();
     }
     $logis = Logistics::find()->where("id=:id", [':id' => $p_param['id']])->one();
     if (!isset($logis)) {
         echo 1;
         Yii::$app->end();
     }
     if ($user_id == $logis->publis_user_id) {
         echo '<p>不允许签订自己的物品</p><button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>';
         Yii::$app->end();
     }
     $oneAccount = Account::find()->where("user_id=:user_id", [':user_id' => $user_id])->one();
     return $this->renderAjax('ajax_showUserMoney', ['oneAccount' => $oneAccount, 'logis' => $logis]);
 }
Exemplo n.º 6
0
<?php

/* @var $this yii\web\View */
$this->title = '提现';
use yii\helpers\Url;
use frontend\services\AccountService;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\models\Account;
use common\models\Bankcard;
$user_id = Yii::$app->user->getId();
$oneuseraccount = Account::find()->where('user_id=:user_id', [':user_id' => $user_id])->one();
$oneBank = Bankcard::find()->where('user_id=:user_id', [':user_id' => $user_id])->one();
?>
<div class="container no-bottom">
    <img class="responsive-image" src="/images/misc/help_server.png" alt="img">
</div>
<div class="container">
    <div class="tabs">
        <a href="<?php 
echo Url::toRoute('/member/account/tixian');
?>
" class="tab-but tab-but-1 tab-active">申请提现</a>
        <a href="<?php 
echo Url::toRoute('/member/account/tixianlog');
?>
" class="tab-but tab-but-2">提现记录</a>     
    </div>     
</div>
<div class="container no-bottom">
    <a href="#" style="width:100%;padding-left:13px;" class="button-big-icon-colse button-white">所属银行:<span class="float-right"><?php 
Exemplo n.º 7
0
 /**
  * 显示可用资金
  */
 public function actionShowmymoney()
 {
     $user_id = \Yii::$app->user->getId();
     #获得用户的可用资金
     $p_param = Yii::$app->request->get();
     if (!isset($p_param['id'])) {
         echo 1;
         Yii::$app->end();
     }
     $product = Product::find()->where("product_id=:id", [':id' => $p_param['id']])->one();
     if (!isset($product)) {
         echo 1;
         Yii::$app->end();
     }
     if ($user_id == $product->product_user_id) {
         echo '<p>不允许购买自己的商品</p><button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>';
         Yii::$app->end();
     }
     $oneAccount = Account::find()->where("user_id=:user_id", [':user_id' => $user_id])->one();
     return $this->renderAjax('ajax_showUserMoney', ['oneAccount' => $oneAccount, 'product' => $product]);
 }
Exemplo n.º 8
0
 /**
  * 
  * @param type $object
  * @return string
  */
 public static function getAccountClick($object, $weixinuser)
 {
     $myAccount = Account::find()->where("user_id=:user_id", [":user_id" => $weixinuser->user_id])->one();
     $content = "我的总金额为:" . $myAccount->total . "\n" . "可用资金为:" . $myAccount->use_money;
     WechatCheck::_transmitText($object, $content);
 }
Exemplo n.º 9
0
 /**
  * handle
  */
 public function handle()
 {
     $attributes = $this->client->getUserAttributes();
     // common
     $continue = false;
     $id = ArrayHelper::getValue($attributes, 'id');
     $fullname = '';
     $email = '';
     // google
     if ($this->client->getName() == 'google') {
         $fullname = ArrayHelper::getValue($attributes, 'displayName');
         $emails = ArrayHelper::getValue($attributes, 'emails');
         $email = $emails[0]['value'];
         $continue = true;
     }
     // facebook
     if ($this->client->getName() == 'facebook') {
         $fullname = ArrayHelper::getValue($attributes, 'name');
         $email = ArrayHelper::getValue($attributes, 'email');
         $continue = true;
     }
     if (!$continue) {
         //            Yii::$app->getSession()->setFlash('info', [
         //                Yii::t('app', 'Flickr'),
         //            ]);
         //Yii::$app->user->setReturnUrl(Yii::$app->request->referrer);
         return;
     }
     /* @var Auth $auth */
     $auth = Auth::find()->where(['source' => $this->client->getId(), 'source_id' => $id])->one();
     if (Yii::$app->user->isGuest) {
         if ($auth) {
             // login
             /* @var Account $user */
             $user = $auth->user;
             $this->updateUserInfo($user);
             Yii::$app->user->login($user, Setting::getValue('rememberMeDuration'));
         } else {
             // signup
             if ($email !== null && Account::find()->where(['email' => $email])->exists()) {
                 Yii::$app->getSession()->setFlash('error', [Yii::t('app', "User with the same email as in {client} account already exists but isn't linked to it. Login using email first to link it.", ['client' => $this->client->getTitle()])]);
             } else {
                 $password = Yii::$app->security->generateRandomString(6);
                 $user = new Account(['fullname' => $fullname, 'email' => $email, 'password' => $password]);
                 $user->generateAuthKey();
                 $user->generatePasswordResetToken();
                 $transaction = Account::getDb()->beginTransaction();
                 //file_put_contents('D:\log', json_encode($transaction));
                 if ($user->save()) {
                     $auth = new Auth(['user_id' => $user->id, 'source' => $this->client->getId(), 'source_id' => (string) $id]);
                     if ($auth->save()) {
                         $transaction->commit();
                         Yii::$app->user->login($user, Setting::getValue('rememberMeDuration'));
                     } else {
                         $transaction->rollBack();
                         Yii::$app->getSession()->setFlash('error', [Yii::t('app', 'Unable to save {client} account: {errors}', ['client' => $this->client->getTitle(), 'errors' => json_encode($auth->getErrors())])]);
                     }
                 } else {
                     $transaction->rollBack();
                     Yii::$app->getSession()->setFlash('error', [Yii::t('app', 'Unable to save user: {errors}', ['client' => $this->client->getTitle(), 'errors' => json_encode($user->getErrors())])]);
                 }
             }
         }
     } else {
         // user already logged in
         Yii::$app->user->setReturnUrl(Yii::$app->request->referrer);
         if (!$auth) {
             // add auth provider
             $auth = new Auth(['user_id' => Yii::$app->user->id, 'source' => $this->client->getId(), 'source_id' => (string) $attributes['id']]);
             if ($auth->save()) {
                 /** @var Account $user */
                 $user = $auth->user;
                 $this->updateUserInfo($user);
                 Yii::$app->getSession()->setFlash('success', [Yii::t('app', 'Linked {client} account.', ['client' => $this->client->getTitle()])]);
             } else {
                 Yii::$app->getSession()->setFlash('error', [Yii::t('app', 'Unable to link {client} account: {errors}', ['client' => $this->client->getTitle(), 'errors' => json_encode($auth->getErrors())])]);
             }
         } else {
             // there's existing auth
             Yii::$app->getSession()->setFlash('error', [Yii::t('app', 'Unable to link {client} account. There is another user using it.', ['client' => $this->client->getTitle()])]);
         }
     }
 }