Index.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. namespace app\active\controller;
  3. use app\core\model\Channel;
  4. use app\core\model\HongbaoPlan;
  5. use app\core\model\Introduce;
  6. use app\core\model\User;
  7. use app\core\model\UserAccount;
  8. use app\core\service\SMS;
  9. use app\core\service\Tongbu;
  10. use think\Controller;
  11. use think\Request;
  12. use tool\Common;
  13. class Index extends Controller
  14. {
  15. public function updateApp() {
  16. return view(__FUNCTION__, ['resourcePath'=>'/static/'.request()->path()]);
  17. }
  18. public function xinshou() {
  19. return view(__FUNCTION__, ['resourcePath'=>'/static/'.request()->path()]);
  20. }
  21. public function register() {
  22. if(request()->isPost()) {
  23. $param = request()->param();
  24. $package = (new SMS())->checkVerificationCode($param['mobile'], $param['mobileCode']);
  25. if($package['code'] != 1) {
  26. return $package;
  27. }
  28. $model = User::get([
  29. 'mobile'=>$param['mobile']
  30. ]);
  31. if($model) {
  32. return Common::rm(-3, '该手机号码已经被注册');
  33. }
  34. if($param['password'] != $param['passwordRe']) {
  35. return Common::rm(-4, '密码不一致');
  36. }
  37. //channel
  38. $channel = Channel::get([
  39. 'code'=>$param['channel']
  40. ]);
  41. //introduce
  42. $introduceUser = null;
  43. if(isset($param['introduce']) && $param['introduce']) {
  44. $introduceUser = User::get([
  45. 'uuid'=>$param['introduce']
  46. ]);
  47. if($introduceUser) {
  48. $introduceUserAccount = $introduceUser->userAccount['introduceCount'];
  49. $introduceUserAccount['introduceCount'] = $introduceUserAccount['introduceCount'] + 1;
  50. $introduceUserAccount->allowField(['introduceCount'])->save();
  51. }
  52. }
  53. //新用户
  54. $model = new User();
  55. $model['uuid'] = Common::token_create(32);
  56. $model['password'] = $model->createPassword($param['password']);
  57. $model['mobile'] = $param['mobile'];
  58. $model['channelID'] = isset($channel['channelID']) ? $channel['channelID'] : 0;
  59. $model['deviceID'] = '';
  60. $model['osV'] = '';
  61. $model['osType'] = $param['osType'];
  62. $model['loginOsType'] = $param['osType'];
  63. $model['apiV'] = '';
  64. $model['appV'] = '';
  65. $model['ip'] = request()->ip();
  66. $model['isNewInvest'] = 1;//为首投用户
  67. $model['loginTime'] = THINK_START_TIME;
  68. $model['introduce'] = $introduceUser ? $introduceUser['userID'] : 0;
  69. $model->save();
  70. //账户
  71. $userAccount = new UserAccount();
  72. $userAccount['userID'] = $model['userID'];
  73. $userAccount->save();
  74. //新手红包
  75. (new HongbaoPlan())->sendUserOnRegister($model);
  76. //开始建立关系
  77. /*//开始登录
  78. $token = '';
  79. //移动app登录
  80. if($this->data['osType'] == 1 || $this->data['osType'] == 2) {
  81. $model['token'] = $model->createToken();
  82. $model['tokenOverTime'] = $model->createTokenOverTime();
  83. $token = $model['token'];
  84. }
  85. //pc登录
  86. else if($this->data['osType'] == 3){
  87. $model['tokenPc'] = $model->createToken();
  88. $model['tokenOverTimePc'] = $model->createTokenOverTime();
  89. $token = $model['tokenPc'];
  90. }
  91. //app登录
  92. else if($this->data['osType'] == 4){
  93. $model['tokenWap'] = $model->createToken();
  94. $model['tokenOverTimeWap'] = $model->createTokenOverTime();
  95. $token = $model['tokenWap'];
  96. }
  97. $model->save();
  98. $this->user = $model;*/
  99. //********************************** 同步,后期删掉就好了 *************************
  100. (new Tongbu())->DY_user($param['mobile']);
  101. //********************************** end *************************
  102. return json(Common::rm(1, '操作成功'));
  103. }
  104. $os = request()->param('os');
  105. $path = '/static/'.request()->path().'PC';
  106. $view = __FUNCTION__.'PC';
  107. if(!$os) {
  108. $path = '/static/'.request()->path();
  109. $view = __FUNCTION__;
  110. }
  111. return view($view, [
  112. 'resourcePath'=>$path,
  113. 'channel'=>request()->param('channel'),
  114. 'introduce'=>request()->param('introduce')
  115. ]);
  116. }
  117. public function registerSendMobileCode() {
  118. $param = Request::instance()->param();
  119. if(strlen($param['mobile']) != 11) {
  120. return json(Common::rm(-2, '手机号码不正确'));
  121. }
  122. $model = User::get([
  123. 'mobile'=>$param['mobile']
  124. ]);
  125. if($model) {
  126. return json(Common::rm(-3, '该手机号码已经被注册'));
  127. }
  128. return json((new SMS())->sendVerificationCode($param['mobile']));
  129. }
  130. public function regAgreement() {
  131. exit;
  132. }
  133. }