问题说明:易联云小票打印兼容问题
修改文件:app\services\message\SystemPrinterServices
修改方法:ylyContent()
public function ylyContent($printContent, $config, $print_num, $print_event)
{
$orderInfo = $config['orderInfo'];
$product = $config['product'];
$name = $config['name'];
$goodsStr = '<table><tr><td>名称</td><td>单价</td><td>数量</td><td>金额</td></tr>';
foreach ($product as $item) {
$goodsStr .= '<tr><td><FH2><FW2>----------------</FW2></FH2></td></tr>';
$goodsStr .= '<tr>';
$price = $item['sum_price'];
$num = $item['cart_num'];
$prices = bcmul((string)$item['cart_num'], (string)$item['sum_price'], 2);
$goodsStr .= "<td>{$item['productInfo']['store_name']} | {$item['productInfo']['attrInfo']['suk']}</td><td>{$price}</td><td>{$num}</td><td>{$prices}</td>";
$goodsStr .= '</tr>';
if (in_array(1, $printContent['goods'])) {
$goodsStr .= '<tr>';
$goodsStr .= "<td>规格编码:{$item['productInfo']['attrInfo']['code']}</td>";
$goodsStr .= '</tr>';
}
unset($price, $num, $prices);
}
$goodsStr .= '</table>';
$total_price = bcadd($orderInfo['total_price'], $orderInfo['pay_postage'], 2);
$addTime = date('Y-m-d H:i:s', $orderInfo['add_time']);
$payTime = isset($orderInfo['pay_time']) ? date('Y-m-d H:i:s', $orderInfo['pay_time']) : '';
$printTime = date('Y-m-d H:i:s', time());
$content = '';
$content .= '<MN>' . $print_num . '</MN>';
if ($printContent['header']) {
if (in_array(0, $printContent['header'])) {
$content .= '<FS2><center>' . $name . '</center></FS2>';
}
if (in_array(1, $printContent['header']) && $orderInfo['store_id']) {
/** @var SystemStoreServices $storeServices */
$storeServices = app()->make(SystemStoreServices::class);
$store_name = $storeServices->value(['id' => $orderInfo['store_id']], 'name');
$content .= '<FS2><center>' . $store_name . '</center></FS2>';
}
$content .= '<FH2><FW2>----------------</FW2></FH2>';
}
if ($printContent['delivery']) {
if (in_array(0, $printContent['delivery'])) {
if ($orderInfo['shipping_type'] == 1) {
$content .= "配送方式:商家配送 \r";
} else {
$content .= "配送方式:门店自提 \r";
}
}
if (in_array(1, $printContent['delivery'])) {
$content .= '客户姓名: ' . $orderInfo['real_name'] . " \r";
}
if (in_array(2, $printContent['delivery'])) {
$content .= '客户电话: ' . $orderInfo['user_phone'] . " \r";
}
if (in_array(3, $printContent['delivery'])) {
if ($orderInfo['shipping_type'] == 1) $content .= '收货地址: ' . $orderInfo['user_address'] . " \r";
}
$content .= '<FH2><FW2>----------------</FW2></FH2>';
}
if ($printContent['buyer_remarks']) {
$content .= '买家备注: ' . $orderInfo['mark'] . " \r";
$content .= '<FH2><FW2>----------------</FW2></FH2>';
}
if (in_array(0, $printContent['goods'])) {
$content .= '*************商品***************';
$content .= " \r";
$content .= $goodsStr;
$content .= "********************************\r";
$content .= '<FH2><FW2>----------------</FW2></FH2>';
}
if ($printContent['freight']) {
$content .= '<RA>邮费:' . $orderInfo['pay_postage'] . '元</RA>';
$content .= '<RA>合计:' . $total_price . '元</RA>';
$content .= '<FH2><FW2>----------------</FW2></FH2>';
}
if ($printContent['preferential']) {
$discount_price = bcsub(bcadd($orderInfo['total_price'], $orderInfo['pay_postage'], 2), bcadd($orderInfo['deduction_price'], $orderInfo['pay_price'], 2), 2);
$content .= '<RA>优惠:-' . $discount_price . '元</RA>';
$content .= '<RA>抵扣:-' . $orderInfo['deduction_price'] . '元</RA>';
$content .= '<FH2><FW2>----------------</FW2></FH2>';
}
if (in_array(0, $printContent['pay'])) {
if ($print_event == 2) {
switch ($orderInfo['pay_type']) {
case 'weixin':
'<RA>支付方式:微信支付</RA>';
break;
case 'alipay':
'<RA>支付方式:支付宝支付</RA>';
break;
case 'yue':
'<RA>支付方式:余额支付</RA>';
break;
case 'offline':
'<RA>支付方式:线下支付</RA>';
break;
default:
'<RA>支付方式:暂无</RA>';
}
} else {
$content .= '<RA>支付方式:暂无</RA>';
}
}
if (in_array(1, $printContent['pay'])) {
$content .= '<RA>实际支付:' . $orderInfo['pay_price'] . '元</RA>';
}
if (count($printContent['pay'])) {
$content .= '<FH2><FW2>----------------</FW2></FH2>';
}
if (in_array(0, $printContent['order'])) {
$content .= '订单编号:' . $orderInfo['order_id'] . "\r";
}
if (in_array(1, $printContent['order'])) {
$content .= '下单时间:' . $addTime . "\r";
}
if (in_array(2, $printContent['order'])) {
$content .= '支付时间:' . $payTime . "\r";
}
if (in_array(3, $printContent['order'])) {
$content .= '打印时间:' . $printTime . "\r";
}
$content .= '<FH2><FW2>----------------</FW2></FH2>';
if ($printContent['code'] && $printContent['code_url']) {
$content .= '<QR>' . sys_config('site_url') . $printContent['code_url'] . '</QR>';
$content .= " \r";
}
if ($printContent['show_notice']) {
$content .= '<center>' . $printContent['notice_content'] . '</center>';
$content .= " \r";
}
return $content;
}
修改方法:ylyTableContent()
public function ylyTableContent($printContent, $config, $print_num, $print_event)
{
$product = $config['product'];
$tableInfo = $config['tableInfo'];
$name = $config['name'];
$goodsStr = '<table><tr><td>名称</td><td>单价</td><td>数量</td><td>金额</td></tr>';
foreach ($product as $item) {
$goodsStr .= '<tr><td><FH2><FW2>----------------</FW2></FH2></td></tr>';
$goodsStr .= '<tr>';
$price = $item['sum_price'];
$num = $item['cart_num'];
$prices = bcmul((string)$item['cart_num'], (string)$item['sum_price'], 2);
$goodsStr .= "<td>{$item['productInfo']['store_name']} | {$item['productInfo']['attrInfo']['suk']}</td><td>{$price}</td><td>{$num}</td><td>{$prices}</td>";
$goodsStr .= '</tr>';
if (in_array(1, $printContent['goods'])) {
$goodsStr .= '<tr>';
$goodsStr .= "<td>规格编码:{$item['productInfo']['attrInfo']['code']}</td>";
$goodsStr .= '</tr>';
}
unset($price, $num, $prices);
}
$goodsStr .= '</table>';
$printTime = date('Y-m-d H:i:s', time());
$content = '';
$content .= '<MN>' . $print_num . '</MN>';
if ($printContent['header']) {
if (in_array(0, $printContent['header'])) {
$content .= '<FS2><center>' . $name . '</center></FS2>';
}
if (in_array(1, $printContent['header'])) {
/** @var SystemStoreServices $storeServices */
$storeServices = app()->make(SystemStoreServices::class);
$store_name = $storeServices->value(['id' => $tableInfo['store_id']], 'name');
$content .= '<FS2><center>' . $store_name . '</center></FS2>';
}
/** @var TableQrcodeServices $qrcodeService */
$qrcodeService = app()->make(TableQrcodeServices::class);
$Info = $qrcodeService->getQrcodeyInfo((int)$tableInfo['qrcode_id'], ['category']);
if (in_array(2, $printContent['header'])) {
$content .= '<RA>桌码流水:' . $tableInfo['serial_number'] . '</RA>';
}
if (in_array(3, $printContent['header'])) {
$content .= '<RA>桌码分类:' . $Info['category']['name'] . '</RA>';
}
if (in_array(4, $printContent['header'])) {
$content .= '<RA>桌码编号:' . $Info['table_number'] . '</RA>';
}
$content .= '<FH2><FW2>----------------</FW2></FH2>';
}
if (in_array(0, $printContent['goods'])) {
$content .= '*************商品***************';
$content .= " \r";
$content .= $goodsStr;
$content .= "********************************\r";
$content .= '<FH2><FW2>----------------</FW2></FH2>';
}
if (in_array(3, $printContent['order'])) {
$content .= '打印时间:' . $printTime . "\r";
}
$content .= '<FH2><FW2>----------------</FW2></FH2>';
if ($printContent['code'] && $printContent['code_url']) {
$content .= '<QR>' . sys_config('site_url') . $printContent['code_url'] . '</QR>';
$content .= " \r";
}
if ($printContent['show_notice']) {
$content .= '<center>' . $printContent['notice_content'] . '</center>';
$content .= " \r";
}
return $content;
}
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}