Browse Source

专用储值卡

gorden 3 months ago
parent
commit
9b60476b72
1 changed files with 3 additions and 3 deletions
  1. 3 3
      app/admin/service/coupon/CardService.php

+ 3 - 3
app/admin/service/coupon/CardService.php

@@ -54,6 +54,7 @@ class CardService
         $prefixLength = strlen($demandConfig['prefix']);
         $suffixLength = strlen($demandConfig['suffix']);
         $rand = $demandConfig['rand'] ?? 0;
+        $begin = $demandConfig['begin'] ?? 1;
         if (!empty($lastCard)) {
             $oldCardId = $lastCard->card_id;
             $oldCardId = ltrim($oldCardId, $demandConfig['prefix']);
@@ -61,7 +62,7 @@ class CardService
             $oldCardId = ltrim($oldCardId, $demandConfig['rand']);
             $number = intval($oldCardId) + 1;
         } else {
-            $number = $demandConfig['begin'];
+            $number = $begin;
         }
 
         return $demandConfig['prefix'] . str_pad($number, $demandConfig['length'] - $prefixLength - $suffixLength, $rand, STR_PAD_LEFT) . $demandConfig['suffix'];
@@ -239,9 +240,8 @@ class CardService
         }
 
         $goodsIds = Goods::whereIn('join_goods_category_id', $categoryId)->pluck('goods_id')->toArray();
-        $goodsIds = array_unique(array_merge($goodsId));
 
-        return $goodsIds;
+        return array_unique(array_merge($goodsId,$goodsIds));
     }
 
     public static $status = [