瀏覽代碼

清理旧文件:移除不再使用的模块和测试代码

Your Name 8 月之前
父節點
當前提交
1f0d9fdc62
共有 47 個文件被更改,包括 0 次插入2584 次删除
  1. 0 36
      app/Module/Dev/Models/Dev.php
  2. 0 33
      app/Module/System/Models/ReceiveAddress.php
  3. 0 20
      app/Module/Transaction/AdminControllers/TestController.php
  4. 0 46
      app/Module/Transaction/Commands/RechargeStatus50To202Command.php
  5. 0 35
      app/Module/Transaction/Commands/TestCommands.php
  6. 0 17
      app/Module/Transaction/Config/test.php
  7. 0 21
      app/Module/Transaction/Enums/ACCOUNT_TYPE.php
  8. 0 43
      app/Module/Transaction/Enums/RECHARGE_STATUS.php
  9. 0 37
      app/Module/Transaction/Enums/STATUS.php
  10. 0 29
      app/Module/Transaction/Enums/TRANSACTION_TYPE.php
  11. 0 37
      app/Module/Transaction/Enums/TRANSFER_STATUS.php
  12. 0 40
      app/Module/Transaction/Enums/WITHDRAWAL_STATUS.php
  13. 0 34
      app/Module/Transaction/Jobs/TestJob.php
  14. 0 31
      app/Module/Transaction/Listeners/TestEventListener.php
  15. 0 20
      app/Module/Transaction/Listeners/TestListener.php
  16. 0 55
      app/Module/Transaction/Models/Transaction.php
  17. 0 93
      app/Module/Transaction/Models/TransactionRecharge.php
  18. 0 53
      app/Module/Transaction/Models/TransactionTransfer.php
  19. 0 54
      app/Module/Transaction/Models/TransactionWithdrawal.php
  20. 0 35
      app/Module/Transaction/Providers/TransactionServiceProvider.php
  21. 0 8
      app/Module/Transaction/Queues/TestQueue.php
  22. 0 105
      app/Module/Transaction/README.md
  23. 0 68
      app/Module/Transaction/Repositorys/TestRepository.php
  24. 0 8
      app/Module/Transaction/Repositorys/TestRepositorys.php
  25. 0 204
      app/Module/Transaction/Services/TestService.php
  26. 0 49
      app/Module/Transaction/Services/TestServiceInterface.php
  27. 0 65
      app/Module/Transaction/Services/TestStatisticsService.php
  28. 0 30
      app/Module/Transaction/Services/TestStatisticsServiceInterface.php
  29. 0 272
      app/Module/Transaction/Services/TransactionService.php
  30. 0 167
      app/Module/Transaction/Tests/TestEventTest.php
  31. 0 133
      app/Module/Transaction/Tests/TestHookTest.php
  32. 0 83
      app/Module/Transaction/Tests/TestSoftDeleteTest.php
  33. 0 92
      app/Module/Transaction/Tests/TestTest.php
  34. 0 36
      app/Module/Transaction/Validations/AddHashValidation.php
  35. 0 48
      app/Module/Transaction/Validations/CreateTransferValidation.php
  36. 0 49
      app/Module/Transaction/Validations/CreateWithdrawalValidation.php
  37. 0 25
      app/Module/Transaction/Validations/HelloValidation.php
  38. 0 31
      app/Module/Transaction/Validations/RechargeValidation.php
  39. 0 10
      app/Module/Transaction/Validations/Test.php
  40. 0 27
      app/Module/Transaction/Validations/TransactionIdValidation.php
  41. 0 34
      app/Module/Transaction/Validators/AddHash.php
  42. 0 28
      app/Module/Transaction/Validators/CheckHash.php
  43. 0 25
      app/Module/Transaction/Validators/InProgress.php
  44. 0 10
      app/Module/Transaction/Validators/Test.php
  45. 0 26
      app/Module/Transaction/Validators/TransactionId.php
  46. 0 122
      app/Module/Ulogic/Models/UserAddress.php
  47. 0 60
      app/Module/Ulogic/Models/UserBans.php

+ 0 - 36
app/Module/Dev/Models/Dev.php

@@ -1,36 +0,0 @@
-<?php
-
-namespace App\Module\Dev\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * App\Module\Dev\Models\Dev
- *
- * field start 
- * field end
- */
-class Dev extends Model
-{
-    /**
-     * 与模型关联的表名
-     *
-     * @var string
-     */
-    protected $table = 'dev';
-
-    // attrlist start 
-    protected $fillable = [
-    ];
-    // attrlist end
-
-
-
-
-    /**
-     * 模型的主键
-     *
-     * @var string
-     */
-    protected $primaryKey = 'id';
-}

+ 0 - 33
app/Module/System/Models/ReceiveAddress.php

@@ -1,33 +0,0 @@
-<?php
-
-namespace App\Module\System\Models;
-
-use Dcat\Admin\Traits\HasDateTimeFormatter;
-use Illuminate\Database\Eloquent\Model;
-use Illuminate\Database\Eloquent\SoftDeletes;
-
-/**
- * field start 
- * field end
- */
-class ReceiveAddress extends Model
-{
-    // attrlist start 
-    protected $fillable = [
-    ];
-    // attrlist end
-	use HasDateTimeFormatter;
-    use SoftDeletes;
-
-    protected $table = 'receive_address';
-
-    /**
-     * @return \Illuminate\Database\Eloquent\Collection
-     * 随机获取系统地址
-     */
-    public static function getAddress()
-    {
-        $query = static::query();
-        return $query->inRandomOrder()->limit(1)->first();
-    }
-}

+ 0 - 20
app/Module/Transaction/AdminControllers/TestController.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\AdminControllers;
-
-use Dcat\Admin\Http\Controllers\AdminController;
-use Illuminate\Routing\Controller;
-use Illuminate\Support\Facades\Log;
-use Spatie\RouteAttributes\Attributes\Get;
-use Spatie\RouteAttributes\Attributes\Prefix;
-
-#[Prefix('test')]
-class TestController extends AdminController
-{
-    #[Get('/test')]
-    public function test()
-    {
-        Log::info(123);
-        echo 1;die;
-    }
-}

+ 0 - 46
app/Module/Transaction/Commands/RechargeStatus50To202Command.php

@@ -1,46 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Commands;
-
-
-use App\Module\System\Services\ConfigService;
-use App\Module\Test\Services\TestService;
-use Illuminate\Console\Command;
-
-
-/**
- * RechargeStatus50To202Command
- * 状态 50 -202
- *
- * @example php a
- *
- */
-class RechargeStatus50To202Command extends Command
-{
-
-    /**
-     *
-     * @var string
-     */
-    protected $signature = 'transaction:status50to202';
-
-    /**
-     * 命令描述
-     *
-     * @var string
-     */
-    protected $description = '充值单,未补充tx的过一段时间自动结束';
-
-    /**
-     * 执行命令
-     */
-    public function handle()
-    {
-        $s = ConfigService::getValueDefault('recharge_status50_to202','3600');
-
-        dump($s);
-
-        return self::SUCCESS;
-    }
-
-}

+ 0 - 35
app/Module/Transaction/Commands/TestCommands.php

@@ -1,35 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Commands;
-
-
-
-use App\Module\Test\Services\TestService;
-use Illuminate\Console\Command;
-
-class TestCommands extends Command
-{
-    /**
-     * 控制台命令的名称和签名
-     *
-     * @var string
-     */
-    protected $signature = 'test';
-
-    /**
-     * 命令描述
-     *
-     * @var string
-     */
-    protected $description = 'Test commands';
-
-    /**
-     * 执行命令
-     */
-    public function handle()
-    {
-        TestService::verify(1);
-        echo '完成';
-    }
-
-}

+ 0 - 17
app/Module/Transaction/Config/test.php

@@ -1,17 +0,0 @@
-<?php
-
-return [
-    /*
-    |--------------------------------------------------------------------------
-    | 测试模块配置
-    |--------------------------------------------------------------------------
-    */
-
-    // 测试配置项
-    'key' => 'value',
-
-    // 测试数组配置
-    'array' => [
-        'key' => 'value'
-    ]
-];

+ 0 - 21
app/Module/Transaction/Enums/ACCOUNT_TYPE.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Enums;
-
-use UCore\Enum\EnumCore;
-use UCore\Enum\EnumExpression;
-use UCore\Enum\EnumToInt;
-
-enum ACCOUNT_TYPE: int
-{
-
-    use EnumCore, EnumExpression, EnumToInt;
-
-    #
-    case URAUS = 1;
-    #
-    case USDT = 2;
-    #
-    case BNB = 3;
-
-}

+ 0 - 43
app/Module/Transaction/Enums/RECHARGE_STATUS.php

