shish 9 ay önce
ebeveyn
işleme
968eb352f0
1 değiştirilmiş dosya ile 47 ekleme ve 7 silme
  1. 47 7
      app-hd/controllers/ProductController.php

+ 47 - 7
app-hd/controllers/ProductController.php

@@ -179,30 +179,70 @@ class ProductController extends BaseController
         $get = Yii::$app->request->get();
         $id = $get['id'] ?? 0;
         $num = $get['num'] ?? 1;
+        $num = floatval($num);
+        $num = (int)$num;
+        $type = $get['type'] ?? 0;
         $info = ProductClass::getById($id, true);
         if (empty($info)) {
             util::fail('没有找到花材');
         }
         $name = $info->name ?? '';
         $ptItemId = $info->itemId ?? 0;
-
+        $mainId = $info->mainId ?? 0;
         $shopId = $this->shopId;
         $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        if (empty($ext)) {
+            util::fail('没有找到门店信息');
+        }
         $printLabelSn = $ext->printLabelSn ?? '';
         if (empty($printLabelSn)) {
             util::fail('请设置标签打印机');
         }
         $p = new printUtil($printLabelSn);
-
         $unit = $info->ratio . $info->smallUnit . '/' . $info->bigUnit;
         if (isset($info->ratioType) && $info->ratioType == 1) {
             $unit = '若干' . $info->smallUnit . '/' . $info->bigUnit;
         }
-
         $p->times = $num;
-        $content = '<TEXT x="360" y="30" font="12" w="2" h="2" r="90">' . $name . '</TEXT>';
-        $content .= '<BC128 x="260" y="30" h="70" s="1" r="90" n="4" w="11">' . $ptItemId . '</BC128>';
-        $content .= '<TEXT x="60" y="30" font="12" w="2" h="2" r="90">' . $unit . '</TEXT>';
+        if (stringUtil::getWordNum($name) > 8) {
+            $content = '<TEXT x="30" y="30" font="12" w="1" h="1" r="0">' . $name . '</TEXT>';
+        } else {
+            $content = '<TEXT x="30" y="30" font="12" w="2" h="2" r="0">' . $name . '</TEXT>';
+        }
+
+        if ($type == 0) {
+            //打标签
+            $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $ptItemId . '</BC128>';
+            if (in_array($mainId, [52, 1459])) {
+                $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">惠雅鲜花</TEXT>';
+            } elseif ($mainId == 16948) {
+                $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">淘花里鲜花</TEXT>';
+            } else {
+                $content .= '<TEXT x="30" y="250" font="12" w="1" h="1" r="0">' . $unit . '</TEXT>';
+            }
+        } else {
+            if (getenv('YII_ENV') == 'production') {
+                $doublePrice = [52, 1459];
+            } else {
+                $doublePrice = [];
+            }
+            if (in_array($this->mainId, $doublePrice)) {
+                //打价格,显示正价和会员价
+                $price = $info->skPrice ?? 0;
+                $price = floatval($price);
+                $hyPrice = $info->price ?? 0;
+                $hyPrice = floatval($hyPrice);
+                $content .= '<TEXT x="35" y="90" font="12" w="2" h="2" r="0">----------</TEXT>';
+                $content .= '<TEXT x="35" y="150" font="12" w="2" h="2" r="0">正价 ' . $price . '元</TEXT>';
+                $content .= '<TEXT x="35" y="230" font="12" w="2" h="2" r="0">会员价 ' . $hyPrice . '元</TEXT>';
+            } else {
+                //打价格,显示零售价,并且不带元,杭州斗南鲜花不要带元
+                $price = $info->skPrice ?? 0;
+                $price = floatval($price);
+                $content .= '<TEXT x="35" y="150" font="12" w="4" h="4" r="0">' . $price . '</TEXT>';
+            }
+        }
+
         $p->printLabelMsg($content);
         util::complete();
     }
@@ -854,7 +894,7 @@ class ProductController extends BaseController
         $list = ProductClass::groupProductInfo([$product], $level);
         $product = current($list);
 
-        $mainId = $product['mainId']??0;
+        $mainId = $product['mainId'] ?? 0;
         $pixTextGoods = PicTextGhsItemClass::getByCondition(['mainId' => $mainId, 'ghsItemId' => $id], true);
         $product['picTextGoods'] = $pixTextGoods;
         // 封面图与多花材图片的兼容处理