瀏覽代碼

绿植花束

shish 8 月之前
父節點
當前提交
bd03f481b4
共有 3 個文件被更改,包括 36 次插入5 次删除
  1. 20 3
      app-hd/controllers/GoodsController.php
  2. 1 1
      app-hd/controllers/MainController.php
  3. 15 1
      biz-hd/goods/classes/GoodsClass.php

+ 20 - 3
app-hd/controllers/GoodsController.php

@@ -46,9 +46,9 @@ class GoodsController extends BaseController
         $name = $info->name ?? '';
         $goodsSn = $info->sn ?? '';
         $price = floatval($info->price) ?? 0;
-        if(stringUtil::getWordNum($name)>7){
+        if (stringUtil::getWordNum($name) > 7) {
             $content = '<TEXT x="30" y="45" font="12" w="1" h="1" r="0">' . $name . '</TEXT>';
-        }else{
+        } 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>';
@@ -429,4 +429,21 @@ class GoodsController extends BaseController
         util::fail("保存失败");
     }
 
-}
+    //创建编号 ssh 20251110
+    public function actionCreateSn()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $info = GoodsClass::getById($id, true);
+        if (empty($info)) {
+            util::fail('没有找到商品');
+        }
+        if ($info->mainId != $this->mainId) {
+            util::fail('不是你的商品');
+        }
+        $shop = $this->shop;
+        GoodsClass::generateSn($info, $shop);
+        util::complete('创建成功');
+    }
+
+}

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

@@ -84,7 +84,7 @@ class MainController extends BaseController
         $goodsImgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $goodsPage, $scene, $ptStyle);
 
         $prefix = imgUtil::getPrefix();
-        $titleBase64 = stringUtil::ossBase64('花束绿植');
+        $titleBase64 = stringUtil::ossBase64('绿植花束');
 
         if ($pfShopId > 0) {
             $goodsUrl = $prefix . 'shop/miniCodeBg.jpg?x-oss-process=image';

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

@@ -867,4 +867,18 @@ class GoodsClass extends BaseClass
         return ['oldStock' => $goodsData['stock'], 'newStock' => $newStock];
     }
 
-}
+    public static function generateSn($goods, $shop)
+    {
+        if (!empty($goods->sn)) {
+            return true;
+        }
+        $shopId = $shop->id;
+        $mainId = $shop->mainId;
+        $data = ['shopId' => $shopId, 'mainId' => $mainId];
+        $sn = orderSn::getGoodsSn($data);
+        $goods->sn = $sn;
+        $goods->save();
+        return true;
+    }
+
+}