Sfoglia il codice sorgente

feat(member-card): 初始化会员卡功能模块

- 创建会员卡定义表(mcard_member_card)
- 创建会员卡订单表(mcard_member_card_order)- 创建会员表(mcard_member)- 修复Extension.php命名空间错误
- 添加README.md文档说明- 增加数据库迁移文件和表结构定义
- 提供会员卡功能的完整数据库支持
runphp 5 mesi fa
parent
commit
325da13740

+ 86 - 0
README.md

@@ -0,0 +1,86 @@
+# Member Card Extension for SixShop
+
+This extension implements member card functionality for the SixShop e-commerce platform, allowing users to purchase membership cards with specific pricing and validity periods.
+
+## Features
+
+- Member card management (create, read, update, delete)
+- Member card order management
+- Member management with membership status tracking
+- Configurable pricing and validity periods for membership cards
+
+## Installation
+
+The extension is automatically loaded by the SixShop system. Ensure that the extension is properly registered in your SixShop installation.
+
+## Database Structure
+
+The extension uses the following database tables:
+
+- `mcard_member_card` - Member card definitions (pricing, validity periods)
+- `mcard_member_card_order` - Member card orders (purchase history)
+- `mcard_member` - Member records (user membership status)
+
+Migration files are located in the [database/migrations](database/migrations) directory:
+
+1. [20251004000001_create_member_card_table.php](database/migrations/20251004000001_create_member_card_table.php) - Creates the member card definitions table
+2. [20251004000002_create_member_card_order_table.php](database/migrations/20251004000002_create_member_card_order_table.php) - Creates the member card orders table
+3. [20251004000003_create_member_table.php](database/migrations/20251004000003_create_member_table.php) - Creates the member management table
+
+## API Endpoints
+
+### Admin Routes
+Admin routes are prefixed with `/admin/six-shop-member-card/`.
+
+### API Routes
+API routes are prefixed with `/api/six-shop-member-card/`.
+
+Authentication middleware should be added to routes as needed:
+```php
+->middleware(['auth'])
+```
+
+## Configuration
+
+The extension configuration can be found in [config.php](config.php).
+
+## Directory Structure
+
+```
+.
+├── config.php              # Extension configuration
+├── composer.json           # Composer configuration
+├── info.php                # Extension metadata
+├── README.md               # This file
+├── database/
+│   └── migrations/         # Database migration files
+├── route/
+│   ├── admin.php           # Admin routes
+│   └── api.php             # API routes
+└── src/
+    └── Extension.php       # Extension main class
+```
+
+## Usage
+
+After installation, the member card functionality will be available through the admin panel and API endpoints. Admins can:
+
+1. Create and manage different types of membership cards with varying prices and validity periods
+2. View member card orders and purchase history
+3. Manage members and their membership status
+
+## Extending the Extension
+
+To extend the functionality:
+
+1. Add new migration files to [database/migrations](database/migrations) for any additional database tables
+2. Add new routes to [route/admin.php](route/admin.php) or [route/api.php](route/api.php)
+3. Create new controllers and services in the src directory
+
+## Contributing
+
+Contributions are welcome. Please follow the SixShop coding standards and submit pull requests for any enhancements.
+
+## License
+
+This extension is licensed under the MIT License.

+ 41 - 0
database/migrations/20251004000001_create_member_card_table.php

@@ -0,0 +1,41 @@
+<?php
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class CreateMemberCardTable extends AbstractMigration
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change(): void
+    {
+        $table = $this->table('mcard_member_card', ['id' => false, 'primary_key' => ['id'], 'comment' => '会员卡定义表']);
+        
+        $table->addColumn('id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'identity' => true, 'comment' => '主键ID'])
+              ->addColumn('name', 'string', ['limit' => 100, 'null' => false, 'comment' => '会员卡名称'])
+              ->addColumn('description', 'text', ['null' => true, 'comment' => '会员卡描述'])
+              ->addColumn('price', 'decimal', ['precision' => 10, 'scale' => 2, 'null' => false, 'comment' => '会员卡价格'])
+              ->addColumn('validity_period', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'comment' => '有效期(天)'])
+              ->addColumn('sort', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '排序'])
+              ->addColumn('status', 'integer', ['limit' => 1, 'null' => false, 'default' => 1, 'comment' => '状态:0=禁用,1=启用'])
+              ->addColumn('create_time', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
+              ->addColumn('update_time', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间'])
+              ->addColumn('delete_time', 'timestamp', ['null' => true, 'comment' => '删除时间']);
+
+        // 添加索引
+        $table->addIndex(['status'])
+              ->addIndex(['sort'])
+              ->addIndex(['create_time']);
+
+        $table->create();
+    }
+}

