wip
This commit is contained in:
@@ -2,11 +2,15 @@
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\admin\controller\Ticket;
|
||||
use app\common\model\Tickets;
|
||||
use app\common\model\CompanyOperators;
|
||||
use app\common\model\Companys;
|
||||
use app\common\model\User;
|
||||
use think\facade\Db;
|
||||
use app\common\service\TicketScope;
|
||||
|
||||
|
||||
|
||||
class TicketService
|
||||
{
|
||||
@@ -17,12 +21,14 @@ class TicketService
|
||||
* @param int $limit 每页数量
|
||||
* @param string $order 排序方式
|
||||
*/
|
||||
public function queryTickets(array $params, int $page, int $limit, string $order)
|
||||
public function queryTickets(array $params, int $page, int $limit, string $order, TicketScope $scope)
|
||||
{
|
||||
try {
|
||||
// 查询构造器
|
||||
$query = Tickets::with(['ticketStaff', 'ticketCompany', 'ticketOperator']);
|
||||
|
||||
$this->applyScope($query, $scope);
|
||||
|
||||
$equalFilters = ['operator_id', 'user_id', 'status'];
|
||||
foreach ($equalFilters as $field) {
|
||||
if (isset($params[$field]) && $params[$field] !== '') {
|
||||
@@ -56,6 +62,21 @@ class TicketService
|
||||
}
|
||||
|
||||
|
||||
private function applyScope($query, TicketScope $scope): void
|
||||
{
|
||||
match ($scope->type) {
|
||||
'admin' => null,
|
||||
'staff' => $query->where(fn($q) => $q
|
||||
->where('status', Tickets::STATUS_UNASSIGNED)
|
||||
->where('user_id', $scope->staffId)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建工单业务逻辑
|
||||
* @param array $data 工单数据
|
||||
|
||||
Reference in New Issue
Block a user