@@ -1,43 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Enums;
-
-
-/**
- * 充值表的状态
- *
- */
-enum RECHARGE_STATUS: int
-{
-
-    // 交易状态
-
-
-    //1:已创建
-    case CREATED = 1;
-
-
-    # 等待填写tx
-    case WAIT_TX = 50;
-
-    # tx校验中
-    case TX_CHECKING = 60;
-
-    # tx校验完成
-    case TX_CHECKED = 70;
-
-
-    //100:完成
-    case COMPLETED = 100;
-
-
-    //200:冻结
-    case FROZEN = 200;
-
-    //201:异常
-    case EXCEPTION = 201;
-
-    // 202:没有补充 Tx
-    case NO_TX = 202;
-
-}

+ 0 - 37
app/Module/Transaction/Enums/STATUS.php

@@ -1,37 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Enums;
-
-enum STATUS:int
-{
-
-    // 交易状态
-
-
-
-
-
-    //1:已创建
-    case CREATED = 1;
-
-    // 附表创建完成
-    case CALL_CREATED = 10;
-
-
-    # 处理中50
-    case PROCESSING =50;
-
-
-    //100:完成
-    case COMPLETED = 100;
-
-
-    //200:冻结
-    case FROZEN = 200;
-
-    //201:异常
-    case EXCEPTION = 201;
-    // refuse 拒绝
-    case REFUSE = 202;
-
-}

+ 0 - 29
app/Module/Transaction/Enums/TRANSACTION_TYPE.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Enums;
-
-use UCore\Enum\EnumCore;
-use UCore\Enum\EnumExpression;
-use UCore\Enum\EnumToInt;
-
-enum TRANSACTION_TYPE: int
-{
-
-    use EnumCore, EnumExpression, EnumToInt;
-
-    /**
-     * 充值 recharge
-     */
-    case RECHARGE = 1;
-
-    /**
-     * 转赠 transfer
-     */
-    case TRANSFER = 2;
-
-    /**
-     * 提现 withdrawal
-     */
-    case WITHDRAWAL = 3;
-
-}

+ 0 - 37
app/Module/Transaction/Enums/TRANSFER_STATUS.php

@@ -1,37 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Enums;
-
-
-/**
- * 提现 表的状态
- * withdrawal
- *
- */
-enum TRANSFER_STATUS:int
-{
-
-    //1:已创建
-    case CREATED = 1;
-
-    # 等待处理
-    case WAIT_CALL =70;
-
-    # 处理完成
-    case CALL_ED =80;
-
-
-    //100:完成
-    case COMPLETED = 100;
-
-
-    //200:冻结
-    case FROZEN = 200;
-
-    //201:异常
-    case EXCEPTION = 201;
-
-    // refuse 拒绝
-    case REFUSE = 202;
-
-}

+ 0 - 40
app/Module/Transaction/Enums/WITHDRAWAL_STATUS.php

@@ -1,40 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Enums;
-
-
-/**
- * 提现 表的状态
- * withdrawal
- *
- */
-enum WITHDRAWAL_STATUS:int
-{
-
-    //1:已创建
-    case CREATED = 1;
-
-    # Waiting for Review 等待审核
-    case WAIT_REVIEW =50;
-
-    # 等待处理
-    case WAIT_CALL =70;
-
-    # 处理完成
-    case CALL_ED =80;
-
-
-    //100:完成
-    case COMPLETED = 100;
-
-
-    //200:冻结
-    case FROZEN = 200;
-
-    //201:异常
-    case EXCEPTION = 201;
-
-    // refuse 拒绝
-    case REFUSE = 202;
-
-}

+ 0 - 34
app/Module/Transaction/Jobs/TestJob.php

@@ -1,34 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Jobs;
-
-use App\Module\Test\Models\Test;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-
-class TestJob implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-    /**
-     * 创建任务实例
-     *
-     * @param Test $test
-     */
-    public function __construct(protected Test $test)
-    {
-    }
-
-    /**
-     * 执行任务
-     *
-     * @return void
-     */
-    public function handle(): void
-    {
-        // 任务处理逻辑
-    }
-}

+ 0 - 31
app/Module/Transaction/Listeners/TestEventListener.php

@@ -1,31 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Listeners;
-
-use App\Module\Test\Events\TestEvent;
-use Illuminate\Contracts\Queue\ShouldQueue;
-
-class TestEventListener implements ShouldQueue
-{
-    /**
-     * 处理事件
-     *
-     * @param TestEvent $event
-     * @return void
-     */
-    public function handle(TestEvent $event): void
-    {
-        // 根据事件类型处理不同的逻辑
-        switch ($event->type) {
-            case 'created':
-                // 处理创建事件
-                break;
-            case 'updated':
-                // 处理更新事件
-                break;
-            case 'deleted':
-                // 处理删除事件
-                break;
-        }
-    }
-}

+ 0 - 20
app/Module/Transaction/Listeners/TestListener.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Listeners;
-
-use App\Module\Test\Events\TestEvent;
-use Illuminate\Contracts\Queue\ShouldQueue;
-
-class TestListener implements ShouldQueue
-{
-    /**
-     * 处理事件
-     *
-     * @param TestEvent $event
-     * @return void
-     */
-    public function handle(TestEvent $event): void
-    {
-        // 处理事件逻辑
-    }
-}

+ 0 - 55
app/Module/Transaction/Models/Transaction.php

@@ -1,55 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Models;
-
-use Dcat\Admin\Traits\HasDateTimeFormatter;
-use UCore\ModelCore;
-
-/**
- * 交易记录
- *
- * field start 
- * field end
- */
-class Transaction extends ModelCore
-{
-    // attrlist start 
-    protected $fillable = [
-    ];
-    // attrlist end
-    use HasDateTimeFormatter;
-
-    protected $table = 'transaction';
-
-    /**
-     * @param $data
-     * @return int
-     */
-    public static function insert($data)
-    {
-        $model = new self();
-        $model->transaction_no = $data['transaction_no'];
-        $model->user_id = $data['user_id'];
-        $model->from_user_id = $data['from_user_id'];
-        $model->to_user_id = $data['to_user_id'];
-        $model->coin_type = $data['coin_type'];
-        $model->type = $data['type'];
-        $model->amount = $data['amount'];
-        $model->status = $data['status'];
-        $model->save();
-        return $model->id;
-    }
-
-    /**
-     * @param $userId
-     * @param $id
-     * @return \Illuminate\Database\Eloquent\Collection
-     */
-    public static function getData($userId, $id)
-    {
-        $query = self::query();
-        $query->where('user_id', $userId);
-        $query->where('id', $id);
-        return $query->first();
-    }
-}

+ 0 - 93
app/Module/Transaction/Models/TransactionRecharge.php

@@ -1,93 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Models;
-
-use App\Module\Transaction\Enums\RECHARGE_STATUS;
-use Dcat\Admin\Traits\HasDateTimeFormatter;
-use UCore\ModelCore;
-
-/**
- * 充值记录
- *
- * field start 
- * field end
- */
-class TransactionRecharge extends ModelCore
-{
-
-    // attrlist start 
-    protected $fillable = [
-    ];
-    // attrlist end
-
-    /**
-     * @param $data
-     * @return static
-     */
-    public static function insert($data): static
-    {
-        $model = new static;
-        $model->transaction_id = $data['transaction_id'];
-        $model->from_address = $data['from_address'];
-        $model->to_address = $data['to_address'];
-        $model->status = $data['status'];
-        if ($model->save()) {
-            return $model;
-        }
-
-        return false;
-    }
-
-    /**
-     * @param $fromAddress
-     * @return null
-     * 检测地址是否有正在进行中的订单
-     */
-    public static function getOrderByFromAddress($fromAddress)
-    {
-        $query = self::query();
-        $query->where('from_address', $fromAddress);
-        $query->whereIn('status', [1, 50, 60, 70]);
-
-        return $query->first();
-    }
-
-    /**
-     * @param $transactionId
-     * @return null
-     * 获取充值单详情
-     */
-    public static function getDetail($transactionId)
-    {
-        $query = self::query();
-        $query->where('transaction_id', $transactionId);
-
-        return $query->first();
-    }
-
-    /**
-     * @param $transactionId
-     * @param $hash
-     * @return int
-     * 交易单添加hash
-     */
-    public static function addHash($transactionId, $hash)
-    {
-        $query = self::query();
-        $query->where('transaction_id', $transactionId);
-        return $query->update(['tx_hash' => $hash]);
-    }
-
-    /**
-     * @param $hash
-     * @return null
-     * 校验hash唯一性(校验已完成状态充值单)
-     */
-    public static function checkHash($hash)
-    {
-        $query = self::query();
-        $query->where('tx_hash', $hash);
-        $query->where('status', RECHARGE_STATUS::COMPLETED);
-        return $query->first();
-    }
-}

