فهرست منبع

Merge branch 'fix/hd-sun-code-invite-bind' of http://git.huaml.com/zhh/huahuibao into fix/hd-sun-code-invite-bind

shish 2 ماه پیش
والد
کامیت
06c4fa18bb

+ 21 - 0
app-ghs/controllers/ItemController.php

@@ -81,6 +81,27 @@ class ItemController extends BaseController
         util::complete('清除成功');
     }
 
+    //取消限购:将 limitBuy 置为 0
+    public function actionCancelLimitBuy()
+    {
+        $get = Yii::$app->request->get();
+        $id = intval($get['id'] ?? 0);
+        $item = ItemClass::getById($id, true);
+        if (empty($item)) {
+            util::fail('没有找到花材');
+        }
+        if ($item->mainId != $this->mainId) {
+            util::fail('不是你的花材');
+        }
+        $oldLimitBuy = intval($item->limitBuy ?? 0);
+        if ($oldLimitBuy <= 0) {
+            util::complete('已取消限购');
+        }
+        ProductClass::clearLimitBuyByProductId($id, $oldLimitBuy);
+        ProductClass::clearLimitBuyCache($id);
+        util::complete('取消限购成功');
+    }
+
     public function actionModifyWeight()
     {
         $shop = $this->shop;

+ 2 - 1
app-ghs/controllers/MainController.php

@@ -64,7 +64,8 @@ class MainController extends BaseController
         $ptStyle = dict::getDict('ptStyle', 'hd');
         //scene不能超过32个字条,这些进行缩写:sId = shopId gId = ghsShopAdminId
         $scene = "sId={$this->shopId}&id=0&gId=" . $this->shopAdminId;
-        $imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle);
+        $envVersion = miniUtil::normalizeMiniEnvVersion(Yii::$app->request->get('env_version', 'release'));
+        $imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle, $envVersion);
         $titleBase64 = stringUtil::ossBase64('扫码买花');
         $prefix = imgUtil::getPrefix();
         $url = $prefix . 'shop/miniCodeBg.jpg?x-oss-process=image';

+ 1 - 0
app-ghs/controllers/PurchaseOrderItemController.php

@@ -133,6 +133,7 @@ class PurchaseOrderItemController extends BaseController
                 $list[$key]['beforeModifyPrice'] = $beforeModifyPrice;
                 $beforeModifyStock = $current['stock'] ?? 0;
                 $list[$key]['beforeModifyStock'] = $beforeModifyStock;
+                $list[$key]['limitBuy'] = intval($current['limitBuy'] ?? 0);
             }
         }
         util::success(['list' => $list]);

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

@@ -475,7 +475,7 @@ class GhsController extends BaseController
         //noticeUtil::push("有新花店上来 {$this->shopId} {$toLat} {$toLnt} {$locationType} {$city}{$address}", '15280215347');
 
         // 找出附近批发店,之后自动给建立关系,然后补充二个店之间的距离
-        //GhsClass::buildNearbyGhsRelations($this->shop['id'], $this->shop->pfShopId, $toLat, $toLnt);
+        GhsClass::buildNearbyGhsRelations($this->shopId, $this->shop->pfShopId ?? 0, $toLat, $toLnt);
 
         //noticeUtil::push("花店 {$name} {$mobile} 新注册,已推荐批发店", '15280215347');
 

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

@@ -81,7 +81,8 @@ class MainController extends BaseController
         $goodsPage = 'pages/home/category';
         $ptStyle = dict::getDict('ptStyle', 'mall');
         $scene = 'a=' . $this->shopAdminId . '&s=' . $this->shopId;
-        $goodsImgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $goodsPage, $scene, $ptStyle);
+        $envVersion = miniUtil::normalizeMiniEnvVersion(Yii::$app->request->get('env_version', 'release'));
+        $goodsImgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $goodsPage, $scene, $ptStyle, $envVersion);
 
         $sjName = $shop->merchantName ?? '';
         $shopName = $shop->shopName ?? '';

