Browse Source

打印

master
lanzu_qsy 5 years ago
parent
commit
7f3e3dd7fe
  1. 6
      app/Admin/Controllers/ImsCjdcOrderMainController.php
  2. 35
      app/Admin/Controllers/LanzuServiceHorsemanController.php
  3. 34
      app/Admin/Extensions/OrderPrint.php
  4. 7
      app/Admin/Extensions/OrderStateHandle.php
  5. 326
      app/Libs/feier_print/api_php_demo.php
  6. 307
      app/Libs/feier_print/httpclient.php
  7. 46
      app/Libs/feier_print/飞鹅云打印说明文档.txt
  8. 14
      app/Models/ImsCjdcMarket.php
  9. 5
      app/Models/ImsCjdcOrderMain.php
  10. 2
      app/Models/LanzuServiceHorseman.php

6
app/Admin/Controllers/ImsCjdcOrderMainController.php

@ -3,6 +3,7 @@
namespace App\Admin\Controllers;
use App\Admin\Extensions\OrderDetail;
use App\Admin\Extensions\OrderPrint;
use App\Admin\Extensions\OrderStateHandle;
use App\Admin\Repositories\ImsCjdcOrderMain;
use Dcat\Admin\Admin;
@ -44,9 +45,14 @@ class ImsCjdcOrderMainController extends AdminController
$state = $actions->row->state;
if ($state==2){
$actions->append(new OrderStateHandle('接单',3));
$actions->append(new OrderPrint('打印'));
}elseif ($state==31){
$actions->append(new OrderStateHandle('完成',4));
$actions->append(new OrderPrint('打印'));
}elseif ($state==3){
$actions->append(new OrderStateHandle('站内自送',30));
}
$actions->append(new OrderDetail('详情'));
//$actions->append("<a class='btn btn-xs action-btn btn-danger grid-row-refuse' data-id='{$actions->getKey()}'><i class='fa fa-close' title='拒绝退款'>拒绝</i></a>&nbsp;&nbsp;");

35
app/Admin/Controllers/LanzuServiceHorsemanController.php

@ -22,10 +22,14 @@ class LanzuServiceHorsemanController extends AdminController
$grid->id->sortable();
$grid->name;
$grid->tel;
$grid->market_id('所属市场');
$grid->status('状态');
$grid->head_url;
$grid->created_at;
$grid->market_id('所属市场')->display(function (){
return ImsCjdcMarket::find($this->market_id)->name;
});
$grid->status('状态')->using([1=>'正常',-1=>'禁用']);
$grid->head_url->image('',50,50);
$grid->created_at->display(function ($time){
return date('Y-m-d H:i',$time);
});
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id');
@ -44,15 +48,20 @@ class LanzuServiceHorsemanController extends AdminController
{
return Show::make($id, new LanzuServiceHorseman(), function (Show $show) {
$show->id;
$show->user_id;
$show->user_id('懒ID');
$show->name;
$show->tel;
$show->market_id;
$show->status;
$show->qr_url;
$show->head_url;
$show->created_at;
$show->updated_at;
$show->market_id('所属市场')->as(function (){
return ImsCjdcMarket::find($this->market_id)->name;
});
$show->status('状态')->using([1=>'正常',-1=>'禁用']);
$show->head_url->image();
$show->created_at->as(function ($time){
return date('Y-m-d H:i',$time);
});
$show->updated_at->as(function ($time){
return date('Y-m-d H:i',$time);
});
});
}
@ -68,9 +77,9 @@ class LanzuServiceHorsemanController extends AdminController
$form->text('user_id','懒ID')->required();
$form->text('name')->required();
$form->mobile('tel')->required();
$form->text('market_id','所属市场')->options(ImsCjdcMarket::getMarket())->required();
$form->select('market_id','所属市场')->options(ImsCjdcMarket::getMarket())->required();
$form->radio('status','状态')->options([1=>'启用',-1=>'禁用'])->value(1)->required();
$form->image('head_url')->uniqueName();
$form->image('head_url')->uniqueName()->required();
$form->display('created_at');
$form->display('updated_at');