+ 0 - 53
app/Module/Transaction/Models/TransactionTransfer.php

@@ -1,53 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Models;
-
-use App\Module\Transaction\Enums\TRANSFER_STATUS;
-use Dcat\Admin\Traits\HasDateTimeFormatter;
-use Illuminate\Database\Eloquent\SoftDeletes;
-use UCore\ModelCore;
-
-/**
- * 转账记录
- *
- * field start 
- * field end
- */
-class TransactionTransfer extends ModelCore
-{
-    // attrlist start 
-    protected $fillable = [
-    ];
-    // attrlist end
-	use HasDateTimeFormatter;
-
-    protected $table = 'transaction_transfer';
-
-    /**
-     * @param $insertData
-     * 增加记录
-     */
-    public static function insert($insertData)
-    {
-        $model = new static;
-        $model->transaction_id = $insertData['transaction_id'];
-        $model->from_address = $insertData['from_address'];
-        $model->to_address = $insertData['to_address'];
-        $model->miner_amount = $insertData['miner_amount'];
-        $model->status = TRANSFER_STATUS::CREATED;
-        $model->save();
-    }
-
-    /**
-     * @param $transactionId
-     * @return null
-     * 获取转赠单详情
-     */
-    public static function getDetail($transactionId)
-    {
-        $query = self::query();
-        $query->where('transaction_id', $transactionId);
-
-        return $query->first();
-    }
-}

+ 0 - 54
app/Module/Transaction/Models/TransactionWithdrawal.php

@@ -1,54 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Models;
-
-use App\Module\Transaction\Enums\WITHDRAWAL_STATUS;
-use Dcat\Admin\Traits\HasDateTimeFormatter;
-use Illuminate\Database\Eloquent\SoftDeletes;
-use UCore\ModelCore;
-
-/**
- * 提现记录
- *
- * field start 
- * field end
- */
-class TransactionWithdrawal extends ModelCore
-{
-    // attrlist start 
-    protected $fillable = [
-    ];
-    // attrlist end
-	use HasDateTimeFormatter;
-
-    protected $table = 'transaction_withdrawal';
-
-    /**
-     * @param $insert
-     * @return bool
-     * 创建提现订单记录
-     */
-    public static function insert($insert)
-    {
-        $model = new static;
-        $model->transaction_id = $insert['transaction_id'];
-        $model->from_address = $insert['from_address'];
-        $model->to_address = $insert['to_address'];
-        $model->status = WITHDRAWAL_STATUS::WAIT_REVIEW;
-        $model->miner_amount = $insert['miner_amount'];
-        return $model->save();
-    }
-
-    /**
-     * @param $transactionId
-     * @return null
-     * 获取提现单详情
-     */
-    public static function getDetail($transactionId)
-    {
-        $query = self::query();
-        $query->where('transaction_id', $transactionId);
-
-        return $query->first();
-    }
-}

+ 0 - 35
app/Module/Transaction/Providers/TransactionServiceProvider.php

@@ -1,35 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Providers;
-
-use App\Module\Transaction\Commands\RechargeStatus50To202Command;
-use Illuminate\Support\ServiceProvider;
-
-
-/**
- *
- */
-class TransactionServiceProvider extends ServiceProvider
-{
-
-    /**
-     * 事件到监听器的映射
-     *
-     * @var array<class-string, array<int, class-string>>
-     */
-    protected $listen = [
-
-
-    ];
-
-    /**
-     * 注册任何事件监听器
-     */
-    public function boot(): void
-    {
-        $this->commands([
-                            RechargeStatus50To202Command::class
-                        ]);
-    }
-
-}

+ 0 - 8
app/Module/Transaction/Queues/TestQueue.php

@@ -1,8 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Queues;
-
-class TestQueue
-{
-
-}

+ 0 - 105
app/Module/Transaction/README.md

@@ -1,105 +0,0 @@
-# Test 模块
-
-## 模块说明
-Test 模块是一个示例模块,用于展示模块化开发的最佳实践。
-
-## 目录结构
-```
-app/Module/Test/
-├── Models/              # 模型目录
-├── Events/              # 事件目录
-├── Services/            # 服务目录
-│   ├── TestService.php              # 基础服务
-│   ├── TestServiceInterface.php     # 基础服务接口
-│   ├── TestStatisticsService.php    # 统计服务
-│   └── TestStatisticsServiceInterface.php  # 统计服务接口
-├── Enums/               # 枚举目录
-│   └── TestType.php     # 测试类型枚举
-├── Database/            # 数据库目录
-│   └── Migrations/      # 迁移文件
-└── Tests/               # 测试目录
-```
-
-## 安装说明
-1. 运行数据库迁移:
-```bash
-php artisan migrate
-```
-
-## 使用说明
-
-### 枚举使用
-```php
-use App\Module\Test\Enums\TestType;
-
-// 获取枚举值
-$enabled = TestType::ENABLED->value; // 1
-$disabled = TestType::DISABLED->value; // 0
-
-// 获取枚举标签
-$enabledLabel = TestType::ENABLED->label(); // "启用"
-$disabledLabel = TestType::DISABLED->label(); // "禁用"
-```
-
-### 基础服务
-```php
-use App\Module\Test\Services\TestService;
-use App\Module\Test\Enums\TestType;
-
-$test = new TestService();
-
-// 创建数据
-$model = $test->create([
-    'name' => '测试数据',
-    'code' => 'TEST001',
-    'status' => TestType::ENABLED->value
-]);
-
-// 更新数据
-$test->update($model, [
-    'name' => '更新后的数据',
-    'status' => TestType::DISABLED->value
-]);
-
-// 删除数据
-$test->delete($model);
-```
-
-### 统计服务
-```php
-use App\Module\Test\Services\TestStatisticsService;
-use App\Module\Test\Enums\TestType;
-
-$statistics = new TestStatisticsService();
-
-// 获取总数统计
-$totals = $statistics->getTotalStatistics();
-
-// 获取状态分布
-$statusDistribution = $statistics->getStatusDistribution();
-
-// 获取每日创建数量统计
-$dailyStats = $statistics->getDailyCreationStatistics(7);
-```
-
-## 配置说明
-暂无配置项。
-
-## 开发说明
-1. 遵循 PSR-12 编码规范
-2. 使用强类型声明
-3. 编写单元测试
-4. 保持代码简洁
-
-## 测试说明
-运行测试:
-```bash
-php artisan test app/Module/Test/Tests
-```
-
-## 贡献指南
-1. Fork 项目
-2. 创建特性分支
-3. 提交更改
-4. 推送到分支
-5. 创建 Pull Request 

+ 0 - 68
app/Module/Transaction/Repositorys/TestRepository.php

@@ -1,68 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Repositorys;
-
-use App\Module\Test\Models\Test;
-
-class TestRepository
-{
-    protected Test $model;
-
-    public function __construct(Test $model)
-    {
-        $this->model = $model;
-    }
-
-    /**
-     * 查找记录
-     *
-     * @param int $id
-     * @return Test|null
-     */
-    public function find(int $id): ?Test
-    {
-        return $this->model->find($id);
-    }
-
-    /**
-     * 创建记录
-     *
-     * @param array $data
-     * @return Test
-     */
-    public function create(array $data): Test
-    {
-        return $this->model->create($data);
-    }
-
-    /**
-     * 更新记录
-     *
-     * @param int $id
-     * @param array $data
-     * @return bool
-     */
-    public function update(int $id, array $data): bool
-    {
-        $model = $this->find($id);
-        if (!$model) {
-            return false;
-        }
-        return $model->update($data);
-    }
-
-    /**
-     * 删除记录
-     *
-     * @param int $id
-     * @return bool
-     */
-    public function delete(int $id): bool
-    {
-        $model = $this->find($id);
-        if (!$model) {
-            return false;
-        }
-        return $model->delete();
-    }
-}

+ 0 - 8
app/Module/Transaction/Repositorys/TestRepositorys.php

@@ -1,8 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Repositorys;
-
-class TestRepositorys
-{
-
-}

+ 0 - 204
app/Module/Transaction/Services/TestService.php