+ 49 - 0
database/migrations/20251004000002_create_member_card_order_table.php

@@ -0,0 +1,49 @@
+<?php
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class CreateMemberCardOrderTable extends AbstractMigration
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change(): void
+    {
+        $table = $this->table('mcard_member_card_order', ['id' => false, 'primary_key' => ['id'], 'comment' => '会员卡订单表']);
+        
+        $table->addColumn('id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'identity' => true, 'comment' => '主键ID'])
+              ->addColumn('order_no', 'string', ['limit' => 32, 'null' => false, 'comment' => '订单编号'])
+              ->addColumn('user_id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'comment' => '用户ID'])
+              ->addColumn('member_card_id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'comment' => '会员卡ID'])
+              ->addColumn('card_name', 'string', ['limit' => 100, 'null' => false, 'comment' => '会员卡名称'])
+              ->addColumn('price', 'decimal', ['precision' => 10, 'scale' => 2, 'null' => false, 'comment' => '购买价格'])
+              ->addColumn('validity_period', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'comment' => '有效期(天)'])
+              ->addColumn('start_time', 'timestamp', ['null' => true, 'comment' => '生效开始时间'])
+              ->addColumn('end_time', 'timestamp', ['null' => true, 'comment' => '生效结束时间'])
+              ->addColumn('status', 'integer', ['limit' => 1, 'null' => false, 'default' => 0, 'comment' => '订单状态:0=待支付,1=已支付,2=已取消'])
+              ->addColumn('pay_time', 'timestamp', ['null' => true, 'comment' => '支付时间'])
+              ->addColumn('pay_type', 'string', ['limit' => 20, 'null' => true, 'comment' => '支付方式'])
+              ->addColumn('payment_id', 'string', ['limit' => 64, 'null' => true, 'comment' => '支付ID'])
+              ->addColumn('create_time', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
+              ->addColumn('update_time', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间'])
+              ->addColumn('delete_time', 'timestamp', ['null' => true, 'comment' => '删除时间']);
+
+        // 添加索引
+        $table->addIndex(['order_no'], ['unique' => true])
+              ->addIndex(['user_id'])
+              ->addIndex(['member_card_id'])
+              ->addIndex(['status'])
+              ->addIndex(['create_time']);
+
+        $table->create();
+    }
+}

+ 46 - 0
database/migrations/20251004000003_create_member_table.php

@@ -0,0 +1,46 @@
+<?php
+declare(strict_types=1);
+
+use Phinx\Migration\AbstractMigration;
+
+final class CreateMemberTable extends AbstractMigration
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change(): void
+    {
+        $table = $this->table('mcard_member', ['id' => false, 'primary_key' => ['id'], 'comment' => '会员表']);
+        
+        $table->addColumn('id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'identity' => true, 'comment' => '主键ID'])
+              ->addColumn('user_id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'comment' => '用户ID'])
+              ->addColumn('member_card_id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'comment' => '会员卡ID'])
+              ->addColumn('card_name', 'string', ['limit' => 100, 'null' => false, 'comment' => '会员卡名称'])
+              ->addColumn('order_id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'comment' => '订单ID'])
+              ->addColumn('start_time', 'timestamp', ['null' => false, 'comment' => '生效开始时间'])
+              ->addColumn('end_time', 'timestamp', ['null' => false, 'comment' => '生效结束时间'])
+              ->addColumn('status', 'integer', ['limit' => 1, 'null' => false, 'default' => 1, 'comment' => '会员状态:0=过期,1=正常'])
+              ->addColumn('create_time', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
+              ->addColumn('update_time', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'update' => 'CURRENT_TIMESTAMP', 'comment' => '更新时间'])
+              ->addColumn('delete_time', 'timestamp', ['null' => true, 'comment' => '删除时间']);
+
+        // 添加索引
+        $table->addIndex(['user_id'])
+              ->addIndex(['member_card_id'])
+              ->addIndex(['order_id'])
+              ->addIndex(['status'])
+              ->addIndex(['start_time'])
+              ->addIndex(['end_time'])
+              ->addIndex(['create_time']);
+
+        $table->create();
+    }
+}

+ 1 - 1
src/Extension.php

@@ -1,7 +1,7 @@
 <?php
 declare(strict_types=1);
 
-namespace SixShop\MemberCard\;
+namespace SixShop\MemberCard;
 
 use SixShop\Core\ExtensionAbstract;