Преглед изворни кода

Merge branch 'llp_gift_26_04_10' into dev

llp пре 3 дана
родитељ
комит
2e2548ea8b

+ 14 - 1
packages/Longyi/Gift/src/DataGrids/GiftCards/GiftCardsDataGrid.php

@@ -4,6 +4,7 @@ namespace Longyi\Gift\DataGrids\GiftCards;
 
 use Illuminate\Support\Facades\DB;
 use Webkul\DataGrid\DataGrid;
+use Longyi\Gift\Models\GiftCardUsageLog;
 
 class GiftCardsDataGrid extends DataGrid
 {
@@ -16,6 +17,10 @@ class GiftCardsDataGrid extends DataGrid
     {
         $queryBuilder = DB::table('gift_cards')
             ->leftJoin('customers', 'gift_cards.customer_id', '=', 'customers.id')
+            ->leftJoin('gift_card_usage_logs as gift_log', function ($leftJoin) {
+                $leftJoin->on('gift_log.customer_id', '=', 'gift_cards.customer_id')
+                    ->where('gift_log.action_type', GiftCardUsageLog::ACTION_ADD);
+            })
             ->select(
                 'gift_cards.id',
                 'gift_cards.giftcard_number',
@@ -28,6 +33,7 @@ class GiftCardsDataGrid extends DataGrid
                 'customers.last_name',
                 'gift_cards.expirationdate',
                 'gift_cards.giftcard_status',
+                'gift_log.notes',
                 'gift_cards.created_at',
                 'gift_cards.updated_at'
             );
@@ -37,6 +43,7 @@ class GiftCardsDataGrid extends DataGrid
         $this->addFilter('giftcard_amount', 'gift_cards.giftcard_amount');
         $this->addFilter('giftcard_status', 'gift_cards.giftcard_status');
         $this->addFilter('created_at', 'gift_cards.created_at');
+        $this->addFilter('notes', 'gift_log.notes');
         $this->addFilter('customer_email', 'customers.email');
 
         return $queryBuilder;
@@ -146,7 +153,13 @@ class GiftCardsDataGrid extends DataGrid
                 }
             },
         ]);
-
+        $this->addColumn([
+            'index'      => 'notes',
+            'label'      => 'notes',
+            'type'       => 'string',
+            'filterable' => true,
+            'sortable'   => true,
+        ]);
         $this->addColumn([
             'index'      => 'created_at',
             'label'      => trans('gift::app.admin.datagrid.created-at'),

+ 1 - 0
packages/Longyi/Gift/src/Database/Migrations/2026_04_01_184903_create_gift_cards_table.php

@@ -20,6 +20,7 @@ return new class extends Migration
             $table->integer('customer_id')->index()->default(0)->nullable();
             $table->tinyInteger('type')->default(1)->nullable()->comment('1:普通 2:other');
             $table->dateTime('expirationdate')->nullable()->comment('过期时间');
+            $table->string('channel', 200)->nullable()->comment('渠道');
             $table->string('giftcard_status', 2)->default(1)->nullable()->comment('1:未使用 2:已使用');
             $table->timestamps();
         });