shish před 2 měsíci
rodič
revize
dbf9c8d6a2

+ 78 - 0
app-hd/controllers/GoodsController.php

@@ -11,6 +11,10 @@ use bizHd\goods\services\CategoryService;
 use bizHd\goods\services\GoodsCategoryService;
 use bizHd\goods\services\GoodsCategoryService;
 use bizHd\goods\services\GoodsSettingService;
 use bizHd\goods\services\GoodsSettingService;
 use bizHd\pictext\classes\PicTextGoodsClass;
 use bizHd\pictext\classes\PicTextGoodsClass;
+use bizHd\wx\classes\WxOpenClass;
+use common\components\dict;
+use common\components\imgUtil;
+use common\components\miniUtil;
 use common\components\printUtil;
 use common\components\printUtil;
 use common\components\stringUtil;
 use common\components\stringUtil;
 use Yii;
 use Yii;
@@ -170,6 +174,80 @@ class GoodsController extends BaseController
         util::success($goods);
         util::success($goods);
     }
     }
 
 
+    // 花束海报(散客扫码进 mall 小程序下单)ssh 20260602
+    public function actionGetPoster()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $goods = GoodsClass::getById($id, true);
+        if (empty($goods)) {
+            util::fail('获取失败');
+        }
+        GoodsClass::valid($goods, $this->mainId);
+        $cover = $goods->cover ?? '';
+        if (empty($cover)) {
+            util::fail('请先上传花束封面');
+        }
+
+        $merchant = WxOpenClass::getMallWxInfo();
+        $page = 'pages/goods/detail';
+        $ptStyle = dict::getDict('ptStyle', 'mall');
+        $shop = $this->shop;
+        $shopId = $shop->id ?? 0;
+        $scene = 'id=' . $id . '&a=' . $shopId;
+        $envVersion = miniUtil::normalizeMiniEnvVersion(Yii::$app->request->get('env_version', 'release'));
+        $miniCode = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle, $envVersion);
+        $miniCode = $miniCode . '?x-oss-process=image/resize,m_fill,h_200,w_200';
+        $miniCodeBase64 = stringUtil::ossBase64($miniCode);
+
+        Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'hd');
+
+        $prefix = imgUtil::getPrefix();
+        $goodsInfo = GoodsClass::getGoodsInfo($id, $shop, $this->custom, []);
+        $priceType = $goodsInfo['priceType'] ?? 0;
+        if ($priceType == 1) {
+            $newPrice = '¥' . floatval($goodsInfo['price'] ?? 0);
+        } else {
+            $newPrice = '面议';
+        }
+        $priceBase64 = stringUtil::ossBase64($newPrice);
+
+        $name = $goods->name ?? '';
+        $nameBase64 = stringUtil::ossBase64($name);
+
+        $staff = $this->shopAdmin;
+        $staffName = $staff->name ?? '';
+        $newStaffName = $staffName . ' 为您推荐';
+        $staffNameBase64 = stringUtil::ossBase64($newStaffName);
+
+        $goodsCover = imgUtil::groupImg($cover) . '?x-oss-process=image/resize,m_fill,h_750,w_750';
+        $goodsCoverBase64 = stringUtil::ossBase64($goodsCover);
+
+        $logoBase64 = '';
+        if (in_array($this->mainId, [52, 1459, 13495])) {
+            $logo = 'poster/hyxh_ncd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90';
+            if ($this->mainId == 1459) {
+                $logo = 'poster/hyxh_gcd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90';
+            }
+            if ($this->mainId == 13495) {
+                $logo = 'poster/hyxh_hzd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90';
+            }
+            $logoBase64 = stringUtil::ossBase64($logo);
+        }
+
+        $url = $prefix . 'poster/1234.jpg?x-oss-process=image';
+        $url .= '/watermark,image_' . $goodsCoverBase64 . ',g_nw,x_0,y_0';
+        $url .= '/watermark,image_' . $miniCodeBase64 . ',g_se';
+        if (!empty($logoBase64)) {
+            $url .= '/watermark,image_' . $logoBase64 . ',g_se,x_65,y_65';
+        }
+        $url .= '/watermark,text_' . $staffNameBase64 . ',g_sw,x_18,y_235,color_8B8989,type_d3F5LW1pY3JvaGVp,size_30';
+        $url .= '/watermark,text_' . $nameBase64 . ',g_sw,x_18,y_145';
+        $url .= '/watermark,text_' . $priceBase64 . ',g_sw,x_18,y_50,color_EE2C2C,type_d3F5LW1pY3JvaGVp,size_50';
+
+        util::success(['imgUrl' => $url]);
+    }
+
     //更新商品 ssh 2019.12.7
     //更新商品 ssh 2019.12.7
     public function actionUpdate()
     public function actionUpdate()
     {
     {

+ 2 - 1
app-hd/controllers/ItemController.php

@@ -291,7 +291,8 @@ class ItemController extends BaseController
         $shopId = $shop->id ?? 0;
         $shopId = $shop->id ?? 0;
         //scene不能超过32个字条
         //scene不能超过32个字条
         $scene = "id=" . $id . '&a=' . $shopId;
         $scene = "id=" . $id . '&a=' . $shopId;
-        $miniCode = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle);
+        $envVersion = miniUtil::normalizeMiniEnvVersion(Yii::$app->request->get('env_version', 'release'));
+        $miniCode = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle, $envVersion);
         $miniCode = $miniCode . '?x-oss-process=image/resize,m_fill,h_200,w_200';
         $miniCode = $miniCode . '?x-oss-process=image/resize,m_fill,h_200,w_200';
         $miniCodeBase64 = stringUtil::ossBase64($miniCode);
         $miniCodeBase64 = stringUtil::ossBase64($miniCode);
 
 

+ 8 - 0
app-mall/controllers/GoodsController.php

@@ -2,6 +2,7 @@
 
 
 namespace mall\controllers;
 namespace mall\controllers;
 
 
+use bizHd\goods\classes\GoodsCategoryClass;
 use bizMall\goods\classes\GoodsClass;
 use bizMall\goods\classes\GoodsClass;
 use bizMall\goods\classes\GoodsSettingClass;
 use bizMall\goods\classes\GoodsSettingClass;
 use bizMall\pictext\classes\PicTextGoodsClass;
 use bizMall\pictext\classes\PicTextGoodsClass;
@@ -17,6 +18,13 @@ class GoodsController extends BaseController
     {
     {
         $id = Yii::$app->request->get('id', 0);
         $id = Yii::$app->request->get('id', 0);
         $categoryId = intval(Yii::$app->request->get('categoryId'));
         $categoryId = intval(Yii::$app->request->get('categoryId'));
+        if ($categoryId <= 0 && $id > 0) {
+            $categoryMap = GoodsCategoryClass::getGoodsHasCategoryIdsBatch([$id]);
+            $categoryIds = $categoryMap[$id] ?? [];
+            if (!empty($categoryIds)) {
+                $categoryId = intval($categoryIds[0]);
+            }
+        }
         $custom = $this->custom;
         $custom = $this->custom;
         if (empty($custom)) {
         if (empty($custom)) {
             util::fail('用户信息缺失');
             util::fail('用户信息缺失');