WIN-2308041133\Administrator 1 week ago
parent
commit
2f4e7bfafd
2 changed files with 4 additions and 11 deletions
  1. 3 10
      app/Request.php
  2. 1 1
      app/api/controller/v1/store/StoreProductController.php

+ 3 - 10
app/Request.php

@@ -116,19 +116,12 @@ class Request extends \think\Request
      */
     public function replaceWord($farr, $str)
     {
-        file_put_contents(__DIR__ . '/../debug_replaceWord.log', "Input: " . var_export($str, true) . "\n", FILE_APPEND);
-        $url = parse_url($str);
-        file_put_contents(__DIR__ . '/../debug_replaceWord.log', "parse_url: " . var_export($url, true) . "\n", FILE_APPEND);
-        if ($url && isset($url['host']) && $url['host'] != '') {
-            if (!isset($url['scheme'])) {
-                $url['scheme'] = 'http';
-            }
-            $path = isset($url['path']) ? $url['path'] : '';
-            $str = $url['scheme'] . '://' . $url['host'] . preg_replace($farr, '', $path);
+        if (parse_url($str, PHP_URL_HOST)) {
+            $url = parse_url($str);
+            $str = $url['scheme'] . '://' . $url['host'] . preg_replace($farr, '', $url['path']);
         } else {
             $str = preg_replace($farr, '', $str);
         }
-        file_put_contents(__DIR__ . '/../debug_replaceWord.log', "Output: " . var_export($str, true) . "\n\n", FILE_APPEND);
         return $str;
     }
 

+ 1 - 1
app/api/controller/v1/store/StoreProductController.php

@@ -229,7 +229,7 @@ class StoreProductController
         $cartInfoServices = app()->make(StoreOrderCartInfoServices::class);
         $hasPurchased = $cartInfoServices->hasUserPurchasedProduct($request->uid(), $id);
 
-        if ($hasPurchased) {
+        if (!$hasPurchased) {
             return app('json')->fail('购买过该礼包商品后才能分享');
         }