/** 二维码订单页面 */
 public function actionQrOrder()
 {
     $session = Yii::$app->session;
     $user = $session->get('user');
     $schemes = Scheme::findPayScheme();
     //获取充值方案
     $recommendUser = Users::findRecommendUser($user['recommendUserID']);
     if ($recommendUser && $recommendUser['role'] != Users::ROLE_BIG) {
         //存在推荐用户且不为大客户则需要有返点消息提示,否则没有提示
         $rebateScheme = Scheme::findRebateScheme($recommendUser['role']);
         //获取返点方案
     } else {
         $rebateScheme = "";
     }
     if ($rebateScheme) {
         $msg = '充值金额大于' . $rebateScheme['payMoney'] . '元时可以获得' . $rebateScheme['rebateSelf'] * 100 . '%返点哦~。';
         CommonFunctions::createAlertMessage($msg, "info");
     }
     $orders = [];
     $wxPayFunctions = new WxPayFunctions();
     foreach ($schemes as $scheme) {
         array_push($orders, $wxPayFunctions->generateQrOrder($scheme));
     }
     return $this->render('qr-order', ['schemes' => $schemes, 'orders' => $orders]);
 }
예제 #2
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = Users::findByUsername($this->username);
     }
     return $this->_user;
 }
예제 #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");
     }
 }
예제 #4
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;
 }
예제 #5
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;
 }
예제 #6
0
 /** 查询 */
 public function actionSearch()
 {
     $request = Yii::$app->request;
     $query = Yii::$app->session->getFlash('query');
     if ($request->isPost) {
         $type = $request->post('type');
         $content = trim($request->post('content'));
     } else {
         $type = $request->get('type');
         $content = trim($request->get('content'));
     }
     if ($type || !$query) {
         $user = Yii::$app->session->get('user');
         $query = Users::find()->where(['recommendUserID' => $user['userId']]);
         switch ($type) {
             case 'userId':
                 $query = $query->andWhere(['userId' => $content]);
                 break;
             case 'nickname':
             case 'realname':
                 $query = $query->andWhere(['like', $type, $content]);
                 break;
             default:
                 break;
         }
     }
     Yii::$app->session->setFlash('query', $query);
     $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('index', ['users' => $users, 'pages' => $pagination]);
 }
 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();
 }
예제 #8
0
 public function register()
 {
     if ($this->provinceId == "" || $this->majorJobId == "") {
         CommonFunctions::createAlertMessage("省份或者专业类型不能为空", "error");
         return false;
     }
     $majorJob = MajorJob::findOne($this->majorJobId);
     if ($this->provinceId != $majorJob['provinceId']) {
         CommonFunctions::createAlertMessage("专业类型与所处省份不一致,请重新选择", "error");
         return false;
     }
     $openId = Yii::$app->session->get('openId');
     $user = Users::findByWeiXin($openId);
     if (!$user) {
         //如果用户不存在,即关注的时候没有把微信的相关信息存入
         $user = new Users();
         $user->weixin = $openId;
     }
     if (!$user->registerDate || $user->registerDate == 0) {
         //如果用户注册日期不存在或为0,表明用户第一次实名认证
         $user->bitcoin = 0;
         $user->registerDate = DateFunctions::getCurrentDate();
         $user->role = Users::ROLE_A;
         $user->state = Users::STATE_NORMAL;
         do {
             //保证生成的推荐码的唯一
             $recommendCode = CommonFunctions::createCommonRecommendCode();
         } while (Users::findUserByRecommendCode($recommendCode));
         $user->recommendCode = $recommendCode;
         if ($this->tjm) {
             //推荐码绑定推荐人
             $this->recommendUser = Users::findUserByRecommendCode($this->tjm);
             if ($this->recommendUser) {
                 if ($this->recommendUser['userId'] != $user['userId']) {
                     //推荐人不是自己
                     $user->recommendUserID = $this->recommendUser['userId'];
                 }
             }
         }
     }
     $user->nickname = $this->nickname;
     $user->realname = $this->realname;
     $user->provinceId = $this->provinceId;
     $user->majorJobId = $this->majorJobId;
     $user->cellphone = $this->cellphone;
     $user->company = $this->company;
     $user->address = $this->address;
     if (!$user->save()) {
         throw new Exception("RegisterForm register Save Error");
     }
     Yii::$app->cache->delete($user->cellphone);
     //注册成功后将验证码缓存清除
     Yii::$app->session->set('user', $user);
     return true;
 }
 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);
 }
