30 lines
751 B
PHP
30 lines
751 B
PHP
<?php
|
|
|
|
namespace app\index\service;
|
|
|
|
use app\common\model\Tickets;
|
|
|
|
|
|
class ClientTicketService
|
|
{
|
|
/* 获取客户关联工单 */
|
|
public function getClientTickets(int $clientCompanyId, bool $canViewAll = false)
|
|
{
|
|
// 普通客户仅查询所属公司的工单;唯一的汇总客户账号可查看全部。
|
|
$query = Tickets::whereIn('status', [0, 1, 2]);
|
|
if (!$canViewAll) {
|
|
$query->where('company_id', $clientCompanyId);
|
|
}
|
|
|
|
$tickets = $query->select();
|
|
|
|
$newList = [];
|
|
foreach ($tickets as $ticket) {
|
|
$ticket->visible(['id', 'website', 'datanum', 'progress', 'status']);
|
|
$newList[] = $ticket->toArray();
|
|
}
|
|
|
|
return $newList;
|
|
}
|
|
}
|