feat : catering

This commit is contained in:
2025-03-13 15:08:26 +08:00
parent d461790c2f
commit 3aa241350c
10 changed files with 530 additions and 11 deletions

View File

@@ -10,17 +10,71 @@ declare(strict_types=1);
namespace App\Service\Admin\Catering\Option;
use App\Service\Admin\BaseService;
use App\Cache\Redis\Admin\PrinterCache;
use App\Constants\Admin\CateringCode;
use App\Exception\ErrException;
use App\Model\OrderOptionCateringLog;
use App\Service\Admin\Catering\CateringBaseService;
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class PrintService extends BaseService
class PrintService extends CateringBaseService
{
public function handle()
{
/**
* @var PrinterCache
*/
#[Inject]
protected PrinterCache $printerCache;
/**
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function handle(): array
{
$type = (int)$this->request->input('type');
$res = match ($type) {
CateringCode::OPTION_PRINT_YLY => $this->printerCache->getYlyPrinter(),
CateringCode::OPTION_PRINT_CODING => $this->printerCache->getOtherPrinter(),
default => throw new ErrException('参数错误')
};
return $this->return->success('success', ['list' => $res]);
}
public function check()
{
use PrintTrait;
/**
* @var OrderOptionCateringLog
*/
#[Inject]
protected OrderOptionCateringLog $orderOptionCateringLogModel;
/**
* @var OrderOptionCateringLog
*/
protected OrderOptionCateringLog $logInfo;
/**
* @return array
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function checkPrint(): array
{
$id = (int)$this->request->input('id');
// 获取数据源
$this->logInfo = $this->orderOptionCateringLogModel->find($id);
if (empty($this->logInfo)) throw new ErrException('配餐记录不存在');
$this->__initRedisKey();
$res = $this->checkIsPrint();
return $this->return->success('success', ['status' => $res]);
}
}