12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- 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 extends BaseServices
- {
-
- public function __construct(TableQrcodeDao $dao)
- {
- $this->dao = $dao;
- }
-
- 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');
- }
-
- public function setQrcodey(int $id, int $store_id, int $table_number)
- {
-
- $qrcodeServices = app()->make(QrcodeServices::class);
- $parame['store_id'] = $store_id;
- $parame['table_number'] = $table_number;
- $qrcode = $qrcodeServices->getRoutineQrcodePath($id, 0, 9, $parame);
- $this->dao->update($id, ['qrcode' => $qrcode]);
- return $qrcode;
- }
-
- 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();
- }
- }
|