Commit ca951ee9 by 孙龙
parents 16dc8515 f66afe25
...@@ -29,7 +29,7 @@ class UserEditAction extends AbstractTool ...@@ -29,7 +29,7 @@ class UserEditAction extends AbstractTool
public function render() public function render()
{ {
$form = EditUserHandle::make(['key'=>$this->getKey()]); $form = EditUserHandle::make(['key'=>$this->getKey()]);
$buttonName = trans('user.labels.handle'); $buttonName = admin_trans('edit');
return Modal::make()->lg()->title($this->title)->body($form->payload(['key'=>$this->getKey()]))->onLoad return Modal::make()->lg()->title($this->title)->body($form->payload(['key'=>$this->getKey()]))->onLoad
($this->getModalScript())->button('<button style="margin-right: 5px" class="btn btn-sm btn-primary"> ($this->getModalScript())->button('<button style="margin-right: 5px" class="btn btn-sm btn-primary">
<i class="feather icon-check-circle"></i> <span class="d-none d-sm-inline" style="margin-left: 5px">' . <i class="feather icon-check-circle"></i> <span class="d-none d-sm-inline" style="margin-left: 5px">' .
......
...@@ -21,7 +21,7 @@ class UserDetail extends \Dcat\Admin\Support\LazyRenderable ...@@ -21,7 +21,7 @@ class UserDetail extends \Dcat\Admin\Support\LazyRenderable
return Show::make($id, new User(), function (Show $show) { return Show::make($id, new User(), function (Show $show) {
$show->panel() $show->panel()
->tools(function (Show\Tools $tools) { ->tools(function (Show\Tools $tools) {
$userEditAction = new UserEditAction("用户编辑"); $userEditAction = new UserEditAction(admin_trans("edit"));
$userEditAction->setKey($this->key); $userEditAction->setKey($this->key);
$tools->disableDelete(); $tools->disableDelete();
$tools->disableEdit(); $tools->disableEdit();
......
...@@ -51,7 +51,7 @@ class UserService ...@@ -51,7 +51,7 @@ class UserService
$grid->column('remark'); $grid->column('remark');
$grid->column('sale_name'); $grid->column('sale_name');
$grid->column('order_num_data')->display(function ($order_num_data) { $grid->column('order_num_data')->display(function ($order_num_data) {
$data = InquiryService::getInquiryCountByUserIds([$this->id])[$this->id] ?? [ $data = OrderService::getUserOrderStatistical([$this->id])[$this->id] ?? [
"pending" => 0, "pending" => 0,
"all" => 0 "all" => 0
]; ];
...@@ -68,6 +68,8 @@ class UserService ...@@ -68,6 +68,8 @@ class UserService
return $time ? date('Y-m-d H:i:s', $time) : ''; return $time ? date('Y-m-d H:i:s', $time) : '';
})->sortable();; })->sortable();;
$grid->column('status')->using(admin_trans('user.options.status')); $grid->column('status')->using(admin_trans('user.options.status'));
//客户来源
$grid->column('reg_source')->using(admin_trans('user.options.reg_source'));
} }
public static function userListTool(Grid $grid) public static function userListTool(Grid $grid)
...@@ -111,6 +113,12 @@ class UserService ...@@ -111,6 +113,12 @@ class UserService
{ {
try { try {
DB::beginTransaction(); DB::beginTransaction();
//判断邮箱是否唯一
$email = $params['email'] ?? '';
$userInfo = User::getInfoByEmail($email);
if ($userInfo) {
throw new \Exception("user email already exists");
}
$userData = [ $userData = [
"company_name" => $params["company_name"] ?? "", "company_name" => $params["company_name"] ?? "",
"user_sn" => $params["user_sn"] ?? "", "user_sn" => $params["user_sn"] ?? "",
...@@ -125,7 +133,7 @@ class UserService ...@@ -125,7 +133,7 @@ class UserService
"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",
"create_time" => time(), "create_time" => time(),
"update_time" => time(), "update_time" => time(),
]; ];
$userId = User::insertData($userData); $userId = User::insertData($userData);
...@@ -143,6 +151,7 @@ class UserService ...@@ -143,6 +151,7 @@ class UserService
'phone' => 'required', 'phone' => 'required',
'country' => 'required', 'country' => 'required',
'city' => 'required', 'city' => 'required',
'address_type' => 'required',
'post_code' => 'required', 'post_code' => 'required',
'detail_address' => 'required', 'detail_address' => 'required',
'is_default' => 'required', 'is_default' => 'required',
......
...@@ -64,6 +64,12 @@ class User extends BaseModel ...@@ -64,6 +64,12 @@ class User extends BaseModel
$res = self::where('id', $userId)->first(); $res = self::where('id', $userId)->first();
return ($res) ? $res->toArray() : []; return ($res) ? $res->toArray() : [];
} }
//根据邮箱获取用户信息
public static function getInfoByEmail($email)
{
$res = self::where('email', $email)->first();
return ($res) ? $res->toArray() : [];
}
// 批量获取用户信息 // 批量获取用户信息
public static function getInfoByUserIds($userId) public static function getInfoByUserIds($userId)
......
...@@ -67,7 +67,7 @@ return [ ...@@ -67,7 +67,7 @@ return [
| |
*/ */
'timezone' => 'UTC', 'timezone' => 'Asia/Shanghai',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
......
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