You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
3.2 KiB
95 lines
3.2 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author: CRMEB Team <admin@crmeb.com>
|
|
// +----------------------------------------------------------------------
|
|
declare (strict_types=1);
|
|
|
|
namespace app\services\activity\table;
|
|
|
|
use app\services\BaseServices;
|
|
use app\dao\activity\table\TableQrcodeDao;
|
|
use app\services\other\QrcodeServices;
|
|
use think\exception\ValidateException;
|
|
|
|
/**
|
|
*
|
|
* Class TableQrcodeServices
|
|
* @package app\services\activity\table
|
|
* @mixin TableQrcodeDao
|
|
*/
|
|
class TableQrcodeServices extends BaseServices
|
|
{
|
|
|
|
/**
|
|
* TableQrcodeServices constructor.
|
|
* @param TableQrcodeDao $dao
|
|
*/
|
|
public function __construct(TableQrcodeDao $dao)
|
|
{
|
|
$this->dao = $dao;
|
|
}
|
|
|
|
/**桌码列表
|
|
* @param array $where
|
|
* @param int $storeId
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function tableQrcodeyList(array $where, int $storeId)
|
|
{
|
|
[$page, $limit] = $this->getPageValue();
|
|
$where['store_id'] = $storeId;
|
|
$where['is_del'] = 0;
|
|
$list = $this->dao->getList($where, $page, $limit, ['category']);
|
|
foreach ($list as $key => &$item) {
|
|
if (!$item['qrcode']) {
|
|
$item['qrcode'] = $this->setQrcodey((int)$item['id'], (int)$item['store_id'], (int)$item['table_number']);
|
|
}
|
|
}
|
|
$count = $this->dao->count($where);
|
|
return compact('list', 'count');
|
|
}
|
|
|
|
/**生成桌码
|
|
* @param int $id
|
|
* @param int $store_id
|
|
* @param int $table_number
|
|
* @return bool|string
|
|
*/
|
|
public function setQrcodey(int $id, int $store_id, int $table_number)
|
|
{
|
|
/** @var QrcodeServices $qrcodeServices */
|
|
$qrcodeServices = app()->make(QrcodeServices::class);
|
|
$param['store_id'] = $store_id;
|
|
$param['table_number'] = $table_number;
|
|
$namePath = 'routine_table_code_' . $param['store_id'] . '_' . $param['table_number'] . '_' . $id . '.jpg';
|
|
$qrcode = $qrcodeServices->getRoutineQrcodePath($id, 0, 9, $namePath, false, $param);
|
|
$this->dao->update($id, ['qrcode' => $qrcode]);
|
|
return $qrcode;
|
|
}
|
|
|
|
/**获取桌码信息
|
|
* @param int $id
|
|
* @param array $with
|
|
* @return array
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function getQrcodeyInfo(int $id, array $with = [])
|
|
{
|
|
$Info = $this->dao->getTableCodeOne(['id' => $id, 'is_using' => 1], $with);
|
|
if (!$Info) {
|
|
throw new ValidateException('获取信息失败');
|
|
}
|
|
return $Info->toArray();
|
|
}
|
|
}
|
|
|