Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9c3f5fab
authored
Nov 17, 2022
by
宁成龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善转让和指派
parent
9b4543c1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
22 deletions
app/Admin/Actions/User/UserAssignAction.php
app/Admin/Actions/User/UserTransferAction.php
app/Admin/Forms/User/AssignUserHandle.php
app/Admin/Forms/User/TransferUserHandle.php
app/Admin/Service/AutoAssignCustomerService.php
app/Admin/Service/UserService.php
app/Admin/Actions/User/UserAssignAction.php
View file @
9c3f5fab
...
...
@@ -54,20 +54,6 @@ JS;
return
parent
::
html
();
// TODO: Change the autogenerated stub
}
// 处理请求
public
function
handle
(
Request
$request
)
{
// 获取选中的文章ID数组
$keys
=
$this
->
getKey
();
// 获取请求参数
$action
=
$request
->
get
(
'action'
);
$message
=
$action
?
'文章发布成功'
:
'文章下线成功'
;
return
$this
->
response
()
->
success
(
$message
)
->
refresh
();
}
// 设置请求参数
public
function
parameters
()
{
...
...
app/Admin/Actions/User/UserTransferAction.php
View file @
9c3f5fab
...
...
@@ -4,6 +4,7 @@ namespace App\Admin\Actions\User;
use
App\Admin\Forms\User\AssignUserHandle
;
use
App\Admin\Forms\User\TransferUserHandle
;
use
App\Models\Order
as
OrderModel
;
use
App\Models\User
;
use
Dcat\Admin\Grid\BatchAction
;
...
...
@@ -27,7 +28,7 @@ class UserTransferAction extends BatchAction
public
function
render
()
{
$form
=
Assign
UserHandle
::
make
();
$form
=
Transfer
UserHandle
::
make
();
$buttonName
=
trans
(
'user.labels.transfer'
);
return
Modal
::
make
()
->
lg
()
->
title
(
$this
->
title
)
->
body
(
$form
->
payload
([]))
->
onLoad
(
$this
->
getModalScript
())
->
button
(
'<button class="btn btn-primary">
<i class="feather icon-check-circle"></i><span class="d-none d-sm-inline" style="margin-left: 5px">'
.
$buttonName
.
'</span>
...
...
app/Admin/Forms/User/AssignUserHandle.php
View file @
9c3f5fab
...
...
@@ -2,6 +2,7 @@
namespace
App\Admin\Forms\User
;
use
App\Admin\Service\UserService
;
use
App\Models\Cms\CmsUser
;
use
App\Models\Inquiry
;
use
App\Models\User
;
...
...
@@ -24,12 +25,7 @@ class AssignUserHandle extends Form implements LazyRenderable
{
try
{
$ids
=
explode
(
","
,
$input
[
'id'
]);
// $userList = User::getListByIdArr($ids);
$cmsUser
=
CmsUser
::
getInfoByUserId
(
$input
[
'sale_id'
]);
if
(
!
$cmsUser
)
{
throw
new
\Exception
(
'销售不存在'
);
}
User
::
updateByIdArr
(
$ids
,
[
'sale_id'
=>
$input
[
'sale_id'
],
"sale_name"
=>
$cmsUser
[
'name'
]]);
UserService
::
transferUser
(
$ids
,
$input
[
'sale_id'
]);
return
$this
->
response
()
->
success
(
trans
(
'admin.update_succeeded'
))
...
...
app/Admin/Forms/User/TransferUserHandle.php
0 → 100644
View file @
9c3f5fab
<?php
namespace
App\Admin\Forms\User
;
use
App\Admin\Service\UserService
;
use
App\Models\Cms\CmsUser
;
use
App\Models\Inquiry
;
use
App\Models\User
;
use
Dcat\Admin\Contracts\LazyRenderable
;
use
Dcat\Admin\Traits\LazyWidget
;
use
Dcat\Admin\Widgets\Form
;
class
TransferUserHandle
extends
Form
implements
LazyRenderable
{
use
LazyWidget
;
/**
* Handle the form request.
*
* @param array $input
*
* @return mixed
*/
public
function
handle
(
array
$input
)
{
try
{
$ids
=
explode
(
","
,
$input
[
'id'
]);
UserService
::
transferUser
(
$ids
,
$input
[
'sale_id'
]);
return
$this
->
response
()
->
success
(
trans
(
'admin.update_succeeded'
))
->
refresh
();
}
catch
(
\Throwable
$throwable
)
{
// var_dump((string)$throwable);
return
$this
->
response
()
->
error
(
trans
(
'admin.update_failed'
));
}
}
/**
* Build a form here.
*/
public
function
form
()
{
$this
->
disableResetButton
();
$this
->
hidden
(
'id'
)
->
attribute
(
'id'
,
'id'
);
$this
->
select
(
'sale_id'
)
->
options
(
CmsUser
::
pluck
(
'name'
,
'userId'
)
->
toArray
())
->
default
(
0
)
->
required
();
}
/**
* The data of the form.
*
* @return array
*/
public
function
default
()
{
return
[
];
}
}
app/Admin/Service/AutoAssignCustomerService.php
View file @
9c3f5fab
...
...
@@ -73,7 +73,6 @@ class AutoAssignCustomerService
$updateData
=
[
'max_num'
=>
count
(
$userList
),
];
var_dump
(
$updateData
);
\App\Models\AutoAssignCustomer
::
updateById
(
$assign
[
'id'
],
$updateData
);
}
}
...
...
app/Admin/Service/UserService.php
View file @
9c3f5fab
...
...
@@ -161,4 +161,30 @@ class UserService
throw
$throwable
;
}
}
public
static
function
transferUser
(
$ids
,
$saleId
)
{
try
{
DB
::
beginTransaction
();
$saleInfo
=
CmsUser
::
getInfoByUserId
(
$saleId
);
if
(
empty
(
$saleInfo
))
{
throw
new
\Exception
(
"saleId is not exist"
);
}
//更新客户的数据
$userList
=
User
::
getListByIdArr
(
$ids
);
$userIds
=
array_column
(
$userList
,
"id"
);
$update
=
[
"sale_id"
=>
$saleId
,
"sale_name"
=>
$saleInfo
[
"name"
],
];
User
::
updateByIdArr
(
$userIds
,
$update
);
DB
::
commit
();
}
catch
(
\Throwable
$throwable
)
{
DB
::
rollBack
();
throw
$throwable
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment