|
|
@@ -2,8 +2,10 @@
|
|
|
|
|
|
namespace ghs\controllers;
|
|
|
|
|
|
+use biz\shop\classes\ShopExtClass;
|
|
|
use biz\stat\classes\StatBookClass;
|
|
|
use common\components\dateUtil;
|
|
|
+use common\components\printUtil;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
|
|
|
@@ -45,22 +47,44 @@ class StatBookController extends BaseController
|
|
|
if (empty($list)) {
|
|
|
util::fail('没有花材需要打印');
|
|
|
}
|
|
|
+ $shop = $this->shop;
|
|
|
$num = count($list);
|
|
|
$pageSize = 6;
|
|
|
$ratio = ceil($num / $pageSize);
|
|
|
-echo $num;
|
|
|
- $content = "<CB>预订汇总</CB><BR><BR>";
|
|
|
if ($ratio > 1) {
|
|
|
for ($i = 1; $i <= $ratio; $i++) {
|
|
|
-
|
|
|
$offset = ($i - 1) * $pageSize;
|
|
|
$current = array_slice($list, $offset, $pageSize);
|
|
|
- print_r($current);
|
|
|
+ self::printOrder($current, $shop, $i);
|
|
|
}
|
|
|
} else {
|
|
|
+ self::printOrder($list, $shop);
|
|
|
+ }
|
|
|
+ util::complete('打印成功');
|
|
|
+ }
|
|
|
|
|
|
+ public static function printOrder($list, $shop, $order = 0)
|
|
|
+ {
|
|
|
+ $content = "<CB>预订汇总</CB><BR><BR>";
|
|
|
+ $content .= "<CB>第{$order}页</CB><BR><BR>";
|
|
|
+ $content .= '商品 数量/单价 金额 <BR>';
|
|
|
+ $content .= '--------------------------------<BR>';
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $date1 = $item['time'];
|
|
|
+ $date2 = substr($date1, 4, 4);
|
|
|
+ $name = $item['name'] ?? '';
|
|
|
+ $num = $item['num'] ?? 0;
|
|
|
+ $content .= '<B>' . $date2 . ' ' . $name . ' ' . $num . '</B><BR>'
|
|
|
+ $content .= '--------------------------------<BR>';
|
|
|
+ }
|
|
|
+ $shopId = $shop->id ?? 0;
|
|
|
+ $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
|
|
|
+ $printSn = $ext['printSn'] ?? '';
|
|
|
+ if (empty($printSn)) {
|
|
|
+ util::fail('没有找到打印机');
|
|
|
}
|
|
|
- die;
|
|
|
+ $p = new printUtil($printSn);
|
|
|
+ $p->printMsg($content, $shop);
|
|
|
}
|
|
|
|
|
|
}
|