@@ -1,204 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Services;
-
-use App\Module\Test\Events\TestEvent;
-use App\Module\Test\Exceptions\TestException;
-use App\Module\Test\Models\Test as TestModel;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Event;
-use Illuminate\Support\Facades\Validator;
-
-class TestService implements TestServiceInterface
-{
-    /**
-     * 创建测试数据
-     *
-     * @param array $data
-     * @return TestModel
-     * @throws TestException
-     */
-    public function create(array $data): TestModel
-    {
-        try {
-            $this->validate($data);
-            $test = TestModel::create($data);
-            Event::dispatch(new TestEvent($test, 'created'));
-            return $test;
-        } catch (\Exception $e) {
-            throw new TestException('创建测试数据失败:' . $e->getMessage());
-        }
-    }
-
-    /**
-     * 更新测试数据
-     *
-     * @param TestModel $test
-     * @param array $data
-     * @return bool
-     * @throws TestException
-     */
-    public function update(TestModel $test, array $data): bool
-    {
-        try {
-            $this->validate($data);
-            $result = $test->update($data);
-            if ($result) {
-                Event::dispatch(new TestEvent($test, 'updated'));
-            }
-            return $result;
-        } catch (\Exception $e) {
-            throw new TestException('更新测试数据失败:' . $e->getMessage());
-        }
-    }
-
-    /**
-     * 删除测试数据
-     *
-     * @param TestModel $test
-     * @return bool
-     * @throws TestException
-     */
-    public function delete(TestModel $test): bool
-    {
-        try {
-            $result = $test->delete();
-            if ($result) {
-                Event::dispatch(new TestEvent($test, 'deleted'));
-            }
-            return $result;
-        } catch (\Exception $e) {
-            throw new TestException('删除测试数据失败:' . $e->getMessage());
-        }
-    }
-
-    /**
-     * 恢复测试数据
-     *
-     * @param TestModel $test
-     * @return bool
-     * @throws TestException
-     */
-    public function restore(TestModel $test): bool
-    {
-        try {
-            $result = $test->restore();
-            if ($result) {
-                Event::dispatch(new TestEvent($test, 'restored'));
-            }
-            return $result;
-        } catch (\Exception $e) {
-            throw new TestException('恢复测试数据失败:' . $e->getMessage());
-        }
-    }
-
-    /**
-     * 强制删除测试数据
-     *
-     * @param TestModel $test
-     * @return bool
-     * @throws TestException
-     */
-    public function forceDelete(TestModel $test): bool
-    {
-        try {
-            $result = $test->forceDelete();
-            if ($result) {
-                Event::dispatch(new TestEvent($test, 'force_deleted'));
-            }
-            return $result;
-        } catch (\Exception $e) {
-            throw new TestException('强制删除测试数据失败:' . $e->getMessage());
-        }
-    }
-
-    /**
-     * 验证数据
-     *
-     * @param array $data
-     * @return void
-     * @throws TestException
-     */
-    protected function validate(array $data): void
-    {
-        $validator = Validator::make($data, [
-            'name' => 'required|string|max:255',
-            'code' => 'required|string|max:50|unique:test,code',
-            'description' => 'nullable|string',
-            'data' => 'nullable|array',
-            'status' => 'required|integer|in:0,1'
-        ]);
-
-        if ($validator->fails()) {
-            throw new TestException('数据验证失败:' . $validator->errors()->first());
-        }
-    }
-
-    public static function insertHash()
-    {
-        // 初始化salt
-        $salt = 'uraus';
-        // 初始化hash
-        $hashInit = 'uraus';
-
-        for ($i = 0; $i < 10000; $i++) {
-            // 获取hash
-            $lashHash = DB::table('lan_hash_test')
-                ->where(['user_id' => 1])
-                ->orderBy('id', 'desc')
-                ->limit(1)
-                ->value('hash');
-            $lastHash = $lashHash ?? $hashInit;
-
-
-            // 验证哈希链
-            $isTrue = self::verify(1);
-            if (!$isTrue) {
-                echo '错误';
-                return;
-            }
-            $num = 1;
-            $time = time();
-            $hashStr = "$time|$num|$lastHash|$salt";
-            $hashValue = hash('sha256', $hashStr);
-            $insert = [
-                'user_id' => 1,
-                'num' => $num,
-                'time' => $time,
-                'hash' => $hashValue
-            ];
-            DB::table('lan_hash_test')->insert($insert);
-            echo $i . PHP_EOL;
-        }
-        return;
-    }
-
-    public static function verify($userId)
-    {
-        // 初始化salt
-        $salt = 'uraus';
-        // 初始化hash
-        $hashInit = 'uraus';
-        $logs = DB::table('lan_hash_test')->where(['user_id' => 1])->orderBy('id')->get()->toArray();
-        foreach ($logs as $key => $value) {
-            if (isset($logs[$key - 1])) {
-                $lastHash = $logs[$key - 1]->hash;
-            } else {
-                $lastHash = $hashInit;
-            }
-
-            $hashStr = "$value->time|$value->num|$lastHash|$salt";
-            $hashValue = hash('sha256', $hashStr);
-            if ($hashValue === $value->hash) {
-                echo $value->hash . PHP_EOL;
-                echo $hashValue . PHP_EOL;
-                echo '第'.$key.'次比对成功' . PHP_EOL;
-                continue;
-            }
-            echo $value->hash . PHP_EOL;
-            echo $hashValue . PHP_EOL;
-            echo '比对失败' . PHP_EOL;
-            return false;
-        }
-    }
-}

+ 0 - 49
app/Module/Transaction/Services/TestServiceInterface.php

@@ -1,49 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Services;
-
-use App\Module\Test\Models\Test as TestModel;
-
-interface TestServiceInterface
-{
-    /**
-     * 创建测试数据
-     *
-     * @param array $data
-     * @return TestModel
-     */
-    public function create(array $data): TestModel;
-
-    /**
-     * 更新测试数据
-     *
-     * @param TestModel $test
-     * @param array $data
-     * @return bool
-     */
-    public function update(TestModel $test, array $data): bool;
-
-    /**
-     * 删除测试数据
-     *
-     * @param TestModel $test
-     * @return bool
-     */
-    public function delete(TestModel $test): bool;
-
-    /**
-     * 恢复测试数据
-     *
-     * @param TestModel $test
-     * @return bool
-     */
-    public function restore(TestModel $test): bool;
-
-    /**
-     * 强制删除测试数据
-     *
-     * @param TestModel $test
-     * @return bool
-     */
-    public function forceDelete(TestModel $test): bool;
-}

+ 0 - 65
app/Module/Transaction/Services/TestStatisticsService.php

@@ -1,65 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Services;
-
-use App\Module\Test\Models\Test as TestModel;
-use Illuminate\Support\Facades\DB;
-
-class TestStatisticsService implements TestStatisticsServiceInterface
-{
-    /**
-     * 获取总数统计
-     *
-     * @return array
-     */
-    public function getTotalStatistics(): array
-    {
-        return [
-            'total' => TestModel::count(),
-            'active' => TestModel::where('status', 1)->count(),
-            'inactive' => TestModel::where('status', 0)->count(),
-            'deleted' => TestModel::onlyTrashed()->count(),
-        ];
-    }
-
-    /**
-     * 获取状态分布统计
-     *
-     * @return array
-     */
-    public function getStatusDistribution(): array
-    {
-        return TestModel::select('status', DB::raw('count(*) as count'))
-            ->groupBy('status')
-            ->get()
-            ->mapWithKeys(function ($item) {
-                return [$item->status => $item->count];
-            })
-            ->toArray();
-    }
-
-    /**
-     * 获取每日创建数量统计
-     *
-     * @param int $days
-     * @return array
-     */
-    public function getDailyCreationStatistics(int $days = 7): array
-    {
-        $startDate = now()->subDays($days)->startOfDay();
-        $endDate = now()->endOfDay();
-
-        return TestModel::select(
-            DB::raw('DATE(created_at) as date'),
-            DB::raw('count(*) as count')
-        )
-            ->whereBetween('created_at', [$startDate, $endDate])
-            ->groupBy('date')
-            ->orderBy('date')
-            ->get()
-            ->mapWithKeys(function ($item) {
-                return [$item->date => $item->count];
-            })
-            ->toArray();
-    }
-}

+ 0 - 30
app/Module/Transaction/Services/TestStatisticsServiceInterface.php

@@ -1,30 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Services;
-
-use App\Module\Test\Models\Test as TestModel;
-
-interface TestStatisticsServiceInterface
-{
-    /**
-     * 获取总数统计
-     *
-     * @return array
-     */
-    public function getTotalStatistics(): array;
-
-    /**
-     * 获取状态分布统计
-     *
-     * @return array
-     */
-    public function getStatusDistribution(): array;
-
-    /**
-     * 获取每日创建数量统计
-     *
-     * @param int $days
-     * @return array
-     */
-    public function getDailyCreationStatistics(int $days = 7): array;
-}

+ 0 - 272
app/Module/Transaction/Services/TransactionService.php

