工单分类

This commit is contained in:
2025-07-04 13:45:50 +08:00
parent 2be25889ea
commit 3be2ae983c
28 changed files with 900 additions and 8 deletions
+85
View File
@@ -0,0 +1,85 @@
<?php
namespace app\ticket\service;
use app\queue\translation\service\TranslationService;
use app\queue\utils\Translat;
use app\ticket\logic\CategorieLogic;
use support\Db;
use support\exception\BusinessException;
class CategorieService
{
public function list($params)
{
$result = (new CategorieLogic())->list($params);
foreach ($result as $key => &$value) {
$value['name'] = isset($item['translation']) ? $item['translation']['name'] : '';
unset($value['translation']);
}
unset($value);
return $result;
}
public function getAll($params)
{
$result = (new CategorieLogic())->getAll($params);
foreach ($result as $key => &$value) {
$value['name'] =isset($item['translation']) ? $item['translation']['name'] : '';
unset($value['translation']);
}
unset($value);
return $result;
}
public $translatFields = ['name'];
public function add(array $data)
{
try {
Db::beginTransaction();
$sourceLocale = locale();
$traitsourceFields = Translat::extractSourceFields($data, $this->translatFields);
$result = (new CategorieLogic())->add($data);
(new TranslationService())->queueTranslations(
'ticket_categorie',
$result->id,
$sourceLocale,
$traitsourceFields
);
Db::commit();
return $result;
} catch (\Throwable $e) {
Db::rollback();
throw $e;
}
}
public function edit(array $data)
{
try {
Db::beginTransaction();
$sourceLocale = locale();
$traitsourceFields = Translat::extractSourceFields($data, $this->translatFields);
$result = (new CategorieLogic())->edit($data);
(new TranslationService())->queueTranslations(
'ticket_categorie',
$data['id'],
$sourceLocale,
$traitsourceFields
);
Db::commit();
return $result;
} catch (\Throwable $e) {
Db::rollback();
throw $e;
}
}
}
+2 -3
View File
@@ -11,8 +11,8 @@ class ConversationService
{
public function list($params)
{
// $locale = locale();
$locale = 'zh';
$locale = locale();
// $locale = 'zh';
$ticket_status = $locale == 'zh'? Constants::TICKET_STATUS_ZH:Constants::TICKET_STATUS_EN;
// $ticket_status = Constants::TICKET_STATUS_ZH;
// $params['locale'] = locale();
@@ -30,7 +30,6 @@ class ConversationService
try {
return (new ConversationLogic())->add($data);
} catch (\Throwable $e) {
Db::rollback();
throw $e;
}
}
+1 -1
View File
@@ -65,7 +65,7 @@ class TicketService
throw new BusinessException('工单不存在');
}
if($data['status'] == $ticket->status){
throw new BusinessException('状态未修改');
throw new BusinessException(trans('status_not_modified'));
}
// if(!in_array($ticket->status, [Constants::TICKET_STATUS['PENDING'], Constants::TICKET_STATUS['CONFIRM']])