예제 #10
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Users::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, 'dob' => $this->dob, 'is_active' => $this->is_active, 'is_deleted' => $this->is_deleted, 'app_status' => $this->app_status, 'otp' => $this->otp, 'created_date' => $this->created_date, 'created_by' => $this->created_by, 'updated_date' => $this->updated_date, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'device_token', $this->device_token])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'role', $this->role])->andFilterWhere(['like', 'mood_message', $this->mood_message])->andFilterWhere(['like', 'area_intrest', $this->area_intrest])->andFilterWhere(['like', 'about_me', $this->about_me]);
     return $dataProvider;
 }
예제 #11
0
 public function actionSearch()
 {
     $request = Yii::$app->request;
     $type = $request->get("type");
     $query = Yii::$app->session->getFlash('query');
     if (!$type) {
         $type = $request->post("type");
         $content = $request->post("content");
     } else {
         $content = $request->get("content");
     }
     if ($type || !$query) {
         switch ($type) {
             case 'userId':
                 $query = Service::find()->where(['userId' => $content]);
                 break;
             case 'date':
                 $query = Service::find()->where(['between', 'createDate', date('Y-m-d H:i:s', strtotime($content)), date('Y-m-d H:i:s')]);
                 break;
             case 'state':
                 if ($content == 'noReply') {
                     $query = Service::find()->where(['state' => Service::STATE_UNREPLY]);
                 } elseif ($content == 'replied') {
                     $query = Service::find()->where(['state' => Service::STATE_REPLIED]);
                 } elseif ($content == 'publish') {
                     $query = Service::find()->where(['state' => Service::STATE_PUBLISH]);
                 } else {
                     $query = Service::find();
                 }
                 break;
             case 'nickname':
                 $table_a = Service::tableName();
                 $table_b = Users::tableName();
                 $query = Service::find()->leftJoin($table_b, "{$table_a}.userId={$table_b}.userId")->where(['like', "{$table_b}.nickname", $content]);
                 break;
             case 'content':
                 $query = Service::find()->where(['like', $type, $content]);
                 break;
             default:
                 $query = Service::find();
                 break;
         }
     }
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $models = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['createDate' => SORT_DESC])->all();
     return $this->render('index', ['models' => $models, 'pages' => $pagination]);
 }
예제 #12
0
 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]);
 }
예제 #13
0
 /** 查询 */
 public function actionSearch()
 {
     $request = Yii::$app->request;
     $query = Yii::$app->session->getFlash('query');
     if ($request->isPost) {
         $type = $request->post('type');
         $content = $request->post('content');
     } else {
         $type = $request->get('type');
         $content = trim($request->get('content'));
     }
     if ($type || !$query) {
         $user = Yii::$app->session->get('user');
         switch ($type) {
             case 'income':
                 if ($content == 'my') {
                     $query = IncomeConsume::find()->where(['type' => IncomeConsume::TYPE_INCOME, 'userId' => $user['userId']]);
                 } elseif ($content == 'others') {
                     $query = IncomeConsume::find()->where(['type' => IncomeConsume::TYPE_INCOME, 'FromUserId' => $user['userId']]);
                 }
                 break;
             case 'consume':
                 if ($content == 'my') {
                     $query = IncomeConsume::find()->where(['type' => IncomeConsume::TYPE_CONSUME, 'userId' => $user['userId']]);
                 }
                 break;
             case 'userId':
                 $query = IncomeConsume::find()->where(['userId' => $user['userId']])->orWhere(['fromUserId' => $user['userId']])->andWhere(['userId' => $content]);
                 break;
             case 'nickname':
             case 'realname':
                 $table_a = IncomeConsume::tableName();
                 $table_b = Users::tableName();
                 $query = IncomeConsume::find()->leftJoin($table_b, "{$table_a}.userId={$table_b}.userId")->where(["{$table_a}.userId" => $user['userId']])->orWhere(["{$table_a}.fromUserId" => $user['userId']])->andWhere(['like', "{$table_b}.{$type}", $content]);
                 break;
             default:
                 $query = IncomeConsume::find()->where(['userId' => $user['userId']])->orWhere(['fromUserId' => $user['userId']]);
                 break;
         }
     }
     Yii::$app->session->setFlash('query', $query);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $model = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['createDate' => SORT_DESC])->all();
     return $this->render('index', ['models' => $model, 'pages' => $pagination]);
 }
