ソースを参照

feat(points): 添加用户积分模块

runphp 7 ヶ月 前
コミット
4bd1e8097f

+ 1 - 4
.gitignore

@@ -1,6 +1,3 @@
 composer.phar
 /vendor/
-
-# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
-# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
-# composer.lock
+.idea/

+ 36 - 0
composer.json

@@ -0,0 +1,36 @@
+{
+  "name": "six-shop/points",
+  "description": "用户积分模块,用户积分的新增 减少 对冲 列表等等",
+  "type": "sixshop-extension",
+  "keywords": [
+    "sixshop",
+    "thinkphp",
+    "points",
+    "积分",
+    "用户积分"
+  ],
+  "require": {
+    "php": ">=8.3",
+    "six-shop/core": ">=0.5.9 <1.0"
+  },
+  "authors": [
+    {
+      "name": "hui he",
+      "email": "runphp@qq.com"
+    }
+  ],
+  "license": "MIT",
+  "autoload": {
+    "psr-4": {
+      "SixShop\\Points\\": "src"
+    }
+  },
+  "extra": {
+    "sixshop": {
+      "id": "points",
+      "class": "SixShop\\Points\\Extension"
+    }
+  },
+  "minimum-stability": "dev",
+  "prefer-stable": true
+}

+ 6 - 0
config.php

@@ -0,0 +1,6 @@
+<?php
+declare(strict_types=1);
+
+return [
+
+];

+ 45 - 0
database/migrations/20250830123540_user_point.php

@@ -0,0 +1,45 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+
+class UserPoint extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change(): void
+    {
+        // 用户积分表
+        $table = $this->table('extension_user_point',[
+            'collation' => 'utf8mb4_unicode_ci',
+            'id' => false,
+            'comment' => '用户积分表',
+        ]);
+        $table->addColumn('user_id', Column::INTEGER, ['signed' => false, 'comment' => '用户ID'])
+            ->addColumn('point', Column::INTEGER, ['signed' => true, 'default' => 0, 'comment' => '积分'])
+            ->addColumn('freeze_point', Column::INTEGER, ['signed' => true, 'default' => 0, 'comment' => '冻结积分'])
+            ->addTimestamps()
+            ->create();
+
+      
+    }
+}

+ 47 - 0
database/migrations/20250830132345_user_point_log.php

@@ -0,0 +1,47 @@
+<?php
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+
+class UserPointLog extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        // 用户积分日志表
+        $table = $this->table('extension_user_point_log',[
+            'collation' => 'utf8mb4_unicode_ci',
+            'comment' => '用户积分日志表',
+        ]);
+        $table->addColumn('user_id', Column::INTEGER, ['signed' => false, 'comment' => '用户ID'])
+            ->addColumn('point', Column::INTEGER, ['signed' => true, 'default' => 0, 'comment' => '积分'])
+            ->addColumn('freeze_point', Column::INTEGER, ['signed' => true, 'default' => 0, 'comment' => '冻结积分'])
+            ->addColumn('type', Column::INTEGER, ['signed' => false, 'default' => 0, 'comment' => '类型 1 新增 2 减少 3 对冲'])
+            ->addColumn('biz_type', Column::TINYINTEGER, ['signed' => false, 'default' => 0, 'comment' => '关联业务类型 1 订单'])
+            ->addColumn('biz_id', Column::INTEGER, ['signed' => false, 'default' => 0, 'comment' => '关联业务ID'])
+            ->addColumn('remark', Column::STRING, ['default' => '', 'comment' => '备注'])
+            ->addTimestamps()
+            ->addIndex('user_id')
+            ->create();
+    }
+}

+ 14 - 0
info.php

@@ -0,0 +1,14 @@
+<?php
+declare(strict_types=1);
+
+return array(
+    'id' => 'points',
+    'name' => '用户积分模块',
+    'category' => 'other',
+    'description' => '用户积分模块,用户积分的新增 减少 对冲 列表等等',
+    'author' => 'runphp',
+    'email' => 'runphp@qq.com',
+    'website' => '',
+    'image' => '',
+    'license' => 'MIT',
+);

+ 10 - 0
src/Entity/UserPointEntity.php

@@ -0,0 +1,10 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Points\Entity;
+
+use SixShop\Core\Entity\BaseEntity;
+
+class UserPointEntity extends BaseEntity
+{
+
+}

+ 10 - 0
src/Entity/UserPointLogEntity.php

@@ -0,0 +1,10 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Points\Entity;
+
+use SixShop\Core\Entity\BaseEntity;
+
+class UserPointLogEntity extends BaseEntity
+{
+
+}          

+ 19 - 0
src/Extension.php

@@ -0,0 +1,19 @@
+<?php
+declare(strict_types=1);
+
+namespace SixShop\Points;
+
+use SixShop\Core\ExtensionAbstract;
+use SixShop\Payment\Contracts\PaymentExtensionInterface;
+use SixShop\Payment\Contracts\PaymentProviderInterface;
+use SixDec\RedeemCode\Hook\RedeemCodeHook;
+
+class Extension extends ExtensionAbstract
+{
+    public const string EXTENSION_NAME = 'points';
+
+    protected function getBaseDir(): string
+    {
+        return dirname(__DIR__);
+    }
+}

+ 16 - 0
src/Model/UserPointLogModel.php

@@ -0,0 +1,16 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Points\Model;
+
+use think\Model;
+
+class UserPointLogModel extends Model
+{
+    protected function getOptions(): array
+    {
+        return [
+            'name' => 'extension_user_point_log',
+        ];
+        
+    }
+}

+ 16 - 0
src/Model/UserPointModel.php

@@ -0,0 +1,16 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Points\Model;
+
+use think\Model;
+
+class UserPointModel extends Model
+{
+    protected function getOptions()
+    {
+        return [
+            'table' => 'extension_user_point',
+            'pk' => 'user_id',
+        ];
+    }
+}