Ver código fonte

打印标签

shish 2 meses atrás
pai
commit
771292b02b

+ 41 - 0
app-ghs/controllers/OrderItemController.php

@@ -19,6 +19,47 @@ class OrderItemController extends BaseController
 
     public $guestAccess = [];
 
+    public function actionPrintItemWlLabel()
+    {
+        $get = Yii::$app->request->get();
+        $orderSn = $get['orderSn'] ?? '';
+        $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
+        if (empty($order)) {
+            util::fail('没有找到订单');
+        }
+        if ($order->mainId != $this->mainId) {
+            util::fail('不是你的订单');
+        }
+        $id = $get['id'] ?? 0;
+        $orderItem = OrderItemClass::getById($id, true);
+        if (empty($orderItem)) {
+            util::fail('没有花材信息');
+        }
+        if (empty($orderItem->productId)) {
+            util::fail('花材信息缺失');
+        }
+        $productId = $orderItem->productId;
+        if ($orderItem->orderSn != $orderSn) {
+            util::fail('你不能操作');
+        }
+        $product = ProductClass::getById($productId, true);
+        if (empty($product)) {
+            util::fail('花材信息没有找到');
+        }
+        $shop = $this->shop;
+        $ext = $this->shopExt;
+        $num = $get['num'] ?? 0;
+        if ($num <= 0) {
+            util::fail('请填写数量');
+        }
+        $boxNum = $get['boxNum'] ?? 0;
+        if ($boxNum <= 0) {
+            util::fail('请填写装箱数');
+        }
+        OrderClass::printItemLabel($order, $shop, $ext, $product, $num, $boxNum,$orderItem);
+        util::complete('打印成功');
+    }
+
     //过滤名称 ssh 20240430
     public function actionFilterName()
     {

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

@@ -1945,7 +1945,7 @@ class OrderClass extends BaseClass
         /**************************如果是好多花的云仓还要再打一下标签纸,多处要同步修改,关键词 hdh_yc *****************************/
         $orderMainId = $orderInfo['mainId'] ?? 0;
         if (getenv('YII_ENV') == 'production') {
-            $map = [65726, 58, 25119, 28500, 1294,12925];
+            $map = [65726, 58, 25119, 28500, 1294, 12925];
         } else {
             $map = [828];
         }
@@ -3003,7 +3003,7 @@ XL;
         /**************************如果是好多花的云仓还要再打一下标签纸,多处要同步修改,关键词 hdh_yc *****************************/
         $orderMainId = $order->mainId;
         if (getenv('YII_ENV') == 'production') {
-            $map = [65726, 58, 25119, 28500, 1294,12925];
+            $map = [65726, 58, 25119, 28500, 1294, 12925];
         } else {
             $map = [828];
         }
@@ -3106,6 +3106,71 @@ XL;
         return true;
     }
 
+
+    //打印花材的物流标 ssh 20260507
+    public static function printItemLabel($order, $shop, $ext, $product, $num, $boxNum, $orderItem)
+    {
+        $customId = $order->customId ?? 0;
+        $custom = CustomClass::getById($customId, true);
+
+        $customMobile = $order->customMobile ?? '';
+
+        $customName = $order->customName ?? '';
+        $remark = $order->remark ?? '';
+        $shortRemark = stringUtil::subStringUtf8($remark, 8);
+        $wlName = $custom->wlName ?? '';
+        if (empty($wlName)) {
+            $wlName = $shortRemark;
+        }
+        $distId = $custom->distId ?? '';
+        $dist = DistClass::getById($distId, true);
+        $distName = $dist->name ?? '未分区';
+
+        $address = $order->address ?? '';
+        $floor = $order->floor ?? '';
+        $fullAddress = $address . $floor;
+
+        $wlLabelSn = $ext->wlLabelSn ?? '';
+        if (empty($wlLabelSn)) {
+            util::fail('请绑定物流标签机');
+        }
+        $p = new printUtil($wlLabelSn);
+        $p->times = $num;
+        $sameTimeIds = $order->sameTimeIds;
+        $num = 1;
+        if (!empty($sameTimeIds)) {
+            $ids = explode(',', $sameTimeIds);
+            if (!empty($ids)) {
+                $num = count($ids);
+            }
+        }
+        if ($num > 1) {
+            $customName = $customName . ' ' . $num . '单';
+        }
+        $remark = '';
+        if (!empty($orderItem->remark)) {
+            $remark .= $orderItem->remark;
+        }
+        if (!empty($order->remark)) {
+            if(!empty($remark)){
+                $remark .= ' '.$order->remark;
+            }else{
+                $remark .= $order->remark;
+            }
+        }
+
+        $productName = $product->name ?? '';
+        $content = '<TEXT x="400" y="30" font="12" w="2" h="2" r="90">客户:' . $customName . '</TEXT>';
+        $content .= '<TEXT x="325" y="30" font="12" w="2" h="2" r="90">地址:' . $fullAddress . '</TEXT>';
+        $content .= '<TEXT x="250" y="30" font="12" w="2" h="2" r="90">电话:' . $customMobile . '</TEXT>';
+        $content .= '<TEXT x="180" y="30" font="12" w="2" h="2" r="90">备注:' . $remark . '</TEXT>';
+        $content .= '<TEXT x="120" y="30" font="12" w="2" h="2" r="90">————————————————————</TEXT>';
+        $content .= '<TEXT x="60" y="30" font="12" w="2" h="2" r="90">' . $productName . ' 装箱数:' . $boxNum . '</TEXT>';
+        $p->printLabelMsg($content);
+        return true;
+    }
+
+
     // 更新同天内的所有订单的 sameTimeIds
     public static function updateSameTimeIds($order, $date)
     {
@@ -3134,12 +3199,12 @@ XL;
         // 排序并去重
         sort($ids);
         $ids = array_unique($ids);
-        
+
         // 限制最多 90 单,避免 someTimeIds 过长(兼容原先业务逻辑限制)
         if (count($ids) > 90) {
             $ids = array_slice($ids, 0, 90);
         }
-        
+
         $sameTimeIdsStr = implode(',', $ids);
         // 更新所有相关订单
         if (!empty($ids) && in_array($id, $ids)) {