예제 #14
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;
 }
예제 #15
0
 /**
  * 消息回复
  */
 public function responseMsg()
 {
     $cache = Yii::$app->cache;
     //get post data, May be due to the different environments
     $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
     //extract post data
     if (!empty($postStr)) {
         /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,
            the best way is to check the validity of xml by yourself */
         libxml_disable_entity_loader(true);
         $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
         /** @var  $fromUsername String */
         $fromUsername = $postObj->FromUserName;
         $toUsername = $postObj->ToUserName;
         $content = trim($postObj->Content) . "";
         //转成字符串
         $event = $postObj->Event;
         $msgType = $postObj->MsgType;
         $time = time();
         $textTpl = "<xml>\n\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t</xml>";
         //订阅事件
         if ($event == "subscribe") {
             $response_msgType = "text";
             Users::wxSubscribe($fromUsername);
             $contentStr = "感谢您关注云豆讲堂。\n\n在这里,您不但可以进行免费模拟考试、免费咨询考试信息、免费代办报名,还可以在线考试练习、与高手们交流学习心得、与朋友们整合考试资源。\n\n为了确保您获得准确的考试信息、试题库信息等,请您首先进行‘实名认证’。相关信息我们会保密哦!\n\n实名认证步骤:点击'模拟与学习'>>'实名认证'或者'<a href='" . Url::to(['account/register', 'openId' => strval($fromUsername)], true) . "'>点击这里</a>'都可以进行,祝您考试顺利!\n\n<a href='http://x.eqxiu.com/s/d3HPgVVe?eqrcode=1&from=groupmessage&isappinstalled=0'>查看云豆平台应用手册</a>";
             $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $response_msgType, $contentStr);
             echo $resultStr;
             exit;
         }
         //任何消息,转往多客服
         if (!empty($content)) {
             $serviceTpl = "<xml>\n                                <ToUserName><![CDATA[%s]]></ToUserName>\n                                <FromUserName><![CDATA[%s]]></FromUserName>\n                                <CreateTime>%s</CreateTime>\n                                <MsgType><![CDATA[transfer_customer_service]]></MsgType>\n                                </xml>";
             $resultStr = sprintf($serviceTpl, $fromUsername, $toUsername, $time);
             echo $resultStr;
             exit;
         } else {
             echo "individual";
             exit;
         }
     } else {
         echo "";
         exit;
     }
 }
예제 #16
0
 public function beforeAction($action)
 {
     $session = Yii::$app->session;
     //$session->removeAll();
     //$session->set('openId','ow-bOvjH7CpKQtxsvjJuRmg6-g-k');
     if ($user = $session->get('user')) {
         if ($user['role'] == Users::ROLE_A) {
             //用户必须是A级用户才能登录前台,避免后台登录了前台也能进行登陆
             return parent::beforeAction($action);
         }
     }
     if ($openId = $session->get('openId')) {
         $session->set('user', Users::findByWeiXin($openId));
         return parent::beforeAction($action);
     }
     $request = Yii::$app->request;
     $state = $request->get("state");
     $current_url = Url::current([], true);
     //认证后跳转至当前网址
     if ($state == 'YUN') {
         //需要与getAuthorizeUrl($redirect_uri)中定义的一致,用户认证后回调操作如下
         $code = $request->get("code");
         if ($code) {
             //code存在表示用户允许授权
             $result = WeiXinFunctions::getAuthAccessToken($code);
             $openId = $result->openid;
             $access_token = $result->access_token;
             //授权成功后继续执行后面的action
             $session->set('openId', $openId);
             $session->set('user', Users::findByWeiXin($openId));
             return parent::beforeAction($action);
             //header("Location:$current_url");
         } else {
             echo "用户不允许授权";
             return false;
         }
     }
     $redirect_uri = urlencode($current_url);
     //认证后跳转至当前网址
     $url = WeiXinFunctions::getAuthorizeUrl($redirect_uri);
     header("Location:{$url}");
     return false;
 }
