|
|
@@ -898,6 +898,8 @@ class OrderClass extends BaseClass
|
|
|
$shopId = $order->shopId ?? 0;
|
|
|
$shop = ShopClass::getById($shopId, true);
|
|
|
$sjId = $shop->sjId ?? 0;
|
|
|
+ // 复杂分支/关键逻辑:云打印字号与批发端一致,读取门店 fontSize 配置(0 加粗,1 放大)
|
|
|
+ $fontSizeType = $shop->fontSize ?? 0;
|
|
|
$sj = SjClass::getById($sjId, true);
|
|
|
$sjName = $sj->name ?? '';
|
|
|
$shopName = $shop->shopName ?? '';
|
|
|
@@ -1030,9 +1032,8 @@ class OrderClass extends BaseClass
|
|
|
|
|
|
if (!empty($respond['product'])) {
|
|
|
foreach ($respond['product'] as $current) {
|
|
|
- $content = self::printGroup($current, $content);
|
|
|
+ $content = self::printGroup($current, $content, $fontSizeType);
|
|
|
}
|
|
|
- $content .= '--------------------------------<BR>';
|
|
|
}
|
|
|
|
|
|
if (!empty($respond['refund'])) {
|
|
|
@@ -1129,13 +1130,21 @@ class OrderClass extends BaseClass
|
|
|
$orderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
|
|
|
if (!empty($orderItemList)) {
|
|
|
foreach ($orderItemList as $itemKey => $itemVal) {
|
|
|
- $unitName = $itemVal['unitName'] ?? '';
|
|
|
+ $unitName = $itemVal['unitName'] ?? '扎';
|
|
|
$unitPrice = $itemVal['unitPrice'] ? floatval($itemVal['unitPrice']) : 0;
|
|
|
+ $itemNum = $itemVal['num'] ?? 0;
|
|
|
$printProduct[] = [
|
|
|
'name' => $itemVal['name'] ?? '',
|
|
|
- 'num' => $itemVal['num'] . $unitName . '*' . $unitPrice,
|
|
|
+ // 第二行小字:数量 * 单价 = 金额,排版与批发端一致
|
|
|
+ 'num' => floatval($itemNum) . $unitName . ' * ' . $unitPrice . '元',
|
|
|
'price' => floatval($itemVal['price']),
|
|
|
- 'sn' => '',
|
|
|
+ 'unitPrice' => $unitPrice,
|
|
|
+ 'itemNum' => $itemNum,
|
|
|
+ 'refundNum' => $itemVal['refundNum'] ?? 0,
|
|
|
+ 'unitName' => $unitName,
|
|
|
+ 'remark' => $itemVal['remark'] ?? '',
|
|
|
+ 'ratioType' => $itemVal['ratioType'] ?? null,
|
|
|
+ 'ratio' => $itemVal['ratio'] ?? '',
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
@@ -1144,12 +1153,23 @@ class OrderClass extends BaseClass
|
|
|
foreach ($orderGoodsList as $itemKey => $itemVal) {
|
|
|
$unitName = $itemVal['unitName'] ?? '份';
|
|
|
$unitPrice = $itemVal['unitPrice'] ? floatval($itemVal['unitPrice']) : 0;
|
|
|
+ $itemNum = $itemVal['num'] ?? 0;
|
|
|
+ $name = $itemVal['name'] ?? '';
|
|
|
$sn = $itemVal['sn'] ?? '';
|
|
|
+ if (!empty($sn)) {
|
|
|
+ $name = '#' . $sn . ' ' . $name;
|
|
|
+ }
|
|
|
$printProduct[] = [
|
|
|
- 'name' => $itemVal['name'] ?? '',
|
|
|
- 'num' => $itemVal['num'] . $unitName . '*' . $unitPrice,
|
|
|
+ 'name' => $name,
|
|
|
+ 'num' => floatval($itemNum) . $unitName . ' * ' . $unitPrice . '元',
|
|
|
'price' => floatval($itemVal['price']),
|
|
|
- 'sn' => $sn,
|
|
|
+ 'unitPrice' => $unitPrice,
|
|
|
+ 'itemNum' => $itemNum,
|
|
|
+ 'refundNum' => 0,
|
|
|
+ 'unitName' => $unitName,
|
|
|
+ 'remark' => '',
|
|
|
+ 'ratioType' => null,
|
|
|
+ 'ratio' => '',
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
@@ -1182,28 +1202,52 @@ class OrderClass extends BaseClass
|
|
|
return $printData;
|
|
|
}
|
|
|
|
|
|
- public static function printGroup($current, $content)
|
|
|
+ /**
|
|
|
+ * 职责:组装零售云打印单条商品行,排版与批发端 printGroup 一致
|
|
|
+ * 入参:$current 商品行数据, $content 已拼接内容, $fontSizeType 字号类型(0 加粗,1 放大)
|
|
|
+ * 返回:拼接后的打印内容
|
|
|
+ * 关键边界:第一行「数量+单位+名称」大字,第二行「数量*单价=金额」小字
|
|
|
+ */
|
|
|
+ public static function printGroup($current, $content, $fontSizeType = 0)
|
|
|
{
|
|
|
//58mm的机器,一行打印16个汉字,32个字母
|
|
|
+ $productPrice = $current['price'] ?? '';
|
|
|
+ $unitPrice = $current['unitPrice'] ?? '';
|
|
|
$name = $current['name'] ?? '';
|
|
|
- if (!empty($current['sn'])) {
|
|
|
- $name = '#' . $current['sn'] . ' ' . $name;
|
|
|
+ if (floatval($unitPrice) == 0.01) {
|
|
|
+ $name = $name . '(送)';
|
|
|
}
|
|
|
- $content .= $name . '<BR>';
|
|
|
- $name = str_repeat(' ', 10);
|
|
|
-
|
|
|
$productNum = $current['num'] ?? '';
|
|
|
- $blankNum = bcsub(12, strlen($productNum));
|
|
|
- if ($blankNum > 0) {
|
|
|
- $productNum = $productNum . str_repeat(' ', $blankNum);
|
|
|
+ $itemNum = $current['itemNum'] ?? 0;
|
|
|
+ $refundNum = $current['refundNum'] ?? 0;
|
|
|
+ $unitName = $current['unitName'] ?? '扎';
|
|
|
+ $remark = $current['remark'] ?? '';
|
|
|
+ $ratioType = $current['ratioType'] === null ? -1 : intval($current['ratioType']);
|
|
|
+ $ratio = $current['ratio'] ?? '';
|
|
|
+
|
|
|
+ $lastNum = bcsub($itemNum, $refundNum);
|
|
|
+
|
|
|
+ // 第一行:数量在前,名称在后(与批发端一致)
|
|
|
+ if (!empty($remark)) {
|
|
|
+ $show = $lastNum . $unitName . ' ' . $name . "【" . $remark . "】";
|
|
|
+ } else {
|
|
|
+ $show = $lastNum . $unitName . ' ' . $name;
|
|
|
}
|
|
|
-
|
|
|
- $productPrice = $current['price'] ?? '';
|
|
|
- $blankNum = bcsub(7, strlen($productPrice));
|
|
|
- if ($blankNum > 0) {
|
|
|
- $productPrice = $productPrice . str_repeat(' ', $blankNum);
|
|
|
+ if ($fontSizeType == 1) {
|
|
|
+ $content .= '<L>' . $show . '</L><BR>';
|
|
|
+ } else {
|
|
|
+ $content .= '<B>' . $show . '</B><BR>';
|
|
|
+ }
|
|
|
+ if ($refundNum > 0) {
|
|
|
+ $content .= '(买' . $itemNum . $unitName . ' 退' . $refundNum . $unitName . ')<BR>';
|
|
|
}
|
|
|
- $content .= $name . " " . $productNum . ' ' . $productPrice . '<BR><BR>';
|
|
|
+ // 第二行:小字体的数量和价格明细
|
|
|
+ if (floatval($unitPrice) == 0.01) {
|
|
|
+ $content .= $productNum . ' = ' . $productPrice . '元 赠送价<BR>';
|
|
|
+ } else {
|
|
|
+ $content .= $productNum . ' = ' . $productPrice . '元 ' . ($ratioType == 0 ? $ratio . '支装' : ($ratioType == 1 ? '若干支装' : '')) . '<BR>';
|
|
|
+ }
|
|
|
+ $content .= '--------------------------------<BR>';
|
|
|
return $content;
|
|
|
}
|
|
|
|