34
app/Admin/Extensions/OrderPrint.php

@ -0,0 +1,34 @@
<?php
namespace App\Admin\Extensions;
use Dcat\Admin\Grid\RowAction;
use Illuminate\Http\Request;
class OrderPrint extends RowAction
{
protected $title;
public function __construct($title=null)
{
parent::__construct($title);
}
public function handle(Request $request)
{
$id = $this->getKey();
dd($id);
}
/**
* 设置要POST到接口的数据
*
* @return array
*/
public function parameters()
{
}
}

7
app/Admin/Extensions/OrderStateHandle.php

@ -33,7 +33,14 @@ class OrderStateHandle extends RowAction
$id = $this->getKey();
$orderMain = new ImsCjdcOrderMain();
$state = $request->get('state');
if ($state==30){
$res = $orderMain->updateShippingType($id,1);
}elseif ($state==100){
}else{
$res = $orderMain->modifyState($id,$state);
}
if ($res==true){
return $this->response()->success('操作成功')->refresh();
}else{

326
app/Libs/feier_print/api_php_demo.php

@ -0,0 +1,326 @@
<?php
use think\Db;
header("Content-type: text/html; charset=utf-8");
include 'httpclient.php';
define('USER', '13161443713@163.com'); //*必填*:飞鹅云后台注册账号
define('UKEY', 'XsaHzgePdyWTfcMX'); //*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】
define('SN', '550510805'); //*必填*:打印机编号,必须要在管理后台里添加打印机或调用API接口添加之后,才能调用API
//以下参数不需要修改
define('IP', 'api.feieyun.cn'); //接口IP或域名
define('PORT', 80); //接口IP端口
define('PATH', '/Api/Open/'); //接口路径
//拼凑订单内容时可参考如下格式
//根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
$content = '<CB>测试打印</CB><BR>';
$content .= '名称      单价 数量 金额<BR>';
$content .= '--------------------------------<BR>';
$content .= '饭       10.0 10 100.0<BR>';
$content .= '炒饭      10.0 10 100.0<BR>';
$content .= '蛋炒饭     10.0 10 100.0<BR>';
$content .= '鸡蛋炒饭    10.0 10 100.0<BR>';
$content .= '西红柿炒饭   10.0 10 100.0<BR>';
$content .= '西红柿蛋炒饭  10.0 10 100.0<BR>';
$content .= '西红柿鸡蛋炒饭 10.0 10 100.0<BR>';
$content .= '--------------------------------<BR>';
$content .= '备注:加辣<BR>';
$content .= '合计:xx.0元<BR>';
$content .= '送货地点:广西南宁五象新区<BR>';
$content .= '联系电话:13888888888888<BR>';
$content .= '订餐时间:2014-08-08 08:08:08<BR>';
$content .= '<QR>http://www.feieyun.com</QR>';//把二维码字符串用标签套上即可自动生成二维码
//标签说明:
$content = "<DIRECTION>1</DIRECTION>";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸,
$content .= "<TEXT x='9' y='10' font='12' w='1' h='2' r='0'>#001 五号桌 1/3</TEXT><TEXT x='80' y='80' font='12' w='2' h='2' r='0'>可乐鸡翅</TEXT><TEXT x='9' y='180' font='12' w='1' h='1' r='0'>张三先生 13800138000</TEXT>";//40mm宽度标签纸打印例子,打开注释调用标签打印接口打印
/**
* [打印订单接口 Open_printMsg]
* @param [string] $sn [打印机编号sn]
* @param [string] $content [打印内容]
* @param [string] $times [打印联数]
* @return [string] [接口返回值]
*/
function printMsg($sn, $content, $times = 1)
{
$time = time(); //请求时间
$msgInfo = array(
'user' => USER,
'stime' => $time,
'sig' => signature($time),
'apiname' => 'Open_printMsg',
'sn' => $sn,
'content' => $content,
'times' => $times//打印次数
);
$client = new HttpClient(IP, PORT);
if (!$client->post(PATH, $msgInfo)) {
echo 'error';
} else {
//服务器返回的JSON字符串,建议要当做日志记录起来
$result = $client->getContent();
return $result;
}
}
/**
* [批量添加打印机接口 Open_printerAddlist]
* @param [string] $printerContent [打印机的sn#key]
* @return [string] [接口返回值]
*/
function printerAddlist($printerContent)
{
$time = time(); //请求时间
$msgInfo = array(
'user' => USER,
'stime' => $time,
'sig' => signature($time),
'apiname' => 'Open_printerAddlist',
'printerContent' => $printerContent
);
$client = new HttpClient(IP, PORT);
if (!$client->post(PATH, $msgInfo)) {
echo 'error';
} else {
$result = $client->getContent();
return $result;
}
}
/**
* [批量删除打印机 Open_printerDelList]
* @param [string] $snlist [打印机编号,多台打印机请用减号“-”连接起来]
* @return [string] [接口返回值]
*/
function printerDelList($snlist)
{
$time = time(); //请求时间
$msgInfo = array(
'user' => USER,
'stime' => $time,
'sig' => signature($time),
'apiname' => 'Open_printerDelList',
'snlist' => $snlist
);
$client = new HttpClient(IP, PORT);
if (!$client->post(PATH, $msgInfo)) {
echo 'error';
} else {
$result = $client->getContent();
return $result;
}
}
/**
* [查询订单是否打印成功接口 Open_queryOrderState]
* @param [string] $orderid [调用打印机接口成功后,服务器返回的JSON中的编号 例如:123456789_20190919163739_95385649]
* @return [string] [接口返回值]
*/
function queryOrderState($orderid)
{
$time = time(); //请求时间
$msgInfo = array(
'user' => USER,
'stime' => $time,
'sig' => signature($time),
'apiname' => 'Open_queryOrderState',
'orderid' => $orderid
);
$client = new HttpClient(IP, PORT);
if (!$client->post(PATH, $msgInfo)) {
echo 'error';
} else {
$result = $client->getContent();
return $result;
}
}
/**
* [signature 生成签名]
* @param [string] $time [当前UNIX时间戳,10位,精确到秒]
* @return [string] [接口返回值]
*/
function signature($time)
{
return sha1(USER . UKEY . $time);//公共参数,请求公钥
}
function FeiePrint($order_num)
{
$data = Db::table('ims_cjdc_order_main')
->alias('m')
->join(['ims_cjdc_order'=>'o'],'o.order_main_id = m.id','inner')
->join(['ims_cjdc_order_goods'=>'g'],'o.id = g.order_id','inner')
->join(['ims_cjdc_feprint'=>'f'],'m.market_id = f.market_id','inner')
->join(['ims_cjdc_store'=>'s'],'s.id = o.store_id','inner')
//->distinct(true)
->where('m.order_num',$order_num)
->field("o.note as o_note,g.name,g.number,g.money,g.good_unit,m.delivery_time as ps_time,m.address,m.note,m.name as user_name,m.dada_fee,m.money as m_money,m.yhq_money2,m.box_money,f.sn,m.tel,m.order_num,g.id,g.spec,s.name as shopname")
->order('s.id')
->select();
// $order_goods = Db::table('ims_cjdc_order_goods')->where('order_id', $order_main['id'])->field("name,number,money")->select();
// $sn = Db::table('ims_cjdc_feprint')->where('market_id', $order_main['market_id'])->value("sn");
$content = PrintFormat($data, 14, 6, 3, 6);
$res = printMsg($data[0]['sn'], $content, 1);
return ($res);
}
function PrintFormat($arr, $A, $B, $C, $D)
{
$orderInfo = '<CB>懒族生活</CB><BR>';
$orderInfo .= '名称 单价 数量 金额<BR>';
$orderInfo .= '--------------------------------<BR>';
$shopname = "";
$shopnum = 0;
foreach ($arr as $k5 => $v5) {
if ($shopname != $v5['shopname']) {
if ($shopname != "") {
$orderInfo .= ' <BR>';
}
$shopnum++;
$orderInfo .= "<C>(" . $shopnum . ")" .$v5['shopname'] . '</C><BR>';
$shopname = $v5['shopname'];
}
$name = $v5['name'];
if(!empty($v5['spec'])) {
$name .= "(规格:". $v5['spec'].")";
}elseif (!empty($v5['good_unit'])){
$name .= "(规格:". $v5['good_unit'].")";
}
$price = $v5['money'];
$num = $v5['number'];
$prices = sprintf("%.2f",$v5['money']*$v5['number']);
$kw3 = '';
$kw1 = '';
$kw2 = '';
$kw4 = '';
$str = $name;
$blankNum = $A;//名称控制为14个字节
$lan = mb_strlen($str,'utf-8');
$m = 0;
$j=1;
$blankNum++;
$result = array();
if(strlen($price) < $B){
$k1 = $B - strlen($price);
for($q=0;$q<$k1;$q++){
$kw1 .= ' ';
}
$price = $kw1.$price;
}
if(strlen($num) < $C){
$k2 = $C - strlen($num);
for($q=0;$q<$k2;$q++){
$kw2 .= ' ';
}
$num = $kw2.$num;
}
if(strlen($prices) < $D){
$k3 = $D - strlen($prices);
for($q=0;$q<$k3;$q++){
$kw4 .= ' ';
}
$prices = $kw4.$prices;
}
for ($i=0;$i<$lan;$i++){
$new = mb_substr($str,$m,$j,'utf-8');
$j++;
if(mb_strwidth($new,'utf-8')<$blankNum) {
if($m+$j>$lan) {
$m = $m+$j;
$tail = $new;
$lenght = iconv("UTF-8", "GBK//IGNORE", $new);
$k = $A - strlen($lenght);
for($q=0;$q<$k;$q++){
$kw3 .= ' ';
}
if($m==$j){
$tail .= $kw3.' '.$price.' '.$num.' '.$prices;
}else{
$tail .= $kw3.'<BR>';
}
break;
}else{
$next_new = mb_substr($str,$m,$j,'utf-8');
if(mb_strwidth($next_new,'utf-8')<$blankNum) continue;
else{
$m = $i+1;
$result[] = $new;
$j=1;
}
}
}
}
$head = '';
foreach ($result as $key=>$value) {
if($key < 1){
$v_lenght = iconv("UTF-8", "GBK//IGNORE", $value);
$v_lenght = strlen($v_lenght);
if($v_lenght == 13) $value = $value." ";
$head .= $value.' '.$price.' '.$num.' '.$prices;
}else{
$head .= $value.'<BR>';
}
}
$orderInfo .= $head.$tail;
if(!empty($v5['o_note'])){
$orderInfo .= '备注:'.$v5['o_note'].'<BR>';
}
@$nums += $prices;
}
// $time = date('Y-m-d H:i:s', time());
$orderInfo .= '--------------------------------<BR>';
if ($arr[0]['box_money'] > 0) {
$kw5 = '';
$len = 24 - strlen($arr[0]['box_money']);
for ($q = 0; $q < $len; $q++) {
$kw5 .= ' ';
}
$orderInfo .= '包装费:' . $kw5 . $arr[0]['box_money'] . '<BR>';
}
if($arr[0]['dada_fee'] > 0){
$kw5 = '';
$len = 24 - strlen($arr[0]['dada_fee']);
for ($q = 0; $q < $len; $q++) {
$kw5 .= ' ';
}
$orderInfo .= '配送费:'.$kw5.$arr[0]['dada_fee'].'<BR>';
}
if($arr[0]['yhq_money2'] > 0){
$yhq_money2 = sprintf("%.2f",$arr[0]['yhq_money2']);
$kw6 = '';
$len = 25 - strlen($yhq_money2);
for ($q = 0; $q < $len; $q++) {
$kw6 .= ' ';
}
$orderInfo .= '红包:'.$kw6.'-'.$yhq_money2.'<BR>';
}
$total = '合计:'.$arr[0]['m_money'];
$user_name = $arr[0]['user_name'];
if(strlen($user_name)>18){
$user_name=substr($user_name,0,18).'...';
}
$str = $user_name . $total;
$kw5 = '';
$lenght = iconv("UTF-8", "GBK//IGNORE", $str);
$total_len = 32 - strlen($lenght);
for ($q = 0; $q < $total_len; $q++) {
$kw5 .= ' ';
}
$total_str = $user_name.$kw5.$total;
$orderInfo .= $total_str.'<BR>';
$orderInfo .= '送货地点:' . $arr[0]['address'] . '<BR>';
$tel = substr_replace( $arr[0]['tel'], '****', 3, 4);
$orderInfo .= '联系电话:' . $tel . '<BR>';
$orderInfo .= '配送时间:' . $arr[0]['ps_time'] . '<BR>';
if(!empty($arr[0]['note'])){
$orderInfo .= '备注:'.$arr[0]['note'].'<BR><BR>';
}
//$orderInfo .= '<QR>http://www.feieyun.com</QR>';//把解析后的二维码生成的字符串用标签套上即可自动生成二维码
return $orderInfo;
}
?>

307
app/Libs/feier_print/httpclient.php

@ -0,0 +1,307 @@
<?php
class HttpClient {
// Request vars
var $host;
var $port;
var $path;
var $method;
var $postdata = '';
var $cookies = array();
var $referer;
var $accept = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*';
var $accept_encoding = 'gzip';
var $accept_language = 'en-us';
var $user_agent = 'Incutio HttpClient v0.9';
var $timeout = 20;
var $use_gzip = true;
var $persist_cookies = true;
var $persist_referers = true;
var $debug = false;
var $handle_redirects = true;
var $max_redirects = 5;
var $headers_only = false;
var $username;
var $password;
var $status;
var $headers = array();
var $content = '';
var $errormsg;
var $redirect_count = 0;
var $cookie_host = '';
function __construct($host, $port=80) {
$this->host = $host;
$this->port = $port;
}
function get($path, $data = false) {
$this->path = $path;
$this->method = 'GET';
if ($data) {
$this->path .= '?'.$this->buildQueryString($data);
}
return $this->doRequest();
}
function post($path, $data) {
$this->path = $path;
$this->method = 'POST';
$this->postdata = $this->buildQueryString($data);
return $this->doRequest();
}
function buildQueryString($data) {
$querystring = '';
if (is_array($data)) {
foreach ($data as $key => $val) {
if (is_array($val)) {
foreach ($val as $val2) {
$querystring .= urlencode($key).'='.urlencode($val2).'&';
}
} else {
$querystring .= urlencode($key).'='.urlencode($val).'&';
}
}
$querystring = substr($querystring, 0, -1); // Eliminate unnecessary &
} else {
$querystring = $data;
}
return $querystring;
}
function doRequest() {
if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) {
switch($errno) {
case -3:
$this->errormsg = 'Socket creation failed (-3)';
case -4:
$this->errormsg = 'DNS lookup failure (-4)';
case -5:
$this->errormsg = 'Connection refused or timed out (-5)';
default:
$this->errormsg = 'Connection failed ('.$errno.')';
$this->errormsg .= ' '.$errstr;
$this->debug($this->errormsg);
}
return false;
}
socket_set_timeout($fp, $this->timeout);
$request = $this->buildRequest();
$this->debug('Request', $request);
fwrite($fp, $request);
$this->headers = array();
$this->content = '';
$this->errormsg = '';
$inHeaders = true;
$atStart = true;
while (!feof($fp)) {
$line = fgets($fp, 4096);
if ($atStart) {
$atStart = false;
if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
$this->errormsg = "Status code line invalid: ".htmlentities($line);
$this->debug($this->errormsg);
return false;
}
$http_version = $m[1];
$this->status = $m[2];
$status_string = $m[3];
$this->debug(trim($line));
continue;
}
if ($inHeaders) {
if (trim($line) == '') {
$inHeaders = false;
$this->debug('Received Headers', $this->headers);
if ($this->headers_only) {
break;
}
continue;
}
if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) {
continue;
}
$key = strtolower(trim($m[1]));
$val = trim($m[2]);
if (isset($this->headers[$key])) {
if (is_array($this->headers[$key])) {
$this->headers[$key][] = $val;
} else {
$this->headers[$key] = array($this->headers[$key], $val);
}
} else {
$this->headers[$key] = $val;
}
continue;
}
$this->content .= $line;
}
fclose($fp);
if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') {
$this->debug('Content is gzip encoded, unzipping it');
$this->content = substr($this->content, 10);
$this->content = gzinflate($this->content);
}
if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) {
$cookies = $this->headers['set-cookie'];
if (!is_array($cookies)) {
$cookies = array($cookies);
}
foreach ($cookies as $cookie) {
if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) {
$this->cookies[$m[1]] = $m[2];
}
}
$this->cookie_host = $this->host;
}
if ($this->persist_referers) {
$this->debug('Persisting referer: '.$this->getRequestURL());
$this->referer = $this->getRequestURL();
}
if ($this->handle_redirects) {
if (++$this->redirect_count >= $this->max_redirects) {
$this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')';
$this->debug($this->errormsg);
$this->redirect_count = 0;
return false;
}
$location = isset($this->headers['location']) ? $this->headers['location'] : '';
$uri = isset($this->headers['uri']) ? $this->headers['uri'] : '';
if ($location || $uri) {
$url = parse_url($location.$uri);
return $this->get($url['path']);
}
}
return true;
}
function buildRequest() {
$headers = array();
$headers[] = "{$this->method} {$this->path} HTTP/1.0";
$headers[] = "Host: {$this->host}";
$headers[] = "User-Agent: {$this->user_agent}";
$headers[] = "Accept: {$this->accept}";
if ($this->use_gzip) {
$headers[] = "Accept-encoding: {$this->accept_encoding}";
}
$headers[] = "Accept-language: {$this->accept_language}";
if ($this->referer) {
$headers[] = "Referer: {$this->referer}";
}
if ($this->cookies) {
$cookie = 'Cookie: ';
foreach ($this->cookies as $key => $value) {
$cookie .= "$key=$value; ";
}
$headers[] = $cookie;
}
if ($this->username && $this->password) {
$headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password);
}
if ($this->postdata) {
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Content-Length: '.strlen($this->postdata);
}
$request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata;
return $request;
}
function getStatus() {
return $this->status;
}
function getContent() {
return $this->content;
}
function getHeaders() {
return $this->headers;
}
function getHeader($header) {
$header = strtolower($header);
if (isset($this->headers[$header])) {
return $this->headers[$header];
} else {
return false;
}
}
function getError() {
return $this->errormsg;
}
function getCookies() {
return $this->cookies;
}
function getRequestURL() {
$url = 'https://'.$this->host;
if ($this->port != 80) {
$url .= ':'.$this->port;
}
$url .= $this->path;
return $url;
}
function setUserAgent($string) {
$this->user_agent = $string;
}
function setAuthorization($username, $password) {
$this->username = $username;
$this->password = $password;
}
function setCookies($array) {
$this->cookies = $array;
}
function useGzip($boolean) {
$this->use_gzip = $boolean;
}
function setPersistCookies($boolean) {
$this->persist_cookies = $boolean;
}
function setPersistReferers($boolean) {
$this->persist_referers = $boolean;
}
function setHandleRedirects($boolean) {
$this->handle_redirects = $boolean;
}
function setMaxRedirects($num) {
$this->max_redirects = $num;
}
function setHeadersOnly($boolean) {
$this->headers_only = $boolean;
}
function setDebug($boolean) {
$this->debug = $boolean;
}
function quickGet($url) {
$bits = parse_url($url);
$host = $bits['host'];
$port = isset($bits['port']) ? $bits['port'] : 80;
$path = isset($bits['path']) ? $bits['path'] : '/';
if (isset($bits['query'])) {
$path .= '?'.$bits['query'];
}
$client = new HttpClient($host, $port);
if (!$client->get($path)) {
return false;
} else {
return $client->getContent();
}
}
function quickPost($url, $data) {
$bits = parse_url($url);
$host = $bits['host'];
$port = isset($bits['port']) ? $bits['port'] : 80;
$path = isset($bits['path']) ? $bits['path'] : '/';
$client = new HttpClient($host, $port);
if (!$client->post($path, $data)) {
return false;
} else {
return $client->getContent();
}
}
function debug($msg, $object = false) {
if ($this->debug) {
print '<div style="border: 1px solid red; padding: 0.5em; margin: 0.5em;"><strong>HttpClient Debug:</strong> '.$msg;
if ($object) {
ob_start();
print_r($object);
$content = htmlentities(ob_get_contents());
ob_end_clean();
print '<pre>'.$content.'</pre>';
}
print '</div>';
}
}
}
?>