예제 #17
0
 public function login()
 {
     $user = Users::find()->where(['username' => $this->username])->one();
     if ($user) {
         if ($user['state'] == Users::STATE_STOP) {
             //用户状态被终止
             $this->addError('username', "该用户已被终止登录");
             return false;
         }
         if ($user['password'] != CommonFunctions::encrypt($this->password)) {
             $this->addError('password', "密码错误");
             return false;
         }
         Yii::$app->session->set('user', $user);
         return true;
     } else {
         $this->addError('username', "用户不存在");
         return false;
     }
 }
예제 #18
0
 public function actionSearch()
 {
     $request = Yii::$app->request;
     $query = Yii::$app->session->getFlash('query');
     if ($request->isPost) {
         $type = $request->post('type');
         $content = trim($request->post('content'));
     } else {
         $type = $request->get('type');
         $content = trim($request->get('content'));
     }
     if ($type || !$query) {
         switch ($type) {
             case 'province':
                 $table_a = Users::tableName();
                 $table_b = Province::tableName();
                 $query = Users::find()->leftJoin($table_b, "{$table_a}.provinceId={$table_b}.provinceId")->where(['like', "{$table_b}.name", $content]);
                 break;
             case 'majorJob':
                 $table_a = Users::tableName();
                 $table_b = MajorJob::tableName();
                 $query = Users::find()->leftJoin($table_b, "{$table_a}.majorJobId={$table_b}.majorJobId")->where(['like', $table_b . ".name", $content]);
                 break;
             case 'nickname':
             case 'cellphone':
                 $query = Users::find()->where(['like', $type, $content]);
                 break;
             default:
                 $query = Users::find();
                 break;
         }
         $query = $query->andWhere('weixin is not null');
         //添加微信用户条件,位置不可改
     }
     Yii::$app->session->setFlash('query', $query);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $user = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['registerDate' => SORT_DESC])->all();
     return $this->render('index', ['users' => $user, 'pages' => $pagination]);
 }
예제 #19
0
 public function getCreateUser()
 {
     return $this->hasOne(Users::className(), ['userId' => 'createUserId']);
 }
예제 #20
0
echo Html::endForm();
?>
            </div>
        </div>
        <table class="table table-bordered table-striped margin-bottom-20">
            <tr>
                <td><strong>总计提现金额:</strong><?php 
echo Withdraw::findTotalMoney($user['userId']);
?>
(元)</td>
                <td><strong>总计消耗云豆:</strong><?php 
echo Withdraw::findTotalBitcoin($user['userId']);
?>
(颗)</td>
                <td><strong>剩余云豆:</strong><?php 
echo Users::findBitcoin($user['userId']);
?>
(颗)</td>
            </tr>
        </table>
        <table class="table table-hover table-bordered text-align-center">
            <thead class="bordered-blue">
            <tr>
                <th class="text-align-center">序号</th>
                <th class="text-align-center">用户名称</th>
                <th class="text-align-center">提现金额(元)</th>
                <th class="text-align-center">消耗云豆(颗)
                </th><th class="text-align-center">申请提现时间</th>
                <th class="text-align-center">发票金额</th>
                <th class="text-align-center">发票单号</th>
                <th class="text-align-center">状态</th>
예제 #21
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(Users::className(), ['user_id' => 'user_id']);
 }
예제 #22
0
    ?>
</td>
                    <td><?php 
    echo Money::findTotalPay($user->userId);
    ?>
</td>
                    <td><?php 
    echo IncomeConsume::findTotalIncome($user->userId);
    ?>
</td>
                    <td><?php 
    echo $user->bitcoin;
    ?>
</td>
                    <td><?php 
    echo count(Users::findBeRecommend($user->userId));
    ?>
</td>
                    <td><?php 
    echo $user->registerDate;
    ?>
</td>
                    <td><?php 
    echo $user->address;
    ?>
</td>
                    <td><?php 
    echo $user->realname;
    ?>
</td>
                    <td><?php 
예제 #23
0
echo $user['cellphone'];
?>
" disabled>
        </div>
        <div class='col-xs-4 no-padding-left'>
            <a href="<?php 