@@ -1,272 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Services;
-
-use App\Module\Fund\Enums\FUND_TYPE;
-use App\Module\Fund\Services\FundService;
-use App\Module\System\Models\ReceiveAddress;
-use App\Module\System\Services\OrderNo;
-use App\Module\Transaction\Enums\ACCOUNT_TYPE;
-use App\Module\Transaction\Enums\RECHARGE_STATUS;
-use App\Module\Transaction\Enums\STATUS;
-use App\Module\Transaction\Models\Transaction;
-use App\Module\Transaction\Models\TransactionRecharge;
-use App\Module\Transaction\Models\TransactionTransfer;
-use App\Module\Transaction\Models\TransactionWithdrawal;
-use App\Module\Ulogic\Services\UserAddressService;
-use Illuminate\Support\Facades\DB;
-use UCore\Helper\Logger;
-
-/**
- * 交易单
- */
-class TransactionService
-{
-
-    /**
-     * @param $userId
-     * @param $coinType
-     * @param $type
-     * @param $amount
-     * @param $addressId
-     * @return bool|int
-     */
-    public function createRecharge($userId, $coinType, $type, $amount, $addressId)
-    {
-        // 系统账户id
-        $adminUserId = 1;
-        $fromAddress = UserAddressService::getAddressById($addressId)->address;
-        $toAddress = ReceiveAddress::getAddress()->address;
-
-        DB::beginTransaction();
-        try {
-            // 插入交易主表
-            $transactionData = [
-                'transaction_no' => OrderNo::generate(),
-                'user_id' => $userId,
-                'from_user_id' => $userId,
-                'to_user_id' => $adminUserId,
-                'coin_type' => $coinType,
-                'type' => $type,
-                'amount' => $amount,
-                'status' => STATUS::CALL_CREATED->value,
-            ];
-            $transactionId = Transaction::insert($transactionData);
-            // 插入附表
-            $rechargeData = [
-                'transaction_id' => $transactionId,
-                'from_address' => $fromAddress,
-                'to_address' => $toAddress,
-                'status' => RECHARGE_STATUS::WAIT_TX->value
-            ];
-            $re = TransactionRecharge::insert($rechargeData);
-            DB::commit();
-
-            return $re->id;
-        } catch (\Exception $exception) {
-            DB::rollBack();
-            Logger::error('充值订单创建失败:'.$exception->getMessage());
-
-            return false;
-        }
-    }
-
-    /**
-     * @param $userId
-     * @param $transactionId
-     * @return \Illuminate\Database\Eloquent\Collection
-     * 获取交易单详情
-     */
-    public function getDetail($userId, $transactionId)
-    {
-        return Transaction::getData($userId, $transactionId);
-    }
-
-    /**
-     * @param $transactionId
-     * @return null
-     * 获取充值单详情
-     */
-    public function getRechargeDetail($transactionId)
-    {
-        return TransactionRecharge::getDetail($transactionId);
-    }
-
-    /**
-     * @param $transactionId
-     * @return null
-     * 获取转赠单详情
-     */
-    public static function getTransferDetail($transactionId)
-    {
-        return TransactionTransfer::getDetail($transactionId);
-    }
-
-    /**
-     * @param $transactionId
-     * @return null
-     * 获取提现单详情
-     */
-    public static function getWithdrawalDetail($transactionId)
-    {
-        return TransactionWithdrawal::getDetail($transactionId);
-    }
-
-    /**
-     * @param $id
-     * @param $hash
-     * @return int
-     * 充值单增加hash
-     */
-    public function addHash($id, $hash)
-    {
-        return TransactionRecharge::addHash($id, $hash);
-    }
-
-    /**
-     * @param $userId
-     * @param $coinType
-     * @param $type
-     * @param $amount
-     * @param $addressId
-     * @return int|void
-     * 创建转赠订单
-     */
-    public function createTransfer($userId, $coinType, $type, $amount, $addressId)
-    {
-        // 矿工费
-        $minerAmount = \App\Module\AppGame\Service\FundService::getMiner($coinType, $amount);
-        $toUserAddressData = UserAddressService::getAddressById($addressId);
-        // 交易主表数据
-        $transactionData = [
-            'transaction_no' => OrderNo::generate(),
-            'user_id' => $userId,
-            'from_user_id' => $userId,
-            'to_user_id' => $toUserAddressData->user_id,
-            'coin_type' => $coinType,
-            'type' => $type,
-            'amount' => $amount,
-            'status' => STATUS::CALL_CREATED->value,
-        ];
-
-
-        DB::beginTransaction();
-        try {
-            // 交易主表数据
-            $transactionId = Transaction::insert($transactionData);
-            // 交易附表数据
-            $transferData = [
-                'transaction_id' => $transactionId,
-                'from_address' => UserAddressService::getDataByUserId($userId)->address,
-                'to_address' => $toUserAddressData->address,
-                'miner_amount' => $minerAmount
-            ];
-            TransactionTransfer::insert($transferData);
-
-            // 资金操作(冻结转出方资金,增加日志)
-            $fund = [];
-            $toUserId = 0;
-            $minerUserId = 0;
-            // uraus转赠
-            if ($coinType == ACCOUNT_TYPE::URAUS->value) {
-                $fund = new FundService($userId, FUND_TYPE::FUND1->value);
-                $toUserId = FUND_TYPE::FUND2;
-                $minerUserId = FUND_TYPE::FUND2;
-            }
-            // usdt转赠
-            if ($coinType == ACCOUNT_TYPE::USDT->value) {
-                $fund = new FundService($userId, FUND_TYPE::USD->value);
-                $toUserId = FUND_TYPE::USD2;
-                $minerUserId = FUND_TYPE::USD2;
-            }
-            // bnb转赠
-            if ($coinType == ACCOUNT_TYPE::BNB->value) {
-                $fund = new FundService($userId, FUND_TYPE::BNB->value);
-                $toUserId = FUND_TYPE::BBB2;
-                $minerUserId = FUND_TYPE::USD2;
-            }
-            $fund->circulation($toUserId, $amount, $transactionId, 'TRANSFER', 'TRANSFER');
-            // 矿工费
-            $fund->circulation($minerUserId, $minerAmount, $transactionId, 'TRANSFER-MINER', 'TRANSFER-MINER');
-            DB::commit();
-            return $transactionId;
-        } catch (\Exception $exception) {
-            DB::rollBack();
-            Logger::error('创建转赠订单出错:'.$exception->getMessage());
-            return 0;
-        }
-    }
-
-    /**
-     * @param $userId
-     * @param $coinType
-     * @param $type
-     * @param $amount
-     * @param $toAddress
-     * @return int
-     * 创建提现订单
-     */
-    public function createWithdrawal($userId, $coinType, $type, $amount, $toAddress)
-    {
-        // 矿工费
-        $minerAmount = \App\Module\AppGame\Service\FundService::getMiner($coinType, $amount);
-        // 交易主表数据
-        $transactionData = [
-            'transaction_no' => OrderNo::generate(),
-            'user_id' => $userId,
-            'from_user_id' => $userId,
-            'to_user_id' => 0,
-            'coin_type' => $coinType,
-            'type' => $type,
-            'amount' => $amount,
-            'status' => STATUS::CALL_CREATED->value,
-        ];
-        DB::beginTransaction();
-        try {
-            // 交易主表数据
-            $transactionId = Transaction::insert($transactionData);
-            // 交易附表数据
-            $transferData = [
-                'transaction_id' => $transactionId,
-                'from_address' => UserAddressService::getDataByUserId($userId)->address,
-                'to_address' => $toAddress,
-                'miner_amount' => $minerAmount
-            ];
-            TransactionWithdrawal::insert($transferData);
-
-            // 资金操作(冻结转出方资金,增加日志)
-            $fund = [];
-            $toUserId = 0;
-            $minerUserId = 0;
-            // uraus提现
-            if ($coinType == ACCOUNT_TYPE::URAUS->value) {
-                $fund = new FundService($userId, FUND_TYPE::FUND1->value);
-                $toUserId = FUND_TYPE::FUND2;
-                $minerUserId = FUND_TYPE::FUND2;
-            }
-            // usdt提现
-            if ($coinType == ACCOUNT_TYPE::USDT->value) {
-                $fund = new FundService($userId, FUND_TYPE::USD->value);
-                $toUserId = FUND_TYPE::USD2;
-                $minerUserId = FUND_TYPE::USD2;
-            }
-            // bnb提现
-            if ($coinType == ACCOUNT_TYPE::BNB->value) {
-                $fund = new FundService($userId, FUND_TYPE::BNB->value);
-                $minerFund = new FundService($userId, FUND_TYPE::USD->value);
-                $toUserId = FUND_TYPE::BBB2;
-                $minerUserId = FUND_TYPE::USD2;
-            }
-            $fund->circulation($toUserId, $amount, $transactionId, 'WITHDRAWAL', 'WITHDRAWAL');
-            // 矿工费
-            $minerFund->circulation($minerUserId, $minerAmount, $transactionId, 'WITHDRAWAL-MINER', 'WITHDRAWAL-MINER');
-
-            Db::commit();
-            return $transactionId;
-        }catch (\Exception $exception){
-            DB::rollBack();
-            Logger::error('创建提现订单出错:'.$exception->getMessage());
-            throw new \Exception('创建提现订单出错');
-        }
-    }
-}

