2489 lines
103 KiB
PHP
2489 lines
103 KiB
PHP
![]() |
<?php
|
|||
|
namespace app\models\common;
|
|||
|
use Yii;
|
|||
|
use yii\base\Model;
|
|||
|
use yii\db\ActiveRecord;
|
|||
|
use app\models\common\Config;
|
|||
|
use app\models\common\HttpClient;
|
|||
|
use App\Config\YlyConfig;
|
|||
|
use App\Oauth\YlyOauthClient;
|
|||
|
use App\Api\PrintService;
|
|||
|
use App\Api\PrinterService;
|
|||
|
class Printing extends ActiveRecord{
|
|||
|
//打印
|
|||
|
public static function orderPrint($orderId,$type=1,$goodsId=null,$modePrint=true)
|
|||
|
{
|
|||
|
|
|||
|
if ($type == 1) {
|
|||
|
self::takeoutOrderPrint($orderId);
|
|||
|
}elseif($type == 2){
|
|||
|
self::instoreOrderPrint($orderId,2,$goodsId,$modePrint);
|
|||
|
}elseif($type == 3){
|
|||
|
self::instoreOrderPrint($orderId,3,$goodsId,$modePrint);
|
|||
|
}elseif($type == 4){
|
|||
|
self::cashierOrderPrint($orderId);
|
|||
|
};
|
|||
|
return true;
|
|||
|
|
|||
|
}
|
|||
|
//测试打印
|
|||
|
public static function printTest($id){
|
|||
|
$message=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('id=:id',[':id'=>$id])->one();
|
|||
|
$rst=json_decode($message['data'],true);
|
|||
|
if($message['type']==1) {
|
|||
|
$content = "<FS2><center>取单号:#001**</center></FS2>";
|
|||
|
$content .= "<FS><center>张周兄弟烧烤</center></FS>";
|
|||
|
$content .= "<FS2><center>--在线支付--</center></FS2>";
|
|||
|
$content .= "<FS2><center>【立即送达】</center></FS2>";
|
|||
|
$content .= "期望送达时间:" . date("Y-m-d H:i") . "\n";
|
|||
|
$content .= str_repeat('.', 32);
|
|||
|
$content .= "订单编号:40807050607030\n";
|
|||
|
$content .= "下单时间:" . date("Y-m-d H:i") . "\n";
|
|||
|
$content .= '名称' . str_repeat(" ", 12) . "数量 单价\n";
|
|||
|
$content .= "<FS><table>";
|
|||
|
$content .= "<tr><td>烤土豆(超级辣)</td><td>x3</td><td>5.96</td></tr>";
|
|||
|
$content .= "<tr><td>烤排骨(超级辣)</td><td>x3</td><td>12.44</td></tr>";
|
|||
|
$content .= "<tr><td>烤韭菜(超级辣)</td><td>x3</td><td>8.96</td></tr>";
|
|||
|
$content .= "</table></FS>";
|
|||
|
$content .= str_repeat('.', 32);
|
|||
|
$content .= "[折扣:¥4 ]\n";
|
|||
|
$content .= "<FS2>实付:¥78</FS2>\n";
|
|||
|
$content .= str_repeat('*', 32);
|
|||
|
$content .= "<QR>这是二维码内容</QR>";
|
|||
|
$content .= "<FS2><center>**#1 完**</center></FS2>";
|
|||
|
$data = self::print($rst,$content);
|
|||
|
}elseif ($message['type']==2){
|
|||
|
$content = '<CB>测试打印</CB><BR>';
|
|||
|
$content .= '名称 数量 金额<BR>';
|
|||
|
$content .= '--------------------------------<BR>';
|
|||
|
$content .= '鸡蛋炒饭 10 100.0<BR>';
|
|||
|
$content .= '西红柿炒饭 10 100.0<BR>';
|
|||
|
$content .= '西红柿鸡蛋炒饭 10 100.0<BR>';
|
|||
|
$content .= '--------------------------------<BR>';
|
|||
|
$content .= '备注:加辣<BR>';
|
|||
|
$content .= '合计:xx.0元<BR>';
|
|||
|
$content .= '送货地点:广州市南沙区xx路xx号<BR>';
|
|||
|
$content .= '联系电话:13888888888888<BR>';
|
|||
|
$content .= '订餐时间:2014-08-08 08:08:08<BR>';
|
|||
|
$content .= '<QR>http://www.feieyun.com</QR>';
|
|||
|
$data = self::feiPrint($rst,$content);
|
|||
|
}elseif ($message['type']==3){
|
|||
|
$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>";
|
|||
|
$data = self::labelPrint($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
return $data;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//标签机打印设置
|
|||
|
public function labelPrintSet($id,$type) {
|
|||
|
$message=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('id=:id',[':id'=>$id])->one();
|
|||
|
$rst=json_decode($message['data'],true);
|
|||
|
|
|||
|
|
|||
|
$content ="<SIZE>40,30</SIZE>";
|
|||
|
if($type==1){
|
|||
|
$content.="<DIRECTION>1</DIRECTION>";
|
|||
|
}elseif ($type==2) {
|
|||
|
$content.="<DIRECTION>0</DIRECTION>";
|
|||
|
}
|
|||
|
$data = self::labelPrint($rst,$content);
|
|||
|
|
|||
|
return $data;
|
|||
|
}
|
|||
|
//易联云打印
|
|||
|
public static function print($params,$content='测试打印内容'){
|
|||
|
try {
|
|||
|
$outTradeNo = date("YmdHis") . rand(111111, 999999);
|
|||
|
$config = new YlyConfig($params['userId'], $params['apiKey']);
|
|||
|
$token = Yii::$app->cache->get($params['userId']);
|
|||
|
if (!$token) {
|
|||
|
//var_dump($token);die;
|
|||
|
$client = new YlyOauthClient($config);
|
|||
|
$token = $client->getToken();
|
|||
|
if ($token->access_token) {
|
|||
|
Yii::$app->cache->set($params['userId'], $token, 7200);
|
|||
|
}
|
|||
|
}
|
|||
|
$print = new PrintService($token->access_token, $config);
|
|||
|
$data = $print->index($params['number'], $content, $outTradeNo);
|
|||
|
//return $data;
|
|||
|
}catch (\Exception $e){
|
|||
|
//var_dump($e);die;
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//飞蛾打印
|
|||
|
public static function feiPrint($params,$content='测试打印内容'){
|
|||
|
//file_put_contents('1.txt','jijjjjjj'.$content);exit;
|
|||
|
header("Content-type: text/html; charset=utf-8");
|
|||
|
$contents = array(
|
|||
|
'user' => $params['fenumber'],
|
|||
|
'stime' => time(),
|
|||
|
'sig' => sha1($params['fenumber'] . $params['feukey'] . time()),
|
|||
|
'apiname' => 'Open_printMsg',
|
|||
|
'sn' => $params['dyjnumber'],
|
|||
|
'content' => $content,
|
|||
|
'times' => $params['wmnum'] ?: 1, //打印次数
|
|||
|
);
|
|||
|
$contents['content'] = $content;
|
|||
|
|
|||
|
//file_put_contents('1.txt',$contents['content'],FILE_APPEND);
|
|||
|
//return true;
|
|||
|
$client = new HttpClient('api.feieyun.cn', '80');
|
|||
|
if (!$client->post('/Api/Open/', $contents)) {
|
|||
|
$result = 'error';
|
|||
|
} else {
|
|||
|
$result = $client->getContent();
|
|||
|
}
|
|||
|
file_put_contents('1.txt',$result);
|
|||
|
$rst = json_decode($result, true);
|
|||
|
|
|||
|
if ($rst['msg'] == 'ok') {
|
|||
|
return true;
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
static function labelPrint($params,$content) {
|
|||
|
header("Content-type: text/html; charset=utf-8");
|
|||
|
$contents = array(
|
|||
|
'user' => $params['labelfenumber'],
|
|||
|
'stime' => time(),
|
|||
|
'sig' => sha1($params['labelfenumber'] . $params['labelfeukey'] . time()),
|
|||
|
'apiname' => 'Open_printLabelMsg',
|
|||
|
'sn' => $params['labeldyjnumber'],
|
|||
|
'content' => $content,
|
|||
|
'times' => $params['wmnum'] ?: 1, //打印次数
|
|||
|
);
|
|||
|
|
|||
|
$contents['content'] = $content;
|
|||
|
//var_dump($contents);die;
|
|||
|
$client = new HttpClient('api.feieyun.cn', '80');
|
|||
|
if (!$client->post('/Api/Open/', $contents)) {
|
|||
|
$result = 'error';
|
|||
|
} else {
|
|||
|
$result = $client->getContent();
|
|||
|
//var_dump($result);die;
|
|||
|
}
|
|||
|
$rst = json_decode($result, true);
|
|||
|
|
|||
|
//}
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//易联云取消所有未打印
|
|||
|
public static function cancelAllPrint($id){
|
|||
|
$message=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('id=:id',[':id'=>$id])->one();
|
|||
|
$params=json_decode($message['data'],true);
|
|||
|
$config = new YlyConfig($params['userId'], $params['apiKey']);
|
|||
|
$token = Yii::$app->cache->get($params['number']);
|
|||
|
if(!$token){
|
|||
|
//var_dump($token);die;
|
|||
|
$client = new YlyOauthClient($config);
|
|||
|
$token = $client->getToken();
|
|||
|
if($token->access_token){
|
|||
|
Yii::$app->cache->set($params['number'], $token, 86400);
|
|||
|
}
|
|||
|
}
|
|||
|
$print = new PrinterService($token->access_token, $config);
|
|||
|
$data = $print->cancelAll($params['number']);
|
|||
|
return $data;
|
|||
|
}
|
|||
|
|
|||
|
//易联云整单
|
|||
|
static function yiAllContent(array $order,array $store,array $goods,$note=null,$display=null,$qrContent=null){
|
|||
|
|
|||
|
if ($order['deliveryMode'] == 10) {
|
|||
|
$ddName = "到店自提";
|
|||
|
$qrContent=$order['selfCode'];
|
|||
|
$order['serviceAt'] = date(" H:i", $order['serviceTime']);
|
|||
|
} else {
|
|||
|
$ddName = "立即送出";
|
|||
|
$order['serviceAt'] = $order['serviceAt'];
|
|||
|
$qrContent=$qrContent;
|
|||
|
}
|
|||
|
if($order['appointment']==1){
|
|||
|
$ddName="预约单";
|
|||
|
$order['serviceAt'] = date("m-d H:i", $order['serviceTime']);
|
|||
|
}
|
|||
|
$payType = '微信支付';
|
|||
|
switch ($order['payMode']) {
|
|||
|
case 2:
|
|||
|
$payType = '支付宝支付';
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
$payType = '余额支付';
|
|||
|
break;
|
|||
|
case 10:
|
|||
|
$payType = '货到付款';
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
$content = "<FS2><center>取单号:#" . $order['takeNo'] . "</center></FS2>\n";
|
|||
|
$content .= "<center>*" . $store['name'] . "*</center>\n";
|
|||
|
if ($order['state'] == 9 or $order['state'] == 10) {
|
|||
|
$content .= "<FS2><center>--售后订单--</center></FS2>\n";
|
|||
|
$content .= "<FS2><center>有订单申请售后了</center></FS2>\n";
|
|||
|
$content .= "<FS2><center>请尽快处理!</center></FS2>\n";
|
|||
|
} elseif ($order['state'] == 7) {
|
|||
|
$content .= "<FS2><center>--取消订单--</center></FS2>\n";
|
|||
|
$content .= "<FS2><center>订单已取消,请尽快处理</center></FS2>\n";
|
|||
|
} else {
|
|||
|
$content .= "<FS2><center>--" . $payType . "--</center></FS2>\n";
|
|||
|
$content .= "<FS2><center>【" . $ddName . "】</center></FS2>\n";
|
|||
|
}
|
|||
|
/* if ($order['selfCode']) {
|
|||
|
$content .= "<FB><FS>取货码:" . $order['selfCode'] . "</FS></FB>\n";
|
|||
|
}*/
|
|||
|
if($order['deliveryMode']==10 and $order['isOut']==1){
|
|||
|
$eatType='店内就餐';
|
|||
|
}else{
|
|||
|
$eatType='打包带走';
|
|||
|
}
|
|||
|
|
|||
|
if($order['deliveryMode']==10){
|
|||
|
$content .= "取单方式:" . $eatType . "\n";
|
|||
|
$content .= "预计到店时间:" . $order['serviceAt'] . "\n";
|
|||
|
$order['receivedName']="预留信息:";
|
|||
|
}else{
|
|||
|
$content .= "期望送达时间:" . $order['serviceAt'] . "\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= "订单编号:" . $order['outTradeNo'] . "\n";
|
|||
|
$content .= "下单时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<FB>备注:" . $order['userNote'] . "</FB>\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= '名称' . str_repeat(" ", 12) . "数量 单价\n";
|
|||
|
$content .= "<FS><table>";
|
|||
|
foreach ($goods as $key => $value) {
|
|||
|
$name = $value['name'];
|
|||
|
if ($value['data']) {
|
|||
|
$name = $value['name'] . '(' . $value['data'] . ')';
|
|||
|
}
|
|||
|
if ($value['attribute']) {
|
|||
|
$name = $name . '(' . $value['attribute'] . ')';
|
|||
|
}
|
|||
|
if ($value['material']) {
|
|||
|
|
|||
|
/* $material = json_decode($value['material'], true);
|
|||
|
$mes = '';
|
|||
|
foreach ($material as $v) {
|
|||
|
$mes .= $v['name'] . '(' . $v['number'] . '),';
|
|||
|
}*/
|
|||
|
$name = $name . '(' .$value['material'] . ')';
|
|||
|
}
|
|||
|
if ($value['vipMoney'] > 0) {
|
|||
|
$value['money'] = $value['vipMoney'];
|
|||
|
}
|
|||
|
$content .= "<tr><td>" . $name . "</td><td>" . $value['num'] . "</td><td> " . $value['money'] . "</td></tr>";
|
|||
|
}
|
|||
|
|
|||
|
$content .= "</table></FS>\n";
|
|||
|
$content .= "<table><tr><td>合计:</td><td>" . $order['num'] . "</td><td> " . $order['originMoney'] . "</td></tr></table>";
|
|||
|
$content .= "<center>----------其它费用----------</center>\n";
|
|||
|
if ($order['deliveryMoney'] > 0) {
|
|||
|
$content .= "[配送费:+" . $order['deliveryMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['boxMoney'] > 0) {
|
|||
|
$content .= "[餐盒费:+" . $order['boxMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['preferentialMoney'] > 0) {
|
|||
|
$content .= "[满减优惠:-" . $order['preferentialMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['platformCouponPreferential'] > 0) {
|
|||
|
$content .= "[平台优惠券优惠:-" . $order['platformCouponPreferential'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['couponPreferential'] > 0) {
|
|||
|
$content .= "[优惠券优惠:-" . $order['couponPreferential'] . "]\n";
|
|||
|
}
|
|||
|
|
|||
|
if ($order['newMoney'] > 0) {
|
|||
|
$content .= "[新客立减:-" . $order['newMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['deliveryPreferential'] > 0) {
|
|||
|
$content .= "[减免配送费:-" . $order['deliveryPreferential'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['giveName']) {
|
|||
|
$content .= "[赠送:-" . $order['giveName'] . "]\n";
|
|||
|
}
|
|||
|
if($order['payMode']==10){
|
|||
|
$content .= "<FS2>应付:¥" . $order['money'] . "</FS2>\n";
|
|||
|
}else{
|
|||
|
$content .= "<FS2>实付:¥" . $order['money'] . "</FS2>\n";
|
|||
|
}
|
|||
|
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= "<FB><FS>" . $order['receivedAddress'] . "</FS></FB>\n\n";
|
|||
|
$content .= "<FB>" . $order['receivedName']. $order['receivedTel'] . "</FB>\n\n";
|
|||
|
if($note){
|
|||
|
$content .= "<center>" . $note . "</center>\n";
|
|||
|
}
|
|||
|
$content .= "<center>门店电话:" . $store['storeTel'] . "</center>\n\n";
|
|||
|
if($display==1) {
|
|||
|
$content .= "<QR>" . $qrContent . "</QR>";
|
|||
|
}
|
|||
|
$content .= "<FS2><center>----#" . $order['takeNo'] . "完----</center></FS2>\n";
|
|||
|
return $content;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
static function yiOneContent(array $order,array $store,array $goods,$note=null){
|
|||
|
$content = "<FS2><center>取单号:#" . $order['takeNo'] . "</center></FS2>\n";
|
|||
|
$content .= "<center>*" . $store['name'] . "*</center>\n";
|
|||
|
$content .= "订单编号:" . $order['outTradeNo'] . "\n";
|
|||
|
$content .= "下单时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<FB>备注:" . $order['userNote'] . "</FB>\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= '名称' . str_repeat(" ", 12) . "数量 单价\n";
|
|||
|
$content .= "<FS><table>";
|
|||
|
$name = $goods['name'];
|
|||
|
if ($goods['data']) {
|
|||
|
$name = $goods['name'] . '(' . $goods['data'] . ')';
|
|||
|
}
|
|||
|
if ($goods['attribute']) {
|
|||
|
$name = $name . '(' . $goods['attribute'] . ')';
|
|||
|
}
|
|||
|
if ($goods['material']) {
|
|||
|
/* $material = json_decode($goods['material'], true);
|
|||
|
$mes = '';
|
|||
|
foreach ($material as $v) {
|
|||
|
$mes .= $v['name'] . '(' . $v['number'] . '),';
|
|||
|
}*/
|
|||
|
$name = $name . '(' . $goods['material'] . ')';
|
|||
|
}
|
|||
|
if ($goods['vipMoney'] > 0) {
|
|||
|
$value['money'] = $goods['vipMoney'];
|
|||
|
}
|
|||
|
$content .= "<tr><td>" . $name . "</td><td>" . $goods['num'] . "</td><td> " . $goods['money'] . "</td></tr>";
|
|||
|
$content .= "</table></FS>\n";
|
|||
|
if($note){
|
|||
|
$content .= "<center>" . $note . "</center>\n";
|
|||
|
}
|
|||
|
$content .= "<FS2><center>----#" . $order['takeNo'] . "完----</center></FS2>\n";
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
static function yiTypeContent(array $order,array $store,array $goods){
|
|||
|
$content = "<FS2><center>取单号:#" . $order['takeNo'] . "</center></FS2>\n";
|
|||
|
$content .= "<center>*" . $store['name'] . "*</center>\n";
|
|||
|
if($order['deliveryMode']==10 and $order['isOut']==1){
|
|||
|
$eatType='店内就餐';
|
|||
|
}else{
|
|||
|
$eatType='打包带走';
|
|||
|
}
|
|||
|
|
|||
|
if($order['deliveryMode']==10){
|
|||
|
$content .= "取单方式:" . $eatType . "\n";
|
|||
|
$content .= "预计到店时间:" . $order['serviceAt'] . "\n";
|
|||
|
$order['receivedName']="预留信息:";
|
|||
|
}else{
|
|||
|
$content .= "期望送达时间:" . $order['serviceAt'] . "\n";
|
|||
|
}
|
|||
|
//$content .= "期望送达时间:" . $order['serviceAt'] . "\n";
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= "订单编号:" . $order['outTradeNo'] . "\n";
|
|||
|
$content .= "下单时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<FB>备注:" . $order['userNote'] . "</FB>\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= '名称' . str_repeat(" ", 12) . "数量 单价\n";
|
|||
|
$content .= "<FS><table>";
|
|||
|
foreach ($goods as $key => $value) {
|
|||
|
$name = $value['name'];
|
|||
|
if ($value['data']) {
|
|||
|
$name = $value['name'] . '(' . $value['data'] . ')';
|
|||
|
}
|
|||
|
if ($value['attribute']) {
|
|||
|
$name = $name . '(' . $value['attribute'] . ')';
|
|||
|
}
|
|||
|
if ($value['material']) {
|
|||
|
/* $material = json_decode($value['material'], true);
|
|||
|
$mes = '';
|
|||
|
foreach ($material as $v) {
|
|||
|
$mes .= $v['name'] . '(' . $v['number'] . '),';
|
|||
|
}*/
|
|||
|
$name = $name . '(' . $value['material'] . ')';
|
|||
|
}
|
|||
|
if ($value['vipMoney'] > 0) {
|
|||
|
$value['money'] = $value['vipMoney'];
|
|||
|
}
|
|||
|
$content .= "<tr><td>" . $name . "</td><td>" . $value['num'] . "</td><td> " . $value['money'] . "</td></tr>";
|
|||
|
}
|
|||
|
$content .= "</table></FS>\n";
|
|||
|
$content .= "<FS2><center>----#" . $order['takeNo'] . "完----</center></FS2>\n";
|
|||
|
return $content;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//整单打印或一菜一单内容
|
|||
|
static function allContent($orderId,$type=1,$printMode=1,$note=null,$display=null,$qrContent=null){
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_takeout_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$store=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where('id=:id',[':id'=>$order['storeId']])->one();
|
|||
|
$goods=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_order_goods}}')
|
|||
|
->where(' orderId=:orderId AND item=1',[':orderId'=>$orderId])->All();
|
|||
|
//整单打印
|
|||
|
if($printMode==1) {
|
|||
|
if ($type == 1) {
|
|||
|
$content = self::yiAllContent($order, $store, $goods,$note,$display,$qrContent);
|
|||
|
return $content;
|
|||
|
}
|
|||
|
if ($type == 2) {
|
|||
|
$content = self::feiAllContent($order, $store, $goods,$note,$display,$qrContent);
|
|||
|
return $content;
|
|||
|
}
|
|||
|
if ($type == 3) {
|
|||
|
$data['order']=$order;
|
|||
|
$data['store']=$store;
|
|||
|
$data['goods']=$goods;
|
|||
|
return $data;
|
|||
|
}
|
|||
|
}elseif($printMode==3){//一菜一单
|
|||
|
$data['order']=$order;
|
|||
|
$data['store']=$store;
|
|||
|
$data['goods']=$goods;
|
|||
|
return $data;
|
|||
|
}
|
|||
|
}
|
|||
|
//分组打印或标签打印内容
|
|||
|
static function typeContent($orderId,$type=1,$printMode=1,$json){
|
|||
|
$categoryArr = json_decode($json);
|
|||
|
$categoryStr = implode(',', $categoryArr)?:[];
|
|||
|
$where='a.orderId=:orderId';
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_takeout_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$store=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where('id=:id',[':id'=>$order['storeId']])->one();
|
|||
|
if($printMode==2 AND $categoryStr){
|
|||
|
$where .=" and item=1 and b.typePid in ($categoryStr)";
|
|||
|
}elseif ($printMode==4 AND $categoryStr){
|
|||
|
$where .=" and item=1 and b.printLabel in ($categoryStr)";
|
|||
|
}
|
|||
|
|
|||
|
$goods=(new \yii\db\Query())
|
|||
|
->select(['a.*','b.typePid'])
|
|||
|
->from('{{%ybwm_order_goods}} as a')
|
|||
|
->join('LEFT JOIN', '{{%ybwm_core_goods}} as b', 'a.goodsId=b.id')
|
|||
|
->where($where,[':orderId'=>$orderId])
|
|||
|
->all();
|
|||
|
if(!$goods){
|
|||
|
return false;
|
|||
|
}
|
|||
|
if ($type == 1) {
|
|||
|
$content = self::yiTypeContent($order, $store, $goods);
|
|||
|
return $content;
|
|||
|
}elseif ($type == 2) {
|
|||
|
$content = self::feiTypeContent($order, $store, $goods);
|
|||
|
return $content;
|
|||
|
}elseif ($type == 3){
|
|||
|
$data['order']=$order;
|
|||
|
$data['store']=$store;
|
|||
|
$data['goods']=$goods;
|
|||
|
return $data;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
static function feiStyle($arr, $A = 20, $B = 6, $C = 3, $D = 6) {
|
|||
|
$orderInfo = '';
|
|||
|
$nums='';
|
|||
|
$prices='';
|
|||
|
foreach ($arr as $k5 => $v5) {
|
|||
|
$name = $v5['name'];
|
|||
|
if ($v5['data']) {
|
|||
|
$name = $v5['name'] . '(' . $v5['data'] . ')';
|
|||
|
}
|
|||
|
if ($v5['attribute']) {
|
|||
|
$name = $name . '(' . $v5['attribute'] . ')';
|
|||
|
}
|
|||
|
if ($v5['material']) {
|
|||
|
$name = $name .'('.$v5['material']. ')';
|
|||
|
}
|
|||
|
$name = $name;
|
|||
|
$num = $v5['num'];
|
|||
|
$price = $v5['money'];
|
|||
|
if ($v5['vipMoney'] > 0) {
|
|||
|
$price = $v5['vipMoney'];
|
|||
|
}
|
|||
|
//$prices = $v5['money']*$v5['num'];
|
|||
|
$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 = $price.$kw1;
|
|||
|
}*/
|
|||
|
if (strlen($num) < $C) {
|
|||
|
$k2 = $C - strlen($num);
|
|||
|
for ($q = 0; $q < $k2; $q++) {
|
|||
|
$kw2 .= ' ';
|
|||
|
}
|
|||
|
$num = $num . $kw2;
|
|||
|
}
|
|||
|
/* if(strlen($prices) < $D){
|
|||
|
$k3 = $D - strlen($prices);
|
|||
|
for($q=0;$q<$k3;$q++){
|
|||
|
$kw4 .= ' ';
|
|||
|
}
|
|||
|
$prices = $prices.$kw4;
|
|||
|
}*/
|
|||
|
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 . ' ' . $num . ' ' . $price . ' ' . $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 . ' ' . $num . ' ' . $price . ' ' . $prices;
|
|||
|
} else {
|
|||
|
$head .= $value . '<BR>';
|
|||
|
}
|
|||
|
}
|
|||
|
$orderInfo .= $head . $tail . '<BR>';
|
|||
|
@$nums += $prices;
|
|||
|
|
|||
|
}
|
|||
|
return $orderInfo;
|
|||
|
}
|
|||
|
|
|||
|
static function feiAllContent(array $order,array $store,array $goods,$note=null,$display=null,$qrContent=null){
|
|||
|
if ($order['deliveryMode'] == 10) {
|
|||
|
$ddName = "到店自提";
|
|||
|
$qrContent=$order['selfCode'];
|
|||
|
$order['serviceAt'] = date(" H:i", $order['serviceTime']);
|
|||
|
} else {
|
|||
|
$ddName = "立即送出";
|
|||
|
$order['serviceAt'] = $order['serviceAt'];
|
|||
|
$qrContent=$qrContent;
|
|||
|
}
|
|||
|
if($order['appointment']==1){
|
|||
|
$ddName="预约单";
|
|||
|
$order['serviceAt'] = date("m-d H:i", $order['serviceTime']);
|
|||
|
}
|
|||
|
$payType = '微信支付';
|
|||
|
switch ($order['payMode']) {
|
|||
|
case 2:
|
|||
|
$payType = '支付宝支付';
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
$payType = '余额支付';
|
|||
|
break;
|
|||
|
case 10:
|
|||
|
$payType = '货到付款';
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
$content= "<CB>取单号 #" . $order['takeNo'] . "</CB><BR>";
|
|||
|
$content .= "<C>*" . $store['name'] . "*</C><BR>";
|
|||
|
if($order['state']==9 or $order['state']==10){
|
|||
|
$content .= "<B><C>--售后订单--</C></B><BR>";
|
|||
|
$content .= "<B><C>有订单申请售后了</C></B><BR>";
|
|||
|
$content .= "<B><C>请尽快处理!</C></B><BR>";
|
|||
|
}elseif($order['state']==7){
|
|||
|
$content .= "<BOLD><C>--取消订单--</C></BOLD><BR>";
|
|||
|
$content .= "<BOLD><C>订单已取消,请尽快处理</C></BOLD><BR>";
|
|||
|
}else{
|
|||
|
$content .= "<CB>--".$payType."--</CB><BR>";
|
|||
|
$content .= "<L><BOLD><C>【".$ddName."】</C></BOLD></L><BR>";
|
|||
|
}
|
|||
|
/* if ($order['selfCode']) {
|
|||
|
$content .= "<C>取货码: " . $order['selfCode'] . "</C><BR>";
|
|||
|
}*/
|
|||
|
if($order['deliveryMode']==10 and $order['isOut']==1){
|
|||
|
$eatType='店内就餐';
|
|||
|
}else{
|
|||
|
$eatType='打包带走';
|
|||
|
}
|
|||
|
|
|||
|
if($order['deliveryMode']==10){
|
|||
|
$content .= "取单方式:" . $eatType . "<BR>";
|
|||
|
$content .= "预计到店时间:" . $order['serviceAt'] . "<BR>";
|
|||
|
$order['receivedName']="预留信息:";
|
|||
|
}else{
|
|||
|
$content .= "期望送达时间:" . $order['serviceAt'] . "<BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "订单号:" . $order['outTradeNo'] . "<BR>";
|
|||
|
$content .= "下单时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "<BR>";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<BOLD>备注:" . $order['userNote'] . "</BOLD><BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "名称 数量 单价<BR>";
|
|||
|
$content .= "<L><BOLD>".self::feiStyle($goods,20,6,3)."</BOLD></L>";
|
|||
|
$content .= self::feiStyle(['0'=>['name'=>'合计','num'=>$order['num'],'money'=>$order['originMoney']]],20,6,3);
|
|||
|
$content .= "<C>----------其它费用----------</C>\n";
|
|||
|
if ($order['deliveryMoney'] > 0) {
|
|||
|
$content .= "配送费:" . $order['deliveryMoney'] . "<BR>";
|
|||
|
}
|
|||
|
if ($order['boxMoney'] > 0) {
|
|||
|
$content .= "[餐盒费:+" . $order['boxMoney'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['preferentialMoney'] > 0) {
|
|||
|
$content .= "[满减优惠:-" . $order['preferentialMoney'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['platformCouponPreferential'] > 0) {
|
|||
|
$content .= "[平台优惠券优惠:-" . $order['platformCouponPreferential'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['couponPreferential'] > 0) {
|
|||
|
$content .= "[优惠券优惠:-" . $order['couponPreferential'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['newMoney'] > 0) {
|
|||
|
$content .= "[新客立减:-" . $order['newMoney'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['deliveryPreferential'] > 0) {
|
|||
|
$content .= "[减免配送费:-" . $order['deliveryPreferential'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['giveName']) {
|
|||
|
$content .= "[赠送:" . $order['giveName'] . "]<BR>";
|
|||
|
}
|
|||
|
|
|||
|
if($order['payMode']==10){
|
|||
|
$content .= "<L><BOLD>应付:¥" . $order['money'] . "</BOLD></L><BR><BR>";
|
|||
|
}else{
|
|||
|
$content .= "<L><BOLD>实付:¥" . $order['money'] . "</BOLD></L><BR><BR>";
|
|||
|
}
|
|||
|
$content .= "<BOLD><B>" . $order['receivedAddress'] . "</B></BOLD><BR><BR>";
|
|||
|
$content .= "<BOLD>" . $order['receivedName'] . $order['receivedTel'] . "</BOLD><BR><BR>";
|
|||
|
if ($note) {
|
|||
|
$content .= "<C>" .$note . "</C><BR>";
|
|||
|
}
|
|||
|
$content .= "<C>门店电话:" . $store['storeTel'] . "</C><BR>";
|
|||
|
if($display==1) {
|
|||
|
$content .= "<QR>" . $qrContent . "</QR>";
|
|||
|
}
|
|||
|
$content .= "<BOLD><C>----#" . $order['takeNo'] . "完----</C></BOLD>\n";
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
static function feiOneContent(array $order,array $store,array $goods,$note=null){
|
|||
|
$goodsInfo[]=$goods;
|
|||
|
$content= "<CB>取单号 #" . $order['takeNo'] . "</CB><BR>";
|
|||
|
$content .= "<C>*" . $store['name'] . "*</C><BR>";
|
|||
|
if($order['deliveryMode']==10 and $order['isOut']==1){
|
|||
|
$eatType='店内就餐';
|
|||
|
}else{
|
|||
|
$eatType='打包带走';
|
|||
|
}
|
|||
|
|
|||
|
if($order['deliveryMode']==10){
|
|||
|
$content .= "取单方式:" . $eatType . "<BR>";
|
|||
|
$content .= "预计到店时间:" . $order['serviceAt'] . "<BR>";
|
|||
|
}else{
|
|||
|
$content .= "期望送达时间:" . $order['serviceAt'] . "<BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "订单号:" . $order['outTradeNo'] . "<BR>";
|
|||
|
$content .= "下单时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "<BR>";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<BOLD>备注:" . $order['userNote'] . "</BOLD><BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "名称 数量 单价<BR>";
|
|||
|
$content .= "<L><BOLD>".self::feiStyle($goodsInfo,20,6,3)."</BOLD></L>";
|
|||
|
|
|||
|
if($note){
|
|||
|
$content .= "<C>" . $note . "</C>\n";
|
|||
|
}
|
|||
|
$content .= "<C>门店电话:" . $store['storeTel'] . "</C>\n\n";
|
|||
|
$content .= "<B><C>----#" . $order['takeNo'] . "完----</C></B>\n";
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
static function feiTypeContent(array $order,array $store,array $goods,$note=null){
|
|||
|
if ($order['deliveryMode'] == 10) {
|
|||
|
$ddName = "到店自提";
|
|||
|
$order['serviceAt'] = date("Y-m-d H:i", $order['serviceTime']);
|
|||
|
} else {
|
|||
|
$ddName = "立即送出";
|
|||
|
$order['serviceAt'] = $order['serviceAt'];
|
|||
|
}
|
|||
|
if($order['appointment']==1){
|
|||
|
$ddName="预约单";
|
|||
|
$order['serviceAt'] = date("m-d H:i", $order['serviceTime']);
|
|||
|
}
|
|||
|
$payType = '微信支付';
|
|||
|
switch ($order['payMode']) {
|
|||
|
case 2:
|
|||
|
$payType = '支付宝支付';
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
$payType = '余额支付';
|
|||
|
break;
|
|||
|
case 10:
|
|||
|
$payType = '货到付款';
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
$content= "<CB>取单号 #" . $order['takeNo'] . "</CB><BR>";
|
|||
|
$content .= "<C>*" . $store['name'] . "*</C><BR>";
|
|||
|
if($order['state']==9){
|
|||
|
$content .= "<BOLD><C>--售后订单--</C></BOLD><BR>";
|
|||
|
$content .= "<BOLD><C>订单申请售后,请尽快处理</C></BOLD><BR>";
|
|||
|
}elseif($order['state']==7){
|
|||
|
$content .= "<BOLD><C>--取消订单--</C></BOLD><BR>";
|
|||
|
$content .= "<BOLD><C>订单已取消,请尽快处理</C></BOLD><BR>";
|
|||
|
}else{
|
|||
|
$content .= "<BOLD><C>--".$payType."--</C></BOLD><BR>";
|
|||
|
$content .= "<L><BOLD><C>【".$ddName."】</C></BOLD></L><BR>";
|
|||
|
}
|
|||
|
/* if ($order['selfCode']) {
|
|||
|
$content .= "<C>取货码 " . $order['selfCode'] . "</C><BR>";
|
|||
|
}*/
|
|||
|
if($order['deliveryMode']==10 and $order['isOut']==1){
|
|||
|
$eatType='店内就餐';
|
|||
|
}else{
|
|||
|
$eatType='打包带走';
|
|||
|
}
|
|||
|
|
|||
|
if($order['deliveryMode']==10){
|
|||
|
$content .= "取单方式:" . $eatType . "<BR>";
|
|||
|
$content .= "预计到店时间:" . $order['serviceAt'] . "<BR>";
|
|||
|
}else{
|
|||
|
$content .= "期望送达时间:" . $order['serviceAt'] . "<BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "订单号:" . $order['outTradeNo'] . "<BR>";
|
|||
|
$content .= "下单时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "<BR>";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<BOLD>备注:" . $order['userNote'] . "</BOLD><BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "名称 数量 单价<BR>";
|
|||
|
$content .= "<L><BOLD>".self::feiStyle($goods,20,6,3)."</BOLD></L>";
|
|||
|
if($note){
|
|||
|
$content .= "<C>" . $note . "</C>\n";
|
|||
|
}
|
|||
|
$content .= "<C>门店电话:" . $store['storeTel'] . "</C>\n\n";
|
|||
|
$content .= "<B><C>----#" . $order['takeNo'] . "完----</C></B>\n";
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
static function labelAllContent(array $order,array $store,array $goods,$num,$typeArr=[]){
|
|||
|
$goodsInfo[]=$goods;
|
|||
|
$content = '';
|
|||
|
foreach ($goodsInfo as $key => $value) {
|
|||
|
$money = $value["money"];
|
|||
|
if ($value["vipMoney"] > 0) {
|
|||
|
$money = $value["vipMoney"];
|
|||
|
}
|
|||
|
$symbol='/';
|
|||
|
$tableName='单号';
|
|||
|
$sign='#';
|
|||
|
if($typeArr['orderType']==1){
|
|||
|
$orderType='堂食';
|
|||
|
$orderTex='';
|
|||
|
$symbol='';
|
|||
|
$tableName='桌号';
|
|||
|
$order['takeNo']=$order['number'];
|
|||
|
$sign='';
|
|||
|
}elseif ($typeArr['orderType']==2){
|
|||
|
$orderType='快餐';
|
|||
|
$orderTex='店内';
|
|||
|
$sign='';
|
|||
|
$order['takeNo']=$order['callNo'];
|
|||
|
if($typeArr['isOut']==2){
|
|||
|
$orderTex='打包';
|
|||
|
}
|
|||
|
|
|||
|
}elseif ($typeArr['orderType']==3){
|
|||
|
$orderType='外卖';
|
|||
|
$orderTex='配送';
|
|||
|
if($typeArr['isOut']==2&&$typeArr['deliveryMode']==10){
|
|||
|
$orderType='自提';
|
|||
|
$orderTex='打包';
|
|||
|
}
|
|||
|
if($typeArr['isOut']==1&&$typeArr['deliveryMode']==10){
|
|||
|
$orderType='自提';
|
|||
|
$orderTex='到店';
|
|||
|
}
|
|||
|
}
|
|||
|
$goodsNum=$order['num']?:$order['goodsNum'];
|
|||
|
|
|||
|
//$num = $key + 1;
|
|||
|
$content .= '<TEXT x="10" y="10" font="12" w="1" h="1" r="0">'.$tableName.':'.$sign. $order['takeNo']." ". ' 杯数:' . $num . '/' . $goodsNum . '</TEXT>';
|
|||
|
$content .= '<TEXT x="10" y="50" font="12" w="1" h="2" r="0">' . $value["name"] . '</TEXT>';
|
|||
|
if ($value["data"]) {
|
|||
|
$content .= '<TEXT x="10" y="110" font="12" w="1" h="1" r="0">规格:' . $value["data"] . '</TEXT>';
|
|||
|
}
|
|||
|
|
|||
|
if ($value["attribute"]) {
|
|||
|
$content .= '<TEXT x="10" y="140" font="12" w="1" h="1" r="0">属性:' . $value["attribute"] . '</TEXT>';
|
|||
|
}
|
|||
|
if ($value['material']) {
|
|||
|
$content .= '<TEXT x="10" y="170" font="12" w="1" h="1" r="0">加料:' . $value['material'] . '</TEXT>';
|
|||
|
}
|
|||
|
//$content.= '<TEXT x="20" y="160" font="12" w="1" h="1" r="0">1×'. $money.' '.$location.'</TEXT>';
|
|||
|
//$content .= '<TEXT x="80" y="120" font="12" w="2" h="2" r="0">'.$value["title"].'</TEXT>';
|
|||
|
$content .= '<TEXT x="10" y="210" font="12" w="1" h="1" r="0">' . date('m-d H:i', $order['createdAt']) ." ".$orderType. $symbol.$orderTex .'</TEXT>';//
|
|||
|
}
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
//外卖订单打印
|
|||
|
public static function takeoutOrderPrint($orderId){
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_takeout_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$print=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('deleteAt=0 AND display=1 AND uniacid=:uniacid AND storeId=:storeId AND support=1',[':uniacid'=>$order['uniacid'],':storeId'=>$order['storeId']])->All();
|
|||
|
if (!$print) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
$systemSet=Config::getSystemSet('print',$order['uniacid']);
|
|||
|
|
|||
|
foreach ($print as $value){
|
|||
|
$rst=json_decode($value['data'],true);
|
|||
|
//易联云
|
|||
|
if($value['type']==1){
|
|||
|
$dynum=$rst['wmnum']?:1;
|
|||
|
$note=$systemSet['sjlNote']?:'';
|
|||
|
$display=$systemSet['display']?:2;
|
|||
|
$qrContent=$systemSet['codeUrl']?:'';
|
|||
|
//商家联
|
|||
|
if($value['pattern']==1){
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
|
|||
|
$content=self::allContent($orderId,$value['type'],$value['printMode'],$note,$display,$qrContent);
|
|||
|
//var_dump($content);die;
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
//一菜一单
|
|||
|
if($value['printMode']==3){
|
|||
|
$note=$systemSet['oneNote']?:'';
|
|||
|
$info=self::allContent($orderId,$value['type'],$value['printMode'],$note);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::yiOneContent($info['order'], $info['store'], $value,$note);
|
|||
|
// var_dump($content);die;
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//顾客联
|
|||
|
if($value['pattern']==2){
|
|||
|
$content=self::allContent($orderId,$value['type'],$value['printMode'],$note,$display,$qrContent);
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
//厨房联
|
|||
|
if($value['pattern']==3){
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
$content=self::allContent($orderId,$value['type'],$value['printMode']);
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
//分组打印
|
|||
|
if($value['printMode']==2){
|
|||
|
$content=self::typeContent($orderId,$value['type'],$value['printMode'],$value['categoryIds']);
|
|||
|
if(!$content){
|
|||
|
continue;
|
|||
|
}
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
//一菜一单
|
|||
|
if($value['printMode']==3){
|
|||
|
$note=$systemSet['oneNote']?:'';
|
|||
|
$info=self::allContent($orderId,$value['type'],$value['printMode'],$note);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::yiOneContent($info['order'], $info['store'], $value,$note);
|
|||
|
// var_dump($content);die;
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
//标签打印
|
|||
|
if($value['printMode']==4){
|
|||
|
$content=self::typeContent($orderId,$value['type'],$value['printMode'],$value['label']);
|
|||
|
if(!$content){
|
|||
|
continue;
|
|||
|
}
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//飞蛾云
|
|||
|
if($value['type']==2){
|
|||
|
$note=$systemSet['gklNote']?:'';
|
|||
|
$display=$systemSet['display2']?:2;
|
|||
|
$qrContent=$systemSet['codeUrl2']?:'';
|
|||
|
//商家联
|
|||
|
if($value['pattern']==1){
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
$content=self::allContent($orderId,$value['type'],$value['printMode'],$note,$display,$qrContent);
|
|||
|
//var_dump($content);die;
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
//一菜一单
|
|||
|
if($value['printMode']==3){
|
|||
|
$note=$systemSet['oneNote']?:'';
|
|||
|
$info=self::allContent($orderId,$value['type'],$value['printMode'],$note);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::feiOneContent($info['order'], $info['store'], $value,$note);
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//顾客联
|
|||
|
if($value['pattern']==2){
|
|||
|
$content=self::allContent($orderId,$value['type'],$value['printMode'],$note,$display,$qrContent);
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
//厨房联
|
|||
|
if($value['pattern']==3){
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
$content=self::allContent($orderId,$value['type'],$value['printMode']);
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
//分组打印
|
|||
|
if($value['printMode']==2){
|
|||
|
$content=self::typeContent($orderId,$value['type'],$value['printMode'],$value['categoryIds']);
|
|||
|
if(!$content){
|
|||
|
continue;
|
|||
|
}
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
//一菜一单
|
|||
|
if($value['printMode']==3){
|
|||
|
$note=$systemSet['oneNote']?:'';
|
|||
|
$info=self::allContent($orderId,$value['type'],$value['printMode'],$note);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::feiOneContent($info['order'], $info['store'], $value,$note);
|
|||
|
// var_dump($content);die;
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
//标签打印
|
|||
|
if($value['printMode']==4){
|
|||
|
$content=self::typeContent($orderId,$value['type'],$value['printMode'],$value['label']);
|
|||
|
if(!$content){
|
|||
|
continue;
|
|||
|
}
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//飞蛾标签打印机
|
|||
|
if($value['type']==3){
|
|||
|
$info=self::allContent($orderId,$value['type'],$value['printMode'],$note='');
|
|||
|
if($value['printMode']==2){
|
|||
|
$info=self::typeContent($orderId,$value['type'],$value['printMode'],$value['categoryIds']);
|
|||
|
}
|
|||
|
if($value['printMode']==4 ){
|
|||
|
$info=self::typeContent($orderId,$value['type'],$value['printMode'],$value['label']);
|
|||
|
}
|
|||
|
$goods=$info['goods'];
|
|||
|
$orderNum=0;
|
|||
|
foreach ($goods as $key => $value) {
|
|||
|
$orderNum+=$value['num'];
|
|||
|
if($value['num']>1){
|
|||
|
for ($i=0; $i <$value['num'] ; $i++) {
|
|||
|
if($i>0){
|
|||
|
array_push($goods,$value);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
foreach ($goods as $key=>$value){
|
|||
|
$num=$key+1;
|
|||
|
$content = self::labelAllContent($info['order'], $info['store'], $value,$num,['orderType'=>3,'isOut'=>$order['isOut'],'deliveryMode'=>$order['deliveryMode']]);
|
|||
|
// var_dump($content);die;
|
|||
|
self::labelPrint($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//退款打印
|
|||
|
public static function refundOrderPrint($orderId){
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_takeout_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$print=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('deleteAt=0 AND display=1 AND uniacid=:uniacid AND storeId=:storeId AND support=1',[':uniacid'=>$order['uniacid'],':storeId'=>$order['storeId']])
|
|||
|
->All();
|
|||
|
if (!$print) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
$systemSet=Config::getSystemSet('print',$order['uniacid']);
|
|||
|
|
|||
|
foreach ($print as $value){
|
|||
|
$rst=json_decode($value['data'],true);
|
|||
|
//易联云
|
|||
|
if($value['type']==1){
|
|||
|
$note=$systemSet['sjlNote']?:'';
|
|||
|
$display=$systemSet['display']?:2;
|
|||
|
$qrContent=$systemSet['codeUrl']?:'';
|
|||
|
//商家联
|
|||
|
if($value['pattern']==1){
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
$content=self::allContent($orderId,$value['type'],$value['printMode'],$note,$display,$qrContent);
|
|||
|
//var_dump($content);die;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
//飞蛾云
|
|||
|
if($value['type']==2){
|
|||
|
$note=$systemSet['gklNote']?:'';
|
|||
|
$display=$systemSet['display2']?:2;
|
|||
|
$qrContent=$systemSet['codeUrl2']?:'';
|
|||
|
//商家联
|
|||
|
if($value['pattern']==1){
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
$content=self::allContent($orderId,$value['type'],$value['printMode'],$note,$display,$qrContent);
|
|||
|
//var_dump($content);die;
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
//一菜一单
|
|||
|
if($value['printMode']==3){
|
|||
|
$note=$systemSet['oneNote']?:'';
|
|||
|
$info=self::allContent($orderId,$value['type'],$value['printMode'],$note);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::feiOneContent($info['order'], $info['store'], $value,$note);
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
static function integralYi($order) {
|
|||
|
$name = $order['receiveName'];
|
|||
|
$address = $order['receiveAddress'];
|
|||
|
$tel = $order['receiveTel'];
|
|||
|
if($order['deliveryMode']==2){
|
|||
|
$user=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_users}}')
|
|||
|
->where('id=:id',[':id'=>$order['userId']])->one();
|
|||
|
$name = $user['userName'];
|
|||
|
$tel = $user['userTel'];
|
|||
|
}
|
|||
|
$price = '';
|
|||
|
if ($order['score']) {
|
|||
|
$price = $order['score'] . '积分';
|
|||
|
}
|
|||
|
if ($order['money']) {
|
|||
|
$price = $order['money'] . '元';
|
|||
|
}
|
|||
|
if ($order['money'] and $order['score']) {
|
|||
|
$price = $order['score'] . '积分+' . $order['money'] . '元';
|
|||
|
}
|
|||
|
$psName = "快递配送";
|
|||
|
if ($order['deliveryMode'] == 2) {
|
|||
|
$psName = "到店自提";
|
|||
|
}
|
|||
|
$content= "<FS2><center>--积分兑换--</center></FS2>\n";
|
|||
|
$content.= "领取方式:" . $psName . "\n";
|
|||
|
$content.= "用户ID:" . $order['userId'] . "\n";
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content.= "订单号:" . $order['outTradeNo'] . "\n";
|
|||
|
$content .= "兑换时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= '商品名称' . str_repeat(" ", 10) . "数量 市场价\n";
|
|||
|
$content .= "<table><tr><td>" . $order['goodsName'] . "</td><td>" . $order['convertNum'] . "</td><td>" .$order['price']. "</td></tr></table>";
|
|||
|
$content .= "--------------------------------\n\n";
|
|||
|
/*$content .= "配送费" . $order['deliveryMoney'] . "\n\n";*/
|
|||
|
$content .= "<FS>实付:" . $price . "</FS>\n\n";
|
|||
|
//$content .= "------------".$psName."------------\n";
|
|||
|
$content .= "------------预留信息------------\n\n";
|
|||
|
$content .= "<FB><FS>" . $name . "</FS> <FS>" . $tel . "</FS></FB>\n";
|
|||
|
$content .= "<FB><FS>" . $address . "</FS></FB>\n";
|
|||
|
|
|||
|
return $content;
|
|||
|
|
|||
|
}
|
|||
|
static function integralFei($order) {
|
|||
|
$name = $order['receiveName'];
|
|||
|
$address = $order['receiveAddress'];
|
|||
|
$tel = $order['receiveTel'];
|
|||
|
if($order['deliveryMode']==2){
|
|||
|
$user=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_users}}')
|
|||
|
->where('id=:id',[':id'=>$order['userId']])->one();
|
|||
|
$name = $user['userName'];
|
|||
|
$tel = $user['userTel'];
|
|||
|
}
|
|||
|
$price = '';
|
|||
|
if ($order['score']) {
|
|||
|
$price = $order['score'] . '积分';
|
|||
|
}
|
|||
|
if ($order['money']) {
|
|||
|
$price = $order['money'] . '元';
|
|||
|
}
|
|||
|
if ($order['money'] and $order['score']) {
|
|||
|
$price = $order['score'] . '积分+' . $order['money'] . '元';
|
|||
|
}
|
|||
|
$psName = "快递配送";
|
|||
|
if ($order['deliveryMode'] == 2) {
|
|||
|
$psName = "到店自提";
|
|||
|
}
|
|||
|
$content= "<BOLD><C>--积分兑换--</C></BOLD><BR>";
|
|||
|
$content.= "领取方式:" . $psName . "<BR>";
|
|||
|
$content.= "用户ID:" . $order['userId'] . "<BR>";
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content.= "订单号:" . $order['outTradeNo'] . "<BR>";
|
|||
|
$content .= "兑换时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "<BR>";
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= '商品名称' . str_repeat(" ", 10) . "数量 市场价<BR>";
|
|||
|
$goods[0] = array('name' => $order['goodsName'], 'money' => $order['price'], 'num' => $order['convertNum']);
|
|||
|
$content .= self::feiStyle($goods);
|
|||
|
$content .= "--------------------------------<BR><BR>";
|
|||
|
$content .= "<BOLD>实付" . $price . "<BOLD><BR><BR>";
|
|||
|
|
|||
|
$content .= "------------预留信息------------<BR><BR>";
|
|||
|
$content .= "<BOLD><B>" . $name . "</B> <B>" . $tel . "</B></BOLD><BR>";
|
|||
|
$content .= "<BOLD><B>" . $address . "</B></BOLD><BR>";
|
|||
|
return $content;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
static function integralOrderPrint($orderId,$storeId){
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_integral_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$print=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('deleteAt=0 AND display=1 AND uniacid=:uniacid AND storeId=:storeId AND support=1 AND printMode=6',[':uniacid'=>$order['uniacid'],':storeId'=>$storeId])->All();
|
|||
|
|
|||
|
if (!$print) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
foreach ($print as $value) {
|
|||
|
$rst = json_decode($value['data'], true);
|
|||
|
if ($value['type'] == 1) {
|
|||
|
if($value['printMode']==6 ) {
|
|||
|
$content = self::integralYi($order);
|
|||
|
//var_dump($content);die;
|
|||
|
return self::print($rst, $content);
|
|||
|
}
|
|||
|
}
|
|||
|
if ($value['type'] == 2) {
|
|||
|
if($value['printMode']==6 ) {
|
|||
|
$content = self::integralFei($order);
|
|||
|
//var_dump($content);die;
|
|||
|
return self::feiPrint($rst, $content);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
static function billContent($data,$type=1) {
|
|||
|
$line="\n";
|
|||
|
$content= "<FS2><center>---营业小结---</center></FS2>\n";
|
|||
|
if($type==2){
|
|||
|
$line="<BR>";
|
|||
|
$content= "<BOLD><C>---营业小结---</C></BOLD><BR>";
|
|||
|
}
|
|||
|
$content.= "日期:" . $data['day'] . $line.$line;
|
|||
|
$content.= "打印时间:" . date('Y-m-d H:i:s') . $line.$line;
|
|||
|
$content.= "营业额:" . $data['turnover'] . $line.$line;
|
|||
|
$content.= "用户实付金额:" . $data['payment'] . $line.$line;
|
|||
|
$content.= "预计结算收益:" . $data['estimate'] . $line.$line;
|
|||
|
$content.= "其他费用:" . $data['otherMoney'] . $line.$line;
|
|||
|
$content.= "有效订单数:" . $data['payNum'] . $line.$line;
|
|||
|
$content.= "付款人数:" . $data['payPeople'] . $line.$line;
|
|||
|
$content.= "取消/售后订单:" . $data['refundNum'] .$line.$line;
|
|||
|
$content.= "取消/售后金额:" . $data['refundMoney'] .$line.$line;
|
|||
|
return $content;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
static function billPrint($data){
|
|||
|
$print=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('deleteAt=0 AND display=1 AND uniacid=:uniacid AND storeId=:storeId AND support=1',[':uniacid'=>$data['uniacid'],':storeId'=>$data['storeId']])->All();
|
|||
|
//var_dump($print);die;
|
|||
|
if (!$print) {
|
|||
|
echo json_encode(['code'=>2,'msg'=>'打印机未开启']);die;
|
|||
|
//return false;
|
|||
|
}
|
|||
|
foreach ($print as $value) {
|
|||
|
$rst = json_decode($value['data'], true);
|
|||
|
if ($value['type'] == 1) {
|
|||
|
if ($value['printMode'] == 5) {
|
|||
|
$content = self::billContent($data, $value['type']);
|
|||
|
//var_dump($content);die;
|
|||
|
return self::print($rst, $content);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
if ($value['type'] == 2) {
|
|||
|
if($value['printMode']==5 ) {
|
|||
|
$content = self::billContent($data, $value['type']);
|
|||
|
//var_dump($content);die;
|
|||
|
return self::feiPrint($rst, $content);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public static function cashierOrderPrint($orderId){
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_cashier_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$print=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('deleteAt=0 AND display=1 AND uniacid=:uniacid AND storeId=:storeId AND support=4',[':uniacid'=>$order['uniacid'],':storeId'=>$order['storeId']])->All();
|
|||
|
if (!$print) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
$systemSet=Config::getSystemSet('print',$order['uniacid']);
|
|||
|
foreach ($print as $value){
|
|||
|
$rst=json_decode($value['data'],true);
|
|||
|
$note=$systemSet['sjlNote']?:'';
|
|||
|
$display=$systemSet['display']?:2;
|
|||
|
$qrContent=$systemSet['codeUrl']?:'';
|
|||
|
//易联云
|
|||
|
if($value['type']==1){
|
|||
|
//商家联
|
|||
|
if($value['pattern']==1){
|
|||
|
$content=self::cashYi($order,$note,$display,$qrContent,$value['pattern']);
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
//顾客联
|
|||
|
if($value['pattern']==2){
|
|||
|
$content=self::cashYi($order,$note,$display,$qrContent,$value['pattern']);
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
//飞蛾云
|
|||
|
if($value['type']==2){
|
|||
|
//商家联
|
|||
|
if($value['pattern']==1){
|
|||
|
$content=self::cashFei($order,$note,$display,$qrContent,$value['pattern']);
|
|||
|
//var_dump($content);die;
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
//顾客联
|
|||
|
if($value['pattern']==2){
|
|||
|
$content=self::cashFei($order,$note,$display,$qrContent,$value['pattern']);
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//收银易联云打印内容
|
|||
|
static function cashYi($order,$note,$display,$qrContent,$pattern) {
|
|||
|
$store=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where('id=:id',[':id'=>$order['storeId']])->one();
|
|||
|
$userInfo=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_member}}')
|
|||
|
->where('id=:id',[':id'=>$order['userId']])->one();
|
|||
|
$payType = '微信支付';
|
|||
|
switch ($order['payMode']) {
|
|||
|
case 2:
|
|||
|
$payType = '支付宝支付';
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
$payType = '余额支付';
|
|||
|
break;
|
|||
|
case 10:
|
|||
|
$payType = '货到付款';
|
|||
|
break;
|
|||
|
}
|
|||
|
$patternContent='商家联';
|
|||
|
if($pattern==2){
|
|||
|
$patternContent='顾客联';
|
|||
|
}
|
|||
|
//$system=Config::getSystemSet('print',$order['uniacid']);
|
|||
|
$content= "<FS2><center>当面付小票</center></FS2>\n";
|
|||
|
$content .= "<center>*" . $store['name'] . "*</center>\n";
|
|||
|
$content .= "用户信息:" .$userInfo['userName']."(UID:".$userInfo['id'] .")\n";
|
|||
|
$content .= "支付方式:" . $payType . "\n";
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= "订单编号:" . $order['outTradeNo'] . "\n";
|
|||
|
$content .= "交易时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<FB><FS>备注:" . $order['userNote'] . "</FB></FS>\n\n";
|
|||
|
}
|
|||
|
$content .= "<FS2>实付:¥" . $order['money'] . "</FS2>\n\n";
|
|||
|
if($note){
|
|||
|
$content .= "<center>" . $note . "</center>\n";
|
|||
|
}
|
|||
|
$content .= "<center>门店电话:" . $store['storeTel'] . "</center>\n\n";
|
|||
|
if($display==1) {
|
|||
|
$content .= "<QR>" . $qrContent . "</QR>";
|
|||
|
}
|
|||
|
$content .= "<FS2><center>----" . $patternContent . "----</center></FS2>\n";
|
|||
|
return $content;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//收银飞蛾打印内容
|
|||
|
static function cashFei($order,$note,$display,$qrContent,$pattern) {
|
|||
|
$store=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where('id=:id',[':id'=>$order['storeId']])->one();
|
|||
|
$userInfo=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_member}}')
|
|||
|
->where('id=:id',[':id'=>$order['userId']])->one();
|
|||
|
switch ($order['payMode']) {
|
|||
|
case 2:
|
|||
|
$payType = '支付宝支付';
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
$payType = '余额支付';
|
|||
|
break;
|
|||
|
case 10:
|
|||
|
$payType = '货到付款';
|
|||
|
break;
|
|||
|
}
|
|||
|
$patternContent='商家联';
|
|||
|
if($pattern==2){
|
|||
|
$patternContent='顾客联';
|
|||
|
}
|
|||
|
//$system=Config::getSystemSet('print',$order['uniacid']);
|
|||
|
$content= "<CB>当面付小票</CB><BR>";
|
|||
|
$content .= "<C>*" . $store['name'] . "*</C><BR>";
|
|||
|
$content .= "用户信息:" .$userInfo['userName']."(UID:".$userInfo['id'] .")<BR>";
|
|||
|
$content .= "支付方式:" . $payType . "<BR>";
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "订单编号:" . $order['outTradeNo'] . "<BR>";
|
|||
|
$content .= "交易时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "<BR>";
|
|||
|
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<BOLD>备注:" . $order['userNote'] . "</BOLD><BR><BR>";
|
|||
|
}
|
|||
|
$content .= "<L><BOLD>实付:¥" . $order['money'] . "</BOLD></L><BR><BR>";
|
|||
|
if($note){
|
|||
|
$content .= "<C>" . $note . "</C><BR>";
|
|||
|
}
|
|||
|
$content .= "<C>门店电话:" . $store['storeTel'] . "</C><BR>";
|
|||
|
if($display==1) {
|
|||
|
$content .= "<QR>" . $qrContent . "</QR>";
|
|||
|
}
|
|||
|
$content .= "<CB>----" . $patternContent . "----</CB>\n";
|
|||
|
//var_dump($content);die;
|
|||
|
return $content;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//整单打印或一菜一单内容
|
|||
|
static function instoreAllContent($orderId,$type=1,$printMode=1,$note=null,$display=null,$qrContent=null,$goodsId=null,$pattern=null){
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_instore_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$store=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where('id=:id',[':id'=>$order['storeId']])->one();
|
|||
|
if($goodsId){
|
|||
|
$goods = (new \yii\db\Query())
|
|||
|
->from('{{%ybwm_order_goods}}')
|
|||
|
->where(['in','id',$goodsId])->All();
|
|||
|
}else {
|
|||
|
$goods = (new \yii\db\Query())
|
|||
|
->from('{{%ybwm_order_goods}}')
|
|||
|
->where(' orderId=:orderId AND addType<3 AND item !=1', [':orderId' => $orderId])->All();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($printMode==1) {
|
|||
|
if ($type == 1) {
|
|||
|
// var_dump($goods);die;
|
|||
|
$content = self::yiInAllContent($order, $store, $goods,$note,$display,$qrContent,$goodsId,$pattern);
|
|||
|
return $content;
|
|||
|
}
|
|||
|
if ($type == 2) {
|
|||
|
|
|||
|
$content = self::feiInAllContent($order, $store, $goods,$note,$display,$qrContent,$goodsId,$pattern);
|
|||
|
return $content;
|
|||
|
}
|
|||
|
if ($type == 3) {
|
|||
|
$data['order']=$order;
|
|||
|
$data['store']=$store;
|
|||
|
$data['goods']=$goods;
|
|||
|
return $data;
|
|||
|
}
|
|||
|
}elseif($printMode==3){//一菜一单
|
|||
|
$data['order']=$order;
|
|||
|
$data['store']=$store;
|
|||
|
$data['goods']=$goods;
|
|||
|
return $data;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//分组打印或标签打印内容
|
|||
|
static function typeInContent($orderId,$type=1,$printMode=1,$json,$goodsId=null){
|
|||
|
$categoryArr = json_decode($json);
|
|||
|
$categoryStr = implode(',', $categoryArr)?:[];
|
|||
|
$where='a.orderId=:orderId';
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_instore_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$store=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where('id=:id',[':id'=>$order['storeId']])->one();
|
|||
|
if($printMode==2 AND $categoryStr){
|
|||
|
$where .=" and item!=1 and b.typePid in ($categoryStr)";
|
|||
|
}elseif ($printMode==4 AND $categoryStr){
|
|||
|
$where .=" and item !=1 and b.printLabel in ($categoryStr)";
|
|||
|
}
|
|||
|
if($goodsId){
|
|||
|
$goods = (new \yii\db\Query())
|
|||
|
->select(['a.*', 'b.typePid'])
|
|||
|
->from('{{%ybwm_order_goods}} as a')
|
|||
|
->join('LEFT JOIN', '{{%ybwm_core_goods}} as b', 'a.goodsId=b.id')
|
|||
|
->where($where, [':orderId' => $orderId])
|
|||
|
->andWhere( ['in','a.id', $goodsId])
|
|||
|
->all();
|
|||
|
}else {
|
|||
|
//echo $categoryStr;die;
|
|||
|
$goods = (new \yii\db\Query())
|
|||
|
->select(['a.*', 'b.typePid'])
|
|||
|
->from('{{%ybwm_order_goods}} as a')
|
|||
|
->join('LEFT JOIN', '{{%ybwm_core_goods}} as b', 'a.goodsId=b.id')
|
|||
|
->where($where, [':orderId' => $orderId])
|
|||
|
->all();
|
|||
|
}
|
|||
|
|
|||
|
if(!$goods){
|
|||
|
return false;
|
|||
|
}
|
|||
|
//var_dump($goods);die;
|
|||
|
if ($type == 1) {
|
|||
|
$content = self::yiTypeInContent($order, $store, $goods);
|
|||
|
return $content;
|
|||
|
}elseif ($type == 2) {
|
|||
|
$content = self::feiTypeInContent($order, $store, $goods);
|
|||
|
return $content;
|
|||
|
}elseif ($type == 3){
|
|||
|
$data['order']=$order;
|
|||
|
$data['store']=$store;
|
|||
|
$data['goods']=$goods;
|
|||
|
return $data;
|
|||
|
}
|
|||
|
}
|
|||
|
static function yiTypeInContent(array $order,array $store,array $goods){
|
|||
|
if($order['orderMode']==1){
|
|||
|
$content= "<FS2><center>台号:" . $order['number'] . "</center></FS2>\n";
|
|||
|
$timeStr="开台时间:";
|
|||
|
}else{
|
|||
|
$content= "<FS2><center>取餐码:" . $order['callNo'] . "</center></FS2>\n";
|
|||
|
$timeStr="下单时间:";
|
|||
|
}
|
|||
|
|
|||
|
$content .= "<center>*" . $store['name'] . "*</center>\n";
|
|||
|
if($order['orderMode']==1){
|
|||
|
$tableName = $order['regionName'] . ' ' . $order['typeName'] . ' ' . $order['people'] . '人';
|
|||
|
$content .= "餐桌信息:" . $tableName . "\n";
|
|||
|
}else {
|
|||
|
if ($order['isOut'] == 1) {
|
|||
|
$eatType = '店内就餐';
|
|||
|
} else {
|
|||
|
$eatType = '打包带走';
|
|||
|
}
|
|||
|
$content .= "取单方式:" . $eatType . "\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= "订单编号:" . $order['outTradeNo'] . "\n";
|
|||
|
$content .= $timeStr . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<FB>备注:" . $order['userNote'] . "</FB>\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
|
|||
|
$content .= '名称' . str_repeat(" ", 12) . "数量 单价\n";
|
|||
|
$content .= "<FS><table>";
|
|||
|
foreach ($goods as $key => $value) {
|
|||
|
$name = $value['name'];
|
|||
|
if ($value['data']) {
|
|||
|
$name = $value['name'] . '(' . $value['data'] . ')';
|
|||
|
}
|
|||
|
if ($value['attribute']) {
|
|||
|
$name = $name . '(' . $value['attribute'] . ')';
|
|||
|
}
|
|||
|
if ($value['material']) {
|
|||
|
/* $material = json_decode($value['material'], true);
|
|||
|
$mes = '';
|
|||
|
foreach ($material as $v) {
|
|||
|
$mes .= $v['name'] . '(' . $v['number'] . '),';
|
|||
|
}*/
|
|||
|
$name = $name . '(' . $value['material'] . ')';
|
|||
|
}
|
|||
|
if ($value['vipMoney'] > 0) {
|
|||
|
$value['money'] = $value['vipMoney'];
|
|||
|
}
|
|||
|
$content .= "<tr><td>" . $name . "</td><td>" . $value['num'] . "</td><td> " . $value['money'] . "</td></tr>";
|
|||
|
}
|
|||
|
$content .= "</table></FS>\n";
|
|||
|
$content .= "<FS2><center>----#" . $order['takeNo'] . "完----</center></FS2>\n";
|
|||
|
return $content;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
static function feiTypeInContent(array $order,array $store,array $goods,$note=null){
|
|||
|
|
|||
|
$payType = '微信支付';
|
|||
|
switch ($order['payMode']) {
|
|||
|
case 2:
|
|||
|
$payType = '支付宝支付';
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
$payType = '余额支付';
|
|||
|
break;
|
|||
|
case 10:
|
|||
|
$payType = '货到付款';
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
if($order['orderMode']==1){
|
|||
|
$content= "<CB>台号:" . $order['number'] . "</CB><BR>";
|
|||
|
$timeStr="开台时间:";
|
|||
|
}else{
|
|||
|
$content= "<CB>取餐码:" . $order['callNo'] . "</CB><BR>";
|
|||
|
$timeStr="下单时间:";
|
|||
|
}
|
|||
|
$content .= "<C>*" . $store['name'] . "*</C><BR>";
|
|||
|
if($order['orderMode']==1){
|
|||
|
$tableName = $order['regionName'] . ' ' . $order['typeName'] . ' ' . $order['people'] . '人';
|
|||
|
$content .= "餐桌信息:" . $tableName . "<BR>";
|
|||
|
}else {
|
|||
|
if ($order['isOut'] == 1) {
|
|||
|
$eatType = '店内就餐';
|
|||
|
} else {
|
|||
|
$eatType = '打包带走';
|
|||
|
}
|
|||
|
$content .= "取单方式:" . $eatType . "<BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "订单号:" . $order['outTradeNo'] . "<BR>";
|
|||
|
$content .= $timeStr . date('Y-m-d H:i:s', $order['createdAt']) . "<BR>";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<BOLD>备注:" . $order['userNote'] . "</BOLD><BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "名称 数量 单价<BR>";
|
|||
|
$content .= "<L><BOLD>".self::feiStyle($goods)."</BOLD></L>";
|
|||
|
if($note){
|
|||
|
$content .= "<C>" . $note . "</C>\n";
|
|||
|
}
|
|||
|
$content .= "<C>门店电话:" . $store['storeTel'] . "</C>\n\n";
|
|||
|
$content .= "<B><C>----#" . $order['takeNo'] . "完----</C></B>\n";
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
static function yiOneInContent(array $order,array $store,array $goods,$note=null){
|
|||
|
if($order['orderMode']==1){
|
|||
|
$content= "<FS2><center>台号:" . $order['number'] . "</center></FS2>\n";
|
|||
|
$timeStr="开台时间:";
|
|||
|
}else{
|
|||
|
$content= "<FS2><center>取餐码:" . $order['callNo'] . "</center></FS2>\n";
|
|||
|
$timeStr="下单时间:";
|
|||
|
}
|
|||
|
$content .= "<center>*" . $store['name'] . "*</center>\n";
|
|||
|
if($order['orderMode']==1){
|
|||
|
$tableName = $order['regionName'] . ' ' . $order['typeName'] . ' ' . $order['people'] . '人';
|
|||
|
$content .= "餐桌信息:" . $tableName . "\n";
|
|||
|
}else {
|
|||
|
if ($order['isOut'] == 1) {
|
|||
|
$eatType = '店内就餐';
|
|||
|
} else {
|
|||
|
$eatType = '打包带走';
|
|||
|
}
|
|||
|
$content .= "取单方式:" . $eatType . "\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= "订单号:" . $order['outTradeNo'] . "\n";
|
|||
|
$content .= $timeStr . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<FB>备注:" . $order['userNote'] . "</FB>\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= '名称' . str_repeat(" ", 12) . "数量 单价\n";
|
|||
|
$content .= "<FS><table>";
|
|||
|
$name = $goods['name'];
|
|||
|
if ($goods['data']) {
|
|||
|
$name = $goods['name'] . '(' . $goods['data'] . ')';
|
|||
|
}
|
|||
|
if ($goods['attribute']) {
|
|||
|
$name = $name . '(' . $goods['attribute'] . ')';
|
|||
|
}
|
|||
|
if ($goods['material']) {
|
|||
|
/* $material = json_decode($goods['material'], true);
|
|||
|
$mes = '';
|
|||
|
foreach ($material as $v) {
|
|||
|
$mes .= $v['name'] . '(' . $v['number'] . '),';
|
|||
|
}*/
|
|||
|
$name = $name . '(' . $goods['material'] . ')';
|
|||
|
}
|
|||
|
if ($goods['vipMoney'] > 0) {
|
|||
|
$value['money'] = $goods['vipMoney'];
|
|||
|
}
|
|||
|
$content .= "<tr><td>" . $name . "</td><td>" . $goods['num'] . "</td><td> " . $goods['money'] . "</td></tr>";
|
|||
|
$content .= "</table></FS>\n";
|
|||
|
if($note){
|
|||
|
$content .= "<center>" . $note . "</center>\n";
|
|||
|
}
|
|||
|
$content .= "<FS2><center>----#" . $order['takeNo'] . "完----</center></FS2>\n";
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
static function feiOneInContent(array $order,array $store,array $goods,$note=null){
|
|||
|
$goodsInfo[]=$goods;
|
|||
|
if($order['orderMode']==1){
|
|||
|
$content= "<CB>台号:" . $order['number'] . "</CB><BR>";
|
|||
|
$timeStr="开台时间:";
|
|||
|
}else{
|
|||
|
$content= "<CB>取餐码:" . $order['callNo'] . "</CB><BR>";
|
|||
|
$timeStr="下单时间:";
|
|||
|
}
|
|||
|
$content .= "<C>*" . $store['name'] . "*</C><BR>";
|
|||
|
if($order['orderMode']==1){
|
|||
|
$tableName = $order['regionName'] . ' ' . $order['typeName'] . ' ' . $order['people'] . '人';
|
|||
|
$content .= "餐桌信息:" . $tableName . "<BR>";
|
|||
|
}else {
|
|||
|
if ($order['isOut'] == 1) {
|
|||
|
$eatType = '店内就餐';
|
|||
|
} else {
|
|||
|
$eatType = '打包带走';
|
|||
|
}
|
|||
|
$content .= "取单方式:" . $eatType . "<BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "订单号:" . $order['outTradeNo'] . "<BR>";
|
|||
|
$content .= $timeStr. date('Y-m-d H:i:s', $order['createdAt']) . "<BR>";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<BOLD>备注:" . $order['userNote'] . "</BOLD><BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "名称 数量 单价<BR>";
|
|||
|
$content .= "<L><BOLD>".self::feiStyle($goodsInfo)."</BOLD></L>";
|
|||
|
|
|||
|
if($note){
|
|||
|
$content .= "<C>" . $note . "</C>\n";
|
|||
|
}
|
|||
|
//$content .= "<C>门店电话:" . $store['storeTel'] . "</C>\n\n";
|
|||
|
$content .= "<B><C>----#" . $order['takeNo'] . "完----</C></B>\n";
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
//易联云整单
|
|||
|
static function yiInAllContent(array $order,array $store,array $goods,$note=null,$display=null,$qrContent=null,$goodsId=null,$pattern=null){
|
|||
|
// var_dump($goodss);die;
|
|||
|
$payType = '微信支付';
|
|||
|
switch ($order['payMode']) {
|
|||
|
case 2:
|
|||
|
$payType = '支付宝支付';
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
$payType = '余额支付';
|
|||
|
break;
|
|||
|
case 10:
|
|||
|
$payType = '货到付款';
|
|||
|
break;
|
|||
|
}
|
|||
|
$orderPay="未支付";
|
|||
|
if($order['payAt']>0){
|
|||
|
$orderPay="已支付";
|
|||
|
}
|
|||
|
if($order['orderMode']==1){
|
|||
|
$content= "<FS2><center>台号:" . $order['number'] . "</center></FS2>\n";
|
|||
|
$timeStr="开台时间:";
|
|||
|
}else{
|
|||
|
$content= "<FS2><center>取餐码:" . $order['callNo'] . "</center></FS2>\n";
|
|||
|
$timeStr="下单时间:";
|
|||
|
|
|||
|
}
|
|||
|
$content .= "<center>*" . $store['name'] . "*</center>\n";
|
|||
|
if($goodsId){
|
|||
|
$num=$goods[0]['addNum']?:1;
|
|||
|
$content.= "<FS><center>[加菜" . $num . "]</center></FS>\n";
|
|||
|
}
|
|||
|
if($order['orderMode']==1){
|
|||
|
$tableName = $order['regionName'] . ' ' . $order['typeName'] . ' ' . $order['people'] . '人';
|
|||
|
$content .= "餐桌信息:" . $tableName . "\n";
|
|||
|
}else {
|
|||
|
if ($order['isOut'] == 1) {
|
|||
|
$eatType = '店内就餐';
|
|||
|
} else {
|
|||
|
$eatType = '打包带走';
|
|||
|
}
|
|||
|
$content .= "取单方式:" . $eatType . "\n";
|
|||
|
}
|
|||
|
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
|
|||
|
$content .= "订单号:" . $order['outTradeNo'] . "\n";
|
|||
|
$content .= $timeStr . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<FB>备注:" . $order['userNote'] . "</FB>\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= '名称' . str_repeat(" ", 12) . "数量 单价\n";
|
|||
|
$content .= "<FS><table>";
|
|||
|
foreach ($goods as $key => $value) {
|
|||
|
|
|||
|
$name = $value['name'];
|
|||
|
if ($value['data']) {
|
|||
|
$name = $value['name'] . '(' . $value['data'] . ')';
|
|||
|
}
|
|||
|
if ($value['attribute']) {
|
|||
|
$name = $name . '(' . $value['attribute'] . ')';
|
|||
|
}
|
|||
|
if ($value['material']) {
|
|||
|
|
|||
|
/* $material = json_decode($value['material'], true);
|
|||
|
$mes = '';
|
|||
|
foreach ($material as $v) {
|
|||
|
$mes .= $v['name'] . '(' . $v['number'] . '),';
|
|||
|
}*/
|
|||
|
$name = $name . '(' . $value['material'] . ')';
|
|||
|
}
|
|||
|
if ($value['vipMoney'] > 0) {
|
|||
|
$value['money'] = $value['vipMoney'];
|
|||
|
}
|
|||
|
$content .= "<tr><td>" . $name . "</td><td>" . $value['num'] . "</td><td> " . $value['money'] . "</td></tr>";
|
|||
|
}
|
|||
|
$content .= "</table></FS>\n";
|
|||
|
if(!$goodsId) {
|
|||
|
$content .= "<table><tr><td>合计:</td><td>" . $order['goodsNum'] . "</td><td> " . $order['originMoney'] . "</td></tr></table>";
|
|||
|
$content .= "<center>----------其它费用----------</center>\n";
|
|||
|
if ($order['deliveryMoney'] > 0) {
|
|||
|
$content .= "[配送费:+" . $order['deliveryMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['tablewareMoney'] > 0) {
|
|||
|
$content .= "[餐桌费:+" . $order['tablewareMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['preferentialMoney'] > 0) {
|
|||
|
$content .= "[满减优惠:-" . $order['preferentialMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['platformCouponPreferential'] > 0) {
|
|||
|
$content .= "[平台优惠券优惠:-" . $order['platformCouponPreferential'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['couponPreferential'] > 0) {
|
|||
|
$content .= "[优惠券优惠:-" . $order['couponPreferential'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['newMoney'] > 0) {
|
|||
|
$content .= "[新客立减:-" . $order['newMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['deliveryPreferential'] > 0) {
|
|||
|
$content .= "[减免配送费:-" . $order['deliveryPreferential'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['giveName']) {
|
|||
|
$content .= "[赠送:-" . $order['giveName'] . "]\n";
|
|||
|
}
|
|||
|
$content .= "<FS>应付:¥" . $order['money'] ."(".$orderPay.")". "</FS>\n";
|
|||
|
if ($note) {
|
|||
|
$content .= "<center>" . $note . "</center>\n";
|
|||
|
}
|
|||
|
$content .= "<center>门店电话:" . $store['storeTel'] . "</center>\n\n";
|
|||
|
if ($display == 1) {
|
|||
|
$content .= "<QR>" . $qrContent . "</QR>";
|
|||
|
}
|
|||
|
$content .= "<FS2><center>----#" . $order['takeNo'] . "完----</center></FS2>\n";
|
|||
|
}
|
|||
|
//var_dump($content);die;
|
|||
|
return $content;
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
static function feiInAllContent(array $order,array $store,array $goods,$note=null,$display=null,$qrContent=null,$goodsId=null,$pattern){
|
|||
|
|
|||
|
$payType = '微信支付';
|
|||
|
switch ($order['payMode']) {
|
|||
|
case 2:
|
|||
|
$payType = '支付宝支付';
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
$payType = '余额支付';
|
|||
|
break;
|
|||
|
case 10:
|
|||
|
$payType = '货到付款';
|
|||
|
break;
|
|||
|
}
|
|||
|
$orderPay="未支付";
|
|||
|
if($order['payAt']>0){
|
|||
|
$orderPay="已支付";
|
|||
|
}
|
|||
|
if($order['orderMode']==1){
|
|||
|
$content= "<CB>台号:" . $order['number'] . "</CB><BR>";
|
|||
|
$timeStr="开台时间:";
|
|||
|
}else{
|
|||
|
$content= "<CB>取餐码:" . $order['callNo'] . "</CB><BR>";
|
|||
|
$timeStr="下单时间:";
|
|||
|
}
|
|||
|
|
|||
|
$content .= "<C>*" . $store['name'] . "*</C><BR>";
|
|||
|
if($goodsId){
|
|||
|
$num=$goods[0]['addNum']?:1;
|
|||
|
$content.= "<CB>[加菜" . $num . "]</CB><BR>";
|
|||
|
}
|
|||
|
if($order['orderMode']==1){
|
|||
|
$tableName = $order['regionName'] . ' ' . $order['typeName'] . ' ' . $order['people'] . '人';
|
|||
|
$content .= "餐桌信息:" . $tableName . "<BR>";
|
|||
|
}else {
|
|||
|
if ($order['isOut'] == 1) {
|
|||
|
$eatType = '店内就餐';
|
|||
|
} else {
|
|||
|
$eatType = '打包带走';
|
|||
|
}
|
|||
|
$content .= "取单方式:" . $eatType . "<BR>";
|
|||
|
}
|
|||
|
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
|
|||
|
$content .= "订单号:" . $order['outTradeNo'] . "<BR>";
|
|||
|
$content .= $timeStr. date('Y-m-d H:i:s', $order['createdAt']) . "<BR>";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<BOLD>备注:" . $order['userNote'] . "</BOLD><BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "名称 数量 单价<BR>";
|
|||
|
$content .= "<L><BOLD>".self::feiStyle($goods)."</BOLD></L>";
|
|||
|
if(!$goodsId) {
|
|||
|
$content .= self::feiStyle(['0' => ['name' => '合计', 'num' => $order['goodsNum'], 'money' => $order['originMoney']]]);
|
|||
|
$content .= "<C>----------其它费用----------</C>\n";
|
|||
|
if ($order['deliveryMoney'] > 0) {
|
|||
|
$content .= "配送费:" . $order['deliveryMoney'] . "<BR>";
|
|||
|
}
|
|||
|
if ($order['tablewareMoney'] > 0) {
|
|||
|
$content .= "[餐桌费:+" . $order['tablewareMoney'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['preferentialMoney'] > 0) {
|
|||
|
$content .= "[满减优惠:-" . $order['preferentialMoney'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['platformCouponPreferential'] > 0) {
|
|||
|
$content .= "[平台优惠券优惠:-" . $order['platformCouponPreferential'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['couponPreferential'] > 0) {
|
|||
|
$content .= "[优惠券优惠:-" . $order['couponPreferential'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['newMoney'] > 0) {
|
|||
|
$content .= "[新客立减:-" . $order['newMoney'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['deliveryPreferential'] > 0) {
|
|||
|
$content .= "[减免配送费:-" . $order['deliveryPreferential'] . "]<BR>";
|
|||
|
}
|
|||
|
if ($order['giveName']) {
|
|||
|
$content .= "[赠送:" . $order['giveName'] . "]<BR>";
|
|||
|
}
|
|||
|
$content .= "<L><BOLD>应付:¥" . $order['money']."(".$orderPay.")</BOLD></L><BR><BR>";
|
|||
|
if ($note) {
|
|||
|
$content .= "<C>" . $note . "</C><BR>";
|
|||
|
}
|
|||
|
$content .= "<C>门店电话:" . $store['storeTel'] . "</C><BR>";
|
|||
|
if ($display == 1) {
|
|||
|
$content .= "<QR>" . $qrContent . "</QR>";
|
|||
|
}
|
|||
|
$content .= "<BOLD><C>----#" . $order['takeNo'] . "完----</C></BOLD>\n";
|
|||
|
}
|
|||
|
return $content;
|
|||
|
}
|
|||
|
|
|||
|
//快餐订单打印
|
|||
|
public static function instoreOrderPrint($orderId,$support=3,$goodsId=null,$modePrint=true){
|
|||
|
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_instore_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$query=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('deleteAt=0 AND display=1 AND uniacid=:uniacid AND storeId=:storeId AND support=:support',[':uniacid'=>$order['uniacid'],':storeId'=>$order['storeId'],'support'=>$support]);
|
|||
|
if($support==2){
|
|||
|
$tableInfo=(new \yii\db\Query())->select('areaId')
|
|||
|
->from('{{%ybwm_table}}')
|
|||
|
->where('id=:id',[':id'=>$order['tableId']])->one();
|
|||
|
$areaId=$tableInfo['areaId'];
|
|||
|
// $query=$query->andWhere(['like','areaId',$areaId]);
|
|||
|
//如果是加菜
|
|||
|
if($goodsId){
|
|||
|
$query=$query->andWhere(['and',['in','pattern',[1,3]],['like','printMode2',1]]);
|
|||
|
}
|
|||
|
}
|
|||
|
$print=$query->All();
|
|||
|
|
|||
|
if (!$print) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
$systemSet=Config::getSystemSet('print',$order['uniacid']);
|
|||
|
|
|||
|
foreach ($print as $value){
|
|||
|
|
|||
|
$rst=json_decode($value['data'],true);
|
|||
|
//易联云
|
|||
|
if($value['type']==1){
|
|||
|
$dynum=$rst['wmnum']?:1;
|
|||
|
$note=$systemSet['sjlNote']?:'';
|
|||
|
$display=$systemSet['display']?:2;
|
|||
|
$qrContent=$systemSet['codeUrl']?:'';
|
|||
|
|
|||
|
//商家联
|
|||
|
if($value['pattern']==1){
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
|
|||
|
$content=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note,$display,$qrContent,$goodsId);
|
|||
|
//var_dump($content);die;
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
//一菜一单
|
|||
|
if($value['printMode']==3){
|
|||
|
$note=$systemSet['oneNote']?:'';
|
|||
|
$info=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note,0,0,$goodsId);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::yiOneInContent($info['order'], $info['store'], $value,$note);
|
|||
|
// var_dump($content);die;
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//顾客联
|
|||
|
if($value['pattern']==2){
|
|||
|
$content=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note,$display,0,$goodsId);
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
//厨房联
|
|||
|
if($value['pattern']==3&&$modePrint){
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
$content=self::instoreAllContent($orderId,$value['type'],$value['printMode'],0,0,0,$goodsId,$value['pattern']);
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
//分组打印
|
|||
|
if($value['printMode']==2){
|
|||
|
$content=self::typeInContent($orderId,$value['type'],$value['printMode'],$value['categoryIds'],$goodsId);
|
|||
|
if(!$content){
|
|||
|
continue;
|
|||
|
}
|
|||
|
if($value['printModeType']==2){
|
|||
|
$info=self::typeInContent($orderId,3,$value['printMode'],$value['categoryIds'],$goodsId);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::yiOneInContent($info['order'], $info['store'], $value,$note);
|
|||
|
//var_dump($content);die;
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
}else{
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//一菜一单
|
|||
|
if($value['printMode']==3){
|
|||
|
$note=$systemSet['oneNote']?:'';
|
|||
|
$info=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note,0,0,$goodsId);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::yiOneInContent($info['order'], $info['store'], $value,$note);
|
|||
|
// var_dump($content);die;
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
//标签打印
|
|||
|
if($value['printMode']==4){
|
|||
|
$content=self::typeInContent($orderId,$value['type'],$value['printMode'],$value['label'],$goodsId);
|
|||
|
|
|||
|
if(!$content){
|
|||
|
continue;
|
|||
|
}
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//飞蛾云
|
|||
|
if($value['type']==2){
|
|||
|
|
|||
|
$note=$systemSet['gklNote']?:'';
|
|||
|
$display=$systemSet['display2']?:2;
|
|||
|
$qrContent=$systemSet['codeUrl2']?:'';
|
|||
|
|
|||
|
// file_put_contents('1.txt', $value['printMode']);
|
|||
|
//商家联
|
|||
|
if($value['pattern']==1){
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
|
|||
|
$content=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note,$display,$qrContent,$goodsId);
|
|||
|
// var_dump($content);die;
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
//一菜一单
|
|||
|
if($value['printMode']==3){
|
|||
|
$note=$systemSet['oneNote']?:'';
|
|||
|
$info=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note,0,0,$goodsId);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::feiOneInContent($info['order'], $info['store'], $value,$note);
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//顾客联
|
|||
|
if($value['pattern']==2){
|
|||
|
$content=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note,$display,$qrContent,$goodsId);
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
//厨房联
|
|||
|
if($value['pattern']==3&&$modePrint){
|
|||
|
|
|||
|
//整单打印
|
|||
|
if($value['printMode']==1){
|
|||
|
$content=self::instoreAllContent($orderId,$value['type'],$value['printMode'],0,0,0,$goodsId);
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
//分组打印
|
|||
|
if($value['printMode']==2){
|
|||
|
|
|||
|
$content=self::typeInContent($orderId,$value['type'],$value['printMode'],$value['categoryIds']);
|
|||
|
//var_dump($content);die;
|
|||
|
if(!$content){
|
|||
|
continue;
|
|||
|
}
|
|||
|
if($value['printModeType']==2){
|
|||
|
$info=self::typeInContent($orderId,3,$value['printMode'],$value['categoryIds'],$goodsId);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::feiOneInContent($info['order'], $info['store'], $value,$note);
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
}else {
|
|||
|
self::feiPrint($rst, $content);
|
|||
|
}
|
|||
|
}
|
|||
|
//一菜一单
|
|||
|
if($value['printMode']==3){
|
|||
|
$note=$systemSet['oneNote']?:'';
|
|||
|
//$info=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note);
|
|||
|
$info=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note,0,0,$goodsId);
|
|||
|
foreach ($info['goods'] as $value){
|
|||
|
$content = self::feiOneInContent($info['order'], $info['store'], $value,$note);
|
|||
|
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
//标签打印
|
|||
|
if($value['printMode']==4){
|
|||
|
$content=self::typeInContent($orderId,$value['type'],$value['printMode'],$value['label'],$goodsId);
|
|||
|
// var_dump($content);die;
|
|||
|
if(!$content){
|
|||
|
continue;
|
|||
|
}
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
//飞蛾标签打印机
|
|||
|
if(($value['type']==3&&$modePrint) or($value['type']==3&&!$modePrint&&$value['pattern']!=3)){
|
|||
|
$info=self::instoreAllContent($orderId,$value['type'],$value['printMode'],$note='',0,0,$goodsId);
|
|||
|
if($value['printMode']==2){
|
|||
|
$info=self::typeInContent($orderId,$value['type'],$value['printMode'],$value['categoryIds']);
|
|||
|
}
|
|||
|
if($value['printMode']==4 ){
|
|||
|
$info=self::typeInContent($orderId,$value['type'],$value['printMode'],$value['label'],$goodsId);
|
|||
|
}
|
|||
|
$goods=$info['goods'];
|
|||
|
$orderNum=0;
|
|||
|
foreach ($goods as $key => $value) {
|
|||
|
$orderNum+=$value['num'];
|
|||
|
if($value['num']>1){
|
|||
|
for ($i=0; $i <$value['num'] ; $i++) {
|
|||
|
if($i>0){
|
|||
|
array_push($goods,$value);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
foreach ($goods as $key=>$value){
|
|||
|
$num=$key+1;
|
|||
|
$content = self::labelAllContent($info['order'], $info['store'], $value,$num,['orderType'=>$order['orderMode'],'isOut'=>$order['isOut']]);
|
|||
|
// var_dump($content);die;
|
|||
|
self::labelPrint($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
static function instoreCashierContent($orderId,$type=1){
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_instore_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$store=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where('id=:id',[':id'=>$order['storeId']])->one();
|
|||
|
$goods = (new \yii\db\Query())
|
|||
|
->from('{{%ybwm_order_goods}}')
|
|||
|
->where(' orderId=:orderId AND item=2 and addType=3', [':orderId' => $orderId])->All();
|
|||
|
// return $goods;
|
|||
|
// var_dump($goodss);die;
|
|||
|
$payType = '微信支付';
|
|||
|
switch ($order['payMode']) {
|
|||
|
case 2:
|
|||
|
$payType = '支付宝支付';
|
|||
|
break;
|
|||
|
case 5:
|
|||
|
$payType = '余额支付';
|
|||
|
break;
|
|||
|
case 10:
|
|||
|
$payType = '货到付款';
|
|||
|
break;
|
|||
|
}
|
|||
|
if($type==1){
|
|||
|
if($order['orderMode']==1){
|
|||
|
$content= "<FS2><center>台号:" . $order['number'] . "</center></FS2>\n";
|
|||
|
$timeStr="开台时间:";
|
|||
|
}else{
|
|||
|
$content= "<FS2><center>取餐码:" . $order['callNo'] . "</center></FS2>\n";
|
|||
|
$timeStr="下单时间:";
|
|||
|
|
|||
|
}
|
|||
|
$content .= "<center>*" . $store['name'] . "*</center>\n";
|
|||
|
$content.= "<FS><center>[退菜]</center></FS>\n";
|
|||
|
if($order['orderMode']==1){
|
|||
|
$tableName = $order['regionName'] . ' ' . $order['typeName'] . ' ' . $order['people'] . '人';
|
|||
|
$content .= "餐桌信息:" . $tableName . "\n";
|
|||
|
}else {
|
|||
|
if ($order['deliveryMode'] == 10 and $order['isOut'] == 1) {
|
|||
|
$eatType = '店内就餐';
|
|||
|
} else {
|
|||
|
$eatType = '打包带走';
|
|||
|
}
|
|||
|
$content .= "取单方式:" . $eatType . "\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= "订单编号:" . $order['outTradeNo'] . "\n";
|
|||
|
$content .= $timeStr . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<FB>备注:" . $order['userNote'] . "</FB>\n";
|
|||
|
}
|
|||
|
$content .= "--------------------------------\n";
|
|||
|
$content .= '名称' . str_repeat(" ", 12) . "数量 单价\n";
|
|||
|
$content .= "<table>";
|
|||
|
foreach ($goods as $key => $value) {
|
|||
|
$name = $value['name'];
|
|||
|
if ($value['data']) {
|
|||
|
$name = $value['name'] . '(' . $value['data'] . ')';
|
|||
|
}
|
|||
|
if ($value['attribute']) {
|
|||
|
$name = $name . '(' . $value['attribute'] . ')';
|
|||
|
}
|
|||
|
if ($value['material']) {
|
|||
|
|
|||
|
/* $material = json_decode($value['material'], true);
|
|||
|
$mes = '';
|
|||
|
foreach ($material as $v) {
|
|||
|
$mes .= $v['name'] . '(' . $v['number'] . '),';
|
|||
|
}*/
|
|||
|
$name = $name . '(' . $value['material'] . ')';
|
|||
|
}
|
|||
|
if ($value['vipMoney'] > 0) {
|
|||
|
$value['money'] = $value['vipMoney'];
|
|||
|
}
|
|||
|
|
|||
|
$content .= "<tr><td>" . $name . "</td><td>" . $value['num'] . "</td><td> " . $value['money'] . "</td></tr>";
|
|||
|
}
|
|||
|
$content .= "</table>\n";
|
|||
|
|
|||
|
|
|||
|
}else{
|
|||
|
if($order['orderMode']==1){
|
|||
|
$content= "<CB>台号:" . $order['number'] . "</CB><BR>";
|
|||
|
$timeStr="开台时间:";
|
|||
|
}else{
|
|||
|
$content= "<CB>取餐码:" . $order['callNo'] . "</CB><BR>";
|
|||
|
$timeStr="下单时间:";
|
|||
|
}
|
|||
|
$content .= "<C>*" . $store['name'] . "*</C><BR>";
|
|||
|
$content.= "<CB>[退菜]</CB><BR>";
|
|||
|
if($order['orderMode']==1){
|
|||
|
$tableName = $order['regionName'] . ' ' . $order['typeName'] . ' ' . $order['people'] . '人';
|
|||
|
$content .= "餐桌信息:" . $tableName . "<BR>";
|
|||
|
}else {
|
|||
|
if ($order['deliveryMode'] == 10 and $order['isOut'] == 1) {
|
|||
|
$eatType = '店内就餐';
|
|||
|
} else {
|
|||
|
$eatType = '打包带走';
|
|||
|
}
|
|||
|
$content .= "取单方式:" . $eatType . "<BR>";
|
|||
|
}
|
|||
|
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
|
|||
|
$content .= "订单号:" . $order['outTradeNo'] . "<BR>";
|
|||
|
$content .= $timeStr. date('Y-m-d H:i:s', $order['createdAt']) . "<BR>";
|
|||
|
if ($order['userNote']) {
|
|||
|
$content .= "<BOLD>备注:" . $order['userNote'] . "</BOLD><BR>";
|
|||
|
}
|
|||
|
$content .= "--------------------------------<BR>";
|
|||
|
$content .= "名称 数量 单价<BR>";
|
|||
|
$content .= self::feiStyle($goods);
|
|||
|
}
|
|||
|
|
|||
|
if ($order['deliveryMoney'] > 0) {
|
|||
|
$content .= "[配送费:+" . $order['deliveryMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['tablewareMoney'] > 0) {
|
|||
|
$content .= "[餐桌费:+" . $order['tablewareMoney'] . "]\n\n";
|
|||
|
}
|
|||
|
if ($order['preferentialMoney'] > 0) {
|
|||
|
$content .= "[满减优惠:-" . $order['preferentialMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['couponPreferential'] > 0) {
|
|||
|
$content .= "[优惠券优惠:-" . $order['couponPreferential'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['newMoney'] > 0) {
|
|||
|
$content .= "[新客立减:-" . $order['newMoney'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['deliveryPreferential'] > 0) {
|
|||
|
$content .= "[减免配送费:-" . $order['deliveryPreferential'] . "]\n";
|
|||
|
}
|
|||
|
if ($order['giveName']) {
|
|||
|
$content .= "[赠送:-" . $order['giveName'] . "]\n";
|
|||
|
}
|
|||
|
if($type==1){
|
|||
|
$content .= "<center>门店电话:" . $store['storeTel'] . "</center>\n\n";
|
|||
|
$content .= "<FS2><center>----#" . $order['takeNo'] . "完----</center></FS2>\n";
|
|||
|
}else{
|
|||
|
$content .= "<C>门店电话:" . $store['storeTel'] . "</C><BR>";
|
|||
|
$content .= "<BOLD><C>----#" . $order['takeNo'] . "完----</C></BOLD>\n";
|
|||
|
}
|
|||
|
return $content;
|
|||
|
}
|
|||
|
//var_dump($content);die;
|
|||
|
|
|||
|
//收银台退菜
|
|||
|
static function returnFoodPrint($orderId){
|
|||
|
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_instore_order}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$tableInfo=(new \yii\db\Query())->select('areaId')
|
|||
|
->from('{{%ybwm_table}}')
|
|||
|
->where('id=:id',[':id'=>$order['tableId']])->one();
|
|||
|
$areaId=$tableInfo['areaId'];
|
|||
|
$print=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('deleteAt=0 AND display=1 AND uniacid=:uniacid AND storeId=:storeId AND support=:support',[':uniacid'=>$order['uniacid'],':storeId'=>$order['storeId'],'support'=>2])
|
|||
|
->andWhere(['and',['in','pattern',[1,3]],['like','printMode2',2]])->All();
|
|||
|
//->andWhere(['like','areaId',$areaId])
|
|||
|
|
|||
|
if (!$print) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
foreach ($print as $value){
|
|||
|
$rst=json_decode($value['data'],true);
|
|||
|
//易联云
|
|||
|
if($value['type']==1){
|
|||
|
$dynum=$rst['wmnum']?:1;
|
|||
|
$content=self::instoreCashierContent($orderId,1);
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
//飞蛾云
|
|||
|
if($value['type']==2){
|
|||
|
// file_put_contents('1.txt','tuicai'.$orderId.'---');
|
|||
|
$content=self::instoreCashierContent($orderId,2);
|
|||
|
|
|||
|
//var_dump($content);die;
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//排队易联云打印内容
|
|||
|
static function queuingContent($order,$type) {
|
|||
|
$store=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_store}}')
|
|||
|
->where('id=:id',[':id'=>$order['storeId']])->one();
|
|||
|
$count=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_queuing}}')
|
|||
|
->where('storeId=:storeId AND tableId=:tableId AND day=:day AND state=1',[':storeId'=>$order['storeId'],':tableId'=>$order['tableId'],':day'=>$order['day']])->count()?:0;
|
|||
|
if($type==1) {
|
|||
|
$content= "<center>*" . $store['name'] . "*</center>\n";
|
|||
|
$content.= "<center>排队号码:<FS2>" . $order['code'] . "</FS2></center>\n";
|
|||
|
$content.= "前面需等待" . $count . "桌,请稍后...\n";
|
|||
|
$content.= "--------------------------------\n";
|
|||
|
$content.= "就餐人数:" . $order['people'] . "人\n";
|
|||
|
$content.= "取号时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
$content.= "--------------------------------\n";
|
|||
|
$content.= "<FS>温馨提示:<center>听到叫号后请到服务台,过号作废!</center></FS>\n";
|
|||
|
|
|||
|
}else{
|
|||
|
$content= "<C>*" . $store['name'] . "*</C>\n";
|
|||
|
$content.= "<C>排队号码:<B>" . $order['code'] . "</B></C>\n";
|
|||
|
$content.= "前面需等待" . $count . "桌,请稍后...\n";
|
|||
|
$content.= "--------------------------------\n";
|
|||
|
$content.= "就餐人数:" . $order['people'] . "人\n";
|
|||
|
$content.= "取号时间:" . date('Y-m-d H:i:s', $order['createdAt']) . "\n";
|
|||
|
$content.= "--------------------------------\n";
|
|||
|
$content.= "<L>温馨提示:<C>听到叫号后请到服务台,过号作废!</C></L>\n";
|
|||
|
|
|||
|
}
|
|||
|
return $content;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//排队
|
|||
|
static function queuingPrint($orderId){
|
|||
|
$order=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_queuing}}')
|
|||
|
->where('id=:id',[':id'=>$orderId])->one();
|
|||
|
$print=(new \yii\db\Query())
|
|||
|
->from('{{%ybwm_print}}')
|
|||
|
->where('deleteAt=0 AND display=1 AND uniacid=:uniacid AND storeId=:storeId AND support=:support',[':uniacid'=>$order['uniacid'],':storeId'=>$order['storeId'],'support'=>5])
|
|||
|
->All();
|
|||
|
if (!$print) {
|
|||
|
return false;
|
|||
|
}
|
|||
|
foreach ($print as $value){
|
|||
|
$rst=json_decode($value['data'],true);
|
|||
|
//易联云
|
|||
|
if($value['type']==1){
|
|||
|
$dynum=$rst['wmnum']?:1;
|
|||
|
$content=self::queuingContent($order,$value['type']);
|
|||
|
$content= "<MN>{$dynum}</MN>".$content;
|
|||
|
self::print($rst,$content);
|
|||
|
}
|
|||
|
//飞蛾云
|
|||
|
if($value['type']==2){
|
|||
|
$content=self::queuingContent($order,$value['type']);
|
|||
|
//var_dump($content);die;
|
|||
|
self::feiPrint($rst,$content);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|