diff --git a/.gitignore b/.gitignore index 53103da..dc35079 100755 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ #/thinkphp/ #/vendor/ /runtime/* -#/addons/* #/public/assets/libs/ #/public/assets/addons/* /public/uploads/* diff --git a/addons/shopro/controller/Index.php b/addons/shopro/controller/Index.php index 7d30ed2..cc9008f 100755 --- a/addons/shopro/controller/Index.php +++ b/addons/shopro/controller/Index.php @@ -11,6 +11,7 @@ use app\admin\model\shopro\decorate\Page; use app\common\library\Sms as Smslib; use app\admin\model\shopro\user\User as UserModel; use addons\shopro\facade\Wechat; +use fast\Random; use think\captcha\Captcha; use think\Hook; @@ -179,8 +180,8 @@ class Index extends Common // $wechatUser = $wechatService->service->login(); // $oauthInfo = $wechatService->createOrUpdateOauthInfo($wechatUser); // $wechatService->registerOrBindUser($oauthInfo, 0, ['mobile' => $mobile ?? '']); - $userAuth = new UserAuth(); - $auth = $userAuth->register(['mobile' => $mobile]); +// $auth = (new UserAuth())->register(['mobile' => $mobile]); +// $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []); // set_token_in_header($auth->getToken()); // set_token_in_header($auth->getToken()); // $this->error(__('手机号未注册')) diff --git a/addons/shopro/controller/user/User.php b/addons/shopro/controller/user/User.php index 0b62964..30626da 100755 --- a/addons/shopro/controller/user/User.php +++ b/addons/shopro/controller/user/User.php @@ -2,6 +2,7 @@ namespace addons\shopro\controller\user; +use app\admin\model\shopro\commission\Agent as AgentModel; use app\common\library\Sms; use addons\shopro\controller\Common; 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\Aftersale as AftersaleModel; use app\admin\model\shopro\ThirdOauth; +use fast\Random; class User extends Common { @@ -141,23 +143,36 @@ class User extends Common // $this->error(__('Captcha is incorrect')); // } $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->status != 'normal') { $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)) { - $user->parent_user_id = $parent_user_id; - $user->save(); - } + if (!empty($parent_user_id) && empty($user->parent_user_id)) { + $user->parent_user_id = $parent_user_id; + $user->save(); } + //如果已经有账号则直接登录 $ret = $this->auth->direct($user->id); }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) { Sms::flush($params['mobile'], 'mobilelogin'); diff --git a/application/admin/controller/ScoreLog.php b/application/admin/controller/ScoreLog.php index d19626f..53b6580 100755 --- a/application/admin/controller/ScoreLog.php +++ b/application/admin/controller/ScoreLog.php @@ -56,7 +56,7 @@ class ScoreLog extends Backend } [$where, $sort, $order, $offset, $limit] = $this->buildparams(); $walletLogs = WalletLogModel::where($where) - ->with(['user.agent.levelInfo']) + ->with(['user.agent.levelInfo','user']) ->score() ->order($sort, $order) ->paginate($limit);