+ 0 - 167
app/Module/Transaction/Tests/TestEventTest.php

@@ -1,167 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Tests;
-
-use App\Module\Test\Events\TestEvent;
-use App\Module\Test\Models\Test;
-use App\Module\Test\Test as TestService;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
-use Illuminate\Support\Facades\Event;
-use Tests\TestCase;
-
-class TestEventTest extends TestCase
-{
-    use DatabaseTransactions;
-
-    protected TestService $service;
-
-    protected function setUp(): void
-    {
-        parent::setUp();
-        $this->service = new TestService();
-    }
-
-    /**
-     * 测试创建事件
-     */
-    public function test_created_event(): void
-    {
-        Event::fake();
-
-        // 创建测试数据
-        $test = $this->service->create([
-            'name' => '测试数据1',
-            'code' => 'TEST001',
-            'description' => '这是一个测试数据',
-            'data' => ['key' => 'value'],
-            'status' => 1
-        ]);
-
-        // 断言事件被触发
-        Event::assertDispatched(TestEvent::class, function ($event) use ($test) {
-            return $event->test->id === $test->id
-                && $event->type === 'created'
-                && $event->test->name === '测试数据1'
-                && $event->test->code === 'TEST001'
-                && $event->test->status === 1;
-        });
-    }
-
-    /**
-     * 测试更新事件
-     */
-    public function test_updated_event(): void
-    {
-        Event::fake();
-
-        // 创建测试数据
-        $test = $this->service->create([
-            'name' => '原始数据',
-            'code' => 'TEST002',
-            'status' => 1
-        ]);
-
-        // 更新数据
-        $this->service->update($test, [
-            'name' => '更新后的数据',
-            'status' => 2
-        ]);
-
-        // 断言事件被触发
-        Event::assertDispatched(TestEvent::class, function ($event) use ($test) {
-            return $event->test->id === $test->id
-                && $event->type === 'updated'
-                && $event->test->name === '更新后的数据'
-                && $event->test->status === 2;
-        });
-    }
-
-    /**
-     * 测试软删除事件
-     */
-    public function test_deleted_event(): void
-    {
-        Event::fake();
-
-        // 创建测试数据
-        $test = $this->service->create([
-            'name' => '待删除数据',
-            'code' => 'TEST003',
-            'status' => 1
-        ]);
-
-        // 软删除数据
-        $this->service->delete($test);
-
-        // 断言事件被触发
-        Event::assertDispatched(TestEvent::class, function ($event) use ($test) {
-            return $event->test->id === $test->id
-                && $event->type === 'deleted'
-                && $event->test->name === '待删除数据'
-                && $event->test->trashed();
-        });
-    }
-
-    /**
-     * 测试恢复事件
-     */
-    public function test_restored_event(): void
-    {
-        Event::fake();
-
-        // 创建并软删除测试数据
-        $test = $this->service->create([
-            'name' => '待恢复数据',
-            'code' => 'TEST004',
-            'status' => 1
-        ]);
-        $this->service->delete($test);
-
-        // 恢复数据
-        $this->service->restore($test);
-
-        // 断言事件被触发
-        Event::assertDispatched(TestEvent::class, function ($event) use ($test) {
-            return $event->test->id === $test->id
-                && $event->type === 'restored'
-                && $event->test->name === '待恢复数据'
-                && !$event->test->trashed();
-        });
-    }
-
-    /**
-     * 测试强制删除事件
-     */
-    public function test_force_deleted_event(): void
-    {
-        Event::fake();
-
-        // 创建测试数据
-        $test = $this->service->create([
-            'name' => '待强制删除数据',
-            'code' => 'TEST005',
-            'status' => 1
-        ]);
-
-        // 强制删除数据
-        $this->service->forceDelete($test);
-
-        // 断言事件被触发
-        Event::assertDispatched(TestEvent::class, function ($event) use ($test) {
-            return $event->test->id === $test->id
-                && $event->type === 'force_deleted'
-                && $event->test->name === '待强制删除数据';
-        });
-    }
-
-    /**
-     * 测试事件未被触发
-     */
-    public function test_event_not_dispatched(): void
-    {
-        Event::fake();
-
-        // 断言事件未被触发
-        Event::assertNotDispatched(TestEvent::class);
-    }
-}

+ 0 - 133
app/Module/Transaction/Tests/TestHookTest.php

@@ -1,133 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Tests;
-
-use App\Module\Test\Hooks\TestHook;
-use App\Module\Test\Models\Test;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
-use Tests\TestCase;
-
-class TestHookTest extends TestCase
-{
-    use DatabaseTransactions;
-
-    protected TestHook $hook;
-
-    public function setUp(): void
-    {
-        parent::setUp();
-        $this->hook = app(TestHook::class);
-    }
-
-    /**
-     * 测试创建并通知
-     *
-     * @return void
-     */
-    public function test_create_and_notify(): void
-    {
-        $data = [
-            'name' => '测试数据',
-            'code' => 'TEST001',
-            'description' => '测试描述'
-        ];
-
-        $result = $this->hook->createAndNotify($data);
-
-        $this->assertIsArray($result);
-        $this->assertEquals('测试数据创建成功', $result['title']);
-        $this->assertStringContainsString($data['name'], $result['content']);
-        $this->assertStringContainsString($data['code'], $result['content']);
-        $this->assertArrayHasKey('test_id', $result['data']);
-        $this->assertEquals($data['name'], $result['data']['name']);
-        $this->assertEquals($data['code'], $result['data']['code']);
-
-        // 验证数据是否真的创建了
-        $test = Test::find($result['data']['test_id']);
-        $this->assertNotNull($test);
-        $this->assertEquals($data['name'], $test->name);
-        $this->assertEquals($data['code'], $test->code);
-    }
-
-    /**
-     * 测试更新并通知
-     *
-     * @return void
-     */
-    public function test_update_and_notify(): void
-    {
-        // 创建测试数据
-        $test = Test::factory()->create();
-
-        $data = [
-            'name' => '更新数据',
-            'code' => 'TEST002'
-        ];
-
-        $result = $this->hook->updateAndNotify($test->id, $data);
-
-        $this->assertIsArray($result);
-        $this->assertEquals('测试数据更新成功', $result['title']);
-        $this->assertStringContainsString($data['name'], $result['content']);
-        $this->assertStringContainsString($data['code'], $result['content']);
-        $this->assertEquals($test->id, $result['data']['test_id']);
-        $this->assertEquals($data['name'], $result['data']['name']);
-        $this->assertEquals($data['code'], $result['data']['code']);
-
-        // 验证数据是否真的更新了
-        $test->refresh();
-        $this->assertEquals($data['name'], $test->name);
-        $this->assertEquals($data['code'], $test->code);
-    }
-
-    /**
-     * 测试更新不存在的数据
-     *
-     * @return void
-     */
-    public function test_update_non_existent(): void
-    {
-        $result = $this->hook->updateAndNotify(999, [
-            'name' => '更新数据',
-            'code' => 'TEST002'
-        ]);
-
-        $this->assertNull($result);
-    }
-
-    /**
-     * 测试删除并通知
-     *
-     * @return void
-     */
-    public function test_delete_and_notify(): void
-    {
-        // 创建测试数据
-        $test = Test::factory()->create();
-
-        $result = $this->hook->deleteAndNotify($test->id);
-
-        $this->assertIsArray($result);
-        $this->assertEquals('测试数据删除成功', $result['title']);
-        $this->assertStringContainsString($test->name, $result['content']);
-        $this->assertStringContainsString($test->code, $result['content']);
-        $this->assertEquals($test->id, $result['data']['test_id']);
-        $this->assertEquals($test->name, $result['data']['name']);
-        $this->assertEquals($test->code, $result['data']['code']);
-
-        // 验证数据是否真的删除了
-        $this->assertNull(Test::find($test->id));
-    }
-
-    /**
-     * 测试删除不存在的数据
-     *
-     * @return void
-     */
-    public function test_delete_non_existent(): void
-    {
-        $result = $this->hook->deleteAndNotify(999);
-
-        $this->assertNull($result);
-    }
-}

+ 0 - 83
app/Module/Transaction/Tests/TestSoftDeleteTest.php

