shish 1 год назад
Родитель
Сommit
f40a37d3a9
2 измененных файлов с 94 добавлено и 2 удалено
  1. 25 2
      app-ghs/controllers/OrderController.php
  2. 69 0
      biz-ghs/order/classes/OrderClass.php

+ 25 - 2
app-ghs/controllers/OrderController.php

@@ -43,6 +43,29 @@ class OrderController extends BaseController
 
     public $guestAccess = ['create-order', 'order-relate', 'fast-pay', 'info'];
 
+    //打印物流列表 ssh 20250712
+    public function actionPrintWlList()
+    {
+        $get = Yii::$app->request->get();
+        $begin = $get['begin'] ?? 1;
+        $hour = $get['hour'] ?? 0;
+        if ($hour > 24 || $hour < 0) {
+            util::fail('必须0到24点');
+        }
+        if ($begin == 0) {
+            $date = date('Y-m-d', strtotime('-1 day'));
+        } else {
+            $date = date('Y-m-d');
+        }
+        $beginGroup = $date . " {$hour}:00:00";
+        $newTime = strtotime($beginGroup);
+        $beginTime = date('Y-m-d H:i:s', $newTime);
+        $endTime = date("Y-m-d H:i:s");
+        $shop = $this->shop;
+        OrderClass::printMyWlList($shop, $beginTime, $endTime);
+        util::complete('打印成功');
+    }
+
     //复核 ssh 20241001
     public function actionModifyReCheck()
     {
@@ -731,7 +754,7 @@ class OrderController extends BaseController
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {
-            $subject = '购买花材 '.$orderSn;
+            $subject = '购买花材 ' . $orderSn;
             $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
             $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
             $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
@@ -1089,7 +1112,7 @@ class OrderController extends BaseController
         if (getenv('YII_ENV') == 'production') {
             //小向花卉开单售后控制
             if ($this->mainId == 23390) {
-                if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960, 28456, 31105, 28456, 31105, 52528, 25011,61449])) {
+                if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960, 28456, 31105, 28456, 31105, 52528, 25011, 61449])) {
                     util::fail('你不能开单哦');
                 }
             }

+ 69 - 0
biz-ghs/order/classes/OrderClass.php

@@ -4,6 +4,7 @@ namespace bizGhs\order\classes;
 
 use bizGhs\item\classes\ItemClassClass;
 use bizHd\purchase\classes\PurchaseItemClass;
+use common\components\arrayUtil;
 use wkhtmltox\Image\Converter;
 use biz\shop\classes\ShopAdminClass;
 use biz\shop\classes\ShopCapitalClass;
@@ -123,6 +124,74 @@ class OrderClass extends BaseClass
         self::REFUND_YES => '有退款',
     ];
 
+    public static function printMyWlList($shop, $beginTime, $endTime)
+    {
+        $end = strtotime($endTime);
+        $begin = strtotime($beginTime);
+        $different = $end - $begin;
+        if ($different > 172800) {
+            util::fail('最多可打印2天订单');
+        }
+        $mainId = $shop->mainId;
+        $orderList = OrderClass::getAllByCondition(['mainId' => $mainId, 'payTime' => ['between', [$beginTime, $endTime]], 'payStatus' => 1], 'id asc', '*', null, true);
+        if (empty($orderList)) {
+            util::fail('没有订单需要打印');
+        }
+        $ids = [];
+        foreach ($orderList as $order) {
+            $customId = $order->customId;
+            $ids[] = $customId;
+        }
+        $ids = array_unique(array_filter($ids));
+        $customList = CustomClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,mainId,shortName,mobile,wlName', 'id');
+        $myList = [];
+        foreach ($orderList as $order) {
+            $customId = $order->customId;
+            $custom = $customList[$customId] ?? [];
+            $sendNum = $order->sendNum;
+            $customMobile = $order->customMobile;
+            $shortName = $custom['shortName'] ?? '';
+            $wlName = $custom['wlName'] ?? '';
+            $myList[] = ['sendNum' => $sendNum, 'customMobile' => $customMobile, 'shortName' => $shortName, 'wlName' => $wlName];
+        }
+        $myList = arrayUtil::arraySort($myList,'customMobile');
+
+        $size = 50;
+        $arr = array_chunk($myList, $size);
+        $totalPage = count($arr);
+        foreach ($arr as $key => $sonList) {
+            $content = '';
+            if ($totalPage > 1) {
+                $currentPage = bcadd($key, 1);
+                $content .= "<CB>第{$currentPage}页,共{$totalPage}页</CB><BR>";
+            }
+            $content .= '<BR>';
+            $content .= '--------------------------------<BR>';
+            if (!empty($sonList)) {
+                foreach ($sonList as $info) {
+                    $sendNum = $info['sendNum'];
+                    $customMobile = $info['customMobile'];
+                    $shortName = $info['shortName'];
+                    $wlName = $info['wlName'];
+                    $content .= '<B>' . $sendNum . ' ' . $shortName . '</B><BR>';
+                    $content .= '<BR>';
+                    $content .= '<B>' . $customMobile . ' ' . $wlName . '</B><BR>';
+                    $content .= '--------------------------------<BR>';
+                }
+            }
+            $content .= '<BR>';
+            $shopId = $shop->id;
+            $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
+            $printSn = $ext['printSn'] ?? '';
+            if (empty($printSn)) {
+                util::fail('没有设置打印机');
+            }
+            $p = new printUtil($printSn);
+            $p->printMsg($content, $shop);
+        }
+
+    }
+
     public static function exportOrderData($respond, $mainId)
     {
         $orderList = $respond['list'] ?? [];