| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * @link:http://www.gdqijianshi.com/
- * @copyright: Copyright (c) 2020 广东七件事集团
- * Created by PhpStorm
- * Author: zal
- * Date: 2020-04-01
- * Time: 21:49
- */
- namespace common\helpers\printer\config;
- class KdtConfig extends BaseConfig
- {
- public $name; // 打印机编号
- public $key; // 打印机密钥
- public $time; // 打印联数
- private $url = "http://open.printcenter.cn:8080/addOrder";
- public function print($content)
- {
- date_default_timezone_set("Asia/Shanghai");
- header("Content-Type: text/html;charset=utf-8");
- $selfMessage = array(
- 'deviceNo' => $this->name,
- 'printContent' => $content,
- 'key' => $this->key,
- 'times' => $this->time
- );
- $options = array(
- 'http' => array(
- 'header' => "Content-type: application/x-www-form-urlencoded ",
- 'method' => 'POST',
- 'content' => http_build_query($selfMessage),
- ),
- );
- $context = stream_context_create($options);
- $result = file_get_contents($this->url, false, $context);
- $result = json_decode($result, true);
- if ($result['responseCode'] != 0) {
- throw new \Exception($result['msg'], $result, 1);
- }
- return $result;
- }
- }
|