@@ -1,83 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Tests;
-
-use App\Module\Test\Models\Test;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
-use Tests\TestCase;
-
-class TestSoftDeleteTest extends TestCase
-{
-    use DatabaseTransactions;
-
-    /**
-     * 测试软删除功能
-     */
-    public function test_soft_delete(): void
-    {
-        // 创建测试数据
-        $test = Test::factory()->create([
-            'name' => '测试数据1',
-            'description' => '这是一个测试数据'
-        ]);
-
-        // 验证数据存在
-        $this->assertDatabaseHas('tests', [
-            'id' => $test->id,
-            'name' => '测试数据1',
-            'description' => '这是一个测试数据'
-        ]);
-
-        // 软删除数据
-        $test->delete();
-
-        // 验证数据在正常查询中不可见
-        $this->assertDatabaseMissing('tests', [
-            'id' => $test->id,
-            'name' => '测试数据1',
-            'description' => '这是一个测试数据'
-        ]);
-
-        // 验证数据在软删除表中可见
-        $this->assertSoftDeleted('tests', [
-            'id' => $test->id,
-            'name' => '测试数据1',
-            'description' => '这是一个测试数据'
-        ]);
-
-        // 恢复数据
-        $test->restore();
-
-        // 验证数据恢复后可见
-        $this->assertDatabaseHas('tests', [
-            'id' => $test->id,
-            'name' => '测试数据1',
-            'description' => '这是一个测试数据'
-        ]);
-    }
-
-    /**
-     * 测试强制删除功能
-     */
-    public function test_force_delete(): void
-    {
-        // 创建测试数据
-        $test = Test::factory()->create([
-            'name' => '测试数据2',
-            'description' => '这是另一个测试数据'
-        ]);
-
-        // 软删除数据
-        $test->delete();
-
-        // 强制删除数据
-        $test->forceDelete();
-
-        // 验证数据完全删除
-        $this->assertDatabaseMissing('tests', [
-            'id' => $test->id,
-            'name' => '测试数据2',
-            'description' => '这是另一个测试数据'
-        ]);
-    }
-}

+ 0 - 92
app/Module/Transaction/Tests/TestTest.php

@@ -1,92 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Tests;
-
-use App\Module\Test\Models\Test;
-use App\Module\Test\Services\TestService;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
-use Tests\TestCase;
-
-class TestTest extends TestCase
-{
-    use DatabaseTransactions;
-
-    protected TestService $service;
-
-    protected function setUp(): void
-    {
-        parent::setUp();
-        $this->service = app(TestService::class);
-    }
-
-    /**
-     * 测试创建数据
-     *
-     * @return void
-     */
-    public function test_create(): void
-    {
-        $data = [
-            'name' => '测试数据',
-            'code' => 'TEST001',
-            'description' => '测试描述'
-        ];
-
-        $test = $this->service->create($data);
-
-        $this->assertInstanceOf(Test::class, $test);
-        $this->assertEquals($data['name'], $test->name);
-        $this->assertEquals($data['code'], $test->code);
-        $this->assertEquals($data['description'], $test->description);
-    }
-
-    /**
-     * 测试获取数据
-     *
-     * @return void
-     */
-    public function test_get(): void
-    {
-        $test = Test::factory()->create();
-
-        $result = $this->service->get($test->id);
-
-        $this->assertInstanceOf(Test::class, $result);
-        $this->assertEquals($test->id, $result->id);
-    }
-
-    /**
-     * 测试更新数据
-     *
-     * @return void
-     */
-    public function test_update(): void
-    {
-        $test = Test::factory()->create();
-        $data = [
-            'name' => '更新数据',
-            'code' => 'TEST002'
-        ];
-
-        $result = $this->service->update($test->id, $data);
-
-        $this->assertTrue($result);
-        $this->assertEquals($data['name'], $test->fresh()->name);
-        $this->assertEquals($data['code'], $test->fresh()->code);
-    }
-
-    /**
-     * 测试删除数据
-     *
-     * @return void
-     */
-    public function test_delete(): void
-    {
-        $test = Test::factory()->create();
-
-        $result = $this->service->delete($test->id);
-
-        $this->assertTrue($result);
-        $this->assertNull(Test::find($test->id));
-    }
-}

+ 0 - 36
app/Module/Transaction/Validations/AddHashValidation.php

@@ -1,36 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validations;
-
-use App\Module\Transaction\Validators\Addhash;
-use App\Module\Transaction\Validators\CheckHash;
-use UCore\ValidationCore;
-
-class AddHashValidation extends ValidationCore
-{
-    /**
-     * @param $rules
-     * @return array
-     * 充值单添加hash值校验
-     */
-    public function rules($rules = [],$data = []): array
-    {
-        $rules = [
-            [
-                'userId,transactionId,hash', 'required'
-            ],
-            [
-                'userId,transactionId',
-                new Addhash($this),
-                'msg' => '充值单错误'
-            ],
-            [
-                'userId,transactionId',
-                new CheckHash($this),
-                'msg' => '充值单错误'
-            ],
-        ];
-
-        return parent::rules($rules);
-    }
-}

+ 0 - 48
app/Module/Transaction/Validations/CreateTransferValidation.php

@@ -1,48 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validations;
-
-use App\Module\Fund\Validators\CheckUserFund;
-use UCore\ValidationCore;
-use UCore\Validator\Address;
-use UCore\Validator\CheckPassword;
-use UCore\Validator\IsUrausAddress;
-use UCore\Validator\IsUserAddress;
-
-class CreateTransferValidation extends ValidationCore
-{
-    /**
-     * @param  array  $rules
-     * @param $data
-     * @return array
-     * 创建转赠订单验证
-     * fromUserId账户内资金,是否是网内地址,网内地址是否存在
-     */
-    public function rules(array $rules = [], $data = []): array
-    {
-        $rules = [
-            [
-                'coinType,amount,userId,to_address,password', 'required'
-            ],
-            [
-                // 验证fromUserId账户内资金
-                'userId,amount',
-                new CheckUserFund($this),
-                'msg' => '用户余额不足'
-            ],
-            [
-                'to_address',
-                new IsUrausAddress($this),
-                'msg' => '地址错误'
-            ],
-            [
-                'user_id,password',
-                new CheckPassword($this),
-                'msg' => '交易密码错误'
-            ]
-
-        ];
-        return parent::rules($rules);
-    }
-
-}

+ 0 - 49
app/Module/Transaction/Validations/CreateWithdrawalValidation.php

@@ -1,49 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validations;
-
-use App\Module\Fund\Validators\CheckUserFund;
-use UCore\ValidationCore;
-use UCore\Validator\Address;
-use UCore\Validator\CheckPassword;
-use UCore\Validator\IsOnlineAddress;
-use UCore\Validator\IsUrausAddress;
-use UCore\Validator\IsUserAddress;
-
-class CreateWithdrawalValidation extends ValidationCore
-{
-    /**
-     * @param  array  $rules
-     * @param $data
-     * @return array
-     * 创建转赠订单验证
-     * fromUserId账户内资金,是否是网内地址,网内地址是否存在
-     */
-    public function rules(array $rules = [], $data = []): array
-    {
-        $rules = [
-            [
-                'coinType,amount,userId,to_address,password', 'required'
-            ],
-            [
-                // 验证fromUserId账户内资金
-                'userId,amount',
-                new CheckUserFund($this),
-                'msg' => '用户余额不足'
-            ],
-            [
-                'to_address',
-                new IsOnlineAddress($this),
-                'msg' => '地址错误'
-            ],
-            [
-                'user_id,password',
-                new CheckPassword($this),
-                'msg' => '交易密码错误'
-            ]
-
-        ];
-        return parent::rules($rules);
-    }
-
-}

+ 0 - 25
app/Module/Transaction/Validations/HelloValidation.php

@@ -1,25 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validations;
-
-use UCore\ValidationCore;
-
-class HelloValidation extends ValidationCore
-{
-
-    public function rules(array $rules = []): array
-    {
-        $rules[] = [
-            'times', 'required'
-        ];
-        $rules[] = [
-            'msg', 'required'
-        ];
-        $rules[] = [
-            'times', 'integer', 'min' => 10
-        ];
-
-        return parent::rules($rules); // TODO: Change the autogenerated stub
-    }
-
-}

+ 0 - 31
app/Module/Transaction/Validations/RechargeValidation.php

@@ -1,31 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validations;
-
-use App\Module\Transaction\Validators\InProgress;
-use UCore\ValidationCore;
-use UCore\Validator\IsUserAddress;
-
-class RechargeValidation extends ValidationCore
-{
-    public function rules($rules = []): array
-    {
-        $rules = [
-            [
-                'userId,addressId', 'required'
-            ],
-            [
-                'userId,addressId',
-                new IsUserAddress($this),
-                'msg' => '地址不属于该用户'
-            ],
-            [
-                'addressId',
-                new InProgress($this),
-                'msg' => '该地址有正在进行中的充值单,请稍后再试'
-            ]
-        ];
-
-        return parent::rules($rules);
-    }
-}

