Commit 6b80ce3e by 宁成龙

优化客户列表

parent 773a7ca3
...@@ -114,13 +114,13 @@ class UserController extends AdminController ...@@ -114,13 +114,13 @@ class UserController extends AdminController
} }
UserService::createUserAndAddress($params); UserService::createUserAndAddress($params);
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
var_dump((string)$throwable); // var_dump((string)$throwable);
return Form::make()->response() return Form::make()->response()
->error(trans('admin.save_failed')) ->error(trans('admin.save_failed'))
->withExceptionIf($throwable->getMessage(), $throwable); ->withExceptionIf($throwable->getMessage(), $throwable);
} }
$url = admin_url("/users/list"); $url = admin_url("/users");
return Form::make()->response()->success('操作成功')->redirect($url)->refresh(); return Form::make()->response()->success(admin_trans("succeeded"))->redirect($url);
} }
......
...@@ -104,8 +104,8 @@ class UserService ...@@ -104,8 +104,8 @@ class UserService
"phone" => $params["phone"], "phone" => $params["phone"],
"email" => $params["email"], "email" => $params["email"],
"reg_source" => User::REG_SOURCE_MANUAL, "reg_source" => User::REG_SOURCE_MANUAL,
"remark" => $params["remark"], "remark" => $params["remark"] ?? "",
"password" => "1234567", "password" => "123456",
"status" => User::STATUS_NORMAL, "status" => User::STATUS_NORMAL,
"sale_id" => request()->user->userId ?? "1000", "sale_id" => request()->user->userId ?? "1000",
"sale_name" => request()->user->name ?? "admin", "sale_name" => request()->user->name ?? "admin",
...@@ -115,6 +115,9 @@ class UserService ...@@ -115,6 +115,9 @@ class UserService
$userId = User::insertData($userData); $userId = User::insertData($userData);
foreach ($params['user_address_list'] as $address) { foreach ($params['user_address_list'] as $address) {
if ($address['_remove_']) {
continue;
}
$validator = Validator::make($address, [ $validator = Validator::make($address, [
'first_name' => 'required', 'first_name' => 'required',
'last_name' => 'required', 'last_name' => 'required',
...@@ -128,7 +131,7 @@ class UserService ...@@ -128,7 +131,7 @@ class UserService
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
$error = $validator->errors()->first(); $error = $validator->errors()->first();
throw new \Exception($error); throw new \Exception("user addressList failed:" . $error);
} }
$addressData = [ $addressData = [
"user_id" => $userId, "user_id" => $userId,
......
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