|
@@ -3,8 +3,8 @@
|
|
namespace app\admin\model;
|
|
namespace app\admin\model;
|
|
|
|
|
|
use think\Model;
|
|
use think\Model;
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+use think\Db;
|
|
|
|
+use think\Exception;
|
|
class User extends Model
|
|
class User extends Model
|
|
{
|
|
{
|
|
|
|
|
|
@@ -56,10 +56,55 @@ class User extends Model
|
|
}
|
|
}
|
|
|
|
|
|
});
|
|
});
|
|
- /*self::beforeUpdate(function ($row) {
|
|
|
|
|
|
+ self::beforeUpdate(function ($row) {
|
|
$changed = $row->getChangedData();
|
|
$changed = $row->getChangedData();
|
|
|
|
+
|
|
|
|
+ //检验 超推上级UID ,intro_uid
|
|
|
|
+ if (isset($row['intro_uid'])) {
|
|
|
|
+ if ($row['intro_uid']) {
|
|
|
|
+ if($row['invite_uid']){
|
|
|
|
+ throw new Exception('超推网上级UID 与 直推上级UID 不能共存');
|
|
|
|
+ }
|
|
|
|
+ $intro_info = Db::name('user')->where('id',$row['intro_uid'])->find();
|
|
|
|
+ if(empty($intro_info)){
|
|
|
|
+ throw new Exception('不存在的 超推网上级UID用户');
|
|
|
|
+ }
|
|
|
|
+ if($intro_info['group_id'] == 1){
|
|
|
|
+ throw new Exception('超推网上级UID用户 不能是普通用户');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //检验二级超推
|
|
|
|
+ if($row['group_id'] == 2){
|
|
|
|
+ if(!$row['agent_id']){
|
|
|
|
+ throw new Exception('二级超推必须填写 上级一级代理UID');
|
|
|
|
+ }
|
|
|
|
+ $agent_info = Db::name('user')->where('group_id',3)->where('id',$row['agent_id'])->find();
|
|
|
|
+ if(empty($agent_info)){
|
|
|
|
+ throw new Exception('不存在的 上级一级代理UID用户');
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ $row['agent_id'] = '';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //检验 直推上级UID ,invite_uid
|
|
|
|
+ if (isset($row['invite_uid'])) {
|
|
|
|
+ if ($row['invite_uid']) {
|
|
|
|
+ if($row['intro_uid']){
|
|
|
|
+ throw new Exception('超推网上级UID 与 直推上级UID 不能共存');
|
|
|
|
+ }
|
|
|
|
+ $invite_info = Db::name('user')->where('id',$row['invite_uid'])->find();
|
|
|
|
+ if(empty($invite_info)){
|
|
|
|
+ throw new Exception('不存在的 直推上级UID用户');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
//如果有修改密码
|
|
//如果有修改密码
|
|
- if (isset($changed['password'])) {
|
|
|
|
|
|
+ /*if (isset($changed['password'])) {
|
|
if ($changed['password']) {
|
|
if ($changed['password']) {
|
|
$salt = \fast\Random::alnum();
|
|
$salt = \fast\Random::alnum();
|
|
$row->password = \app\common\library\Auth::instance()->getEncryptPassword($changed['password'], $salt);
|
|
$row->password = \app\common\library\Auth::instance()->getEncryptPassword($changed['password'], $salt);
|
|
@@ -67,9 +112,9 @@ class User extends Model
|
|
} else {
|
|
} else {
|
|
unset($row->password);
|
|
unset($row->password);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
//手机去重
|
|
//手机去重
|
|
- if (isset($changed['mobile'])) {
|
|
|
|
|
|
+ /*if (isset($changed['mobile'])) {
|
|
if($changed['mobile']){
|
|
if($changed['mobile']){
|
|
$exists = db('user')->where('mobile', $changed['mobile'])->where('id', '<>', $row->id)->find();
|
|
$exists = db('user')->where('mobile', $changed['mobile'])->where('id', '<>', $row->id)->find();
|
|
if ($exists) {
|
|
if ($exists) {
|
|
@@ -78,17 +123,17 @@ class User extends Model
|
|
}else {
|
|
}else {
|
|
unset($row->mobile);
|
|
unset($row->mobile);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
//手机去重
|
|
//手机去重
|
|
- if (isset($changed['simplemobile'])) {
|
|
|
|
|
|
+ /*if (isset($changed['simplemobile'])) {
|
|
if($changed['simplemobile']){
|
|
if($changed['simplemobile']){
|
|
|
|
|
|
}else {
|
|
}else {
|
|
unset($row->simplemobile);
|
|
unset($row->simplemobile);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
});
|
|
});
|
|
- self::beforeInsert(function ($row){
|
|
|
|
|
|
+ /*self::beforeInsert(function ($row){
|
|
if (isset($row['password'])) {
|
|
if (isset($row['password'])) {
|
|
if ($row['password']) {
|
|
if ($row['password']) {
|
|
$salt = \fast\Random::alnum();
|
|
$salt = \fast\Random::alnum();
|