+ 0 - 10
app/Module/Transaction/Validations/Test.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validations;
-
-use Inhere\Validate\Validation;
-
-class Test extends Validation
-{
-
-}

+ 0 - 27
app/Module/Transaction/Validations/TransactionIdValidation.php

@@ -1,27 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validations;
-
-use App\Module\Transaction\Validators\InProgress;
-use App\Module\Transaction\Validators\TransactionId;
-use UCore\ValidationCore;
-use UCore\Validator\isUserAddress;
-
-class TransactionIdValidation extends ValidationCore
-{
-    public function rules($rules = []): array
-    {
-        $rules = [
-            [
-                'userId,transactionId', 'required'
-            ],
-            [
-                'userId,transactionId',
-                new TransactionId($this),
-                'msg' => '非法请求充值单'
-            ]
-        ];
-
-        return parent::rules($rules);
-    }
-}

+ 0 - 34
app/Module/Transaction/Validators/AddHash.php

@@ -1,34 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validators;
-
-use App\Module\Transaction\Enums\RECHARGE_STATUS;
-use App\Module\Transaction\Enums\STATUS;
-use App\Module\Transaction\Models\Transaction;
-use App\Module\Transaction\Models\TransactionRecharge;
-use UCore\Validator;
-
-class AddHash extends Validator
-{
-    /**
-     * @param  mixed  $value
-     * @param  array  $data
-     * @return bool
-     * 添加hash校验
-     */
-
-    public function validate(mixed $value, array $data): bool
-    {
-        $data = Transaction::getData($data['userId'], $data['transactionId']);
-        $rechargeData = TransactionRecharge::getDetail($data->id);
-
-        if ($rechargeData->tx_hash) {
-            return false;
-        }
-
-        if ($data->status != STATUS::CALL_CREATED->value || $rechargeData->status != RECHARGE_STATUS::WAIT_TX->value) {
-            return false;
-        }
-        return true;
-    }
-}

+ 0 - 28
app/Module/Transaction/Validators/CheckHash.php

@@ -1,28 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validators;
-
-use App\Module\Transaction\Enums\RECHARGE_STATUS;
-use App\Module\Transaction\Enums\STATUS;
-use App\Module\Transaction\Models\Transaction;
-use App\Module\Transaction\Models\TransactionRecharge;
-use UCore\Validator;
-
-class CheckHash extends Validator
-{
-    /**
-     * @param  mixed  $value
-     * @param  array  $data
-     * @return bool
-     * 添加hash校验
-     */
-    public function validate(mixed $value, array $data): bool
-    {
-        $rechargeData = TransactionRecharge::checkHash($data['hash']);
-
-        if ($rechargeData) {
-            return false;
-        }
-        return true;
-    }
-}

+ 0 - 25
app/Module/Transaction/Validators/InProgress.php

@@ -1,25 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validators;
-
-use App\Module\Transaction\Models\TransactionRecharge;
-use App\Module\Ulogic\Services\UserAddressService;
-use UCore\Validator;
-
-class InProgress extends Validator
-{
-    /**
-     * @param  mixed  $value
-     * @param  array  $data
-     * @return bool
-     */
-    public function validate(mixed $value, array $data): bool
-    {
-        $address = UserAddressService::getAddressById($value)->address;
-        $data = TransactionRecharge::getOrderByFromAddress($address);
-        if ($data) {
-            return false;
-        }
-        return true;
-    }
-}

+ 0 - 10
app/Module/Transaction/Validators/Test.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validators;
-
-use Inhere\Validate\Validation;
-
-class Test implements Validator
-{
-
-}

+ 0 - 26
app/Module/Transaction/Validators/TransactionId.php

@@ -1,26 +0,0 @@
-<?php
-
-namespace App\Module\Transaction\Validators;
-
-use App\Module\Transaction\Models\Transaction;
-use App\Module\Transaction\Models\TransactionRecharge;
-use App\Module\Ulogic\Services\UserAddressService;
-use UCore\Validator;
-
-class TransactionId extends Validator
-{
-    /**
-     * @param  mixed  $value
-     * @param  array  $data
-     * @return bool
-     */
-    public function validate(mixed $value, array $data): bool
-    {
-
-        $info = Transaction::getData($data['userId'], $data['transactionId']);
-        if (!$info) {
-            return false;
-        }
-        return true;
-    }
-}

+ 0 - 122
app/Module/Ulogic/Models/UserAddress.php

@@ -1,122 +0,0 @@
-<?php
-
-namespace App\Module\Ulogic\Models;
-
-use Dcat\Admin\Traits\HasDateTimeFormatter;
-use Illuminate\Database\Eloquent\SoftDeletes;
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * App\Module\Ulogic\Models\UserAddress
- *
- * field start 
- * field end
- */
-class UserAddress extends Model
-{
-    use HasDateTimeFormatter;
-    use SoftDeletes;
-
-    protected $table = 'user_address';
-
-    // attrlist start 
-    protected $fillable = [
-    ];
-    // attrlist end
-
-    /**
-     * @param $userId
-     * @return \Illuminate\Database\Eloquent\Collection
-     * 用户保存地址列表
-     */
-    public static function list($userId, $type)
-    {
-        $query = self::query();
-        $query->where('user_id', $userId);
-        if ($type != 0) {
-            $query->where('type', $type);
-        }
-        return $query->orderBy('id', 'desc')->get();
-    }
-
-    /**
-     * @param $userId
-     * @param $addressId
-     * @return null
-     * 查询用户地址
-     */
-    public static function getUserAddress($userId, $addressId)
-    {
-        $query = self::query();
-        $query->where('user_id', $userId);
-        $query->where('id', $addressId);
-        return $query->first();
-    }
-
-    /**
-     * @param $userId
-     * @param $addressType
-     * @param $addressName
-     * @param $address
-     * @return bool
-     * 添加地址
-     */
-    public static function add($userId, $addressType, $addressName, $address)
-    {
-        $model = new self();
-        $model->user_id = $userId;
-        $model->nickname = $addressName;
-        $model->type = $addressType;
-        $model->address = $address;
-        return $model->save();
-    }
-
-    /**
-     * @param $addressId
-     * @return mixed
-     * 删除地址
-     */
-    public static function userDelete($addressId)
-    {
-        $model = self::find($addressId);
-        $model->status = 2;
-        $model->deleted_at = date('Y-m-d H:i:s');
-        return $model->save();
-    }
-
-    /**
-     * @param $addressId
-     * @return null
-     * 根据id获取地址
-     */
-    public static function getAddressById($addressId)
-    {
-        $query = self::query();
-        $query->where('id', $addressId);
-        return $query->first();
-    }
-
-    /**
-     * @param $addressId
-     * @return null
-     * 根据地址获取信息
-     */
-    public static function getDataByAddress($address)
-    {
-        $query = self::query();
-        $query->where('address', $address);
-        return $query->first();
-    }
-
-    /**
-     * @param $addressId
-     * @return null
-     * 根据地址获取信息
-     */
-    public static function getDataByUserId($userId)
-    {
-        $query = self::query();
-        $query->where('user_id', $userId);
-        return $query->first();
-    }
-}

+ 0 - 60
app/Module/Ulogic/Models/UserBans.php

@@ -1,60 +0,0 @@
-<?php
-
-namespace App\Module\Ulogic\Models;
-
-use Dcat\Admin\Traits\HasDateTimeFormatter;
-use Illuminate\Database\Eloquent\SoftDeletes;
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * 用户封禁记录
- * *
- * * field start 
- * field end
- */
-class UserBans extends Model
-{
-    use HasDateTimeFormatter;
-    use SoftDeletes;
-
-    protected $table = 'user_bans';
-
-    // attrlist start 
-    protected $fillable = [
-    ];
-    // attrlist end
-
-    /**
-     * @param $userId
-     * @param $type
-     * @param $adminId
-     * @param $endTime
-     * @return bool
-     * 用户封禁
-     */
-    public static function create($userId, $type, $adminId = 0, $endTime = 0)
-    {
-        $model = new self();
-        $model->user_id = $userId;
-        $model->type = $type;
-        $model->admin_id = $adminId;
-        $model->end_time = $endTime;
-        return $model->save();
-    }
-
-    /**
-     * @param $userId
-     * @param $type
-     * @return null
-     * 获取封禁信息
-     */
-    public static function getRow($userId, $type)
-    {
-        $query = self::query();
-        $query->where(['user_id' => $userId, 'type' => $type]);
-        if ($type == 1) {
-            $query->where('end_time', '>', time());
-        }
-        return $query->first();
-    }
-}