echo Url::to(['account/update-cellphone']);
?>
" class='btn btn-primary'>修改手机号</a>
        </div>
    </div>
    <div class="form-group">
        <label class="col-xs-3 control-label">推荐人</label>
        <div class='col-xs-9 no-padding-left'>
            <input type="text" class="form-control" name="cellphone" value="<?php 
echo Users::findRecommendUserName($user['recommendUserID']);
?>
" disabled>
        </div>
    </div>
    <div class="form-group">
        <div class="col-xs-offset-3 col-xs-9 no-padding-left">
            <button type="submit" class="btn btn-primary">提交</button>
        </div>
    </div>
    <?php 
ActiveForm::end();
?>
</div>

<div class="modal fade" id="provinceSelect" tabindex="-1" role="dialog" aria-labelledby="省份选择">
예제 #24
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">
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getResearcher()
 {
     return $this->hasOne(Users::className(), ['id' => 'researcher_id']);
 }
예제 #26
0
    </div>
</div>

<?php 
if ($practiceRecordFlag && $schemes) {
    ?>
<div class="modal fade" id="pay_modal" tabindex="-1" role="dialog" aria-labelledby="在线学习支付">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">在线学习支付</h4>
            </div>
            <div class="modal-body">
                <p class="margin-bottom-20">您还剩余云豆:<strong><?php 
    echo Users::findBitcoin($sessionUser['userId']);
    ?>
</strong>颗</p>
                <input type="hidden" name="schemeId" value="">
                <?php 
    foreach ($schemes as $scheme) {
        ?>
                    <div class="pic_box_3 practice_select" data-id="<?php 
        echo $scheme['schemeId'];
        ?>
">
                        <div class="bitcoin"><?php 
        echo $scheme['payBitcoin'];
        ?>
<small>云豆</small></div>
                        <div class="rmb">使用<?php 
예제 #27
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsers()
 {
     return $this->hasMany(Users::className(), ['status_id' => 'id']);
 }
예제 #28
0
 /**
  * 查询被推荐的人
  * @param $userId
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function findBeRecommend($userId)
 {
     return Users::find()->where(['recommendUserID' => $userId])->all();
 }
예제 #29
0
 /**
  * 查询用户的咨询
  * @param $openId
  * @param int $limit
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function findUserServiceByOpenId($openId, $limit = 5)
 {
     $user = Users::findByWeiXin($openId);
     return Service::find()->where(['userId' => $user->userId])->limit($limit)->all();
 }
예제 #30
0
 /**
  * 针对大客户充值,大客户充值自己没有返点
  * 记录用户的充值,包含返点、用户余额的改变和云豆收入支出记录的记录
  * @param $user
  * @param $money
  * @param $bitcoin
  * @param $from
  * @param null $operateUserId
  * @param null $agreement
  * @throws Exception
  */
 public static function recordOneForBig($user, $money, $bitcoin, $from, $operateUserId = null, $agreement = null)
 {
     $moneyModel = new Money();
     $moneyModel->userId = $user['userId'];
     $moneyModel->money = $money;
     $moneyModel->type = Money::TYPE_PAY;
     $moneyModel->bitcoin = $bitcoin;
     $moneyModel->createDate = DateFunctions::getCurrentDate();
     $moneyModel->from = $from;
     $moneyModel->operateUserId = $operateUserId;
     $moneyModel->agreement = $agreement;
     if (!$moneyModel->save()) {
         throw new Exception("money save error");
     }
     //云豆收入支出记录+用户余额改变
     IncomeConsume::saveRecord($user['userId'], $bitcoin, UsageMode::USAGE_PAY, IncomeConsume::TYPE_INCOME, $operateUserId);
     $recommendUser = Users::findRecommendUser($user['recommendUserID']);
     if ($recommendUser) {
         //存在推荐用户
         $rebateScheme = Scheme::findRebateScheme(Users::ROLE_BIG);
         if ($rebateScheme && $money >= $rebateScheme['payMoney']) {
             //存在返点方案,并且达到当前返点的起始要求
             $proportion = Yii::$app->params['proportion'];
             $addBitcoin = $money * $proportion * $rebateScheme['rebate'];
             //返点云豆,返给推荐人
             IncomeConsume::saveRecord($recommendUser['userId'], $addBitcoin, UsageMode::USAGE_REBATE_BIG, IncomeConsume::TYPE_INCOME, $user['userId']);
         }
     }
 }