{{wikiTitle}}
小票打印
目录:
目前已有易联云WIFI打印机扩展
扩展入口文件
文件目录 crmeb\services\printer\Printer.php
namespace crmeb\services\printer;
use crmeb\basic\BaseManager;
use think\facade\Config;
use think\Container;
/**
* Class Printer
* @package crmeb\services\auth
* @mixin \crmeb\services\printer\storage\YiLianYun
*/
class Printer extends BaseManager
{
//...
}
使用打印扩展
use crmeb\services\printer\Printer;
$printer = new Printer([
'clientId'=>'',
'apiKey'=>'',
'partner'=>' ',
'terminal'=>'',
]);
$res = $printer->setPrinterContent([
'name'=> '标题',
'orderInfo'=> [],//订单信息
'product'=> [],//商品信息
])->startPrinter();
var_dump($res);
举例增加:小鹅通打印扩展
创建文件:crmeb\services\printer\storage\XiaoETong.php
namespace crmeb\services\printer\storage;
class XiaoETong extends BasePrinter
{
//初始化
protected function initialize(array $config)
{
}
//开始打印
public function startPrinter()
{
}
//设置打印内容
public function setPrinterContent(array $config): self
{
return $this;
}
}
增加小鹅通获取AccessToken
namespace crmeb\services\printer;
class AccessToken extends HttpService
{
/**
* 获取token
* @return mixed|null|string
* @throws \Exception
*/
public function getAccessToken()
{
if (isset($this->accessToken[$this->name])) {
return $this->accessToken[$this->name];
}
$action = 'get' . Str::studly($this->name) . 'AccessToken';
if (method_exists($this, $action)) {
return $this->{$action}();
} else {
throw new \RuntimeException(__CLASS__ . '->' . $action . '(),Method not worn in');
}
}
//增加小鹅通获取access_token类
protected function getXiaoETongAccessToken()
{
/** @var CacheServices $cacheServices */
$cacheServices = app()->make(CacheServices::class);
$this->accessToken[$this->name] = $cacheServices->getDbCache('XET_access_token', function () {
//写获取$access_token的逻辑
//...
$access_token = '';
return $access_token;
}, 86400);
if (!$this->accessToken[$this->name])
throw new AdminException(400718);
return $this->accessToken[$this->name];
}
}
使用小鹅通打印机
use crmeb\services\printer\Printer;
$printer = new Printer('xiao_e_tong',[
'clientId'=>'',//小鹅通打印配置
'apiKey'=>'',//小鹅通打印配置
'partner'=>' ',//小鹅通打印配置
'terminal'=>'',//小鹅通打印配置
]);
$res = $printer->setPrinterContent([
'name'=> '标题',
'orderInfo'=> [],//订单信息
'product'=> [],//商品信息
])->startPrinter();
var_dump($res);
{{cateWiki.like_num}}人点赞
0人点赞
评论({{cateWiki.comment_num}})
{{commentWhere.order ? '评论从旧到新':'评论从新到旧'}}
{{cateWiki.page_view_num}}人看过该文档
评论(0)
{{commentWhere.order ? '评论从旧到新':'评论从新到旧'}}
51人看过该文档
{{item.user ? item.user.nickname : ''}} (自评)
{{item.content}}
{{item.create_time}} 删除
{{item.like ? item.like.like_num : 0}}
{{replyIndex == index ? '取消回复' : '回复'}}
搜索结果
为您找到{{wikiCount}}条结果
位置:{{path.name}} {{(i+1) == item.catalogue.path_data.length ? '':'/'}}
{{item.page_view_num}}
{{item.like ? item.like.like_num : 0}}
{{item.comment ? item.comment.comment_num : 0}}