User.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <?php
  2. namespace app\shop\controller;
  3. use app\common\controller\Frontend;
  4. use app\common\library\CoinRate;
  5. use app\common\model\Config;
  6. class User extends Frontend{
  7. protected $noNeedLogin = ['findpwd','register','login'];
  8. protected $noNeedRight = '*';
  9. protected $layout = '';
  10. public function _initialize()
  11. {
  12. parent::_initialize();
  13. }
  14. function index()
  15. {
  16. $info = db('user')->where(['id' => $this->auth->id])->find();
  17. $this->view->assign([
  18. "user" => $info,
  19. ]);
  20. return $this->fetch();
  21. }
  22. function myhost()
  23. {
  24. $studio=db('studio')->where(['id'=>$this->auth->stuid])->find();
  25. $total1=db('goods')->where(['stuid'=>$studio['id'],'on_sale'=>1,'on_resale'=>2])->count();
  26. $total2=db('trade')->where(['status'=>0,'stuid'=>$studio['id']])->count();
  27. $this->view->assign([
  28. "studio" => $studio,
  29. "total1"=>$total1,
  30. "total2"=>$total2,
  31. ]);
  32. return $this->fetch();
  33. }
  34. function safecenter()
  35. {
  36. return $this->fetch();
  37. }
  38. function xieyi()
  39. {
  40. $list=db('article')->where(['catid'=>5])->select();
  41. $this->view->assign([
  42. "list" => $list,
  43. ]);
  44. return $this->fetch();
  45. }
  46. /**
  47. * 注销登录
  48. */
  49. public function logout()
  50. {
  51. //注销本站
  52. $this->auth->logout();
  53. $this->redirect("/index/user/login");
  54. }
  55. function userteam()
  56. {
  57. $user=db('user')->where(['id'=>$this->auth->id])->find();
  58. $total=db('user')->where(['refereeids'=>['like','%,'.$this->auth->id.',%']])->count();
  59. $total=db('user')->where(['refereeids'=>['like','%,'.$this->auth->id.',%'],'isuser'=>1])->count();
  60. $today_cnt=db('user')->where(['refereeids'=>['like','%,'.$this->auth->id.',%'],'createtime'=>['gt',strtotime('today')]])->count();
  61. $today_upload=db('user')->where(['refereeids'=>['like','%,'.$this->auth->id.',%'],'isuser'=>1,'intime'=>['gt',strtotime('today')]])->count();
  62. $list=db('user')->where(['refereeid'=>$this->auth->id])->select();
  63. if(empty($list))
  64. {
  65. $list=[];
  66. }
  67. $this->view->assign([
  68. "list"=>$list,
  69. "total"=>$total,
  70. "total1"=>$total,
  71. "today_cnt"=>$today_cnt,
  72. 'today_upload'=>$today_upload,
  73. ]);
  74. return $this->view->fetch();
  75. }
  76. function tjpv()
  77. {
  78. $uids=db('user')->where(['refereeids'=>['like','%,'.$this->auth->id.',%']])->column('id');
  79. if($uids)
  80. {
  81. $total_nums=db('trade')->where(['status'=>['egt',3],'relevant_userid'=>['in',$uids]])->sum('nums');
  82. $total_cnt=db('trade')->where(['status'=>['egt',3],'relevant_userid'=>['in',$uids]])->count();
  83. $totalt_nums=db('trade')->where(['status'=>['egt',3],'create_time'=>strtotime('today'),'relevant_userid'=>['in',$uids]])->sum('nums');
  84. $totalt_cnt=db('trade')->where(['status'=>['egt',3],'create_time'=>strtotime('today'),'relevant_userid'=>['in',$uids]])->count();
  85. }else{
  86. $total_nums=0;
  87. $total_cnt=0;
  88. $totalt_nums=0;
  89. $totalt_cnt=0;
  90. }
  91. $this->view->assign([
  92. "total_nums"=>$total_nums,
  93. "total_cnt"=>$total_cnt,
  94. "totalt_nums"=>$totalt_nums,
  95. "totalt_cnt"=>$totalt_cnt,
  96. ]);
  97. return $this->view->fetch();
  98. }
  99. function sonteam()
  100. {
  101. $id=input('id');
  102. $list=db('user')->where(['refereeid'=>$id])->select();
  103. if(empty($list))
  104. {
  105. $list=[];
  106. }
  107. $this->view->assign([
  108. "list"=>$list,
  109. 'id'=>$id
  110. ]);
  111. return $this->view->fetch();
  112. }
  113. function bonusdetailed()
  114. {
  115. $user=db('user')->where(['id'=>$this->auth->id])->find();
  116. $zt=db('detailed_cash')->where(['userid'=>$this->auth->id,'type'=>16])->sum('money');
  117. $jt=db('detailed_cash')->where(['userid'=>$this->auth->id,'type'=>20])->sum('money');
  118. $manager=db('detailed_cash')->where(['userid'=>$this->auth->id,'type'=>['in','17,18']])->sum('money');
  119. //今日
  120. $zt1=db('detailed_cash')->where(['userid'=>$this->auth->id,'type'=>16,'create_time'=>['egt',strtotime('today')]])->sum('money');
  121. $jt1=db('detailed_cash')->where(['userid'=>$this->auth->id,'type'=>20,'create_time'=>['egt',strtotime('today')]])->sum('money');
  122. $manager1=db('detailed_cash')->where(['userid'=>$this->auth->id,'type'=>['in','17,18'],'create_time'=>['egt',strtotime('today')]])->sum('money');
  123. $this->view->assign([
  124. 'user'=> $user,
  125. 'zt'=>$zt,
  126. 'jt'=>$jt,
  127. 'manager'=>$manager,
  128. 'zt1'=>$zt1,
  129. 'jt1'=>$jt1,
  130. 'manager1'=>$manager1,
  131. ]);
  132. return $this->view->fetch();
  133. }
  134. function xieyidetail()
  135. {
  136. $id=input('id');
  137. $info=db('article')->where("id",$id)->find();
  138. $this->view->assign("info",$info);
  139. return $this->view->fetch();
  140. }
  141. function sharelink()
  142. {
  143. $user = get_user_data($this->auth->id);
  144. $tjurl = 'http://' . $_SERVER['HTTP_HOST'] . '/index.php/index/user/register?code=' . $user['username'];
  145. $img_url = 'http://' . $_SERVER['HTTP_HOST'] . '/getqrcode.php?t=' . $tjurl;
  146. $save_path = 'uploads/tj/';
  147. put_file_from_url_content($img_url, $user['id'] . ".png", $save_path);
  148. $this->assign("imgurl", 'http://' . $_SERVER['HTTP_HOST'] . '/uploads/tj/' . $user['id'] . '.png');
  149. $myset= \app\common\model\Config::getConfigByGroup('Iindex');
  150. $this->view->assign("shareBg",$myset['share_bg']['value']);
  151. $this->view->assign("tjurl", $tjurl);
  152. $this->view->assign("user", $user);
  153. return $this->view->fetch();
  154. }
  155. /**
  156. * 推广素材
  157. * @return string
  158. * @throws \think\Exception
  159. * @throws \think\db\exception\DataNotFoundException
  160. * @throws \think\db\exception\ModelNotFoundException
  161. * @throws \think\exception\DbException
  162. */
  163. function material(){
  164. $lists=db('material')->where(['status'=>1])
  165. ->order('create_time desc,id desc')
  166. ->limit(100)
  167. ->select();
  168. if($lists){
  169. foreach ($lists as &$item){
  170. $item['images'] = $item['images']? explode(',', $item['images']) : [];
  171. }
  172. }
  173. $this->view->assign("lists", $lists);
  174. return $this->view->fetch();
  175. }
  176. function setting()
  177. {
  178. $user = db('user')->where(['id' => $this->auth->id])->find();
  179. $this->view->assign('user', $user);
  180. return $this->fetch();
  181. }
  182. /**
  183. * 联系我们
  184. * @return mixed
  185. */
  186. function aboutus(){
  187. return $this->fetch();
  188. }
  189. /*修改资料*/
  190. function updatenickname()
  191. {
  192. $user=$this->auth->getUserinfo();
  193. $this->view->assign("user",$user);
  194. return $this->view->fetch();
  195. }
  196. /* 流水 */
  197. function detailed()
  198. {
  199. $group = input('group');
  200. $this->view->assign('group', $group);
  201. $this->view->assign('mate_title', get_detailed_type_text($group));
  202. return $this->view->fetch();
  203. }
  204. function updatepwd1()
  205. {
  206. return $this->view->fetch();
  207. }
  208. function updatepwd2()
  209. {
  210. return $this->view->fetch();
  211. }
  212. function isreal()
  213. {
  214. $user=db('user')->where(['id'=>$this->auth->id])->find();
  215. $this->view->assign("user",$user);
  216. return $this->view->fetch();
  217. }
  218. function profile()
  219. {
  220. $user=db('user')->where(['id'=>$this->auth->id])->find();
  221. $this->view->assign("user",$user);
  222. return $this->view->fetch();
  223. }
  224. function trans()
  225. {
  226. $user=get_user_data($this->auth->id);
  227. $this->view->assign("user",$user);
  228. $this->view->assign("money_type",input('money_type'));
  229. return $this->view->fetch();
  230. }
  231. function transfer()
  232. {
  233. $user=get_user_data($this->auth->id);
  234. $this->view->assign("user",$user);
  235. return $this->view->fetch();
  236. }
  237. function withdraw()
  238. {
  239. $tradeConfig = Config::getConfigByGroup('trade');
  240. $config['withdraw_min'] = isset($tradeConfig['withdraw_min'])? $tradeConfig['withdraw_min']['value'] : 0;
  241. $config['withdraw_cap'] = isset($tradeConfig['withdraw_cap'])? $tradeConfig['withdraw_cap']['value'] : 0;
  242. $config['withdraw_fee'] = isset($tradeConfig['withdraw_fee'])? $tradeConfig['withdraw_fee']['value'] : 0;
  243. $this->view->assign("config",$config);
  244. $user=get_user_data($this->auth->id);
  245. $user['usdt_address_text'] = $user['usdt_address']? substr($user['usdt_address'],0,4).'***'.substr($user['usdt_address'],-4,4) : '';
  246. $this->view->assign("user",$user);
  247. $this->view->assign("coinRate",CoinRate::getRate());
  248. return $this->view->fetch();
  249. }
  250. /**
  251. * 佣金提现
  252. * @return string
  253. * @throws \think\Exception
  254. * @throws \think\db\exception\DataNotFoundException
  255. * @throws \think\db\exception\ModelNotFoundException
  256. * @throws \think\exception\DbException
  257. */
  258. function withdraw1()
  259. {
  260. $tradeConfig = Config::getConfigByGroup('trade');
  261. $config['withdraw_min'] = isset($tradeConfig['withdraw_min'])? $tradeConfig['withdraw_min']['value'] : 0;
  262. $config['withdraw_cap'] = isset($tradeConfig['withdraw_cap'])? $tradeConfig['withdraw_cap']['value'] : 0;
  263. $config['withdraw_fee'] = isset($tradeConfig['withdraw_bonus_fee'])? $tradeConfig['withdraw_bonus_fee']['value'] : 0;
  264. $this->view->assign("config",$config);
  265. $user=get_user_data($this->auth->id);
  266. $this->view->assign("user",$user);
  267. $this->view->assign("coinRate",CoinRate::getRate());
  268. return $this->view->fetch();
  269. }
  270. function withdrawdetaile()
  271. {
  272. return $this->view->fetch();
  273. }
  274. function withdrawdetaile1()
  275. {
  276. return $this->view->fetch();
  277. }
  278. function releaselog()
  279. {
  280. return $this->view->fetch();
  281. }
  282. function bonuspage()
  283. {
  284. $user=get_user_data($this->auth->id);
  285. if($user['stuid']>0)
  286. {
  287. $studio=db('studio')->where(['id'=>$user['stuid']])->find();
  288. $this->view->assign('studio',$studio);
  289. }
  290. $total=db('withdrawals')->where(['process_status'=>2,'userid'=>$user['id']])->sum('amount');
  291. $fensi=db('user')->where(['refereeid'=>$user['id']])->count();
  292. //var_dump($user);
  293. $loginStu=db('studio')->where(['title'=>$this->auth->login_studio])->find();
  294. $this->view->assign([
  295. "user"=>$user,
  296. 'total'=>$total,
  297. 'fensi'=>$fensi,
  298. 'studio'=>$loginStu,
  299. 'login_studio'=> $this->auth->login_studio,
  300. ]);
  301. return $this->view->fetch();
  302. }
  303. function viewwithdraw()
  304. {
  305. return $this->view->fetch();
  306. }
  307. public function login()
  308. {
  309. if ($this->auth->id) {
  310. $this->redirect('shop/index/index');
  311. }
  312. if ($this->request->isPost()) {
  313. $account = $this->request->post('account');
  314. $password = $this->request->post('password');
  315. $keeplogin = (int)$this->request->post('keeplogin');
  316. $token = $this->request->post('__token__');
  317. $rule = [
  318. 'account' => 'require|length:3,50',
  319. 'password' => 'require|length:6,30',
  320. '__token__' => 'require|token',
  321. ];
  322. $msg = [
  323. 'account.require' => 'Account can not be empty',
  324. 'account.length' => 'Account must be 3 to 50 characters',
  325. 'password.require' => 'Password can not be empty',
  326. 'password.length' => 'Password must be 6 to 30 characters',
  327. ];
  328. $data = [
  329. 'account' => $account,
  330. 'password' => $password,
  331. '__token__' => $token,
  332. ];
  333. $validate = new Validate($rule, $msg);
  334. $result = $validate->check($data);
  335. if (!$result) {
  336. $this->error(__($validate->getError()), null, ['token' => $this->request->token()]);
  337. return false;
  338. }
  339. if ($this->auth->login($account, $password)) {
  340. $this->success(__('Logged in successful'), url('shop/index/index'));
  341. } else {
  342. $this->error($this->auth->getError(), null, ['token' => $this->request->token()]);
  343. }
  344. }
  345. //判断来源
  346. $referer = $this->request->server('HTTP_REFERER');
  347. if ((strtolower(parse_url($referer, PHP_URL_HOST)) == strtolower($this->request->host()))
  348. && !preg_match("/(user\/login|user\/register|user\/logout)/i", $referer)) {
  349. $url = $referer;
  350. }
  351. $myset=config('site');
  352. $this->view->assign("logoimg",$myset['web_site_logo']);
  353. return $this->view->fetch();
  354. }
  355. /**
  356. * 注册会员
  357. */
  358. public function register()
  359. {
  360. $code=input('code');
  361. if(empty($code))
  362. {
  363. $code='';
  364. }
  365. $this->view->assign('code',$code);
  366. return $this->view->fetch();
  367. }
  368. function findpwd()
  369. {
  370. return $this->view->fetch();
  371. }
  372. }