Browse Source

修改字段

llp 4 days ago
parent
commit
ccc72d7a88

+ 7 - 12
packages/Longyi/Gift/src/Http/Controllers/Shop/GiftController.php

@@ -29,6 +29,7 @@ class GiftController extends Controller
 
     public function lists(): JsonResponse
     {
+        $customerId = auth()->user()->id;
         $gifts = $this->giftCardsModel->giftcards();
         return ApiResponse::success($gifts);
     }
@@ -60,10 +61,8 @@ class GiftController extends Controller
                 ->where('expirationdate', '>=', now())
                 ->orderBy('created_at', 'desc')
                 ->get();
-
-            return response()->json([
-                'success' => true,
-                'data' => $giftCards->map(function ($giftCard) {
+            return ApiResponse::success(
+                $giftCards->map(function ($giftCard) {
                     return [
                         'id' => $giftCard->id,
                         'giftcard_number' => $giftCard->giftcard_number,
@@ -72,16 +71,12 @@ class GiftController extends Controller
                         'formatted_remaining_giftcard_amount' => core()->formatPrice(core()->convertPrice($giftCard->remaining_giftcard_amount)),
                         'used_giftcard_amount' => $giftCard->used_giftcard_amount,
                         'expirationdate' => $giftCard->expirationdate->format('Y-m-d'),
-                        'giftcard_status' => $giftCard->giftcard_status,
+                        'giftcard_status' => $giftCard->giftcard_status
                     ];
-                }),
-            ]);
+                })
+            );
         } catch (\Exception $e) {
-            return response()->json([
-                'success' => false,
-                'message' => 'Failed to fetch gift cards',
-                'error' => $e->getMessage(),
-            ], Response::HTTP_INTERNAL_SERVER_ERROR);
+            return ApiResponse::error($e->getMessage());
         }
     }
     /**

+ 4 - 4
packages/Longyi/Gift/src/Models/GiftCards.php

@@ -180,7 +180,7 @@ class GiftCards extends Model implements GiftCardsContract
                 'num' => 0,
                 'expirationdate' => 30,
                 'channel' => 'activity_26_04_21',
-                'notes' => '拉新活动添加'
+                'notes' => ''
             ],
             2 => [
                 'id' => 2,
@@ -190,7 +190,7 @@ class GiftCards extends Model implements GiftCardsContract
                 'num' => 0,
                 'expirationdate' => 30,
                 'channel' => 'activity_26_04_21',
-                'notes' => '拉新活动添加'
+                'notes' => ''
             ],
             3 => [
                 'id' => 3,
@@ -200,7 +200,7 @@ class GiftCards extends Model implements GiftCardsContract
                 'num' => 0,
                 'expirationdate' => 30,
                 'channel' => 'activity_26_04_21',
-                'notes' => '拉新活动添加'
+                'notes' => ''
             ],
             4 => [
                 'id' => 4,
@@ -210,7 +210,7 @@ class GiftCards extends Model implements GiftCardsContract
                 'num' => 0,
                 'expirationdate' => 30,
                 'channel' => 'activity_26_04_21',
-                'notes' => '拉新活动添加'
+                'notes' => ''
             ],
         ];
     }