shish 2 лет назад
Родитель
Сommit
1b16e11cef

+ 9 - 6
app-hd/controllers/PurchaseClearController.php

@@ -87,18 +87,21 @@ class PurchaseClearController extends BaseController
         }
         $name = '采购单结算';
         $totalFee = $order->actPrice;
-        //强制使用小程序的miniOpenId
-        $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
+        $openId = '';
+        if (isset($post['currentMiniOpenId']) && !empty($post['currentMiniOpenId'])) {
+            $openId = $post['currentMiniOpenId'];
+        }
         if (empty($openId)) {
-            if (isset($post['currentMiniOpenId']) && !empty($post['currentMiniOpenId'])) {
-                $openId = $post['currentMiniOpenId'];
+            if (isset($this->admin) && !empty($this->admin)) {
+                if (isset($this->admin->miniOpenId) && !empty($this->admin->miniOpenId)) {
+                    $openId = $this->admin->miniOpenId;
+                }
             }
         }
         if (empty($openId)) {
-            util::fail('没有openId');
+            util::fail('没有找到openId');
         }
         $capitalType = dict::getDict('capitalType', 'hdPurchaseClear', 'id');
-
         $ghsShopId = $order->ghsShopId ?? 0;
         $ghsShop = ShopClass::getById($ghsShopId, true);
         if (empty($ghsShop)) {

+ 11 - 2
app-hd/controllers/PurchaseController.php

@@ -859,8 +859,17 @@ class PurchaseController extends BaseController
 
         $name = $orderSn;
         $totalFee = $order->realPrice;
-        //强制使用小程序的miniOpenId
-        $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
+        $openId = '';
+        if (isset($post['currentMiniOpenId']) && !empty($post['currentMiniOpenId'])) {
+            $openId = $post['currentMiniOpenId'];
+        }
+        if (empty($openId)) {
+            if (isset($this->admin) && !empty($this->admin)) {
+                if (isset($this->admin->miniOpenId) && !empty($this->admin->miniOpenId)) {
+                    $openId = $this->admin->miniOpenId;
+                }
+            }
+        }
         if (empty($openId)) {
             $currentShopId = $order->shopId ?? 0;
             $currentShop = ShopClass::getById($currentShopId, true);