| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- <?php
- namespace app\shop\controller;
- use app\common\controller\Frontend;
- use app\common\library\CoinRate;
- use app\common\model\Config;
- class User extends Frontend
- {
- protected $noNeedLogin = ['findpwd', 'register', 'login'];
- protected $noNeedRight = '*';
- protected $layout = '';
- public function _initialize()
- {
- parent::_initialize();
- }
- function index()
- {
- $info = db('user')->where(['id' => $this->auth->id])->find();
- $loginStu = db('studio')->where(['title' => $this->auth->login_studio])->find();
- $stuid = isset($loginStu['id'])? $loginStu['id'] : 0;
- $counts = [
- 'status1'=> db('trade')->where(['relevant_userid'=>$this->auth->id,'status'=>1,'stuid'=>$stuid])->count('id'),
- 'status2'=> db('trade')->where(['relevant_userid'=>$this->auth->id,'status'=>2,'stuid'=>$stuid])->count('id'),
- 'status3'=> db('trade')->where(['relevant_userid'=>$this->auth->id,'status'=>3,'issell'=>[['egt',0],['elt',2]],'stuid'=>$stuid])->count('id'),
- ];
- $this->view->assign('counts', $counts);
- $this->view->assign([
- "user" => $info,
- ]);
- return $this->fetch();
- }
- function myhost()
- {
- $studio = db('studio')->where(['id' => $this->auth->stuid])->find();
- $total1 = db('goods')->where(['stuid' => $studio['id'], 'on_sale' => 1, 'on_resale' => 2])->count();
- $total2 = db('trade')->where(['status' => 0, 'stuid' => $studio['id']])->count();
- $this->view->assign([
- "studio" => $studio,
- "total1" => $total1,
- "total2" => $total2,
- ]);
- return $this->fetch();
- }
- function safecenter()
- {
- return $this->fetch();
- }
- function xieyi()
- {
- $list = db('article')->where(['catid' => 5])->select();
- $this->view->assign([
- "list" => $list,
- ]);
- return $this->fetch();
- }
- /**
- * 注销登录
- */
- public function logout()
- {
- //注销本站
- $this->auth->logout();
- $this->redirect("/index/user/login");
- }
- function userteam()
- {
- $user = db('user')->where(['id' => $this->auth->id])->find();
- $total = db('user')->where(['refereeids' => ['like', '%,' . $this->auth->id . ',%'], 'status' => 1])->count();
- $total1 = db('user')->where(['refereeids' => ['like', '%,' . $this->auth->id . ',%'], 'isuser' => 1, 'status' => 1])->count();
- $today_cnt = db('user')->where(['refereeids' => ['like', '%,' . $this->auth->id . ',%'], 'createtime' => ['gt', strtotime('today')], 'status' => 1])->count();
- $today_upload = db('user')->where(['refereeids' => ['like', '%,' . $this->auth->id . ',%'], 'isuser' => 1, 'intime' => ['gt', strtotime('today')], 'status' => 1])->count();
- $list = db('user')->where(['refereeid' => $this->auth->id, 'status' => 1])->select();
- if (empty($list)) {
- $list = [];
- }
- $this->view->assign([
- "list" => $list,
- "total" => $total,
- "total1" => $total1,
- "today_cnt" => $today_cnt,
- 'today_upload' => $today_upload,
- ]);
- return $this->view->fetch();
- }
- function tjpv()
- {
- $config = Config::getConfigByGroup('trade');
- $releaseRate = isset($config['release_rate'])? floatval($config['release_rate']['value']) : 0;
- $this->view->assign('release_rate', $releaseRate);
- return $this->fetch();
- }
- function tjpv1()
- {
- $uids = db('user')->where(['refereeids' => ['like', '%,' . $this->auth->id . ',%']])->column('id');
- if ($uids) {
- $total_nums = db('trade')->where(['status' => ['egt', 3], 'relevant_userid' => ['in', $uids]])->sum('nums');
- $total_cnt = db('trade')->where(['status' => ['egt', 3], 'relevant_userid' => ['in', $uids]])->count();
- $totalt_nums = db('trade')->where(['status' => ['egt', 3], 'create_time' => strtotime('today'), 'relevant_userid' => ['in', $uids]])->sum('nums');
- $totalt_cnt = db('trade')->where(['status' => ['egt', 3], 'create_time' => strtotime('today'), 'relevant_userid' => ['in', $uids]])->count();
- } else {
- $total_nums = 0;
- $total_cnt = 0;
- $totalt_nums = 0;
- $totalt_cnt = 0;
- }
- $this->view->assign([
- "total_nums" => $total_nums,
- "total_cnt" => $total_cnt,
- "totalt_nums" => $totalt_nums,
- "totalt_cnt" => $totalt_cnt,
- ]);
- return $this->view->fetch();
- }
- function sonteam()
- {
- $id = input('id');
- $list = db('user')->where(['refereeid' => $id])->select();
- if (empty($list)) {
- $list = [];
- }
- $this->view->assign([
- "list" => $list,
- 'id' => $id
- ]);
- return $this->view->fetch();
- }
- function bonusdetailed()
- {
- $user = db('user')->where(['id' => $this->auth->id])->find();
- $zt = db('detailed_cash')->where(['userid' => $this->auth->id, 'type' => 16])->sum('money');
- $jt = db('detailed_cash')->where(['userid' => $this->auth->id, 'type' => 20])->sum('money');
- $manager = db('detailed_cash')->where(['userid' => $this->auth->id, 'type' => ['in', '17,18']])->sum('money');
- //今日
- $zt1 = db('detailed_cash')->where(['userid' => $this->auth->id, 'type' => 16, 'create_time' => ['egt', strtotime('today')]])->sum('money');
- $jt1 = db('detailed_cash')->where(['userid' => $this->auth->id, 'type' => 20, 'create_time' => ['egt', strtotime('today')]])->sum('money');
- $manager1 = db('detailed_cash')->where(['userid' => $this->auth->id, 'type' => ['in', '17,18'], 'create_time' => ['egt', strtotime('today')]])->sum('money');
- $this->view->assign([
- 'user' => $user,
- 'zt' => $zt,
- 'jt' => $jt,
- 'manager' => $manager,
- 'zt1' => $zt1,
- 'jt1' => $jt1,
- 'manager1' => $manager1,
- ]);
- return $this->view->fetch();
- }
- function xieyidetail()
- {
- $id = input('id');
- $info = db('article')->where("id", $id)->find();
- $this->view->assign("info", $info);
- return $this->view->fetch();
- }
- function sharelink()
- {
- $user = get_user_data($this->auth->id);
- $tjurl = 'http://' . $_SERVER['HTTP_HOST'] . '/index.php/index/user/register?code=' . $user['username'];
- $img_url = 'http://' . $_SERVER['HTTP_HOST'] . '/getqrcode.php?t=' . $tjurl;
- $save_path = 'uploads/tj/';
- put_file_from_url_content($img_url, $user['id'] . ".png", $save_path);
- $this->assign("imgurl", 'http://' . $_SERVER['HTTP_HOST'] . '/uploads/tj/' . $user['id'] . '.png');
- $myset = \app\common\model\Config::getConfigByGroup('Iindex');
- $this->view->assign("shareBg", $myset['share_bg']['value']);
- $this->view->assign("tjurl", $tjurl);
- $this->view->assign("user", $user);
- return $this->view->fetch();
- }
- /**
- * 推广素材
- * @return string
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- function material()
- {
- $lists = db('material')->where(['status' => 1])
- ->order('create_time desc,id desc')
- ->limit(100)
- ->select();
- if ($lists) {
- foreach ($lists as &$item) {
- $item['images'] = $item['images'] ? explode(',', $item['images']) : [];
- }
- }
- $this->view->assign("lists", $lists);
- return $this->view->fetch();
- }
- function setting()
- {
- $user = db('user')->where(['id' => $this->auth->id])->find();
- $this->view->assign('user', $user);
- return $this->fetch();
- }
- /**
- * 联系我们
- * @return mixed
- */
- function aboutus()
- {
- $config = Config::getConfigByGroup('basic');
- $about = isset($config['site_about']) ? htmlspecialchars_decode($config['site_about']['value']) : '';
- $this->view->assign('about', $about);
- return $this->fetch();
- }
- /*修改资料*/
- function updatenickname()
- {
- $user = $this->auth->getUserinfo();
- $this->view->assign("user", $user);
- return $this->view->fetch();
- }
- /* 流水 */
- function detailed()
- {
- $group = input('group');
- $this->view->assign('group', $group);
- $this->view->assign('mate_title', get_detailed_type_text($group));
- return $this->view->fetch();
- }
- function updatepwd1()
- {
- return $this->view->fetch();
- }
- function updatepwd2()
- {
- return $this->view->fetch();
- }
- function isreal()
- {
- $user = db('user')->where(['id' => $this->auth->id])->find();
- $this->view->assign("user", $user);
- return $this->view->fetch();
- }
- function profile()
- {
- $user = db('user')->where(['id' => $this->auth->id])->find();
- $this->view->assign("user", $user);
- return $this->view->fetch();
- }
- function trans()
- {
- $user = get_user_data($this->auth->id);
- $this->view->assign("user", $user);
- $this->view->assign("money_type", input('money_type'));
- return $this->view->fetch();
- }
- function transfer()
- {
- $user = get_user_data($this->auth->id);
- $this->view->assign("user", $user);
- return $this->view->fetch();
- }
- function withdraw()
- {
- $tradeConfig = Config::getConfigByGroup('trade');
- $config['withdraw_min'] = isset($tradeConfig['withdraw_min']) ? $tradeConfig['withdraw_min']['value'] : 0;
- $config['withdraw_cap'] = isset($tradeConfig['withdraw_cap']) ? $tradeConfig['withdraw_cap']['value'] : 0;
- $config['withdraw_fee'] = isset($tradeConfig['withdraw_fee']) ? $tradeConfig['withdraw_fee']['value'] : 0;
- $this->view->assign("config", $config);
- $user = get_user_data($this->auth->id);
- $user['usdt_address_text'] = $user['usdt_address'] ? substr($user['usdt_address'], 0, 4) . '***' . substr($user['usdt_address'], -4, 4) : '';
- $this->view->assign("user", $user);
- $this->view->assign("coinRate", CoinRate::getRate());
- return $this->view->fetch();
- }
- /**
- * 佣金提现
- * @return string
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- function withdraw1()
- {
- $tradeConfig = Config::getConfigByGroup('trade');
- $config['withdraw_min'] = isset($tradeConfig['withdraw_min']) ? $tradeConfig['withdraw_min']['value'] : 0;
- $config['withdraw_cap'] = isset($tradeConfig['withdraw_cap']) ? $tradeConfig['withdraw_cap']['value'] : 0;
- $config['withdraw_fee'] = isset($tradeConfig['withdraw_bonus_fee']) ? $tradeConfig['withdraw_bonus_fee']['value'] : 0;
- $this->view->assign("config", $config);
- $user = get_user_data($this->auth->id);
- $this->view->assign("user", $user);
- $this->view->assign("coinRate", CoinRate::getRate());
- return $this->view->fetch();
- }
- function withdrawdetaile()
- {
- return $this->view->fetch();
- }
- function withdrawdetaile1()
- {
- return $this->view->fetch();
- }
- function releaselog()
- {
- return $this->view->fetch();
- }
- function bonuspage()
- {
- $user = get_user_data($this->auth->id);
- if ($user['stuid'] > 0) {
- $studio = db('studio')->where(['id' => $user['stuid']])->find();
- $this->view->assign('studio', $studio);
- }
- $total = db('withdrawals')->where(['process_status' => 2, 'userid' => $user['id']])->sum('amount');
- $fensi = db('user')->where(['refereeid' => $user['id']])->count();
- //var_dump($user);
- $loginStu = db('studio')->where(['title' => $this->auth->login_studio])->find();
- $stuid = isset($loginStu['id'])? $loginStu['id'] : 0;
- $counts = [
- 'status1'=> db('trade')->where(['relevant_userid'=>$this->auth->id,'status'=>1,'stuid'=>$stuid])->count('id'),
- 'status2'=> db('trade')->where(['relevant_userid'=>$this->auth->id,'status'=>2,'stuid'=>$stuid])->count('id'),
- 'status3'=> db('trade')->where(['relevant_userid'=>$this->auth->id,'status'=>3,'issell'=>[['egt',0],['elt',2]],'stuid'=>$stuid])->count('id'),
- ];
- $this->view->assign('counts', $counts);
- $this->view->assign([
- "user" => $user,
- 'total' => $total,
- 'fensi' => $fensi,
- 'studio' => $loginStu,
- 'login_studio' => $this->auth->login_studio,
- ]);
- return $this->view->fetch();
- }
- function viewwithdraw()
- {
- return $this->view->fetch();
- }
- public function login()
- {
- if ($this->auth->id) {
- $this->redirect('shop/index/index');
- }
- if ($this->request->isPost()) {
- $account = $this->request->post('account');
- $password = $this->request->post('password');
- $keeplogin = (int)$this->request->post('keeplogin');
- $token = $this->request->post('__token__');
- $rule = [
- 'account' => 'require|length:3,50',
- 'password' => 'require|length:6,30',
- '__token__' => 'require|token',
- ];
- $msg = [
- 'account.require' => 'Account can not be empty',
- 'account.length' => 'Account must be 3 to 50 characters',
- 'password.require' => 'Password can not be empty',
- 'password.length' => 'Password must be 6 to 30 characters',
- ];
- $data = [
- 'account' => $account,
- 'password' => $password,
- '__token__' => $token,
- ];
- $validate = new Validate($rule, $msg);
- $result = $validate->check($data);
- if (!$result) {
- $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
- return false;
- }
- if ($this->auth->login($account, $password)) {
- $this->success(__('Logged in successful'), url('shop/index/index'));
- } else {
- $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
- }
- }
- //判断来源
- $referer = $this->request->server('HTTP_REFERER');
- if ((strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
- && !preg_match("/(user\/login|user\/register|user\/logout)/i", $referer)) {
- $url = $referer;
- }
- $myset = config('site');
- $this->view->assign("logoimg", $myset['web_site_logo']);
- return $this->view->fetch();
- }
- /**
- * 注册会员
- */
- public function register()
- {
- $code = input('code');
- if (empty($code)) {
- $code = '';
- }
- $this->view->assign('code', $code);
- return $this->view->fetch();
- }
- function findpwd()
- {
- return $this->view->fetch();
- }
- }
|