Esempio n. 1
0
 public function update()
 {
     if ($this->provinceId == "" || $this->majorJobId == "") {
         CommonFunctions::createAlertMessage("省份或者专业类型不能为空", "error");
         return false;
     }
     $user = Yii::$app->session->get('user');
     $majorJob = MajorJob::findOne($this->majorJobId);
     if ($this->provinceId != $majorJob['provinceId']) {
         CommonFunctions::createAlertMessage("专业类型与所处省份不一致,请重新选择", "error");
         return false;
     }
     //修改省份或专业岗位,需要清除用户的在线练习相关信息
     if ($this->provinceId != $user['provinceId'] || $this->majorJobId != $user['majorJobId']) {
         CurrentTestLibrary::deleteAll(['userId' => $user['userId']]);
         //删除当前记录
         ErrorQuestion::deleteAll(['userId' => $user['userId']]);
         //删除错题记录
         Collection::deleteAll(['userId' => $user['userId']]);
         //删除收藏
     }
     /** @var $user \common\models\Users */
     $user = Users::findOne($user['userId']);
     $user->nickname = $this->nickname;
     $user->realname = $this->realname;
     $user->provinceId = $this->provinceId;
     $user->majorJobId = $this->majorJobId;
     $user->company = $this->company;
     $user->address = $this->address;
     if (!$user->save()) {
         throw new Exception("UpdateInfoForm update Save Error");
     }
     Yii::$app->session->set('user', $user);
     return true;
 }
Esempio n. 2
0
 /**
  * 微信支付成功后的通知处理
  * @param $xml
  * @return string
  * @throws \yii\base\Exception
  */
 public static function payNotify($xml)
 {
     $cache = \Yii::$app->cache;
     //转xml为array
     $xmlArray = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
     if ($xmlArray['return_code'] == 'SUCCESS') {
         $transaction_id = $xmlArray['transaction_id'];
         if ('ok' == $cache->get($transaction_id)) {
             $msg = "订单:" . $transaction_id . ",已处理完,重复通知";
             Yii::info($msg, 'wx');
             echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
         } else {
             $cache->set($transaction_id, 'ok', 24 * 3600);
             //缓存1天
             $money = $xmlArray['total_fee'] / 100;
             //总金额(元)
             $attachArray = explode("|", $xmlArray['attach']);
             $userId = intval($attachArray[0]);
             //获取充值用户
             $user = Users::findOne($userId);
             $addBitcoin = intval($attachArray[1]);
             //获取充值获得的云豆数
             Money::recordOne($user, $money, $addBitcoin, Money::TYPE_PAY, Money::FROM_WX);
             //记录充值记录+返点+收入支出表变化+用户云豆数增加
             $msg = "订单:" . $transaction_id . ",首次记录,userId:" . $user['userId'] . ",支付" . $money . "元,获得" . $addBitcoin . "云豆,交易类型:" . $xmlArray['trade_type'] . ",交易结束时间:" . $xmlArray['time_end'];
             Yii::info($msg, 'wx');
             echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
         }
     } else {
         $msg = "错误消息:" . $xmlArray['return_msg'];
         Yii::info($msg, 'wx');
         echo 'fail';
     }
     exit;
 }
Esempio n. 3
0
 /**
  * 保存一条记录,注意:此处会对应增加或减少用户的云豆数!!
  * @param $userId
  * @param $bitcoin
  * @param $usageModeId
  * @param $type
  * @param $fromUserId
  * @throws Exception
  * @throws \Exception
  */
 public static function saveRecord($userId, $bitcoin, $usageModeId, $type, $fromUserId = null)
 {
     $record = new IncomeConsume();
     $record->userId = $userId;
     $record->bitcoin = $bitcoin;
     $record->usageModeId = $usageModeId;
     $record->type = $type;
     $record->fromUserId = $fromUserId;
     $record->createDate = DateFunctions::getCurrentDate();
     if (!$record->save()) {
         throw new Exception("IncomeConsume save error");
     }
     $user = Users::findOne($userId);
     if ($type == IncomeConsume::TYPE_INCOME) {
         $user->bitcoin += $bitcoin;
     } elseif ($type == IncomeConsume::TYPE_CONSUME) {
         if ($user->bitcoin < $bitcoin) {
             throw new Exception("IncomeConsume user bitcoin less than need error");
         } else {
             $user->bitcoin -= $bitcoin;
         }
     }
     if (!$user->save()) {
         throw new Exception("IncomeConsume user update error");
     }
 }
 public function modifyPassword()
 {
     $user = Yii::$app->session->get('user');
     /** @var $user \common\models\Users */
     $user = Users::findOne($user['userId']);
     $user->password = CommonFunctions::encrypt($this->newPassword);
     $user->save();
 }
 public function update()
 {
     $user = Yii::$app->session->get('user');
     /** @var $user \common\models\Users */
     $user = Users::findOne($user['userId']);
     $user->cellphone = $this->cellphone;
     if (!$user->save()) {
         throw new Exception("UpdateCellphoneForm update Save Error");
     }
     Yii::$app->session->set('user', $user);
 }
 public function actionIndex()
 {
     $session = Yii::$app->session;
     $user = $session->get('user');
     $user = Users::findOne($user['userId']);
     if ($user['password'] == CommonFunctions::encrypt("123456")) {
         if (!CommonFunctions::isExistAlertMessage()) {
             CommonFunctions::createAlertMessage("您的登录密码过于简单,请及时修改", "warning");
         }
     }
     if ($user['state'] == Users::STATE_FROZEN) {
         if (!CommonFunctions::isExistAlertMessage()) {
             CommonFunctions::createAlertMessage("您的帐号已被冻结,部分操作不可见,需要解冻请联系管理员", "warning");
         }
     }
     return $this->render('index', ['user' => $user]);
 }