46
app/Libs/feier_print/飞鹅云打印说明文档.txt

@ -0,0 +1,46 @@
一、添加打印机
方法名 printerContent($content)
参数说明 $content 打印机编号(必填) # 打印机识别码(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100台
如:316500010 # abcdefgh # 快餐前台 # 13688889999
316500011 # abcdefgh # 快餐厨房 # 13688889990
二、删除打印机
方法名 printerDelList($snlist)
参数说明 $snlist 打印机编号 多台用-连接
如:316500010-316500011
三、打印订单
方法名 printMsg($sn,$content,$times)
参数说明 $sn 打印机编码 $content 打印内容 $times 打印张数 无值默认为1
如: $sn = 550510805;
$content = '<CB>测试打印</CB><BR>';
$content .= '名称      单价 数量 金额<BR>';
$content .= '--------------------------------<BR>';
$content .= '饭       10.0 10 100.0<BR>';
$content .= '炒饭      10.0 10 100.0<BR>';
$content .= '蛋炒饭     10.0 10 100.0<BR>';
$content .= '鸡蛋炒饭    10.0 10 100.0<BR>';
$content .= '西红柿炒饭   10.0 10 100.0<BR>';
$content .= '西红柿蛋炒饭  10.0 10 100.0<BR>';
$content .= '西红柿鸡蛋炒饭 10.0 10 100.0<BR>';
$content .= '--------------------------------<BR>';
$content .= '备注:加辣<BR>';
$content .= '合计:xx.0元<BR>';
$content .= '送货地点:广西南宁五象新区<BR>';
$content .= '联系电话:13888888888888<BR>';
$content .= '订餐时间:2014-08-08 08:08:08<BR>';
$content .= '<QR>http://www.feieyun.com</QR>';//把二维码字符串用标签套上即可自动生成二维码
//标签说明:
$content = "<DIRECTION>1</DIRECTION>";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸,
$content .= "<TEXT x='9' y='10' font='12' w='1' h='2' r='0'>#001 五号桌 1/3</TEXT><TEXT x='80' y='80' font='12' w='2' h='2' r='0'>可乐鸡翅</TEXT><TEXT x='9' y='180' font='12' w='1' h='1' r='0'>张三先生 13800138000</TEXT>";//40mm宽度标签纸打印例子,打开注释调用标签打印接口打印
四、查询订单状态
方法名 queryOrderState($orderid)
参数说明 $orderid 飞鹅订单号(发起打印请求成功时,从回调的参数中获取)
如:550510805_20200603103522_387054119

14
app/Models/ImsCjdcMarket.php

@ -29,6 +29,18 @@ class ImsCjdcMarket extends Model
return $this->hasOne('\App\Models\LanzuMpInfo','id','mp_id');
}
/**
* 获取市场信息
* @return \Illuminate\Http\JsonResponse
*/
public static function getMarket()
{
$markets = self::get();
$item = [];
foreach ($markets as $market) {
$item[$market->id] = $market->name;
}
return $item;
}
}

5
app/Models/ImsCjdcOrderMain.php

@ -55,5 +55,8 @@ class ImsCjdcOrderMain extends Model
}
public function updateShippingType($oid,$type)
{
return self::where('id',$oid)->update(['order_shipping_code'=>$type]);
}
}

2
app/Models/LanzuServiceHorseman.php

@ -12,5 +12,5 @@ class LanzuServiceHorseman extends Model
use SoftDeletes;
protected $table = 'lanzu_service_horseman';
protected $dateFormat = 'U';
}
Loading…
Cancel
Save