+ 29 - 0
biz/ghs/classes/GhsClass.php

@@ -3,6 +3,7 @@
 namespace biz\ghs\classes;
 
 use biz\shop\classes\ShopClass;
+use biz\shop\classes\ShopAdminClass;
 use biz\sj\classes\MerchantAssetClass;
 use biz\sj\classes\SjClass;
 use biz\wx\classes\WxMessageClass;
@@ -222,6 +223,31 @@ class GhsClass extends BaseClass
         }
         $ids = array_column($list, 'shopId');
         $shopInfo = ShopClass::getByIds($ids, null, 'id');
+
+        $mainIds = [];
+        foreach ($shopInfo as $shop) {
+            $mainId = $shop['mainId'] ?? 0;
+            if (!empty($mainId)) {
+                $mainIds[(int)$mainId] = (int)$mainId;
+            }
+        }
+        $mainIds = array_values($mainIds);
+
+        $founderStaffMap = [];
+        if (!empty($mainIds)) {
+            $founderStaffList = ShopAdminClass::getAllByCondition(
+                ['mainId' => ['in', $mainIds], 'founder' => 2, 'delStatus' => 0],
+                null,
+                'id,mainId',
+                'mainId',
+                true
+            );
+            foreach ($founderStaffList as $mainId => $founderStaff) {
+				//分享批发店时,通过这个员工找到相应批发店
+                $founderStaffMap[$mainId] = intval($founderStaff->id ?? 0);
+            }
+        }
+
         foreach ($list as $key => $val) {
             $avatar = $val['avatar'] ?? '';
             $list[$key]['shortAvatar'] = $avatar;
@@ -282,6 +308,9 @@ class GhsClass extends BaseClass
             $pfLevel = $currentShop['pfLevel'] ?? 0;
             $list[$key]['pfLevel'] = $pfLevel;
 
+            $mainId = $currentShop['mainId'] ?? 0;
+            $list[$key]['ghsShopAdminId'] = !empty($mainId) ? ($founderStaffMap[$mainId] ?? 0) : 0;
+
             if (isset($val['mobile']) == false || empty($val['mobile'])) {
                 $mobile = $currentShop['mobile'] ?? '';
                 $list[$key]['mobile'] = $mobile;

+ 15 - 2
common/components/miniUtil.php

@@ -1574,10 +1574,20 @@ class miniUtil
     }
 
     //小程序码生成,永久有效,数量暂无限制 ssh 2020.4.17
-    public static function generateUnlimitedMiniCode($merchant, $page, $scene = '', $ptStyle = 0)
+    public static function normalizeMiniEnvVersion($envVersion = 'release')
     {
+        $envVersion = is_string($envVersion) ? strtolower(trim($envVersion)) : 'release';
+        if (!in_array($envVersion, ['develop', 'trial', 'release'], true)) {
+            return 'release';
+        }
+        return $envVersion;
+    }
+
+    public static function generateUnlimitedMiniCode($merchant, $page, $scene = '', $ptStyle = 0, $envVersion = 'release')
+    {
+        $envVersion = self::normalizeMiniEnvVersion($envVersion);
         $id = isset($merchant['id']) ? $merchant['id'] : 0;
-        $fileName = md5($page . '_' . $scene) . '.jpg';
+        $fileName = md5($page . '_' . $scene . '_' . $envVersion) . '.jpg';
         $behind = 'retail/mimiCode/' . date("Ym") . '/' . date("d") . '/' . $id . '/';
         $filePath = dirUtil::getImgDir() . $behind;
         if (!file_exists($filePath)) {
@@ -1595,6 +1605,9 @@ class miniUtil
             $data["page"] = $page;
         }
         $data["scene"] = $scene;
+        if ($envVersion !== 'release') {
+            $data["env_version"] = $envVersion;
+        }
         $result = $curl->setOption(CURLOPT_POSTFIELDS, Json::encode($data))->post($url);
         Yii::info('获取小程序图片资源:' . json_encode($result));
         file_put_contents($file, $result);