Esempio n. 7
0
 /**
  *填写基本信息内容
  * @param $id
  * @return UpdateUserForm
  */
 public static function initUser($id)
 {
     /** @var $user \common\models\Users */
     $user = Users::findOne($id);
     $form = new UpdateUserForm();
     $form->username = $user->username;
     $form->nickname = $user->nickname;
     $form->realname = $user->realname;
     $form->cellphone = $user->cellphone;
     $form->weixin = $user->weixin;
     $form->qq = $user->qq;
     $form->address = $user->address;
     $form->bankName = $user->bankCard['bankName'];
     $form->cardName = $user->bankCard['cardName'];
     $form->cardNumber = $user->bankCard['cardNumber'];
     $form->email = $user->email;
     return $form;
 }
Esempio n. 8
0
 /**
  * 更新用户状态
  * @param $userId
  * @param $newState
  */
 public static function updateState($userId, $newState)
 {
     $user = Users::findOne($userId);
     $user->state = $newState;
     $user->save();
 }
Esempio n. 9
0
<?php

/* @var $this yii\web\View */
/* @var $users common\models\Users[] */
/* @var $pages */
use yii\helpers\Html;
use yii\helpers\Url;
use common\models\Users;
$this->title = '关联用户列表';
$this->params['breadcrumbs'] = [$this->title];
$userSession = Yii::$app->session->get('user');
$loginUser = Users::findOne($userSession['userId']);
?>

<div class="widget flat">
    <div class="widget-body">
        <?php 
echo \common\widgets\AlertWidget::widget();
?>
        <div class="well bordered-left bordered-blue">
            <a class="btn btn-default" href="javascript:void(0);" data-toggle="collapse" data-target="#search"><i class="fa fa-search"></i>查询</a>
            <label>快速查找:</label>
            <a class="btn btn-default" href="<?php 
echo Url::to(['user/index']);
?>
">所有</a>
            <a class="btn btn-default" href="<?php 
echo Url::to(['user/search', 'type' => 'bitcoin-less', 'content' => 2000]);
?>
">云豆余额小于2000</a>
            <div id="search" class="collapse">
 /** 关联用户 */
 public function actionLinkUser()
 {
     $request = Yii::$app->request;
     $userId = $request->get('id');
     if (!$userId) {
         CommonFunctions::createAlertMessage("缺少对应的用户序号", "error");
         return $this->redirect(['user-big/previous']);
     }
     $recommendUser = Users::findOne($userId);
     Yii::$app->session->setFlash('recommendUser', $recommendUser);
     //记录推荐用户,便于查询页面使用
     $query = Users::find()->where(['recommendUserID' => $recommendUser['userId']]);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $users = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['registerDate' => SORT_DESC])->all();
     return $this->render('link-user', ['users' => $users, 'pages' => $pagination]);
 }
 /**
  * Finds the Users model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Users the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Users::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 12
0
 public function record()
 {
     $userSession = Yii::$app->session->get('user');
     $user = Users::findOne($this->userId);
     Money::recordOneForBig($user, $this->money, $this->bitcoin, $this->from, $userSession['userId'], $this->agreement);
 }
Esempio n. 13
0
 public function recordOne()
 {
     if (!$this->userId) {
         //新添加
         $user = new Users();
         $user->bitcoin = 0;
         $user->password = CommonFunctions::encrypt("123456");
         //初始密码设置为123456
         $user->state = Users::STATE_NORMAL;
         do {
             if ($this->role == Users::ROLE_AA) {
                 $recommendCode = CommonFunctions::create2ARecommendCode();
             } elseif ($this->role == Users::ROLE_AAA) {
                 $recommendCode = CommonFunctions::create3ARecommendCode();
             } elseif ($this->role == Users::ROLE_BIG) {
                 $recommendCode = CommonFunctions::createBigRecommendCode();
             } else {
                 throw new Exception("未知的角色类型");
             }
         } while (Users::findUserByRecommendCode($recommendCode));
         $user->recommendCode = $recommendCode;
         $recommendUser = Users::findUserByRecommendCode($this->recommendCode);
         $user->recommendUserID = $recommendUser['userId'];
         $user->registerDate = DateFunctions::getCurrentDate();
     } else {
         //已存在
         $user = Users::findOne($this->userId);
     }
     $user->role = $this->role;
     $user->departmentId = $this->departmentId;
     $user->username = $this->username;
     $user->nickname = $this->nickname;
     $user->address = $this->address;
     $user->realname = $this->realname;
     $user->cellphone = $this->cellphone;
     $user->email = $this->email;
     $user->qq = $this->qq;
     $user->weixin = $this->weixin;
     if (!$user->save()) {
         throw new Exception("add-user-form user save error");
     } else {
         /** @var $bankCard \common\models\BankCard */
         $bankCard = BankCard::findOne(['userId' => $user->userId]);
         if (!$bankCard) {
             //如果没有
             $bankCard = new BankCard();
             $bankCard->userId = $user->userId;
             $bankCard->state = BankCard::STATE_DEFAULT;
         }
         $bankCard->bankName = $this->bankName;
         $bankCard->cardNumber = $this->cardNumber;
         $bankCard->cardName = $this->cardName;
         $bankCard->save();
     }
 }
Esempio n. 14
0
 public function actionIndex($userId)
 {
     $user = Users::findOne($userId);
     return $this->render('index', ['user' => $user]);
 }