|
|
@ -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'])) { |
|
|
|
if (!empty($parent_user_id) && empty($user->parent_user_id)) { |
|
|
|
$parent_user_id = UserModel::where('user_code', $params['user_code'])->value('id'); |
|
|
|
$user->parent_user_id = $parent_user_id; |
|
|
|
if (!empty($parent_user_id) && empty($user->parent_user_id)) { |
|
|
|
$user->save(); |
|
|
|
$user->parent_user_id = $parent_user_id; |
|
|
|
|
|
|
|
$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'); |
|
|
|