修改用户注册

main
ztt 8 months ago
parent 198faffc5c
commit 852e3588bf
  1. 1
      .gitignore
  2. 5
      addons/shopro/controller/Index.php
  3. 23
      addons/shopro/controller/user/User.php
  4. 2
      application/admin/controller/ScoreLog.php

1
.gitignore vendored

@ -2,7 +2,6 @@
#/thinkphp/ #/thinkphp/
#/vendor/ #/vendor/
/runtime/* /runtime/*
#/addons/*
#/public/assets/libs/ #/public/assets/libs/
#/public/assets/addons/* #/public/assets/addons/*
/public/uploads/* /public/uploads/*

@ -11,6 +11,7 @@ use app\admin\model\shopro\decorate\Page;
use app\common\library\Sms as Smslib; use app\common\library\Sms as Smslib;
use app\admin\model\shopro\user\User as UserModel; use app\admin\model\shopro\user\User as UserModel;
use addons\shopro\facade\Wechat; use addons\shopro\facade\Wechat;
use fast\Random;
use think\captcha\Captcha; use think\captcha\Captcha;
use think\Hook; use think\Hook;
@ -179,8 +180,8 @@ class Index extends Common
// $wechatUser = $wechatService->service->login(); // $wechatUser = $wechatService->service->login();
// $oauthInfo = $wechatService->createOrUpdateOauthInfo($wechatUser); // $oauthInfo = $wechatService->createOrUpdateOauthInfo($wechatUser);
// $wechatService->registerOrBindUser($oauthInfo, 0, ['mobile' => $mobile ?? '']); // $wechatService->registerOrBindUser($oauthInfo, 0, ['mobile' => $mobile ?? '']);
$userAuth = new UserAuth(); // $auth = (new UserAuth())->register(['mobile' => $mobile]);
$auth = $userAuth->register(['mobile' => $mobile]); // $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []);
// set_token_in_header($auth->getToken()); // set_token_in_header($auth->getToken());
// set_token_in_header($auth->getToken()); // set_token_in_header($auth->getToken());
// $this->error(__('手机号未注册')) // $this->error(__('手机号未注册'))

@ -2,6 +2,7 @@
namespace addons\shopro\controller\user; namespace addons\shopro\controller\user;
use app\admin\model\shopro\commission\Agent as AgentModel;
use app\common\library\Sms; use app\common\library\Sms;
use addons\shopro\controller\Common; use addons\shopro\controller\Common;
use addons\shopro\service\user\UserAuth; use addons\shopro\service\user\UserAuth;
@ -10,6 +11,7 @@ use app\admin\model\shopro\user\Coupon as UserCouponModel;
use app\admin\model\shopro\order\Order as OrderModel; use app\admin\model\shopro\order\Order as OrderModel;
use app\admin\model\shopro\order\Aftersale as AftersaleModel; use app\admin\model\shopro\order\Aftersale as AftersaleModel;
use app\admin\model\shopro\ThirdOauth; use app\admin\model\shopro\ThirdOauth;
use fast\Random;
class User extends Common class User extends Common
{ {
@ -141,23 +143,36 @@ class User extends Common
// $this->error(__('Captcha is incorrect')); // $this->error(__('Captcha is incorrect'));
// } // }
$user = UserModel::getByMobile($params['mobile']); $user = UserModel::getByMobile($params['mobile']);
$parent_user_id = 0;
if (!empty($params['user_code'])) {
$parent_user_id = UserModel::where('user_code', $params['user_code'])->value('id');
}
if ($user) { if ($user) {
if ($user->status != 'normal') { if ($user->status != 'normal') {
$this->error(__('Account is locked')); $this->error(__('Account is locked'));
} }
//登录注册根据注册码绑定上级 //登录注册根据注册码绑定上级
if (!empty($params['user_code'])) {
$parent_user_id = UserModel::where('user_code', $params['user_code'])->value('id');
if (!empty($parent_user_id) && empty($user->parent_user_id)) { if (!empty($parent_user_id) && empty($user->parent_user_id)) {
$user->parent_user_id = $parent_user_id; $user->parent_user_id = $parent_user_id;
$user->save(); $user->save();
} }
}
//如果已经有账号则直接登录 //如果已经有账号则直接登录
$ret = $this->auth->direct($user->id); $ret = $this->auth->direct($user->id);
}else { }else {
$this->error('该手机号暂未注册'); $ret = $this->auth->register($params['mobile'], Random::alnum(), '', $params['mobile'], ['parent_user_id'=>$parent_user_id]);
$user = $this->auth->getUserinfo();
//写入分销表
AgentModel::create([
'user_id' => $user['id'],
'level' => 1, // 默认分销商等级
'status' => 'normal',
'apply_info' => [],
'apply_num' => 1,
'become_time' => time()
]);
// $this->error('该手机号暂未注册');
} }
if (isset($ret) && $ret) { if (isset($ret) && $ret) {
Sms::flush($params['mobile'], 'mobilelogin'); Sms::flush($params['mobile'], 'mobilelogin');

@ -56,7 +56,7 @@ class ScoreLog extends Backend
} }
[$where, $sort, $order, $offset, $limit] = $this->buildparams(); [$where, $sort, $order, $offset, $limit] = $this->buildparams();
$walletLogs = WalletLogModel::where($where) $walletLogs = WalletLogModel::where($where)
->with(['user.agent.levelInfo']) ->with(['user.agent.levelInfo','user'])
->score() ->score()
->order($sort, $order) ->order($sort, $order)
->paginate($limit); ->paginate($limit);

Loading…
Cancel
Save