Commit afe33c71 by 杨树贤

用户修改sn

parent f1cc3fbb
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Http\Services\UserService;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class HomeController extends Controller class HomeController extends Controller
......
...@@ -9,12 +9,10 @@ use Illuminate\Support\Facades\Redis; ...@@ -9,12 +9,10 @@ use Illuminate\Support\Facades\Redis;
class UserService class UserService
{ {
public static function generateSn() public static function generateSn($userId)
{ {
$maxInquiryId = UserModel::orderBy('id', 'desc')->value('id'); $id = str_pad($userId, 6, 0, STR_PAD_LEFT);
$id = str_pad(($maxInquiryId + 1), 6, 0, STR_PAD_LEFT); return 'SU' . $id;
$time = Carbon::now()->addMonths(-9)->addDays(-10)->timestamp;
return date('Ymd',$time) . $id;
} }
} }
...@@ -43,17 +43,20 @@ class UserModel extends Authenticatable implements MustVerifyEmail ...@@ -43,17 +43,20 @@ class UserModel extends Authenticatable implements MustVerifyEmail
public static function createUser($data) public static function createUser($data)
{ {
return UserModel::insertGetId([ $userId = UserModel::insertGetId([
'first_name' => $data['first_name'], 'first_name' => $data['first_name'],
'last_name' => $data['last_name'], 'last_name' => $data['last_name'],
'email' => $data['email'], 'email' => $data['email'],
'phone' => $data['phone'], 'phone' => $data['phone'],
'email_verified_at' => now(), 'email_verified_at' => now(),
'company_name' => $data['company_name'], 'company_name' => $data['company_name'],
'user_sn' => UserService::generateSn(),
'account_properties' => $data['account_properties'], 'account_properties' => $data['account_properties'],
'password' => Hash::make($data['password']), 'password' => Hash::make($data['password']),
]); ]);
$userSn = UserService::generateSn($userId);
return self::where('id', $userId)->update([
'user_sn' => $userSn,
]);
} }
//获取用户详情 //获取用户详情
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment