Skip to content

Commit

Permalink
添加产品预售功能及相关字段
Browse files Browse the repository at this point in the history
- 在 Product 模型中添加 is_pre_sale 字段,用于标记产品是否为预售
- 在数据库中添加预售相关的字段:is_pre_sale、start_sale_time 和 end_sale_time
- 更新表单和表格列,以支持预售功能
-调整产品状态枚举,移除预售状态
- 修改产品查询逻辑,不再包含预售状态- 更新产品转换器,处理预售时间
- 调整库存模型,简化预售判断逻辑
  • Loading branch information
liushoukun committed Oct 12, 2024
1 parent 3e571a6 commit e3f1760
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions src/Clusters/Product/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Support\Arr;
use RedJasmine\Ecommerce\Domain\Form\Models\Enums\FieldTypeEnum;
use RedJasmine\Ecommerce\Domain\Models\Enums\OrderQuantityLimitTypeEnum;
use RedJasmine\Ecommerce\Domain\Models\Enums\ProductTypeEnum;
use RedJasmine\Ecommerce\Domain\Models\Enums\ShippingTypeEnum;
use RedJasmine\Ecommerce\Domain\Form\Models\Enums\FieldTypeEnum;
use RedJasmine\FilamentCore\Helpers\ResourcePageHelper;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductResource\Pages\CreateProduct;
use RedJasmine\FilamentProduct\Clusters\Product\Resources\ProductResource\Pages\EditProduct;
Expand Down Expand Up @@ -135,14 +133,28 @@ public static function basicInfoFields() : array
->default(ShippingTypeEnum::EXPRESS)
->useEnum(ShippingTypeEnum::class),


Forms\Components\Toggle::make('is_pre_sale')
->label(__('red-jasmine-product::product.fields.is_pre_sale'))
->required()
->inline()
->default(false)
,

Forms\Components\ToggleButtons::make('status')
->label(__('red-jasmine-product::product.fields.status'))
->required()
->inline()
->default(ProductStatusEnum::ON_SALE)
->useEnum(ProductStatusEnum::class),


Forms\Components\DateTimePicker::make('start_sale_time')
->nullable()
->label(__('red-jasmine-product::product.fields.start_sale_time'))
->format('Y-m-d\TH:i:sP'),
Forms\Components\DateTimePicker::make('end_sale_time')
->nullable()
->label(__('red-jasmine-product::product.fields.end_sale_time'))
->format('Y-m-d\TH:i:sP'),
];
}

Expand Down Expand Up @@ -353,11 +365,11 @@ protected static function customizeProps() : Repeater
protected static function specifications() : array
{
return [ Forms\Components\Toggle::make('is_multiple_spec')
->label(__('red-jasmine-product::product.fields.is_multiple_spec'))
->required()
->live()
->inline()
->default(0),
->label(__('red-jasmine-product::product.fields.is_multiple_spec'))
->required()
->live()
->inline()
->default(0),

static::saleProps()->visible(fn(Forms\Get $get) => $get('is_multiple_spec'))
->live()
Expand Down Expand Up @@ -637,10 +649,9 @@ public static function saleInfoFields() : array


Forms\Components\Toggle::make('is_alone_order')
->label(__('red-jasmine-product::product.fields.is_alone_order'))
->required()

->default(false)
->label(__('red-jasmine-product::product.fields.is_alone_order'))
->required()
->default(false)

,

Expand Down Expand Up @@ -807,10 +818,10 @@ public static function table(Table $table) : Table

Tables\Columns\TextColumn::make('product_type')
->label(__('red-jasmine-product::product.fields.product_type'))
->enum(),
->enum()->toggleable(true, true),
Tables\Columns\TextColumn::make('shipping_type')
->label(__('red-jasmine-product::product.fields.shipping_type'))
->enum(),
->enum()->toggleable(true, true),
Tables\Columns\TextColumn::make('status')
->label(__('red-jasmine-product::product.fields.status'))
->enum(),
Expand All @@ -834,8 +845,8 @@ public static function table(Table $table) : Table
Tables\Columns\TextColumn::make('category.name')
->label(__('red-jasmine-product::product.fields.category_id'))
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('sellerCategory.name')
->label(__('red-jasmine-product::product.fields.seller_category_id'))
Tables\Columns\TextColumn::make('productGroup.name')
->label(__('red-jasmine-product::product.fields.product_group_id'))
->toggleable(isToggledHiddenByDefault: true),

Tables\Columns\TextColumn::make('price')
Expand Down

0 comments on commit e3f1760

Please sign in to comment.