shish 9 ay önce
ebeveyn
işleme
821efd0a96

+ 1 - 1
app-hd/controllers/GoodsController.php

@@ -51,7 +51,7 @@ class GoodsController extends BaseController
         }else{
             $content = '<TEXT x="30" y="45" font="12" w="2" h="2" r="0">' . $name . '</TEXT>';
         }
-        $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $goodsSn . '</BC128>';
+        $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">#' . $goodsSn . '</BC128>';
         if ($price > 0) {
             $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">' . $price . '元</TEXT>';
         }

+ 1 - 1
biz-hd/goods/classes/GoodsClass.php

@@ -482,7 +482,7 @@ class GoodsClass extends BaseClass
         $flowerNum = $data['flowerNum'] ?? 0;
         $kindId = $data['kindId'] ?? 0;
         $kindName = $data['kindName'] ?? '';
-        $sn = orderSn::getGoodsSn();
+        $sn = orderSn::getGoodsSn($data);
         $data['sn'] = $sn;
         $addStock = $data['stock'] ?? 0;
         unset($data['stock']);

+ 16 - 9
common/components/orderSn.php

@@ -475,15 +475,22 @@ class orderSn
     }
 
     //商品有效编号1-开头 ssh 20220405
-    public static function getGoodsSn()
-    {
-        $prefix = '1-';
-        $respond = GoodsSnClass::add(['id' => null]);
-        $id = $respond['id'] ?? 0;
-        if (empty($id)) {
-            util::fail('单号没有生成');
-        }
-        return $prefix . $id;
+    public static function getGoodsSn($data)
+    {
+        $mainId = $data['mainId'] ?? 0;
+        $shopId = $data['shopId'] ?? 0;
+        $info = GoodsSnClass::getByCondition(['mainId' => $mainId], true, 'sn DESC', 'id,sn');
+        if (empty($info)) {
+            $sn = 1;
+        } else {
+            $sn = $info->sn ?? 1;
+            $sn++;
+        }
+        $respond = GoodsSnClass::add(['id' => null, 'mainId' => $mainId, 'shopId' => $shopId, 'sn' => $sn]);
+        if (empty($respond)) {
+            util::fail('商品编号生成失败');
+        }
+        return $sn;
     }
 
     //二批采购退款 ssh 20220909