Your Name пре 8 месеци
родитељ
комит
9e00b28e37
100 измењених фајлова са 1006 додато и 3169 уклоњено
  1. 0 3
      .roo/rules-code/rules.md
  2. 0 3
      UCore/DcatAdmin/AdminController.php
  3. 0 14
      app/Models/ModelCore.php
  4. 0 1
      app/Module/Blockchain/ApiDto/AI.md
  5. 0 27
      app/Module/Blockchain/ApiDto/EthGetTransactionByHashDto.php
  6. 0 110
      app/Module/Blockchain/ApiDto/Result/EthGetTransactionByHashResultDto.php
  7. 0 13
      app/Module/Blockchain/Config/blockchain.php
  8. 0 5
      app/Module/Blockchain/Config/bnbchain.php
  9. 0 72
      app/Module/Blockchain/Config/bscscan.php
  10. 0 71
      app/Module/Blockchain/Contracts/BlockchainServiceInterface.php
  11. 0 61
      app/Module/Blockchain/Database/blockchain.sql
  12. 0 62
      app/Module/Blockchain/Dto/TransactionResult.php
  13. 0 99
      app/Module/Blockchain/Dto/TransactionStatus.php
  14. 0 26
      app/Module/Blockchain/Json/proxy_eth_getTransactionByHash.json
  15. 0 199
      app/Module/Blockchain/Models/BlockchainTransaction.php
  16. 0 119
      app/Module/Blockchain/Models/BlockchainWallet.php
  17. 0 34
      app/Module/Blockchain/Providers/BlockchainServiceProvider.php
  18. 0 1
      app/Module/Blockchain/README.md
  19. 0 207
      app/Module/Blockchain/Services/BnbChainService.php
  20. 0 351
      app/Module/Blockchain/Services/BscScanService.php
  21. 0 39
      app/Module/Blockchain/Tests/Unit/BlServiceTest.php
  22. 0 54
      app/Module/Blockchain/Tests/Unit/BnbScanServiceTest.php
  23. 0 184
      app/Module/Blockchain/Tests/Unit/BscScanServiceTest.php
  24. 0 144
      app/Module/Blockchain/Tests/Unit/Models/BlockchainTransactionTest.php
  25. 0 176
      app/Module/Blockchain/Tests/Unit/Models/BlockchainWalletTest.php
  26. 0 189
      app/Module/Blockchain/Tests/Unit/Services/BnbChainServiceTest.php
  27. 1 1
      app/Module/Ulogic/DayTimes.php
  28. 1 1
      app/Module/Ulogic/Models/AppMessage.php
  29. 1 1
      app/Module/Ulogic/Models/AppMessageRecipient.php
  30. 1 1
      app/Module/Ulogic/Models/AppMessageTemplate.php
  31. 0 0
      app/Module/Ulogic/Models/Internal.php
  32. 0 0
      app/Module/Ulogic/Models/README.md
  33. 1 1
      app/Module/Ulogic/Models/UserAddress.php
  34. 1 1
      app/Module/Ulogic/Models/UserBans.php
  35. 5 5
      app/Module/Ulogic/Models/UserDaytime.php
  36. 1 1
      app/Module/Ulogic/Models/UserPunish.php
  37. 1 1
      app/Module/Ulogic/Models/UserRelation.php
  38. 5 5
      app/Module/Ulogic/Models/UserTime.php
  39. 1 1
      app/Module/Ulogic/Models/UserWord.php
  40. 1 1
      app/Module/Ulogic/Models/WalletAddress.php
  41. 3 3
      app/Module/Ulogic/Queues/SendAppMessageQueue.php
  42. 0 96
      app/Module/UrausSys/AdminControllers/ReceiveAddressController.php
  43. 0 35
      app/Module/UrausSys/Commands/TestCommands.php
  44. 0 17
      app/Module/UrausSys/Config/test.php
  45. 0 19
      app/Module/UrausSys/Controllers/TestController.php
  46. 0 35
      app/Module/UrausSys/Database/Factories/TestFactory.php
  47. 0 33
      app/Module/UrausSys/Database/Migrations/2024_01_01_000000_create_test_table.php
  48. 0 18
      app/Module/UrausSys/Database/Seeders/DatabaseSeeder.php
  49. 0 38
      app/Module/UrausSys/Database/Seeders/TestSeeder.php
  50. 0 26
      app/Module/UrausSys/Enums/ACTYPE2.php
  51. 0 31
      app/Module/UrausSys/Enums/RECEIVE_ADDRESS_STATUS.php
  52. 0 40
      app/Module/UrausSys/Events/TestEvent.php
  53. 0 18
      app/Module/UrausSys/Exceptions/TestException.php
  54. 0 34
      app/Module/UrausSys/Jobs/TestJob.php
  55. 0 31
      app/Module/UrausSys/Listeners/TestEventListener.php
  56. 0 20
      app/Module/UrausSys/Listeners/TestListener.php
  57. 0 49
      app/Module/UrausSys/Models/ReceiveAddress.php
  58. 0 29
      app/Module/UrausSys/Providers/TestServiceProvider.php
  59. 0 8
      app/Module/UrausSys/Queues/TestQueue.php
  60. 0 1
      app/Module/UrausSys/README.md
  61. 0 12
      app/Module/UrausSys/Repositorys/ReceiveAddressRepository.php
  62. 0 20
      app/Module/UrausSys/Services/AddressService.php
  63. 0 43
      app/Module/UrausSys/Services/ReceiveAddressService.php
  64. 0 55
      app/Module/UrausSys/Tests/Services/ReceiveAddressServiceTest.php
  65. 0 92
      app/Module/UrausSys/Tests/TestTest.php
  66. 0 25
      app/Module/UrausSys/Validations/HelloValidation.php
  67. 0 10
      app/Module/UrausSys/Validations/Test.php
  68. 0 10
      app/Module/UrausSys/Validators/Test.php
  69. 3 3
      app/Module/User/Action.php
  70. 15 0
      app/Module/User/AdminControllers/UserController.php
  71. 37 0
      app/Module/User/Enums/ActionStatus.php
  72. 33 0
      app/Module/User/Enums/ActionType.php
  73. 35 0
      app/Module/User/Enums/PhoneStatus.php
  74. 29 0
      app/Module/User/Enums/PhoneType.php
  75. 1 1
      app/Module/User/Enums/README.md
  76. 34 0
      app/Module/User/Enums/SecertPasswordStatus.php
  77. 39 0
      app/Module/User/Enums/Status.php
  78. 51 0
      app/Module/User/Enums/Status2.php
  79. 34 0
      app/Module/User/Google2Fa.php
  80. 15 0
      app/Module/User/Model/Events/UserId.php
  81. 9 0
      app/Module/User/Model/Events/UserIdInterface.php
  82. 15 0
      app/Module/User/Model/Events/UserInfoSaved.php
  83. 15 0
      app/Module/User/Model/Events/UserInfoUpdate.php
  84. 16 0
      app/Module/User/Model/Events/UserPhoneSaved.php
  85. 16 0
      app/Module/User/Model/Events/UserPhoneUpdate.php
  86. 16 0
      app/Module/User/Model/Events/UserSaved.php
  87. 16 0
      app/Module/User/Model/Events/UserSecretPasswordSaved.php
  88. 1 1
      app/Module/User/Model/User.php
  89. 65 0
      app/Module/User/Model/UserInfo.php
  90. 0 27
      app/Module/User/Model/UserPassword.php
  91. 51 0
      app/Module/User/Model/UserPhone.php
  92. 38 0
      app/Module/User/Model/UserSecretPassword.php
  93. 60 0
      app/Module/User/Online.php
  94. 36 0
      app/Module/User/Phone.php
  95. 18 0
      app/Module/User/Repository/UserAction.php
  96. 17 0
      app/Module/User/Repository/UserInfo.php
  97. 1 0
      app/Module/User/Repository/readme.md
  98. 29 0
      app/Module/User/SecurityPassword.php
  99. 4 5
      app/Module/User/Services/UserService.php
  100. 234 0
      app/Module/User/User.php

+ 0 - 3
.roo/rules-code/rules.md

@@ -15,9 +15,6 @@
 3. 进行开发
 
 
-# Handler的开发规则
-- 参考 app/ProtoLogic/Hello/AreYouOkHandler.php (读取最新内容)
-
 
 # 模块开发的规则
 - 模块在项目的app/Module目录下

+ 0 - 3
UCore/DcatAdmin/AdminController.php

@@ -2,9 +2,6 @@
 
 namespace UCore\DcatAdmin;
 
-
-
-
 use UCore\DcatAdmin\Traits\ResController;
 use UCore\DcatAdmin\Traits\ReturnRes;
 

+ 0 - 14
app/Models/ModelCore.php

@@ -1,14 +0,0 @@
-<?php
-
-namespace App\Models;
-
-use Illuminate\Database\Eloquent\SoftDeletes;
-
-/**
- *
- */
-class ModelCore extends \UCore\ModelCore
-{
-
-    protected $connection = 'mysql';
-}

+ 0 - 1
app/Module/Blockchain/ApiDto/AI.md

@@ -1 +0,0 @@
-根据json文件,来自编写Dto文件,存放与ApiDto目录,符合psr4标准

+ 0 - 27
app/Module/Blockchain/ApiDto/EthGetTransactionByHashDto.php

@@ -1,27 +0,0 @@
-<?php
-
-
-namespace App\Module\Blockchain\ApiDto;
-
-use App\Module\Blockchain\ApiDto\Result\EthGetTransactionByHashResultDto;
-
-/**
- * 以太坊获取交易详情DTO
- */
-class EthGetTransactionByHashDto
-{
-    /**
-     * @var string JSON-RPC版本
-     */
-    public string $jsonrpc;
-
-    /**
-     * @var int 请求ID
-     */
-    public int $id;
-
-    /**
-     * @var EthGetTransactionByHashResultDto 交易详情结果
-     */
-    public EthGetTransactionByHashResultDto $result;
-}

+ 0 - 110
app/Module/Blockchain/ApiDto/Result/EthGetTransactionByHashResultDto.php

@@ -1,110 +0,0 @@
-<?php
-
-
-namespace App\Module\Blockchain\ApiDto\Result;
-
-/**
- * 以太坊交易详情结果DTO
- */
-class EthGetTransactionByHashResultDto
-{
-    /**
-     * @var string 区块哈希
-     */
-    public string $blockHash;
-
-    /**
-     * @var string 区块号(十六进制)
-     */
-    public string $blockNumber;
-
-    /**
-     * @var string 发送方地址
-     */
-    public string $from;
-
-    /**
-     * @var string 燃料限额(十六进制)
-     */
-    public string $gas;
-
-    /**
-     * @var string 燃料价格(十六进制)
-     */
-    public string $gasPrice;
-
-    /**
-     * @var string 最大燃料费用(十六进制)
-     */
-    public string $maxFeePerGas;
-
-    /**
-     * @var string 最大优先燃料费用(十六进制)
-     */
-    public string $maxPriorityFeePerGas;
-
-    /**
-     * @var string 交易哈希
-     */
-    public string $hash;
-
-    /**
-     * @var string 输入数据
-     */
-    public string $input;
-
-    /**
-     * @var string 随机数
-     */
-    public string $nonce;
-
-    /**
-     * @var string 接收方地址
-     */
-    public string $to;
-
-    /**
-     * @var string 交易索引(十六进制)
-     */
-    public string $transactionIndex;
-
-    /**
-     * @var string 交易值(十六进制)
-     */
-    public string $value;
-
-    /**
-     * @var string 交易类型(十六进制)
-     */
-    public string $type;
-
-    /**
-     * @var array 访问列表
-     */
-    public array $accessList = [];
-
-    /**
-     * @var string 链ID(十六进制)
-     */
-    public string $chainId;
-
-    /**
-     * @var string 恢复ID(十六进制)
-     */
-    public string $v;
-
-    /**
-     * @var string R值(十六进制)
-     */
-    public string $r;
-
-    /**
-     * @var string S值(十六进制)
-     */
-    public string $s;
-
-    /**
-     * @var string Y奇偶校验(十六进制)
-     */
-    public string $yParity;
-}

+ 0 - 13
app/Module/Blockchain/Config/blockchain.php

@@ -1,13 +0,0 @@
-<?php
-
-return [
-    'bscscan'=>[
-        // bscscan.php 文件覆盖
-    ],
-    // 缓存配置
-    'cache' => [
-        'balance_ttl' => env('BLOCKCHAIN_CACHE_BALANCE_TTL', 300),
-        'gas_price_ttl' => env('BLOCKCHAIN_CACHE_GAS_PRICE_TTL', 60),
-        'transaction_ttl' => env('BLOCKCHAIN_CACHE_TRANSACTION_TTL', 60),
-    ],
-];

+ 0 - 5
app/Module/Blockchain/Config/bnbchain.php

@@ -1,5 +0,0 @@
-<?php
-
-return [
-
-];

+ 0 - 72
app/Module/Blockchain/Config/bscscan.php

@@ -1,72 +0,0 @@
-<?php
-
-return [
-    'api' => [
-        'mainnet' => [
-            'url' => env('BSCSCAN_API_URL', 'https://api.bscscan.com/api'),
-            'key' => env('BSCSCAN_API_KEY'),
-            'timeout' => env('BSCSCAN_TIMEOUT', 30),
-            'retry' => [
-                'times' => env('BSCSCAN_RETRY_TIMES', 3),
-                'delay' => env('BSCSCAN_RETRY_DELAY', 1000), // 毫秒
-            ],
-            'rate_limit' => env('BSCSCAN_RATE_LIMIT', 5), // 每秒请求数
-        ],
-        'testnet' => [
-            'url' => env('BSCSCAN_TESTNET_API_URL', 'https://api-testnet.bscscan.com/api'),
-            'key' => env('BSCSCAN_TESTNET_API_KEY'),
-            'timeout' => env('BSCSCAN_TIMEOUT', 30),
-            'retry' => [
-                'times' => env('BSCSCAN_RETRY_TIMES', 3),
-                'delay' => env('BSCSCAN_RETRY_DELAY', 1000),
-            ],
-            'rate_limit' => env('BSCSCAN_RATE_LIMIT', 5),
-        ],
-    ],
-    
-    'endpoints' => [
-        'account' => [
-            'balance' => [
-                'action' => 'balance',
-                'module' => 'account',
-            ],
-            'token_balance' => [
-                'action' => 'tokenbalance',
-                'module' => 'account',
-            ],
-            'transactions' => [
-                'action' => 'txlist',
-                'module' => 'account',
-            ],
-            'token_transactions' => [
-                'action' => 'tokentx',
-                'module' => 'account',
-            ],
-        ],
-        'proxy' => [
-            'gas_price' => [
-                'action' => 'eth_gasPrice',
-                'module' => 'proxy',
-            ],
-            'transaction' => [
-                'action' => 'eth_getTransactionByHash',
-                'module' => 'proxy',
-            ],
-            'transaction_receipt' => [
-                'action' => 'eth_getTransactionReceipt',
-                'module' => 'proxy',
-            ],
-        ],
-    ],
-    
-    'contracts' => [
-        'usdt' => [
-            'address' => env('BSC_USDT_CONTRACT_ADDRESS','0x8de2fa0c3a530f68663827bfe2ee2f8b1873f148'),
-            'decimals' => env('BSC_USDT_DECIMALS', 18),
-        ],
-        'uraus' => [
-            'address' => env('BSC_URAUS_CONTRACT_ADDRESS','0x55d398326f99059fF775485246999027B3197955'),
-            'decimals' => env('BSC_URAUS_DECIMALS', 18),
-        ],
-    ],
-];

+ 0 - 71
app/Module/Blockchain/Contracts/BlockchainServiceInterface.php

@@ -1,71 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Contracts;
-
-use App\Module\Blockchain\Dto\TransactionStatus;
-use App\Module\Transaction\Enums\ACCOUNT_TYPE;
-
-interface BlockchainServiceInterface
-{
-
-    /**
-     * 获取代币余额
-     *
-     * @param string $address 钱包地址
-     * @param ACCOUNT_TYPE $tokenType 代币类型
-     * @return float 余额
-     */
-    public function getBalance(string $address, ACCOUNT_TYPE $tokenType): float;
-
-    /**
-     * 验证地址是否有效
-     *
-     * @param string $address 钱包地址
-     * @return bool
-     */
-    public function isValidAddress(string $address): bool;
-
-    /**
-     * 获取交易状态
-     *
-     * @param string $txHash 交易哈希
-     * @return array{
-     *     status: int,
-     *     blockNumber: ?int,
-     *     gasUsed: ?string,
-     *     effectiveGasPrice: ?string
-     * }
-     */
-    public function getTransactionStatus(string $txHash): TransactionStatus;
-
-    /**
-     * 获取交易收据
-     *
-     * @param string $txHash 交易哈希
-     * @return array 交易收据详情
-     */
-    public function getTransactionReceipt(string $txHash): array;
-
-    /**
-     * 估算Gas费用
-     *
-     * @param string $from 发送地址
-     * @param string $to 接收地址
-     * @param ACCOUNT_TYPE $tokenType 代币类型
-     * @param float $amount 金额
-     * @return float Gas费用(BNB)
-     */
-    public function estimateGasFee(string $from, string $to, ACCOUNT_TYPE $tokenType, float $amount): float;
-
-    /**
-     * 获取交易历史
-     *
-     * @param string $address 钱包地址
-     * @param ACCOUNT_TYPE $tokenType 代币类型
-     * @param int $page 页码
-     * @param int $limit 每页数量
-     * @return array 交易历史列表
-     */
-    public function getTransactionHistory(string $address, ACCOUNT_TYPE $tokenType, int $page = 1, int $limit = 10): array;
-
-}

+ 0 - 61
app/Module/Blockchain/Database/blockchain.sql

@@ -1,61 +0,0 @@
--- 区块链钱包表
-CREATE TABLE IF NOT EXISTS `blockchain_wallets` (
-    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
-    `address` varchar(42) NOT NULL COMMENT '钱包地址',
-    `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '钱包类型:1=bnb, 2=usdt, 3=uraus',
-    `balance` decimal(65,18) NOT NULL DEFAULT '0' COMMENT '余额',
-    `balance_updated_at` timestamp NULL DEFAULT NULL COMMENT '余额最后更新时间',
-    `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态:1=启用,0=禁用',
-    `created_at` timestamp NULL DEFAULT NULL,
-    `updated_at` timestamp NULL DEFAULT NULL,
-    PRIMARY KEY (`id`),
-    UNIQUE KEY `address_type_unique` (`address`,`type`),
-    KEY `address_index` (`address`),
-    KEY `type_index` (`type`),
-    KEY `status_index` (`status`),
-    KEY `balance_updated_at_index` (`balance_updated_at`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='区块链钱包表';
-
--- 区块链交易记录表
-CREATE TABLE IF NOT EXISTS `blockchain_transactions` (
-    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
-    `tx_hash` varchar(66) NOT NULL COMMENT '交易哈希',
-    `from_address` varchar(42) NOT NULL COMMENT '发送地址',
-    `to_address` varchar(42) NOT NULL COMMENT '接收地址',
-    `amount` decimal(65,18) NOT NULL COMMENT '转账金额',
-    `token_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '代币类型:1=bnb, 2=usdt, 3=uraus',
-    `gas_price` decimal(65,18) NOT NULL COMMENT '矿工费单价(GWEI)',
-    `gas_used` bigint(20) NOT NULL COMMENT '消耗的Gas数量',
-    `gas_fee` decimal(65,18) NOT NULL COMMENT '矿工费总额(BNB)',
-    `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态:0=待确认,1=成功,2=失败',
-    `block_number` bigint(20) DEFAULT NULL COMMENT '区块号',
-    `created_at` timestamp NULL DEFAULT NULL,
-    `updated_at` timestamp NULL DEFAULT NULL,
-    PRIMARY KEY (`id`),
-    UNIQUE KEY `tx_hash_unique` (`tx_hash`),
-    KEY `from_address_index` (`from_address`),
-    KEY `to_address_index` (`to_address`),
-    KEY `token_type_index` (`token_type`),
-    KEY `status_index` (`status`),
-    KEY `block_number_index` (`block_number`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='区块链交易记录表';
-
--- 钱包余额变更记录表
-CREATE TABLE IF NOT EXISTS `blockchain_wallet_balance_logs` (
-    `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
-    `wallet_id` bigint(20) unsigned NOT NULL COMMENT '钱包ID',
-    `old_balance` decimal(65,18) NOT NULL COMMENT '原余额',
-    `new_balance` decimal(65,18) NOT NULL COMMENT '新余额',
-    `change_type` tinyint(1) NOT NULL COMMENT '变更类型:1=交易,2=同步,3=手动修改',
-    `sync_block_number` bigint(20) DEFAULT NULL COMMENT '同步时的区块号',
-    `sync_tx_hash` varchar(66) DEFAULT NULL COMMENT '同步时的交易哈希',
-    `sync_timestamp` bigint(20) DEFAULT NULL COMMENT '同步时的区块时间戳',
-    `sync_data` json DEFAULT NULL COMMENT '同步的原始数据',
-    `created_at` timestamp NULL DEFAULT NULL,
-    PRIMARY KEY (`id`),
-    KEY `wallet_id_index` (`wallet_id`),
-    KEY `created_at_index` (`created_at`),
-    KEY `sync_block_number_index` (`sync_block_number`),
-    KEY `sync_tx_hash_index` (`sync_tx_hash`),
-    CONSTRAINT `blockchain_wallet_balance_logs_wallet_id_foreign` FOREIGN KEY (`wallet_id`) REFERENCES `blockchain_wallets` (`id`) ON DELETE CASCADE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='钱包余额变更记录表';

+ 0 - 62
app/Module/Blockchain/Dto/TransactionResult.php

@@ -1,62 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Dto;
-
-/**
- * 区块链交易结果数据传输对象
- */
-class TransactionResult
-{
-    /** 
-     * @var int 交易状态 1=已确认 0=未确认 
-     */
-    public $status;
-    
-    /** 
-     * @var int|null 区块高度(十进制)
-     */
-    public $blockNumber;
-    
-    /** 
-     * @var string|null 消耗的Gas数量
-     */
-    public $gasUsed;
-    
-    /** 
-     * @var string|null 实际Gas价格
-     */
-    public $effectiveGasPrice;
-
-    /**
-     * 构造函数
-     * @param int $status 交易状态
-     * @param int|null $blockNumber 区块高度
-     * @param string|null $gasUsed 消耗的Gas数量
-     * @param string|null $effectiveGasPrice 实际Gas价格
-     */
-    public function __construct(
-        int $status,
-        ?int $blockNumber = null,
-        ?string $gasUsed = null,
-        ?string $effectiveGasPrice = null
-    ) {
-        $this->status = $status;
-        $this->blockNumber = $blockNumber;
-        $this->gasUsed = $gasUsed;
-        $this->effectiveGasPrice = $effectiveGasPrice;
-    }
-
-    /**
-     * 转换为数组
-     * @return array
-     */
-    public function toArray(): array
-    {
-        return [
-            'status' => $this->status,
-            'blockNumber' => $this->blockNumber,
-            'gasUsed' => $this->gasUsed,
-            'effectiveGasPrice' => $this->effectiveGasPrice
-        ];
-    }
-}

+ 0 - 99
app/Module/Blockchain/Dto/TransactionStatus.php

@@ -1,99 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Dto;
-
-use JsonMapper;
-
-/**
- * 区块链交易状态数据传输对象
- *
- */
-class TransactionStatus
-{
-    /**
-     * @var int 交易状态 1=已确认 0=未确认
-     */
-    public $status;
-
-    /**
-     * @var string 区块哈希值
-     */
-    public $blockHash;
-
-    /**
-     * @var int 区块高度(十进制)
-     */
-    public $blockNumber;
-
-    /**
-     * @var string 交易发送方地址
-     */
-    public $from;
-
-    /**
-     * @var int 交易消耗的Gas数量(十进制)
-     */
-    public $gas;
-
-    /**
-     * @var int Gas价格(wei单位,十进制)
-     */
-    public $gasPrice;
-
-    /**
-     * @var string 交易哈希
-     */
-    public $hash;
-
-    /**
-     * @var string 交易输入数据(十六进制)
-     */
-    public $input;
-
-    /**
-     * @var int 交易nonce值(十进制)
-     */
-    public $nonce;
-
-    /**
-     * @var string 交易接收方地址
-     */
-    public $to;
-
-    /**
-     * @var int 交易在区块中的索引位置(十进制)
-     */
-    public $transactionIndex;
-
-    /**
-     * @var int 交易转账金额(wei单位,十进制)
-     */
-    public $value;
-
-    /**
-     * @var int 交易类型(0=传统交易)
-     */
-    public $type;
-
-    /**
-     * @var int 交易签名V值(十进制)
-     */
-    public $v;
-
-    /**
-     * @var string 交易签名R值
-     */
-    public $r;
-
-    /**
-     * @var string 交易签名S值
-     */
-    public $s;
-
-    /**
-     * @var array 原始交易数据
-     */
-    public $rawData;
-
-
-}

+ 0 - 26
app/Module/Blockchain/Json/proxy_eth_getTransactionByHash.json

@@ -1,26 +0,0 @@
-{
-    "jsonrpc": "2.0",
-    "id": 1,
-    "result": {
-        "blockHash": "0x5fabab7e15cedf66f303ee2671c54ccbf452adf65c81b4be4f76abd7dd8f2d60",
-        "blockNumber": "0x2df1709",
-        "from": "0xc82b3c1fc26525b55a5261b5a5f7e939bb7ff127",
-        "gas": "0x13e97",
-        "gasPrice": "0x3b9aca00",
-        "maxFeePerGas": "0x3b9aced3",
-        "maxPriorityFeePerGas": "0x3b9aca00",
-        "hash": "0x60d9401026de26d6871ed00e2fbbe8b3ae5349a4d634ae14981653d1ed729a64",
-        "input": "0xa9059cbb000000000000000000000000c5981423927fc49270477505013222e70e4c917300000000000000000000000000000000000000000000000ad78ebc5ac6200000",
-        "nonce": "0x1",
-        "to": "0x8de2fa0c3a530f68663827bfe2ee2f8b1873f148",
-        "transactionIndex": "0x6d",
-        "value": "0x0",
-        "type": "0x2",
-        "accessList": [],
-        "chainId": "0x38",
-        "v": "0x1",
-        "r": "0xded3f0d1523dbf70b1acb99bcb797d04a3493657f65ba2b82a5179e64db31cae",
-        "s": "0x439243175c1d1ea7de2f22416547f84c4685497a4418ec09485110bb2ccef2c5",
-        "yParity": "0x1"
-    }
-}

+ 0 - 199
app/Module/Blockchain/Models/BlockchainTransaction.php

@@ -1,199 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Models;
-
-
-use App\Module\Transaction\Enums\ACCOUNT_TYPE;
-use Illuminate\Database\Eloquent\Model;
-use Illuminate\Database\Eloquent\Relations\BelongsTo;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Cache;
-
-/**
- *
- *
- * field start 
- * @property   int  $id  
- * @property   string  $tx_hash  交易哈希
- * @property   string  $from_address  发送地址
- * @property   string  $to_address  接收地址
- * @property   float  $amount  转账金额
- * @property   int  $token_type  代币类型:1=bnb, 2=usdt, 3=uraus
- * @property   float  $gas_price  矿工费单价(GWEI)
- * @property   int  $gas_used  消耗的Gas数量
- * @property   float  $gas_fee  矿工费总额(BNB)
- * @property   int  $status  状态:0=待确认,1=成功,2=失败
- * @property   int  $block_number  区块号
- * @property   \Carbon\Carbon  $created_at  
- * @property   \Carbon\Carbon  $updated_at  
- * field end
- */
-class BlockchainTransaction extends Model
-{
-    protected $table = 'blockchain_transactions';
-
-    // attrlist start 
-    protected $fillable = [
-        'id',
-        'tx_hash',
-        'from_address',
-        'to_address',
-        'amount',
-        'token_type',
-        'gas_price',
-        'gas_used',
-        'gas_fee',
-        'status',
-        'block_number',
-    ];
-    // attrlist end
-
-    protected $casts = [
-        'token_type' => ACCOUNT_TYPE::class,
-        'amount' => 'decimal:18',
-        'gas_price' => 'decimal:18',
-        'gas_used' => 'integer',
-        'gas_fee' => 'decimal:18',
-        'status' => 'integer',
-        'block_number' => 'integer'
-    ];
-
-    protected static function booted()
-    {
-        static::creating(function ($transaction) {
-            // 自动计算矿工费
-            if ($transaction->gas_price && $transaction->gas_used) {
-                $transaction->gas_fee = bcdiv(
-                    bcmul($transaction->gas_price, (string)$transaction->gas_used),
-                    '1000000000',
-                    18
-                );
-            }
-        });
-
-        static::updating(function ($transaction) {
-            // 当 gas_price 或 gas_used 更新时重新计算矿工费
-            if ($transaction->isDirty('gas_price') || $transaction->isDirty('gas_used')) {
-                $transaction->gas_fee = bcdiv(
-                    bcmul($transaction->gas_price, (string)$transaction->gas_used),
-                    '1000000000',
-                    18
-                );
-            }
-        });
-
-        static::updated(function ($transaction) {
-            if ($transaction->isDirty('status')) {
-                if ($transaction->status === 1) { // 交易成功
-                    $transaction->updateWalletBalances();
-                }
-            }
-        });
-    }
-
-    public function fromWallet(): BelongsTo
-    {
-        return $this->belongsTo(BlockchainWallet::class, 'from_address', 'address');
-    }
-
-    public function toWallet(): BelongsTo
-    {
-        return $this->belongsTo(BlockchainWallet::class, 'to_address', 'address');
-    }
-
-    public function getStatusLabelAttribute(): string
-    {
-        return match($this->status) {
-            0 => '待确认',
-            1 => '成功',
-            2 => '失败',
-            default => '未知'
-        };
-    }
-
-    public function updateWalletBalances(): void
-    {
-        DB::transaction(function () {
-            // 更新发送方钱包余额
-            $fromWallet = $this->fromWallet;
-            if ($fromWallet) {
-                $newBalance = bcsub($fromWallet->balance, $this->amount, 18);
-                $fromWallet->updateBalance($newBalance);
-            }
-
-            // 更新接收方钱包余额
-            $toWallet = $this->toWallet;
-            if ($toWallet) {
-                $newBalance = bcadd($toWallet->balance, $this->amount, 18);
-                $toWallet->updateBalance($newBalance);
-            }
-        });
-    }
-
-    public function getConfirmations(): int
-    {
-        if (!$this->block_number) {
-            return 0;
-        }
-
-        $latestBlockNumber = Cache::remember('latest_block_number', 60, function () {
-            $bscScanService = app(BscScanService::class);
-            return $bscScanService->getLatestBlockNumber();
-        });
-
-        return max(0, $latestBlockNumber - $this->block_number);
-    }
-
-    public function isSafe(): bool
-    {
-        $requiredConfirmations = config('blockchain.transaction.confirmations', 12);
-        return $this->getConfirmations() >= $requiredConfirmations;
-    }
-
-    public function getTotalGasFee(): float
-    {
-        if (!$this->gas_price || !$this->gas_used) {
-            return 0;
-        }
-
-        return bcmul($this->gas_price, (string)$this->gas_used, 18);
-    }
-
-    /**
-     * 获取交易的总成本(转账金额 + 矿工费)
-     * 仅当代币类型为 BNB 时才包含矿工费
-     */
-    public function getTotalCost(): string
-    {
-        if ($this->token_type === ACCOUNT_TYPE::BNB) {
-            return bcadd($this->amount, $this->gas_fee, 18);
-        }
-        return $this->amount;
-    }
-
-    /**
-     * 获取格式化的矿工费(带单位)
-     */
-    public function getFormattedGasFeeAttribute(): string
-    {
-        return $this->gas_fee . ' BNB';
-    }
-
-    /**
-     * 获取预估的矿工费
-     */
-    public static function estimateGasFee(ACCOUNT_TYPE $tokenType, float $gasPrice): float
-    {
-        $gasLimit = $tokenType === ACCOUNT_TYPE::BNB ? 21000 : 65000;
-        return bcdiv(bcmul((string)$gasPrice, (string)$gasLimit), '1000000000', 18);
-    }
-
-    /**
-     * 检查矿工费是否超过最大限制
-     */
-    public function isGasFeeTooHigh(): bool
-    {
-        $maxGasPrice = config('blockchain.transaction.max_gas_price', 10); // GWEI
-        return bccomp($this->gas_price, (string)$maxGasPrice, 18) === 1;
-    }
-}

+ 0 - 119
app/Module/Blockchain/Models/BlockchainWallet.php

@@ -1,119 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Models;
-
-use App\Module\Blockchain\Enums\TokenType;
-use Illuminate\Database\Eloquent\Model;
-use Illuminate\Database\Eloquent\Relations\HasMany;
-use Illuminate\Support\Facades\DB;
-use InvalidArgumentException;
-use Illuminate\Support\Facades\Cache;
-
-class BlockchainWallet extends Model
-{
-    protected $table = 'blockchain_wallets';
-
-    protected $fillable = [
-        'address',
-        'type',
-        'balance',
-        'balance_updated_at',
-        'status'
-    ];
-
-    protected $casts = [
-        'type' => TokenType::class,
-        'balance' => 'decimal:18',
-        'balance_updated_at' => 'datetime',
-        'status' => 'boolean'
-    ];
-
-    protected static function booted()
-    {
-        static::creating(function ($wallet) {
-            if (!preg_match('/^0x[a-fA-F0-9]{40}$/', $wallet->address)) {
-                throw new InvalidArgumentException('Invalid wallet address format');
-            }
-        });
-
-        static::updating(function ($wallet) {
-            if ($wallet->isDirty('balance')) {
-                $wallet->balance_updated_at = now();
-            }
-        });
-    }
-
-    /**
-     * 更新钱包余额
-     * @param float $newBalance 新余额
-     * @param array|null $syncData 同步数据
-     */
-    public function updateBalance(float $newBalance, ?array $syncData = null): void
-    {
-        DB::transaction(function () use ($newBalance, $syncData) {
-            // 获取原始余额
-            $oldBalance = $this->balance;
-
-            // 更新钱包余额
-            DB::table($this->table)
-                ->where('id', $this->id)
-                ->lockForUpdate()
-                ->update([
-                    'balance' => $newBalance,
-                    'balance_updated_at' => now()
-                ]);
-
-            // 刷新模型
-            $this->refresh();
-
-            // 记录余额变更
-            $logData = [
-                'wallet_id' => $this->id,
-                'old_balance' => $oldBalance,
-                'new_balance' => $newBalance,
-                'change_type' => 2, // 2=同步
-                'created_at' => now()
-            ];
-
-            // 如果有同步数据,添加到日志
-            if ($syncData) {
-                $logData['sync_block_number'] = $syncData['block_number'] ?? null;
-                $logData['sync_tx_hash'] = $syncData['tx_hash'] ?? null;
-                $logData['sync_timestamp'] = $syncData['timestamp'] ?? null;
-                $logData['sync_data'] = json_encode($syncData);
-            }
-
-            DB::table('blockchain_wallet_balance_logs')->insert($logData);
-
-            // 清除缓存
-            $this->clearBalanceCache();
-        });
-    }
-
-    public function transactions(): HasMany
-    {
-        return $this->hasMany(BlockchainTransaction::class, 'from_address', 'address');
-    }
-
-    public function receivedTransactions(): HasMany
-    {
-        return $this->hasMany(BlockchainTransaction::class, 'to_address', 'address');
-    }
-
-    public function getCachedBalance(): float
-    {
-        $cacheKey = "wallet_balance_{$this->address}_{$this->type->value}";
-        return Cache::remember($cacheKey, config('blockchain.cache.balance_ttl', 300), function () {
-            return $this->balance;
-        });
-    }
-
-    /**
-     * 清除余额缓存
-     */
-    protected function clearBalanceCache(): void
-    {
-        $cacheKey = "wallet_balance_{$this->address}_{$this->type->value}";
-        Cache::forget($cacheKey);
-    }
-}

+ 0 - 34
app/Module/Blockchain/Providers/BlockchainServiceProvider.php

@@ -1,34 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Providers;
-
-use Illuminate\Support\ServiceProvider;
-
-class BlockchainServiceProvider extends ServiceProvider
-{
-    /**
-     * 注册服务
-     */
-    public function register()
-    {
-        // 合并配置
-        $this->mergeConfigFrom(
-            __DIR__.'/../Config/blockchain.php', 'blockchain'
-        );
-
-        $this->mergeConfigFrom(
-            __DIR__.'/../Config/bscscan.php', 'blockchain.bscscan'
-        );
-
-
-    }
-
-    /**
-     * 启动服务
-     */
-    public function boot()
-    {
-        // 发布配置文件
-
-    }
-}

+ 0 - 1
app/Module/Blockchain/README.md

@@ -1 +0,0 @@
-# Blockchain( 真实区块链操作)

+ 0 - 207
app/Module/Blockchain/Services/BnbChainService.php

@@ -1,207 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Services;
-
-use App\Module\Blockchain\Contracts\BlockchainServiceInterface;
-use App\Module\Blockchain\Enums\TokenType;
-use Illuminate\Support\Facades\Http;
-use Illuminate\Support\Facades\Cache;
-use Web3\Web3;
-use Web3\Providers\HttpProvider;
-use Web3\RequestManagers\HttpRequestManager;
-use InvalidArgumentException;
-
-class BnbChainService implements BlockchainServiceInterface
-{
-    protected Web3 $web3;
-    protected array $config;
-    protected string $network;
-    protected BscScanService $bscScanService;
-
-    public function __construct(BscScanService $bscScanService, string $network = 'mainnet')
-    {
-        $this->config = config('blockchain.bnbchain');
-        $this->network = $network;
-        $this->bscScanService = $bscScanService;
-
-        // 初始化 Web3 连接
-        $provider = new HttpProvider(new HttpRequestManager(
-            $this->config['networks'][$network]['rpc'][0],
-            10 // 超时时间(秒)
-        ));
-        $this->web3 = new Web3($provider);
-    }
-
-    /**
-     * 获取当前网络配置
-     */
-    public function getNetwork(): array
-    {
-        return $this->config['networks'][$this->network];
-    }
-
-    /**
-     * 获取当前链 ID
-     */
-    public function getChainId(): int
-    {
-        return $this->config['networks'][$this->network]['chain_id'];
-    }
-
-    /**
-     * 获取区块浏览器 URL
-     */
-    public function getExplorerUrl(): string
-    {
-        return $this->config['networks'][$this->network]['explorer'];
-    }
-
-    /**
-     * 获取交易浏览器链接
-     */
-    public function getTransactionUrl(string $txHash): string
-    {
-        return $this->getExplorerUrl() . '/tx/' . $txHash;
-    }
-
-    /**
-     * 获取地址浏览器链接
-     */
-    public function getAddressUrl(string $address): string
-    {
-        return $this->getExplorerUrl() . '/address/' . $address;
-    }
-
-    /**
-     * 获取代币合约浏览器链接
-     */
-    public function getTokenUrl(TokenType $tokenType): ?string
-    {
-        $contractAddress = $tokenType->contractAddress();
-        if (!$contractAddress) {
-            return null;
-        }
-        return $this->getExplorerUrl() . '/token/' . $contractAddress;
-    }
-
-    /**
-     * 获取最新区块号
-     */
-    public function getLatestBlockNumber(): int
-    {
-        return Cache::remember('latest_block_number', 10, function () {
-            $response = $this->web3->eth->blockNumber();
-            return hexdec($response);
-        });
-    }
-
-    /**
-     * 获取当前推荐的 Gas 价格
-     */
-    public function getGasPrice(): array
-    {
-        return Cache::remember('gas_price', $this->config['cache']['gas_price_ttl'], function () {
-            $response = $this->web3->eth->gasPrice();
-            $gasPrice = hexdec($response) / 1e9; // 转换为 GWEI
-
-            return [
-                'safe_low' => max($this->config['gas']['price']['safe_low'], $gasPrice),
-                'standard' => max($this->config['gas']['price']['standard'], $gasPrice * 1.1),
-                'fast' => max($this->config['gas']['price']['fast'], $gasPrice * 1.2),
-                'current' => $gasPrice
-            ];
-        });
-    }
-
-    /**
-     * MEV 保护:获取带有保护的 Gas 价格
-     */
-    public function getMevProtectedGasPrice(): array
-    {
-        if (!$this->config['mev_protection']['enabled']) {
-            return $this->getGasPrice();
-        }
-
-        $gasPrice = $this->getGasPrice();
-        return [
-            'max_priority_fee_per_gas' => $this->config['mev_protection']['max_priority_fee'],
-            'max_fee_per_gas' => min(
-                $this->config['mev_protection']['max_fee'],
-                $gasPrice['standard'] + $this->config['mev_protection']['max_priority_fee']
-            )
-        ];
-    }
-
-    /**
-     * 实现接口方法:获取余额
-     */
-    public function getBalance(string $address, TokenType $tokenType): float
-    {
-        return $this->bscScanService->getBalance($address, $tokenType);
-    }
-
-    /**
-     * 实现接口方法:验证地址
-     */
-    public function isValidAddress(string $address): bool
-    {
-        return $this->bscScanService->isValidAddress($address);
-    }
-
-    /**
-     * 实现接口方法:获取交易状态
-     */
-    public function getTransactionStatus(string $txHash): array
-    {
-        return $this->bscScanService->getTransactionStatus($txHash);
-    }
-
-    /**
-     * 实现接口方法:获取交易收据
-     */
-    public function getTransactionReceipt(string $txHash): array
-    {
-        return $this->bscScanService->getTransactionReceipt($txHash);
-    }
-
-    /**
-     * 实现接口方法:估算 Gas 费用
-     */
-    public function estimateGasFee(string $from, string $to, TokenType $tokenType, float $amount): float
-    {
-        return $this->bscScanService->estimateGasFee($from, $to, $tokenType, $amount);
-    }
-
-    /**
-     * 实现接口方法:获取交易历史
-     */
-    public function getTransactionHistory(string $address, TokenType $tokenType, int $page = 1, int $limit = 10): array
-    {
-        return $this->bscScanService->getTransactionHistory($address, $tokenType, $page, $limit);
-    }
-
-    /**
-     * 检查交易确认数
-     */
-    public function getTransactionConfirmations(string $txHash): int
-    {
-        $receipt = $this->getTransactionReceipt($txHash);
-        if (!isset($receipt['blockNumber'])) {
-            return 0;
-        }
-
-        $currentBlock = $this->getLatestBlockNumber();
-        $txBlock = hexdec($receipt['blockNumber']);
-
-        return max(0, $currentBlock - $txBlock);
-    }
-
-    /**
-     * 检查交易是否已经安全确认
-     */
-    public function isTransactionSafe(string $txHash): bool
-    {
-        $confirmations = $this->getTransactionConfirmations($txHash);
-        return $confirmations >= $this->config['confirmations']['safe'];
-    }
-}

+ 0 - 351
app/Module/Blockchain/Services/BscScanService.php

@@ -1,351 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Services;
-
-use App\Module\Blockchain\Contracts\BlockchainServiceInterface;
-use App\Module\Blockchain\Dto\TransactionStatus;
-use App\Module\Blockchain\Dto\TransactionResult;
-use App\Module\Transaction\Enums\ACCOUNT_TYPE;
-use Illuminate\Support\Facades\Http;
-use JsonMapper;
-use JsonMapper_Exception;
-use Illuminate\Support\Facades\Cache;
-use Illuminate\Support\Facades\RateLimiter;
-use InvalidArgumentException;
-
-class BscScanService implements BlockchainServiceInterface
-{
-
-    protected string $apiUrl;
-    protected string $apiKey;
-    protected int    $cacheTime = 300; // 5分钟缓存
-    protected int    $retryTimes;
-    protected int    $retryDelay;
-    protected int    $timeout;
-    protected int    $rateLimit;
-    protected bool   $isTest;
-    protected bool   $saveResponse = false; // 是否保存API响应到JSON文件
-
-    /**
-     * 构造函数
-     *
-     * @param bool $isTest 是否使用测试网络
-     */
-    public function __construct(bool $isTest = false)
-    {
-        $this->isTest     = $isTest;
-        $configPath       = $isTest ? 'blockchain.bscscan.api.testnet' : 'blockchain.bscscan.api.mainnet';
-        $this->apiUrl     = config("$configPath.url");
-        $this->apiKey     = config("$configPath.key");
-        $this->retryTimes = config("$configPath.retry.times", 3);
-        $this->retryDelay = config("$configPath.retry.delay", 1000);
-        $this->timeout    = config("$configPath.timeout", 30);
-        $this->rateLimit  = config("$configPath.rate_limit", 5);
-    }
-
-    /**
-     * 发送API请求
-     *
-     * @param string $action API动作
-     * @param array $params 请求参数
-     * @param string $module API模块
-     * @return array API响应数据
-     * @throws \Exception API请求失败时抛出异常
-     */
-    protected function makeRequest(string $action, array $params = [], string $module = 'account'): array
-    {
-        // 检查 API 调用频率
-        if (!$this->checkRateLimit()) {
-            throw new \Exception('API rate limit exceeded');
-        }
-
-        $params = array_merge([
-                                  'module' => $module,
-                                  'action' => $action,
-                                  'apikey' => $this->apiKey
-                              ], $params);
-
-        $attempt       = 1;
-        $lastException = null;
-
-        while ($attempt <= $this->retryTimes) {
-            try {
-                $response = Http::timeout($this->timeout)
-                    ->get($this->apiUrl, $params);
-
-                if ($response->successful()) {
-                    $data = $response->json();
-
-                    // 保存API响应到JSON文件
-                    if ($this->saveResponse) {
-                        $this->saveApiResponse($module, $action, $data);
-                    }
-
-                    return $data;
-                }
-
-                throw new \Exception('Invalid response from BSCScan API');
-            } catch (\Exception $e) {
-                $lastException = $e;
-                if ($attempt < $this->retryTimes) {
-                    usleep($this->retryDelay * 1000); // 转换为微秒
-                }
-                $attempt++;
-            }
-        }
-
-        throw new \Exception("Failed after {$this->retryTimes} attempts: " . $lastException->getMessage());
-    }
-
-    /**
-     * 保存API响应到JSON文件
-     * @param string $module 模块名
-     * @param string $action 操作名
-     * @param array $data 响应数据
-     */
-    protected function saveApiResponse(string $module, string $action, array $data): void
-    {
-        $dir = dirname(__DIR__) . '/Json';
-        if (!is_dir($dir)) {
-            mkdir($dir, 0755, true);
-        }
-
-        $filename = sprintf('%s/%s_%s.json',
-            $dir,
-            $module,
-            $action
-        );
-
-        file_put_contents($filename, json_encode($data, JSON_PRETTY_PRINT));
-    }
-
-    /**
-     * 设置是否保存API响应
-     * @param bool $enable 是否启用
-     * @return $this
-     */
-    public function enableResponseSaving(bool $enable = true): self
-    {
-        $this->saveResponse = $enable;
-        return $this;
-    }
-
-    protected function checkRateLimit(): bool
-    {
-        return RateLimiter::attempt(
-            'bscscan_api',
-            $this->rateLimit,
-            function () {
-                return true;
-            },
-            60 // 1分钟
-        );
-    }
-
-    /**
-     * 获取账户余额
-     *
-     * @param string $address 钱包地址
-     * @param ACCOUNT_TYPE $tokenType 代币类型
-     * @return float 余额数值
-     * @throws InvalidArgumentException 当合约地址不存在时抛出
-     */
-    public function getBalance(string $address, ACCOUNT_TYPE $tokenType): float
-    {
-        $cacheKey = "balance_{$address}_{$tokenType->value}";
-
-        return Cache::remember($cacheKey, $this->cacheTime, function () use ($address, $tokenType) {
-            if ($tokenType === ACCOUNT_TYPE::BNB) {
-                return $this->getBnbBalance($address);
-            }
-
-            $contractAddress = $this->getContractAddress($tokenType);
-            if (!$contractAddress) {
-                throw new InvalidArgumentException("Contract address not found for token type: {$tokenType->value}");
-            }
-
-            return $this->getTokenBalance($address, $contractAddress, $this->getTokenDecimals($tokenType));
-        });
-    }
-
-    protected function getContractAddress(ACCOUNT_TYPE $tokenType): ?string
-    {
-        return match ($tokenType) {
-            ACCOUNT_TYPE::USDT  => config('blockchain.bscscan.contracts.usdt.address'),
-            ACCOUNT_TYPE::URAUS => config('blockchain.bscscan.contracts.uraus.address'),
-            default             => null
-        };
-    }
-
-    protected function getTokenDecimals(ACCOUNT_TYPE $tokenType): int
-    {
-        return match ($tokenType) {
-            ACCOUNT_TYPE::BNB   => 18,
-            ACCOUNT_TYPE::USDT  => config('blockchain.bscscan.contracts.usdt.decimals', 18),
-            ACCOUNT_TYPE::URAUS => config('blockchain.bscscan.contracts.uraus.decimals', 18),
-            default             => 18
-        };
-    }
-
-    public function isValidAddress(string $address): bool
-    {
-        return preg_match('/^0x[a-fA-F0-9]{40}$/', $address) === 1;
-    }
-
-    /**
-     * 获取交易状态
-     *
-     * @param string $txHash 交易哈希
-     * @return array{
-     *     status: int,
-     *     blockNumber: ?int,
-     *     gasUsed: ?string,
-     *     effectiveGasPrice: ?string
-     * }
-     * @throws \Exception 获取失败时抛出异常
-     */
-    public function getTransactionStatus(string $txHash):TransactionStatus
-    {
-        $data = $this->makeRequest('eth_getTransactionByHash', [
-            'txhash' => $txHash
-        ], 'proxy');
-
-        if (!isset($data['result'])) {
-            throw new \Exception('Failed to get transaction status');
-        }
-
-        $result = new TransactionResult(
-            $data['result']['blockNumber'] ? 1 : 0,
-            $data['result']['blockNumber'] ? hexdec($data['result']['blockNumber']) : null,
-            $data['result']['gasUsed'] ?? null,
-            $data['result']['effectiveGasPrice'] ?? null
-        );
-
-        return $result->toArray();
-    }
-
-    /**
-     * 获取交易收据
-     *
-     * @param string $txHash 交易哈希
-     * @return array 交易收据信息
-     * @throws \Exception 获取失败时抛出异常
-     */
-    public function getTransactionReceipt(string $txHash): array
-    {
-        $data = $this->makeRequest('eth_getTransactionReceipt', [
-            'txhash' => $txHash
-        ],                         'proxy');
-
-
-        if (!isset($data['result'])) {
-            throw new \Exception('Failed to get transaction receipt');
-        }
-
-        return $data['result'];
-    }
-
-    /**
-     * 估算交易手续费
-     *
-     * @param string $from 发送方地址
-     * @param string $to 接收方地址
-     * @param ACCOUNT_TYPE $tokenType 代币类型
-     * @param float $amount 转账金额
-     * @return float 预估的gas费用(以BNB为单位)
-     * @throws \Exception 估算失败时抛出异常
-     */
-    public function estimateGasFee(string $from, string $to, ACCOUNT_TYPE $tokenType, float $amount): float
-    {
-        // 获取当前 gas 价格
-        $response = Http::get($this->apiUrl, [
-            'module' => 'proxy',
-            'action' => 'eth_gasPrice',
-            'apikey' => $this->apiKey
-        ]);
-
-        $data = $response->json();
-        if (!isset($data['result'])) {
-            throw new \Exception('Failed to get gas price');
-        }
-
-        $gasPrice = hexdec($data['result']);
-        $gasLimit = $tokenType === ACCOUNT_TYPE::BNB ? 21000 : 65000; // BNB转账固定21000,代币约65000
-
-        return ($gasPrice * $gasLimit) / 1e18; // 转换为BNB单位
-    }
-
-    /**
-     * 获取交易历史记录
-     *
-     * @param string $address 钱包地址
-     * @param ACCOUNT_TYPE $tokenType 代币类型
-     * @param int $page 页码
-     * @param int $limit 每页数量
-     * @return array 交易历史记录
-     * @throws InvalidArgumentException 当合约地址不存在时抛出
-     */
-    public function getTransactionHistory(string $address, ACCOUNT_TYPE $tokenType, int $page = 1, int $limit = 10): array
-    {
-        if ($tokenType === ACCOUNT_TYPE::BNB) {
-            return $this->getNormalTransactions($address, $page, $limit);
-        }
-
-        return $this->getTokenTransactions($address, $tokenType, $page, $limit);
-    }
-
-    protected function getBnbBalance(string $address): float
-    {
-        $data = $this->makeRequest('balance', [
-            'address' => $address
-        ],                         'account');
-
-        return bcdiv($data['result'], '1000000000000000000', 18);
-    }
-
-    protected function getTokenBalance(string $address, string $contractAddress, int $decimals): float
-    {
-        $data = $this->makeRequest('tokenbalance', [
-            'contractaddress' => $contractAddress,
-            'address'         => $address,
-            'tag'             => 'latest'
-        ],                         'account');
-
-        return bcdiv($data['result'], bcpow('10', (string)$decimals), $decimals);
-    }
-
-    protected function getNormalTransactions(string $address, int $page, int $limit): array
-    {
-        $data = $this->makeRequest('txlist', [
-            'address'    => $address,
-            'startblock' => 0,
-            'endblock'   => 99999999,
-            'page'       => $page,
-            'offset'     => $limit,
-            'sort'       => 'desc'
-        ],                         'account');
-
-        return $data['result'];
-    }
-
-    protected function getTokenTransactions(string $address, ACCOUNT_TYPE $tokenType, int $page, int $limit): array
-    {
-        $contractAddress = $this->getContractAddress($tokenType);
-        if (!$contractAddress) {
-            throw new InvalidArgumentException("Contract address not found for token type: {$tokenType->value}");
-        }
-
-        $data = $this->makeRequest('tokentx', [
-            'address'         => $address,
-            'contractaddress' => $contractAddress,
-            'startblock'      => 0,
-            'endblock'        => 99999999,
-            'page'            => $page,
-            'offset'          => $limit,
-            'sort'            => 'desc'
-        ],                         'account');
-
-        return $data['result'];
-    }
-
-}

+ 0 - 39
app/Module/Blockchain/Tests/Unit/BlServiceTest.php

@@ -1,39 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Tests\Unit;
-
-use App\Module\Blockchain\Services\BscScanService;
-use App\Module\Transaction\Enums\ACCOUNT_TYPE;
-use Tests\TestCase;
-use Illuminate\Support\Facades\Http;
-use Illuminate\Support\Facades\Cache;
-
-/**
- * BlServiceTest
- * BlServiceTest
- */
-class BlServiceTest extends TestCase
-{
-    protected BscScanService $service;
-
-
-    public function setUp(): void
-    {
-        parent::setUp();
-        $this->service = new BscScanService();
-
-
-
-    }
-
-    /**
-     * 测试获取BNB余额
-     * @test
-     */
-    public function testGetBnbBalance()
-    {
-        dump(config()->all());
-        $config = config('easysms');
-        dump($config);
-    }
-}

+ 0 - 54
app/Module/Blockchain/Tests/Unit/BnbScanServiceTest.php

@@ -1,54 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Tests\Unit;
-
-use App\Module\Blockchain\Services\BscScanService;
-use App\Module\Transaction\Enums\ACCOUNT_TYPE;
-use Tests\TestCase;
-use Illuminate\Support\Facades\Http;
-use Illuminate\Support\Facades\Cache;
-
-/**
- * BscScan API 真实接口测试
- * 注意:需要配置有效的BSCSCAN_API_KEY才能运行
- */
-class BnbScanServiceTest extends TestCase
-{
-    protected BscScanService $service;
-    protected string $testAddress = '0xc5981423927fC49270477505013222e70E4C9173';
-    protected string $testTxHash = '0x60d9401026de26d6871ed00e2fbbe8b3ae5349a4d634ae14981653d1ed729a64';
-
-    //
-    public function setUp(): void
-    {
-        parent::setUp();
-        $this->service = new BscScanService();
-
-
-    }
-
-    /**
-     * 测试获取BNB余额
-     * @test
-     */
-    public function testGetBnbBalance()
-    {
-        $balance = $this->service->getBalance($this->testAddress, ACCOUNT_TYPE::BNB);
-
-        dump($balance);
-        // 验证返回值为数字类型且大于等于0
-        $this->assertIsNumeric($balance);
-        $this->assertGreaterThanOrEqual(0, $balance);
-        $balanceUsdt = $this->service->getBalance($this->testAddress, ACCOUNT_TYPE::USDT);
-        dump($balanceUsdt);
-        $balanceURAUS = $this->service->getBalance($this->testAddress, ACCOUNT_TYPE::URAUS);
-        dump($balanceURAUS);
-    }
-
-    public function testGetTxInfo()
-    {
-        $this->service->enableResponseSaving(true);
-        $txInfo = $this->service->getTransactionStatus($this->testTxHash, ACCOUNT_TYPE::BNB);
-        dump($txInfo);
-    }
-}

+ 0 - 184
app/Module/Blockchain/Tests/Unit/BscScanServiceTest.php

@@ -1,184 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Tests\Unit;
-
-use App\Module\Blockchain\Services\BscScanService;
-use App\Module\Blockchain\Enums\TokenType;
-use Tests\TestCase;
-use Illuminate\Support\Facades\Http;
-use Illuminate\Support\Facades\Cache;
-
-/**
- * BSCScan 服务单元测试
- */
-class BscScanServiceTest extends TestCase
-{
-    protected BscScanService $service;
-    protected string $testAddress = '0x1234567890123456789012345678901234567890';
-    protected string $testTxHash = '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890';
-
-    protected function setUp(): void
-    {
-        parent::setUp();
-        $this->service = new BscScanService();
-    }
-
-    /**
-     * 测试获取BNB余额
-     * @test
-     */
-    public function testGetBnbBalance()
-    {
-        Http::fake([
-            '*' => Http::response([
-                'status' => '1',
-                'message' => 'OK',
-                'result' => '1000000000000000000' // 1 BNB
-            ])
-        ]);
-
-        $balance = $this->service->getBalance($this->testAddress, TokenType::BNB);
-        $this->assertEquals(1.0, $balance);
-    }
-
-    /**
-     * 测试获取代币余额
-     * @test
-     */
-    public function testGetTokenBalance()
-    {
-        Http::fake([
-            '*' => Http::response([
-                'status' => '1',
-                'message' => 'OK',
-                'result' => '1000000000000000000000' // 1000 USDT
-            ])
-        ]);
-
-        $balance = $this->service->getBalance($this->testAddress, TokenType::USDT);
-        $this->assertEquals(1000.0, $balance);
-    }
-
-    /**
-     * 测试地址验证
-     * @test
-     */
-    public function testAddressValidation()
-    {
-        $this->assertTrue($this->service->isValidAddress($this->testAddress));
-        $this->assertFalse($this->service->isValidAddress('invalid_address'));
-    }
-
-    /**
-     * 测试获取交易状态
-     * @test
-     */
-    public function testGetTransactionStatus()
-    {
-        Http::fake([
-            '*' => Http::response([
-                'result' => [
-                    'blockNumber' => '0x100',
-                    'gas' => '0x5208',
-                    'gasPrice' => '0x4a817c800'
-                ]
-            ])
-        ]);
-
-        $status = $this->service->getTransactionStatus($this->testTxHash);
-        $this->assertArrayHasKey('status', $status);
-        $this->assertArrayHasKey('blockNumber', $status);
-    }
-
-    /**
-     * 测试获取交易收据
-     * @test
-     */
-    public function testGetTransactionReceipt()
-    {
-        Http::fake([
-            '*' => Http::response([
-                'result' => [
-                    'status' => '0x1',
-                    'blockNumber' => '0x100',
-                    'gasUsed' => '0x5208'
-                ]
-            ])
-        ]);
-
-        $receipt = $this->service->getTransactionReceipt($this->testTxHash);
-        $this->assertArrayHasKey('status', $receipt);
-    }
-
-    /**
-     * 测试估算Gas费用
-     * @test
-     */
-    public function testEstimateGasFee()
-    {
-        Http::fake([
-            '*' => Http::response([
-                'result' => '0x4a817c800' // 20 GWEI
-            ])
-        ]);
-
-        $fee = $this->service->estimateGasFee(
-            $this->testAddress,
-            '0x0987654321098765432109876543210987654321',
-            TokenType::BNB,
-            1.0
-        );
-
-        $this->assertIsFloat($fee);
-    }
-
-    /**
-     * 测试获取交易历史
-     * @test
-     */
-    public function testGetTransactionHistory()
-    {
-        Http::fake([
-            '*' => Http::response([
-                'status' => '1',
-                'message' => 'OK',
-                'result' => [
-                    [
-                        'hash' => $this->testTxHash,
-                        'from' => $this->testAddress,
-                        'to' => '0x0987654321098765432109876543210987654321',
-                        'value' => '1000000000000000000'
-                    ]
-                ]
-            ])
-        ]);
-
-        $history = $this->service->getTransactionHistory($this->testAddress, TokenType::BNB);
-        $this->assertIsArray($history);
-        $this->assertNotEmpty($history);
-    }
-
-    /**
-     * 测试缓存机制
-     * @test
-     */
-    public function testBalanceCaching()
-    {
-        Http::fake([
-            '*' => Http::response([
-                'status' => '1',
-                'message' => 'OK',
-                'result' => '1000000000000000000'
-            ])
-        ]);
-
-        // 第一次调用会发起HTTP请求
-        $balance1 = $this->service->getBalance($this->testAddress, TokenType::BNB);
-
-        // 第二次调用应该使用缓存
-        $balance2 = $this->service->getBalance($this->testAddress, TokenType::BNB);
-
-        $this->assertEquals($balance1, $balance2);
-        Http::assertSentCount(1); // 确保只发送了一次HTTP请求
-    }
-}

+ 0 - 144
app/Module/Blockchain/Tests/Unit/Models/BlockchainTransactionTest.php

@@ -1,144 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Tests\Unit\Models;
-
-use App\Module\Blockchain\Models\BlockchainTransaction;
-use App\Module\Blockchain\Models\BlockchainWallet;
-use App\Module\Blockchain\Enums\TokenType;
-use Tests\TestCase;
-
-/**
- * 区块链交易模型单元测试
- */
-class BlockchainTransactionTest extends TestCase
-{
-    protected string $fromAddress = '0x1234567890123456789012345678901234567890';
-    protected string $toAddress = '0x0987654321098765432109876543210987654321';
-
-    /**
-     * 测试创建交易记录
-     * @test
-     */
-    public function testCreateTransaction()
-    {
-        $transaction = BlockchainTransaction::create([
-            'tx_hash' => '0x' . str_repeat('a', 64),
-            'from_address' => $this->fromAddress,
-            'to_address' => $this->toAddress,
-            'amount' => '1.0',
-            'token_type' => TokenType::BNB,
-            'gas_price' => '5.0',
-            'gas_used' => 21000,
-            'status' => 0,
-            'block_number' => null
-        ]);
-
-        $this->assertInstanceOf(BlockchainTransaction::class, $transaction);
-        $this->assertEquals($this->fromAddress, $transaction->from_address);
-        $this->assertEquals($this->toAddress, $transaction->to_address);
-        $this->assertEquals('1.000000000000000000', $transaction->amount);
-        $this->assertEquals(TokenType::BNB, $transaction->token_type);
-        $this->assertEquals('5.000000000000000000', $transaction->gas_price);
-        $this->assertEquals(21000, $transaction->gas_used);
-        $this->assertEquals(0, $transaction->status);
-        $this->assertNull($transaction->block_number);
-    }
-
-    /**
-     * 测试交易哈希唯一性约束
-     * @test
-     */
-    public function testTransactionHashUnique()
-    {
-        $txHash = '0x' . str_repeat('a', 64);
-
-        BlockchainTransaction::create([
-            'tx_hash' => $txHash,
-            'from_address' => $this->fromAddress,
-            'to_address' => $this->toAddress,
-            'amount' => '1.0',
-            'token_type' => TokenType::BNB,
-            'gas_price' => '5.0',
-            'gas_used' => 21000,
-            'status' => 0
-        ]);
-
-        $this->expectException(\Illuminate\Database\QueryException::class);
-
-        // 尝试创建相同交易哈希的记录应该失败
-        BlockchainTransaction::create([
-            'tx_hash' => $txHash,
-            'from_address' => $this->fromAddress,
-            'to_address' => $this->toAddress,
-            'amount' => '2.0',
-            'token_type' => TokenType::BNB,
-            'gas_price' => '5.0',
-            'gas_used' => 21000,
-            'status' => 0
-        ]);
-    }
-
-    /**
-     * 测试交易状态标签
-     * @test
-     */
-    public function testTransactionStatusLabel()
-    {
-        $transaction = new BlockchainTransaction();
-
-        $transaction->status = 0;
-        $this->assertEquals('待确认', $transaction->status_label);
-
-        $transaction->status = 1;
-        $this->assertEquals('成功', $transaction->status_label);
-
-        $transaction->status = 2;
-        $this->assertEquals('失败', $transaction->status_label);
-
-        $transaction->status = 99;
-        $this->assertEquals('未知', $transaction->status_label);
-    }
-
-    /**
-     * 测试钱包关联关系
-     * @test
-     */
-    public function testWalletRelations()
-    {
-        // 创建发送方钱包
-        $fromWallet = BlockchainWallet::create([
-            'address' => $this->fromAddress,
-            'type' => TokenType::BNB,
-            'balance' => '10.0',
-            'status' => true
-        ]);
-
-        // 创建接收方钱包
-        $toWallet = BlockchainWallet::create([
-            'address' => $this->toAddress,
-            'type' => TokenType::BNB,
-            'balance' => '0.0',
-            'status' => true
-        ]);
-
-        // 创建交易记录
-        $transaction = BlockchainTransaction::create([
-            'tx_hash' => '0x' . str_repeat('a', 64),
-            'from_address' => $this->fromAddress,
-            'to_address' => $this->toAddress,
-            'amount' => '1.0',
-            'token_type' => TokenType::BNB,
-            'gas_price' => '5.0',
-            'gas_used' => 21000,
-            'status' => 1,
-            'block_number' => 12345678
-        ]);
-
-        // 测试关联关系
-        $this->assertInstanceOf(BlockchainWallet::class, $transaction->fromWallet);
-        $this->assertInstanceOf(BlockchainWallet::class, $transaction->toWallet);
-
-        $this->assertEquals($fromWallet->id, $transaction->fromWallet->id);
-        $this->assertEquals($toWallet->id, $transaction->toWallet->id);
-    }
-}

+ 0 - 176
app/Module/Blockchain/Tests/Unit/Models/BlockchainWalletTest.php

@@ -1,176 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Tests\Unit\Models;
-
-use App\Module\Blockchain\Models\BlockchainWallet;
-use App\Module\Blockchain\Models\BlockchainTransaction;
-use App\Module\Blockchain\Enums\TokenType;
-use Tests\TestCase;
-
-/**
- * 区块链钱包模型单元测试
- */
-class BlockchainWalletTest extends TestCase
-{
-    protected string $testAddress = '0x1234567890123456789012345678901234567890';
-
-    /**
-     * 测试创建钱包
-     * @test
-     */
-    public function testCreateWallet()
-    {
-        $now = now();
-
-        $wallet = BlockchainWallet::create([
-            'address' => $this->testAddress,
-            'type' => TokenType::BNB,
-            'balance' => '1.0',
-            'balance_updated_at' => $now,
-            'status' => true
-        ]);
-
-        $this->assertInstanceOf(BlockchainWallet::class, $wallet);
-        $this->assertEquals($this->testAddress, $wallet->address);
-        $this->assertEquals(TokenType::BNB, $wallet->type);
-        $this->assertEquals('1.000000000000000000', $wallet->balance);
-        $this->assertEquals($now->timestamp, $wallet->balance_updated_at->timestamp);
-        $this->assertTrue($wallet->status);
-    }
-
-    /**
-     * 测试余额更新时间
-     * @test
-     */
-    public function testBalanceUpdateTime()
-    {
-        $wallet = BlockchainWallet::create([
-            'address' => $this->testAddress,
-            'type' => TokenType::BNB,
-            'balance' => '1.0',
-            'status' => true
-        ]);
-
-        $this->assertNull($wallet->balance_updated_at);
-
-        $now = now();
-        $wallet->update([
-            'balance' => '2.0',
-            'balance_updated_at' => $now
-        ]);
-
-        $this->assertEquals('2.000000000000000000', $wallet->balance);
-        $this->assertEquals($now->timestamp, $wallet->balance_updated_at->timestamp);
-    }
-
-    /**
-     * 测试钱包关联交易
-     * @test
-     */
-    public function testWalletTransactions()
-    {
-        $wallet = BlockchainWallet::create([
-            'address' => $this->testAddress,
-            'type' => TokenType::BNB,
-            'balance' => '1.0',
-            'status' => true
-        ]);
-
-        // 创建发送交易
-        BlockchainTransaction::create([
-            'tx_hash' => '0x' . str_repeat('a', 64),
-            'from_address' => $this->testAddress,
-            'to_address' => '0x' . str_repeat('b', 40),
-            'amount' => '0.1',
-            'token_type' => TokenType::BNB,
-            'gas_price' => '5.0',
-            'gas_used' => 21000,
-            'status' => 1,
-            'block_number' => 12345678
-        ]);
-
-        // 创建接收交易
-        BlockchainTransaction::create([
-            'tx_hash' => '0x' . str_repeat('c', 64),
-            'from_address' => '0x' . str_repeat('b', 40),
-            'to_address' => $this->testAddress,
-            'amount' => '0.2',
-            'token_type' => TokenType::BNB,
-            'gas_price' => '5.0',
-            'gas_used' => 21000,
-            'status' => 1,
-            'block_number' => 12345679
-        ]);
-
-        // 测试发送交易关联
-        $this->assertCount(1, $wallet->transactions);
-        $this->assertEquals('0.100000000000000000', $wallet->transactions->first()->amount);
-
-        // 测试接收交易关联
-        $this->assertCount(1, $wallet->receivedTransactions);
-        $this->assertEquals('0.200000000000000000', $wallet->receivedTransactions->first()->amount);
-    }
-
-    /**
-     * 测试钱包地址唯一性约束
-     * @test
-     */
-    public function testWalletAddressUnique()
-    {
-        BlockchainWallet::create([
-            'address' => $this->testAddress,
-            'type' => TokenType::BNB,
-            'balance' => '1.0',
-            'status' => true
-        ]);
-
-        $this->expectException(\Illuminate\Database\QueryException::class);
-
-        // 尝试创建相同地址和类型的钱包应该失败
-        BlockchainWallet::create([
-            'address' => $this->testAddress,
-            'type' => TokenType::BNB,
-            'balance' => '2.0',
-            'status' => true
-        ]);
-    }
-
-    /**
-     * 测试不同代币类型的钱包
-     * @test
-     */
-    public function testMultipleTokenTypes()
-    {
-        // 创建BNB钱包
-        $bnbWallet = BlockchainWallet::create([
-            'address' => $this->testAddress,
-            'type' => TokenType::BNB,
-            'balance' => '1.0',
-            'status' => true
-        ]);
-
-        // 创建USDT钱包
-        $usdtWallet = BlockchainWallet::create([
-            'address' => $this->testAddress,
-            'type' => TokenType::USDT,
-            'balance' => '1000.0',
-            'status' => true
-        ]);
-
-        // 创建URAUS钱包
-        $urausWallet = BlockchainWallet::create([
-            'address' => $this->testAddress,
-            'type' => TokenType::URAUS,
-            'balance' => '500.0',
-            'status' => true
-        ]);
-
-        $this->assertEquals(TokenType::BNB, $bnbWallet->type);
-        $this->assertEquals(TokenType::USDT, $usdtWallet->type);
-        $this->assertEquals(TokenType::URAUS, $urausWallet->type);
-
-        $this->assertEquals('1.000000000000000000', $bnbWallet->balance);
-        $this->assertEquals('1000.000000000000000000', $usdtWallet->balance);
-        $this->assertEquals('500.000000000000000000', $urausWallet->balance);
-    }
-}

+ 0 - 189
app/Module/Blockchain/Tests/Unit/Services/BnbChainServiceTest.php

@@ -1,189 +0,0 @@
-<?php
-
-namespace App\Module\Blockchain\Tests\Unit\Services;
-
-use App\Module\Blockchain\Services\BnbChainService;
-use App\Module\Blockchain\Services\BscScanService;
-use App\Module\Blockchain\Enums\TokenType;
-use Tests\TestCase;
-use Illuminate\Support\Facades\Cache;
-use Web3\Web3;
-
-/**
- * BNB Chain 服务单元测试
- */
-class BnbChainServiceTest extends TestCase
-{
-    protected BnbChainService $service;
-    protected BscScanService $bscScanService;
-    protected string $testAddress = '0x1234567890123456789012345678901234567890';
-    protected string $testTxHash = '0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890';
-
-    protected function setUp(): void
-    {
-        parent::setUp();
-        $this->bscScanService = $this->createMock(BscScanService::class);
-        $this->service = new BnbChainService($this->bscScanService, 'testnet');
-    }
-
-    /**
-     * 测试获取网络配置
-     * @test
-     */
-    public function testGetNetwork()
-    {
-        $network = $this->service->getNetwork();
-
-        $this->assertEquals('BNB Smart Chain Testnet', $network['name']);
-        $this->assertEquals(97, $network['chain_id']);
-        $this->assertEquals('https://testnet.bscscan.com', $network['explorer']);
-    }
-
-    /**
-     * 测试获取链 ID
-     * @test
-     */
-    public function testGetChainId()
-    {
-        $this->assertEquals(97, $this->service->getChainId());
-    }
-
-    /**
-     * 测试获取浏览器 URL
-     * @test
-     */
-    public function testGetExplorerUrls()
-    {
-        $this->assertEquals(
-            'https://testnet.bscscan.com',
-            $this->service->getExplorerUrl()
-        );
-
-        $this->assertEquals(
-            'https://testnet.bscscan.com/tx/' . $this->testTxHash,
-            $this->service->getTransactionUrl($this->testTxHash)
-        );
-
-        $this->assertEquals(
-            'https://testnet.bscscan.com/address/' . $this->testAddress,
-            $this->service->getAddressUrl($this->testAddress)
-        );
-
-        $tokenUrl = $this->service->getTokenUrl(TokenType::USDT);
-        $this->assertStringContainsString('https://testnet.bscscan.com/token/', $tokenUrl);
-    }
-
-    /**
-     * 测试 Gas 价格计算
-     * @test
-     */
-    public function testGasPriceCalculation()
-    {
-        Cache::shouldReceive('remember')
-            ->once()
-            ->andReturn([
-                'safe_low' => 5,
-                'standard' => 6,
-                'fast' => 7,
-                'current' => 5.5
-            ]);
-
-        $gasPrice = $this->service->getGasPrice();
-
-        $this->assertArrayHasKey('safe_low', $gasPrice);
-        $this->assertArrayHasKey('standard', $gasPrice);
-        $this->assertArrayHasKey('fast', $gasPrice);
-        $this->assertArrayHasKey('current', $gasPrice);
-
-        $this->assertGreaterThanOrEqual(5, $gasPrice['safe_low']);
-        $this->assertGreaterThanOrEqual($gasPrice['safe_low'], $gasPrice['standard']);
-        $this->assertGreaterThanOrEqual($gasPrice['standard'], $gasPrice['fast']);
-    }
-
-    /**
-     * 测试 MEV 保护
-     * @test
-     */
-    public function testMevProtection()
-    {
-        Cache::shouldReceive('remember')
-            ->once()
-            ->andReturn([
-                'safe_low' => 5,
-                'standard' => 6,
-                'fast' => 7,
-                'current' => 5.5
-            ]);
-
-        $mevPrice = $this->service->getMevProtectedGasPrice();
-
-        $this->assertArrayHasKey('max_priority_fee_per_gas', $mevPrice);
-        $this->assertArrayHasKey('max_fee_per_gas', $mevPrice);
-
-        $this->assertLessThanOrEqual(10, $mevPrice['max_fee_per_gas']);
-        $this->assertGreaterThan(0, $mevPrice['max_priority_fee_per_gas']);
-    }
-
-    /**
-     * 测试交易确认检查
-     * @test
-     */
-    public function testTransactionConfirmations()
-    {
-        // Mock 交易收据
-        $this->bscScanService->method('getTransactionReceipt')
-            ->willReturn([
-                'blockNumber' => '0x100' // 区块 256
-            ]);
-
-        // Mock 最新区块号
-        Cache::shouldReceive('remember')
-            ->once()
-            ->andReturn(276); // 当前区块 276
-
-        $confirmations = $this->service->getTransactionConfirmations($this->testTxHash);
-        $this->assertEquals(20, $confirmations); // 276 - 256 = 20
-
-        $isSafe = $this->service->isTransactionSafe($this->testTxHash);
-        $this->assertTrue($isSafe); // 20 确认数已经安全
-    }
-
-    /**
-     * 测试余额查询代理到 BscScanService
-     * @test
-     */
-    public function testBalanceQueryDelegation()
-    {
-        $this->bscScanService->expects($this->once())
-            ->method('getBalance')
-            ->with($this->testAddress, TokenType::BNB)
-            ->willReturn(1.5);
-
-        $balance = $this->service->getBalance($this->testAddress, TokenType::BNB);
-        $this->assertEquals(1.5, $balance);
-    }
-
-    /**
-     * 测试交易历史查询代理到 BscScanService
-     * @test
-     */
-    public function testTransactionHistoryDelegation()
-    {
-        $expectedHistory = [
-            [
-                'hash' => $this->testTxHash,
-                'from' => $this->testAddress,
-                'to' => '0x0987654321098765432109876543210987654321',
-                'value' => '1000000000000000000'
-            ]
-        ];
-
-        $this->bscScanService->expects($this->once())
-            ->method('getTransactionHistory')
-            ->with($this->testAddress, TokenType::BNB, 1, 10)
-            ->willReturn($expectedHistory);
-
-        $history = $this->service->getTransactionHistory($this->testAddress, TokenType::BNB);
-        $this->assertEquals($expectedHistory, $history);
-    }
-}

+ 1 - 1
app/Module/Ulogic/DayTimes.php

@@ -4,7 +4,7 @@ namespace App\Module\Ulogic;
 
 
 
-use App\Module\Ulogic\Model\UserDaytime;
+use App\Module\Ulogic\Models\UserDaytime;
 
 /**
  * 用户 日计数器

+ 1 - 1
app/Module/Ulogic/Model/AppMessage.php → app/Module/Ulogic/Models/AppMessage.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\AppMessage\Models;
+namespace App\Module\Ulogic\Models;
 
 use App\Module\AppMessage\Enums\APP_MESSAGE_STATUS;
 use App\Module\AppMessage\Enums\APP_MESSAGE_TYPE;

+ 1 - 1
app/Module/Ulogic/Model/AppMessageRecipient.php → app/Module/Ulogic/Models/AppMessageRecipient.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\AppMessage\Models;
+namespace App\Module\Ulogic\Models;
 
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;

+ 1 - 1
app/Module/Ulogic/Model/AppMessageTemplate.php → app/Module/Ulogic/Models/AppMessageTemplate.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\AppMessage\Models;
+namespace App\Module\Ulogic\Models;
 
 use App\Module\AppMessage\Enums\APP_MESSAGE_TYPE;
 use Illuminate\Database\Eloquent\Model;

+ 0 - 0
app/Module/Ulogic/Model/Internal.php → app/Module/Ulogic/Models/Internal.php


+ 0 - 0
app/Module/Ulogic/Model/README.md → app/Module/Ulogic/Models/README.md


+ 1 - 1
app/Module/Ulogic/Model/UserAddress.php → app/Module/Ulogic/Models/UserAddress.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Ulogic\Model;
+namespace App\Module\Ulogic\Models;
 
 use Dcat\Admin\Traits\HasDateTimeFormatter;
 use Illuminate\Database\Eloquent\SoftDeletes;

+ 1 - 1
app/Module/Ulogic/Model/UserBans.php → app/Module/Ulogic/Models/UserBans.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Ulogic\Model;
+namespace App\Module\Ulogic\Models;
 
 use Dcat\Admin\Traits\HasDateTimeFormatter;
 use Illuminate\Database\Eloquent\SoftDeletes;

+ 5 - 5
app/Module/Ulogic/Model/UserDaytime.php → app/Module/Ulogic/Models/UserDaytime.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Ulogic\Model;
+namespace App\Module\Ulogic\Models;
 
 use App\Models\ModelCore;
 
@@ -8,16 +8,16 @@ use App\Models\ModelCore;
 /**
  * 用户每日计数
  *
- * field start 
+ * field start
  * @property   int  $id  主键id
  * @property   int  $user_id  用户id
  * @property   string  $stype  产品类型
  * @property   int  $sid  产品id
  * @property   int  $number  计数
  * @property   int  $day  日期
- * @property   \Carbon\Carbon  $created_at  
- * @property   \Carbon\Carbon  $updated_at  
- * @property   \Carbon\Carbon  $deleted_at  
+ * @property   \Carbon\Carbon  $created_at
+ * @property   \Carbon\Carbon  $updated_at
+ * @property   \Carbon\Carbon  $deleted_at
  * field end
  *
  */

+ 1 - 1
app/Module/Ulogic/Model/UserPunish.php → app/Module/Ulogic/Models/UserPunish.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Ulogic\Model;
+namespace App\Module\Ulogic\Models;
 
 use App\Models\ModelCore;
 use App\Module\Ulogic\Enum\PUNISH_TYPE;

+ 1 - 1
app/Module/Ulogic/Model/UserRelation.php → app/Module/Ulogic/Models/UserRelation.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Ulogic\Model;
+namespace App\Module\Ulogic\Models;
 
 use Dcat\Admin\Traits\HasDateTimeFormatter;
 

+ 5 - 5
app/Module/Ulogic/Model/UserTime.php → app/Module/Ulogic/Models/UserTime.php

@@ -1,21 +1,21 @@
 <?php
 
-namespace App\Module\Ulogic\Model;
+namespace App\Module\Ulogic\Models;
 
 use App\Models\ModelCore;
 
 
 /**
  * 用户计数
- * field start 
+ * field start
  * @property   int  $id  主键id
  * @property   int  $user_id  用户id
  * @property   string  $stype  产品类型
  * @property   int  $sid  产品id
  * @property   int  $number  计数
- * @property   \Carbon\Carbon  $created_at  
- * @property   \Carbon\Carbon  $updated_at  
- * @property   \Carbon\Carbon  $deleted_at  
+ * @property   \Carbon\Carbon  $created_at
+ * @property   \Carbon\Carbon  $updated_at
+ * @property   \Carbon\Carbon  $deleted_at
  * field end
  *
  */

+ 1 - 1
app/Module/Ulogic/Model/UserWord.php → app/Module/Ulogic/Models/UserWord.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Ulogic\Model;
+namespace App\Module\Ulogic\Models;
 
 use Dcat\Admin\Traits\HasDateTimeFormatter;
 

+ 1 - 1
app/Module/Ulogic/Model/WalletAddress.php → app/Module/Ulogic/Models/WalletAddress.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace App\Module\Ulogic\Model;
+namespace App\Module\Ulogic\Models;
 
 use App\Module\Ulogic\Enum\WALLET_ADDRESS_STATUS;
 use App\Module\Ulogic\Enum\WALLET_ADDRESS_TYPE;

+ 3 - 3
app/Module/Ulogic/Queues/SendAppMessageQueue.php

@@ -1,9 +1,9 @@
 <?php
 
-namespace App\Module\AppMessage\Queues;
+namespace App\Module\Ulogic\Queues;
 
-use App\Module\AppMessage\Models\AppMessage;
-use App\Module\AppMessage\Services\AppMessageService;
+use App\Module\Ulogic\Models\AppMessage;
+use App\Module\Ulogic\Services\AppMessageService;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Foundation\Bus\Dispatchable;

+ 0 - 96
app/Module/UrausSys/AdminControllers/ReceiveAddressController.php

@@ -1,96 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\AdminControllers;
-
-
-use App\Module\Fund\Repositorys\FundAdminRepository;
-use App\Module\UrausSys\Enums\RECEIVE_ADDRESS_STATUS;
-use App\Module\UrausSys\Models\ReceiveAddress;
-use App\Module\UrausSys\Repositorys\ReceiveAddressRepository;
-use Dcat\Admin\Form;
-use Dcat\Admin\Grid;
-use Dcat\Admin\Show;
-use Spatie\RouteAttributes\Attributes\Prefix;
-use Spatie\RouteAttributes\Attributes\Resource;
-use UCore\DcatAdmin\AdminController;
-use UCore\DcatAdmin\FilterHelper;
-
-#[Resource('receive_address', names: 'dcat.admin.receive_address')]
-class ReceiveAddressController extends AdminController
-{
-
-    protected $title = '收款地址';
-
-
-    /**
-     * Make a grid builder.
-     *
-     * @return Grid
-     */
-    protected function grid()
-    {
-
-        return Grid::make(new ReceiveAddressRepository(), function (Grid $grid) {
-
-            $helper = new \UCore\DcatAdmin\GridHelper($grid,$this);
-            $helper->disableAll();
-            $helper->columnIdDesc();
-
-
-
-            $grid->column('name');
-            $grid->column('address');
-            $helper->columnModelCats('status',null,'状态',true);
-
-            $helper->columnAt('create_time');
-
-
-
-            $grid->filter(function (Grid\Filter $filter) {
-                $helper= new FilterHelper($filter,$this);
-                $helper->equalRadioModelCats('status');
-
-                $filter->expand();
-                $filter->panel();
-            });
-            $grid->showCreateButton();
-            $grid->actions(function (Grid\Displayers\Actions $actions) {
-//                $actions->disableDelete();
-                $actions->disableView();
-
-            });
-
-        });
-    }
-
-    /**
-     * Make a show builder.
-     *
-     * @param mixed $id
-     *
-     * @return Show
-     */
-    protected function detail($id)
-    {
-        return Show::make($id, new ReceiveAddressRepository(), function (Show $show) {
-            $show->field('id');
-            $show->field('name');
-            $show->field('address');
-            $show->field('status');
-        });
-    }
-
-    /**
-     * Make a form builder.
-     *
-     * @return Form
-     */
-    protected function form()
-    {
-        return Form::make(new ReceiveAddressRepository(), function (Form $form) {
-            $form->text('name','备注名字');
-            $form->text('address','地址');
-            $form->select('status','选择')->options(RECEIVE_ADDRESS_STATUS::getValueDescription());
-        });
-    }
-}

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

@@ -1,35 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Commands;
-
-
-
-use App\Module\UrausSys\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/UrausSys/Config/test.php

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

+ 0 - 19
app/Module/UrausSys/Controllers/TestController.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Controllers;
-
-use App\Module\UrausSys\Services\TestService;
-use Illuminate\Routing\Controller;
-use Illuminate\Support\Facades\Log;
-use Spatie\RouteAttributes\Attributes\Get;
-use Spatie\RouteAttributes\Attributes\Prefix;
-
-#[Prefix('test')]
-class TestController extends Controller
-{
-    #[Get('/test')]
-    public function test()
-    {
-        TestService::insertHash();
-    }
-}

+ 0 - 35
app/Module/UrausSys/Database/Factories/TestFactory.php

@@ -1,35 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Database\Factories;
-
-use App\Module\UrausSys\Models\ReceiveAddress;
-use Illuminate\Database\Eloquent\Factories\Factory;
-
-class TestFactory extends Factory
-{
-    /**
-     * 指定模型类
-     *
-     * @var string
-     */
-    protected $model = ReceiveAddress::class;
-
-    /**
-     * 定义模型的默认状态
-     *
-     * @return array
-     */
-    public function definition(): array
-    {
-        return [
-            'name' => $this->faker->word,
-            'code' => $this->faker->unique()->word,
-            'description' => $this->faker->sentence,
-            'data' => [
-                'key' => $this->faker->word,
-                'value' => $this->faker->word
-            ],
-            'status' => 1
-        ];
-    }
-}

+ 0 - 33
app/Module/UrausSys/Database/Migrations/2024_01_01_000000_create_test_table.php

@@ -1,33 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
-
-return new class extends Migration
-{
-    /**
-     * Run the migrations.
-     */
-    public function up(): void
-    {
-        Schema::create('test', function (Blueprint $table) {
-            $table->id();
-            $table->string('name')->comment('名称');
-            $table->string('code')->unique()->comment('编码');
-            $table->text('description')->nullable()->comment('描述');
-            $table->json('data')->nullable()->comment('数据');
-            $table->tinyInteger('status')->default(1)->comment('状态:0禁用 1启用');
-            $table->timestamps();
-            $table->softDeletes();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     */
-    public function down(): void
-    {
-        Schema::dropIfExists('test');
-    }
-};

+ 0 - 18
app/Module/UrausSys/Database/Seeders/DatabaseSeeder.php

@@ -1,18 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Database\Seeders;
-
-use Illuminate\Database\Seeder;
-
-class DatabaseSeeder extends Seeder
-{
-    /**
-     * Seed the application's database.
-     */
-    public function run(): void
-    {
-        $this->call([
-            TestSeeder::class,
-        ]);
-    }
-}

+ 0 - 38
app/Module/UrausSys/Database/Seeders/TestSeeder.php

@@ -1,38 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Database\Seeders;
-
-use App\Module\UrausSys\Models\ReceiveAddress;
-use Illuminate\Database\Seeder;
-
-class TestSeeder extends Seeder
-{
-    /**
-     * Run the database seeds.
-     */
-    public function run(): void
-    {
-        // 创建测试数据
-        ReceiveAddress::create([
-            'name' => '测试数据1',
-            'code' => 'TEST001',
-            'description' => '这是测试数据1的描述',
-            'data' => [
-                'key1' => 'value1',
-                'key2' => 'value2'
-            ],
-            'status' => 1
-        ]);
-
-        ReceiveAddress::create([
-            'name' => '测试数据2',
-            'code' => 'TEST002',
-            'description' => '这是测试数据2的描述',
-            'data' => [
-                'key3' => 'value3',
-                'key4' => 'value4'
-            ],
-            'status' => 1
-        ]);
-    }
-}

+ 0 - 26
app/Module/UrausSys/Enums/ACTYPE2.php

@@ -1,26 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Enums;
-
-use App\Module\Transaction\Enums\ACCOUNT_TYPE;
-
-class ACTYPE2
-{
-
-    static $ac2name  = [
-        \Uraus\App\ACCOUNT_TYPE::URAUS => ACCOUNT_TYPE::URAUS->name,
-        \Uraus\App\ACCOUNT_TYPE::USDT  => ACCOUNT_TYPE::USDT->name,
-        \Uraus\App\ACCOUNT_TYPE::BNB   => ACCOUNT_TYPE::BNB->name,
-    ];
-    static $ac2ac    = [
-        \Uraus\App\ACCOUNT_TYPE::URAUS => ACCOUNT_TYPE::URAUS,
-        \Uraus\App\ACCOUNT_TYPE::USDT  => ACCOUNT_TYPE::USDT,
-        \Uraus\App\ACCOUNT_TYPE::BNB   => ACCOUNT_TYPE::BNB,
-    ];
-    static $ac2value = [
-        \Uraus\App\ACCOUNT_TYPE::URAUS => ACCOUNT_TYPE::URAUS->value,
-        \Uraus\App\ACCOUNT_TYPE::USDT  => ACCOUNT_TYPE::USDT->value,
-        \Uraus\App\ACCOUNT_TYPE::BNB   => ACCOUNT_TYPE::BNB->value,
-    ];
-
-}

+ 0 - 31
app/Module/UrausSys/Enums/RECEIVE_ADDRESS_STATUS.php

@@ -1,31 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Enums;
-
-use UCore\Enum\EnumCore;
-use UCore\Enum\EnumExpression;
-use UCore\Enum\EnumToInt;
-use UCore\Enum\EnumToString;
-
-enum RECEIVE_ADDRESS_STATUS: int
-{
-
-    use EnumToInt, EnumCore, EnumExpression;
-
-
-    /**
-     * 可用
-     */
-    case OK = 1;
-
-    /**
-     * 使用中
-     */
-    case ING = 20;
-
-    /**
-     * 停用
-     */
-    case STOP = 101;
-
-}

+ 0 - 40
app/Module/UrausSys/Events/TestEvent.php

@@ -1,40 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Events;
-
-use App\Module\UrausSys\Models\ReceiveAddress;
-use Illuminate\Broadcasting\InteractsWithSockets;
-use Illuminate\Foundation\Events\Dispatchable;
-use Illuminate\Queue\SerializesModels;
-
-class TestEvent
-{
-    use Dispatchable, InteractsWithSockets, SerializesModels;
-
-    /**
-     * 测试数据
-     *
-     * @var ReceiveAddress
-     */
-    public ReceiveAddress $test;
-
-    /**
-     * 事件类型
-     *
-     * @var string
-     */
-    public string $type;
-
-    /**
-     * 创建事件实例
-     *
-     * @param ReceiveAddress $test
-     * @param string $type
-     * @return void
-     */
-    public function __construct(ReceiveAddress $test, string $type)
-    {
-        $this->test = $test;
-        $this->type = $type;
-    }
-}

+ 0 - 18
app/Module/UrausSys/Exceptions/TestException.php

@@ -1,18 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Exceptions;
-
-class TestException extends \Exception
-{
-    /**
-     * 创建异常实例
-     *
-     * @param string $message
-     * @param int $code
-     * @return void
-     */
-    public function __construct(string $message = "", int $code = 0)
-    {
-        parent::__construct($message, $code);
-    }
-}

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

@@ -1,34 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Jobs;
-
-use App\Module\UrausSys\Models\ReceiveAddress;
-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 ReceiveAddress $test
-     */
-    public function __construct(protected ReceiveAddress $test)
-    {
-    }
-
-    /**
-     * 执行任务
-     *
-     * @return void
-     */
-    public function handle(): void
-    {
-        // 任务处理逻辑
-    }
-}

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

@@ -1,31 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Listeners;
-
-use App\Module\UrausSys\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/UrausSys/Listeners/TestListener.php

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

+ 0 - 49
app/Module/UrausSys/Models/ReceiveAddress.php

@@ -1,49 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Models;
-
-use App\Module\UrausSys\Enums\RECEIVE_ADDRESS_STATUS;
-use UCore\ModelCore;
-use Illuminate\Database\Eloquent\SoftDeletes;
-
-
-/**
- * 收款账户 , 平台的
- * ReceiveAddress
- * ReceiveAddressController
- *
- * field start 
- * @property   int  $id  
- * @property   string  $name  地址
- * @property   int  $status  状态
- * @property   string  $address  地址
- * @property   \Carbon\Carbon  $created_at  创建时间
- * @property   \Carbon\Carbon  $updated_at  更新时间
- * @property   \Carbon\Carbon  $deleted_at  删除时间
- * field end
- *
- */
-class ReceiveAddress extends ModelCore
-{
-
-    use  SoftDeletes;
-
-    /**
-     * @var string
-     */
-    protected $table = 'receive_address';
-
-    // attrlist start 
-    protected $fillable = [
-        'id',
-        'name',
-        'status',
-        'address',
-    ];
-    // attrlist end
-
-    protected $casts =[
-        'status' => RECEIVE_ADDRESS_STATUS::class,
-    ];
-
-}

+ 0 - 29
app/Module/UrausSys/Providers/TestServiceProvider.php

@@ -1,29 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Providers;
-
-use App\Module\UrausSys\Events\TestEvent;
-use App\Module\UrausSys\Listeners\TestEventListener;
-use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
-
-class TestServiceProvider extends ServiceProvider
-{
-    /**
-     * 事件到监听器的映射
-     *
-     * @var array<class-string, array<int, class-string>>
-     */
-    protected $listen = [
-        TestEvent::class => [
-            TestEventListener::class,
-        ],
-    ];
-
-    /**
-     * 注册任何事件监听器
-     */
-    public function boot(): void
-    {
-        parent::boot();
-    }
-}

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

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

+ 0 - 1
app/Module/UrausSys/README.md

@@ -1 +0,0 @@
-# Uraus特色功能

+ 0 - 12
app/Module/UrausSys/Repositorys/ReceiveAddressRepository.php

@@ -1,12 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Repositorys;
-
-use App\Module\UrausSys\Models\ReceiveAddress;
-use UCore\DcatAdmin\Repository\EloquentRepository;
-
-class ReceiveAddressRepository extends EloquentRepository
-{
-
-    protected $eloquentClass = ReceiveAddress::class;
-}

+ 0 - 20
app/Module/UrausSys/Services/AddressService.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Services;
-
-class AddressService
-{
-    /**
-     * 生成符合BNB Chain规范的地址(模拟实现)
-     * 规范说明:
-     * - 以"0x"开头
-     * - 后接40位小写十六进制字符(0-9, a-f)
-     * - 总长度42字符
-     * 
-     * @return string 符合规范的BNB Chain地址
-     */
-    public static function generateBnbAddress(): string
-    {
-        return '0x' . bin2hex(random_bytes(20)); // 20字节随机数生成40位十六进制
-    }
-}

+ 0 - 43
app/Module/UrausSys/Services/ReceiveAddressService.php

@@ -1,43 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Services;
-
-use App\Module\UrausSys\Enums\RECEIVE_ADDRESS_STATUS;
-use App\Module\UrausSys\Models\ReceiveAddress;
-
-/**
- * 收款地址管理服务
- */
-class ReceiveAddressService
-{
-
-    /**
-     * 获取可用收款地址(优先最新OK状态,无则随机取ING状态)
-     *
-     * @return \App\Module\UrausSys\Models\ReceiveAddress|null
-     */
-    public function getAvailableAddress()
-    {
-        // 优先获取最新可用状态地址(OK=1)
-        $address = ReceiveAddress::where('status', RECEIVE_ADDRESS_STATUS::OK->value)
-            ->latest('id')
-            ->first();
-
-        // 无可用地址时随机获取使用中状态地址(ING=20)
-        if (!$address) {
-            $address = ReceiveAddress::where('status', RECEIVE_ADDRESS_STATUS::ING->value)
-                ->inRandomOrder()  // 使用数据库原生随机排序
-                ->first();
-        }
-        if ($address) {
-            if ($address->status === RECEIVE_ADDRESS_STATUS::OK) {
-                $address->status = RECEIVE_ADDRESS_STATUS::ING;
-                $address->save();
-            }
-
-        }
-
-        return $address;
-    }
-
-}

+ 0 - 55
app/Module/UrausSys/Tests/Services/ReceiveAddressServiceTest.php

@@ -1,55 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Tests\Services;
-
-use App\Module\UrausSys\Enums\RECEIVE_ADDRESS_STATUS;
-use App\Module\UrausSys\Models\ReceiveAddress;
-use App\Module\UrausSys\Services\AddressService;
-use App\Module\UrausSys\Services\ReceiveAddressService;
-use Faker\Provider\Address;
-use Tests\TestCase;
-
-class ReceiveAddressServiceTest extends TestCase
-{
-
-    protected ReceiveAddressService $service;
-
-    public function setUp(): void
-    {
-        parent::setUp();
-        $this->service = new ReceiveAddressService();
-    }
-
-    /**
-     * 测试获取最新OK状态地址
-     * 验证逻辑:当存在多个OK状态地址时,应返回最新创建的一个
-     */
-    public function test_get_latest_ok_status_address()
-    {
-        $address1 = ReceiveAddress::create([
-                                               "name"   => "phpunit",
-                                               'status' => RECEIVE_ADDRESS_STATUS::OK->value,
-
-                                               'address' => AddressService::generateBnbAddress()
-                                           ]);
-
-
-        $result = $this->service->getAvailableAddress();
-        $this->assertEquals($address1->id, $result->id);
-        dump($result);
-    }
-
-    /**
-     * 测试无OK地址时随机获取ING状态地址
-     * 验证逻辑:当没有OK状态地址时,应随机返回一个ING状态地址
-     */
-    public function test_get_random_ing_address_when_no_ok_available()
-    {
-
-        $result = $this->service->getAvailableAddress();
-        $this->assertGreaterThan(0,$result->id);
-        dump($result);
-    }
-
-
-}

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

@@ -1,92 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\Tests;
-
-use App\Module\UrausSys\Models\ReceiveAddress;
-use App\Module\UrausSys\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(ReceiveAddress::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 = ReceiveAddress::factory()->create();
-
-        $result = $this->service->get($test->id);
-
-        $this->assertInstanceOf(ReceiveAddress::class, $result);
-        $this->assertEquals($test->id, $result->id);
-    }
-
-    /**
-     * 测试更新数据
-     *
-     * @return void
-     */
-    public function test_update(): void
-    {
-        $test = ReceiveAddress::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 = ReceiveAddress::factory()->create();
-
-        $result = $this->service->delete($test->id);
-
-        $this->assertTrue($result);
-        $this->assertNull(ReceiveAddress::find($test->id));
-    }
-}

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

@@ -1,25 +0,0 @@
-<?php
-
-namespace App\Module\UrausSys\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 - 10
app/Module/UrausSys/Validations/Test.php

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

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

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

+ 3 - 3
app/Module/User/Action.php

@@ -8,9 +8,9 @@ use App\Module\User\Enums\ActionType;
 use App\Module\User\Enums\Status2;
 use App\Module\User\Model\UserAction;
 use App\Module\User\Unit\UserPublic;
-use UCore\Db\Arr;
-use UCore\Db\Helper;
-use UCore\Helper\Logger;
+use Dcore\Db\Arr;
+use Dcore\Db\Helper;
+use Dcore\Helper\Logger;
 use Illuminate\Database\Query\Builder;
 use Illuminate\Support\Facades\DB;
 

+ 15 - 0
app/Module/User/AdminControllers/UserController.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Module\User\AdminControllers;
+
+use Spatie\RouteAttributes\Attributes\Resource;
+use UCore\DcatAdmin\AdminController;
+
+/**
+ *
+ */
+#[Resource('user_index', names: 'dcat.admin.user_index')]
+class UserController extends AdminController
+{
+
+}

+ 37 - 0
app/Module/User/Enums/ActionStatus.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Module\User\Enums;
+
+use UCore\Enum\EnumCore;
+use UCore\Enum\EnumExpression;
+use UCore\Enum\EnumToInt;
+use Illuminate\Contracts\Database\Query\Expression;
+
+/**
+ * 触发状态
+ */
+enum ActionStatus:int implements Expression
+{
+    use EnumToInt,EnumCore,EnumExpression;
+
+    /**
+     * 生效中
+     */
+    case Ing = 1;
+
+
+    /**
+     * 没有过期时间
+     */
+    case Ok = 2;
+
+    /**
+     * 过期
+     */
+    case OutTime = 9;
+
+    /**
+     * 结束
+     */
+    case End = 10;
+}

+ 33 - 0
app/Module/User/Enums/ActionType.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Module\User\Enums;
+
+use UCore\Enum\EnumCore;
+use UCore\Enum\EnumExpression;
+use UCore\Enum\EnumName;
+use Illuminate\Contracts\Database\Query\Expression;
+
+enum ActionType  implements Expression
+{
+    use EnumName,EnumCore,EnumExpression;
+    /**
+     * 封禁
+     */
+    case Ban;
+
+    /**
+     * 禁止登录
+     */
+    case Restrict;
+
+    /**
+     * 删除
+     */
+    case Delete;
+
+    /**
+     * 正常化
+     */
+    case Normal;
+
+}

+ 35 - 0
app/Module/User/Enums/PhoneStatus.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Module\User\Enums;
+
+use UCore\Enum\EnumCore;
+use UCore\Enum\EnumExpression;
+use UCore\Enum\EnumName;
+use UCore\Enum\EnumToInt;
+use Illuminate\Contracts\Database\Query\Expression;
+
+/**
+ * 手机号码状态
+ *
+ */
+enum PhoneStatus: int implements Expression
+{
+
+    use EnumToInt, EnumCore, EnumExpression;
+
+    /**
+     * 绑定
+     */
+    case BIND = 9;
+
+    /**
+     * 未绑定
+     */
+    case UNBIND = 0;
+
+    /**
+     * 等待验证
+     */
+    case WAIT_CHECK = 1;
+
+}

+ 29 - 0
app/Module/User/Enums/PhoneType.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Module\User\Enums;
+
+use UCore\Enum\EnumCore;
+use UCore\Enum\EnumExpression;
+use UCore\Enum\EnumName;
+use Illuminate\Contracts\Database\Query\Expression;
+
+/**
+ * 手机号码类型
+ *
+ */
+enum PhoneType: int implements Expression
+{
+
+    use EnumName, EnumCore, EnumExpression;
+
+    /**
+     * 系统认证
+     */
+    case SYS = 1;
+
+    /**
+     * 第三方认证
+     */
+    case THREE = 2;
+
+}

+ 1 - 1
app/Module/User/Enums/README.md

@@ -1 +1 @@
-# 枚举
+# 枚举-用户模块

+ 34 - 0
app/Module/User/Enums/SecertPasswordStatus.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Module\User\Enums;
+
+use UCore\Enum\EnumCore;
+use UCore\Enum\EnumExpression;
+use UCore\Enum\EnumName;
+use Illuminate\Contracts\Database\Query\Expression;
+
+/**
+ * 手机号码状态
+ *
+ */
+enum SecertPasswordStatus: int implements Expression
+{
+
+    use EnumName, EnumCore, EnumExpression;
+
+    /**
+     * 绑定
+     */
+    case BIND = 9;
+
+    /**
+     * 未绑定
+     */
+    case UNBIND = 0;
+
+    /**
+     * 等待验证
+     */
+    case WAIT_CHECK = 1;
+
+}

+ 39 - 0
app/Module/User/Enums/Status.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Module\User\Enums;
+
+use UCore\Enum\EnumCore;
+use UCore\Enum\EnumExpression;
+use UCore\Enum\EnumToInt;
+use Illuminate\Contracts\Database\Query\Expression;
+
+/**
+ * 状态
+ */
+enum Status: int  implements Expression
+{
+
+    use EnumToInt,EnumCore,EnumExpression;
+
+    /**
+     * 未知
+     */
+    case Hidden = 0;
+
+    /**
+     * 不在线
+     */
+    case Off = 1;
+
+    /**
+     * 在线
+     */
+    case Online = 2;
+
+
+    /**
+     * 忙碌
+     */
+    case Busily = 6;
+
+}

+ 51 - 0
app/Module/User/Enums/Status2.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Module\User\Enums;
+
+use UCore\Enum\EnumCore;
+use UCore\Enum\EnumExpression;
+use UCore\Enum\EnumToInt;
+use Illuminate\Contracts\Database\Query\Expression;
+
+/**
+ * 状态2
+ *
+ */
+enum Status2: int  implements Expression
+{
+
+    use EnumToInt, EnumCore,EnumExpression;
+
+
+    /**
+     * 隐藏账户
+     */
+    case Hidden = 0;
+
+    /**
+     * 正常
+     */
+    case Normal = 1;
+
+    // 下面负面的状态
+
+    /**
+     * 限制登录
+     */
+    case Restrict = -1;
+
+    /**
+     * 封禁
+     */
+    case Ban = -2;
+
+    /**
+     * 删除中
+     */
+    case Deleteing = -10;
+
+    /**
+     * 删除了
+     */
+    case Deleted = -11;
+}

+ 34 - 0
app/Module/User/Google2Fa.php

@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Module\User;
+
+use App\Module\Sys\Config;
+use App\Module\Sys\Key;
+use App\Module\User\Model\UserInfo;
+
+class Google2Fa
+{
+
+
+    /**
+     * 是否必须进行 2fa 验证
+     *
+     * @param UserOInfo $info
+     * @return void
+     */
+    static public function must_check(UserInfo $info,$scene = 'vorder_add')
+    {
+        $authArray = Config::getValueDefault('auth_'.$scene);
+        if(!$authArray['open_password2fa']){
+            return false;
+        }
+        $f              = $info->google2fa_secret ? true : false;
+
+        if ($authArray['must_password2fa']) {
+            $f = true;
+        }
+
+        return $f;
+    }
+
+}

+ 15 - 0
app/Module/User/Model/Events/UserId.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Module\User\Model\Events;
+
+abstract class UserId implements UserIdInterface
+{
+
+    public int $user_id;
+
+    public function getUserId(): int
+    {
+        return $this->user_id;
+    }
+
+}

+ 9 - 0
app/Module/User/Model/Events/UserIdInterface.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace App\Module\User\Model\Events;
+
+interface UserIdInterface
+{
+    public function getUserId():int;
+
+}

+ 15 - 0
app/Module/User/Model/Events/UserInfoSaved.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Module\User\Model\Events;
+
+use App\Module\User\Model\UserInfo;
+
+class UserInfoSaved extends UserId
+{
+
+    public function __construct(public UserInfo $userInfo)
+    {
+        $this->user_id = $this->userInfo->user_id;
+    }
+
+}

+ 15 - 0
app/Module/User/Model/Events/UserInfoUpdate.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace App\Module\User\Model\Events;
+
+use App\Module\User\Model\UserInfo;
+
+class UserInfoUpdate extends UserId
+{
+
+    public function __construct(public UserInfo $userInfo)
+    {
+        $this->user_id = $this->userInfo->user_id;
+    }
+
+}

+ 16 - 0
app/Module/User/Model/Events/UserPhoneSaved.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Module\User\Model\Events;
+
+use App\Module\User\Model\UserInfo;
+use App\Module\User\Model\UserPhone;
+
+class UserPhoneSaved extends UserId
+{
+
+    public function __construct(public UserPhone $userPhone)
+    {
+        $this->user_id = $this->userPhone->user_id;
+    }
+
+}

+ 16 - 0
app/Module/User/Model/Events/UserPhoneUpdate.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Module\User\Model\Events;
+
+use App\Module\User\Model\UserInfo;
+use App\Module\User\Model\UserPhone;
+
+class UserPhoneUpdate extends UserId
+{
+
+    public function __construct(public UserPhone $userPhone)
+    {
+        $this->user_id = $this->userPhone->user_id;
+    }
+
+}

+ 16 - 0
app/Module/User/Model/Events/UserSaved.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Module\User\Model\Events;
+
+use App\Module\User\Model\User;
+use App\Module\User\Model\UserInfo;
+
+class UserSaved extends UserId
+{
+
+    public function __construct(public User $user)
+    {
+        $this->user_id = $this->user->id;
+    }
+
+}

+ 16 - 0
app/Module/User/Model/Events/UserSecretPasswordSaved.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Module\User\Model\Events;
+
+use App\Module\User\Model\User;
+use App\Module\User\Model\UserSecretPassword;
+
+class UserSecretPasswordSaved extends UserId
+{
+
+    public function __construct(public UserSecretPassword $user)
+    {
+        $this->user_id = $this->user->user_id;
+    }
+
+}

+ 1 - 1
app/Module/User/Model/User.php

@@ -5,7 +5,7 @@ namespace App\Module\User\Model;
 use Dcat\Admin\Traits\HasDateTimeFormatter;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Str;
-use UCore\ModelCore;
+use \ModelCore;
 
 /**
  *

+ 65 - 0
app/Module/User/Model/UserInfo.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Module\User\Model;
+
+use App\Module\Merchant\Model\Merchant;
+use App\Module\User\Enums\PhoneStatus;
+use App\Module\User\Enums\Status;
+use App\Module\User\Enums\Status2;
+use App\Module\User\Model\Events\UserInfoSaved;
+use App\Module\User\Model\Events\UserInfoUpdate;
+use UCore\ModelCore;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+
+/**
+ * 用户信息
+ *
+ * field start
+ *
+ * @property   int $user_id  用户ID
+ * @property   int $status  状态
+ * @property   string $google2fa_secret
+ * @property   string $nickname  昵称
+ * @property   string $avatar  头像
+ * @property   \Carbon\Carbon $created_at
+ * @property   \Carbon\Carbon $updated_at
+ * @property   \Carbon\Carbon $deleted_at
+ * field end
+ *
+ * Class UserInfo
+ * @property UserPhone $user_phone
+ */
+class UserInfo extends \App\Models\ModelCore
+{
+
+    use SoftDeletes;
+
+    protected $primaryKey = 'user_id';
+
+    protected $casts = [
+        'status' => Status::class,
+    ];
+
+    protected $dispatchesEvents = [
+        'updated' => UserInfoUpdate::class,
+        'saved' => UserInfoSaved::class
+    ];
+
+    public function merchant(): HasOne
+    {
+        return $this->hasOne(Merchant::class, 'user_id', 'user_id')->orderByDesc('id');
+    }
+
+    public function user(): HasOne
+    {
+        return $this->hasOne(User::class, 'id', 'user_id');
+    }
+
+    public function user_phone(): HasOne
+    {
+        return $this->hasOne(UserPhone::class, 'user_id', 'user_id')->where('status', '=', PhoneStatus::BIND);
+    }
+
+}

+ 0 - 27
app/Module/User/Model/UserPassword.php

@@ -1,27 +0,0 @@
-<?php
-
-namespace App\Module\User\Model;
-
-use Dcat\Admin\Traits\HasDateTimeFormatter;
-use Illuminate\Database\Eloquent\SoftDeletes;
-use Illuminate\Database\Eloquent\Model;
-
-/**
- * field start
- * field end
- */
-class UserPassword extends Model
-{
-    // attrlist start
-    // attrlist end
-	use HasDateTimeFormatter;
-    use SoftDeletes;
-
-    protected $fillable = [
-        'user_id',      // 必须添加
-        'secret_password' // 如果需通过 create/update 批量赋值,也需添加
-    ];
-
-    protected $table = 'user_password';
-
-}

+ 51 - 0
app/Module/User/Model/UserPhone.php

@@ -0,0 +1,51 @@
+<?php
+
+namespace App\Module\User\Model;
+
+use App\Module\Merchant\Model\Merchant;
+use App\Module\User\Enums\PhoneStatus;
+use App\Module\User\Enums\Status;
+use App\Module\User\Enums\Status2;
+use App\Module\User\Model\Events\UserPhoneSaved;
+use App\Module\User\Model\Events\UserSaved;
+use App\Module\VOrder\Enums\Type;
+use UCore\ModelCore;
+use Illuminate\Database\Eloquent\Relations\HasOne;
+use Illuminate\Database\Eloquent\SoftDeletes;
+
+
+/**
+ * 用户信息
+ *
+ * field start
+ * @property   int  $id
+ * @property   int  $user_id  用户ID
+ * @property   int  $status  状态
+ * @property   int  $type  类型
+ * @property   string  $phone
+ * @property   \Carbon\Carbon  $created_at
+ * @property   \Carbon\Carbon  $updated_at
+ * @property   \Carbon\Carbon  $deleted_at
+ * field end
+ */
+class UserPhone extends \App\Models\ModelCore
+{
+
+    use SoftDeletes;
+
+    protected $primaryKey='id';
+
+    protected $casts = [
+        'type' => Type::class,
+        'status'=>PhoneStatus::class
+    ];
+
+    protected $dispatchesEvents = [
+        'saved' => UserPhoneSaved::class
+    ];
+
+    public function user(): HasOne
+    {
+        return $this->hasOne(User::class,'id','user_id');
+    }
+}

+ 38 - 0
app/Module/User/Model/UserSecretPassword.php

@@ -0,0 +1,38 @@
+<?php
+
+namespace App\Module\User\Model;
+
+use App\Module\User\Enums\SecertPasswordStatus;
+use App\Module\User\Model\Events\UserPhoneSaved;
+use App\Module\User\Model\Events\UserSecretPasswordSaved;
+use UCore\ModelCore;
+
+/**
+ * 用户 - 安全密码
+ *
+ * field start
+ * @property   int  $id
+ * @property   int  $user_id  用户ID
+ * @property   int  $status  状态
+ * @property   string  $last_check_at  最后验证时间
+ * @property   string  $secret_password  安全密码
+ * @property   \Carbon\Carbon  $created_at
+ * @property   \Carbon\Carbon  $updated_at
+ * @property   \Carbon\Carbon  $deleted_at
+ * field end
+ *
+ */
+class UserSecretPassword extends ModelCore
+{
+
+    protected $primaryKey = 'id';
+
+    protected $casts = [
+        'status' => SecertPasswordStatus::class
+    ];
+
+
+    protected $dispatchesEvents = [
+        'saved' => UserSecretPasswordSaved::class
+    ];
+}

+ 60 - 0
app/Module/User/Online.php

@@ -0,0 +1,60 @@
+<?php
+
+namespace App\Module\User;
+
+use Illuminate\Support\Facades\Redis;
+
+/**
+ * 在线
+ * 在线统计
+ */
+class Online
+{
+
+    static public function on($user_id)
+    {
+
+        /**
+         * @var \Redis $a
+         */
+        $a = Redis::client();
+
+        $a->zAdd('user_online', time(), $user_id);
+
+    }
+
+    /**
+     * 统计
+     * @param int  $min 几分钟之内
+     * @return false|int|\Redis
+     * @throws \RedisException
+     */
+    static public function count($min = 10)
+    {
+        $start = time() - ($min * 60);
+        /**
+         * @var \Redis $a
+         */
+        $a = Redis::client();
+
+        return $a->zCount('user_online', $start, time());
+    }
+
+
+    /**
+     * 垃圾回收
+     *
+     * @param int $min 几分钟之前
+     * @return void
+     * @throws \RedisException
+     */
+    static public function gc($min = 30)
+    {
+        $start = time() - ($min * 60);
+        /**
+         * @var \Redis $a
+         */
+        $a = Redis::client();
+        $a->zRemRangeByScore('user_online', 0, $start);
+    }
+}

+ 36 - 0
app/Module/User/Phone.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace App\Module\User;
+
+use App\Module\User\Enums\PhoneStatus;
+use App\Module\User\Enums\PhoneType;
+use App\Module\User\Model\UserPhone;
+
+class Phone
+{
+
+
+    /**
+     * 绑定 手机号码
+     * @param $user_id
+     * @param $phone
+     * @param PhoneType $phoneType
+     * @return UserPhone|false
+     */
+    static public function bind($user_id, $phone, PhoneType $phoneType = PhoneType::SYS)
+    {
+        $new          = new UserPhone();
+        $new->phone   = $phone;
+        $new->user_id = $user_id;
+        $new->status  = PhoneStatus::BIND;
+        $new->type    = $phoneType;
+
+
+        if ($new->save() === false) {
+            return false;
+        }
+
+        return $new;
+    }
+
+}

+ 18 - 0
app/Module/User/Repository/UserAction.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Module\User\Repository;
+
+use App\Admin\Core\Repositories\EloquentRepository;
+
+
+/**
+ *
+ * 用户处理记录
+ *
+ */
+class UserAction extends EloquentRepository
+{
+
+    protected $eloquentClass = \App\Module\User\Model\UserAction::class;
+
+}

+ 17 - 0
app/Module/User/Repository/UserInfo.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Module\User\Repository;
+
+use App\Admin\Core\Repositories\EloquentRepository;
+
+/**
+ *
+ * 用户信息
+ *
+ */
+class UserInfo extends EloquentRepository
+{
+
+    protected $eloquentClass = \App\Module\User\Model\UserInfo::class;
+
+}

+ 1 - 0
app/Module/User/Repository/readme.md

@@ -0,0 +1 @@
+# 仓库

+ 29 - 0
app/Module/User/SecurityPassword.php

@@ -0,0 +1,29 @@
+<?php
+
+namespace App\Module\User;
+
+
+use App\Module\User\Enums\SecertPasswordStatus;
+use App\Module\User\Model\UserSecretPassword;
+use Carbon\Carbon;
+
+class SecurityPassword
+{
+
+
+    static public function resetSPassword($user_id, $auth_password)
+    {
+
+        $model = UserSecretPassword::query()->where('user_id', $user_id)->first();
+        if(!$model){
+            $model = new UserSecretPassword();
+            $model->user_id = $user_id;
+        }
+        $model->secret_password = password_hash($auth_password,PASSWORD_DEFAULT);
+        $model->status= SecertPasswordStatus::BIND;
+        $model->last_check_at =Carbon::now();
+        $model->save();
+        return true;
+    }
+
+}

+ 4 - 5
app/Module/User/Services/UserService.php

@@ -7,10 +7,9 @@ use App\Module\App\SessionApp;
 use App\Module\Ulogic\Model\UserBans;
 use App\Module\Ulogic\Model\UserWord;
 use App\Module\User\Model\User;
-use App\Module\User\Model\UserPassword;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
-use UCore\Exception\ValidateException;
+
 
 class UserService
 {
@@ -41,7 +40,7 @@ class UserService
     /**
      * @param $mobile
      * @return \App\Module\Ulogic\Unit\User|array|false
-     * @throws \UCore\Exception\LogicException
+     * @throws \\Exception\LogicException
      * 注册
      */
     public static function register($mobile)
@@ -86,7 +85,7 @@ class UserService
      * @param $password
      * @return \App\Module\Ulogic\Unit\User|array|false
      * @throws \FurqanSiddiqui\BIP39\Exception\Bip39MnemonicException
-     * @throws \UCore\Exception\LogicException
+     * @throws \\Exception\LogicException
      * 登录
      */
     public static function login($data)
@@ -147,7 +146,7 @@ class UserService
      *
      * @param $user_id
      * @return \App\Module\Ulogic\Unit\User|array
-     * @throws \UCore\Exception\LogicException
+     * @throws \\Exception\LogicException
      */
     public static function loginById($user_id)
     {

+ 234 - 0
app/Module/User/User.php

@@ -2,7 +2,241 @@
 
 namespace App\Module\User;
 
+use App\Module\User\Enums\Status2;
+use App\Module\User\Unit\UserPublic;
+use Dcore\Db\Arr;
+use Dcore\Exception\LogicException;
+use Illuminate\Support\Facades\Hash;
+use function Symfony\Component\Translation\t;
+
 class User
 {
 
+    /**
+     * 创建用户
+     *
+     * @param $username
+     * @param $password
+     * @param $mobile
+     * @param $role
+     * @return string|true
+     */
+    static public function create($username, $password)
+    {
+        $user           = new \App\Module\User\Model\User();
+        $user->username = $username;
+        $user->password = Hash::make($password);
+        $user->status2 = Status2::Normal;
+        $res = $user->save();
+
+        if(\App\Module\Sys\User::isSysUid($user->id)){
+            $user->delete();
+            throw new \LogicException("错误34");
+        }
+        if ($res === false) {
+            return 'create-error';
+        }
+        User::infoinfo($user->id,true);
+
+        return $user;
+    }
+
+
+    /**
+     * 使用手机号码注册
+     * @param $phone
+     * @param $password
+     * @return Model\User|string|true
+     * @throws LogicException
+     */
+    static public function createPhone($phone, $password)
+    {
+        $user = self::create($phone, $password);
+        if ($user === false) {
+            throw new LogicException("create error");
+        }
+        $b = Phone::bind($user->id, $phone);
+        if ($user === false) {
+            throw new LogicException("create bind error");
+        }
+
+        return $user;
+
+    }
+
+
+    /**
+     * 更改密码
+     *
+     * @param $id
+     * @param $password
+     * @return string|true
+     */
+    static public function resetPassword($id, $password)
+    {
+        $user = \App\Module\User\Model\User::query()->find($id);
+        if (!$user) {
+            return 'user-notfind';
+        }
+        $user->password = Hash::make($password);
+        $res            = $user->save();
+
+
+        if ($res === false) {
+            return 'update-error';
+        }
+
+        return true;
+    }
+
+    /**
+     * 列表
+     *
+     * @param $page
+     * @param $limit
+     * @param $where
+     * @return \Illuminate\Pagination\LengthAwarePaginator
+     */
+    static public function lisss($page, $limit, $where)
+    {
+        $q    = \App\Module\User\Model\User::query()->with([
+                                                               'fund', 'merchant', 'info'
+                                                           ]);
+        $wArr = new Arr($where, $q);
+        $wArr->queryNumber('user_id')
+            ->queryString('mobile');
+
+        return $q->paginate($limit, [
+            'user_id',
+            'nick_name'
+        ],                  '', $page);
+
+    }
+
+    /**
+     * @param $id
+     * @return Model\User|null
+     */
+    static public function info($id, $create = false)
+    {
+        $info = \App\Module\User\Logic\User::info($id, $create);
+
+        return $info;
+    }
+
+    /**
+     *
+     * @param $id
+     * @param $create
+     * @return Model\UserInfo|null
+     */
+    static public function infoinfo($id, $create = false)
+    {
+        $info = \App\Module\User\Logic\User::infoinfo($id, $create);
+
+        return $info;
+    }
+
+
+    /**
+     * 获取用户公共信息
+     *
+     * @param $ids
+     * @return array
+     */
+    static public function pinfos($ids = [])
+    {
+
+        if(empty($ids)){
+            return [];
+        }
+        $ids2 = [];
+        foreach ($ids as $id) {
+            if(empty($id)){
+                continue;
+            }
+            if(\App\Module\Sys\User::isSysUid($id)){
+                continue;
+            }
+            $ids2[$id] = $id;
+        }
+        $res = self::pinfoCaches($ids2);
+        if ($ids2) {
+            /**
+             * @var \App\Module\User\Model\UserInfo[] $users
+             */
+            $users = \App\Module\User\Model\UserInfo::query()->whereIn('user_id', $ids2)->with([
+                                                                                                   'merchant'
+                                                                                               ])->get();
+
+            foreach ($users as $user) {
+                $userp            = new UserPublic();
+                $userp->avatar    = $user->avatar;
+                $userp->user_id   = $user->user_id;
+                $userp->nick_name = $user->nickname;
+                $userp->status    = $user->status->value();
+
+                $res[$userp->user_id] = $userp;
+                \Illuminate\Support\Facades\Cache::put(self::publicInfoKey($user->user_id), $userp);
+                unset($ids2[$userp->user_id]);
+            }
+        }
+
+
+        if (count($ids2)) {
+            foreach ($ids2 as $id) {
+                $userp                = new UserPublic();
+                $userp->avatar        = '';
+                $userp->user_id       = $id;
+                $userp->nick_name     = '已注销';
+                $res[$userp->user_id] = $userp;
+                \Illuminate\Support\Facades\Cache::put(self::publicInfoKey($userp->user_id), $userp);
+                unset($ids2[$userp->user_id]);
+            }
+        }
+
+        return $res;
+    }
+
+    /**
+     *
+     * @param $ids
+     * @return void
+     */
+    static public function pinfoCaches(&$ids)
+    {
+        $res = [];
+
+        return $res;
+        foreach ($ids as $id) {
+            $c = \Illuminate\Support\Facades\Cache::get(self::publicInfoKey($id));
+            if ($c) {
+                $res[$id] = $c;
+                unset($ids[$id]);
+            }
+        }
+
+        return $res;
+
+    }
+
+
+    /**
+     * 用户公共数据缓存key
+     *
+     * @param $uid
+     * @return string
+     */
+    static public function publicInfoKey($uid)
+    {
+        return 'lan_userpublic_' . $uid;
+    }
+
+
+    static public function getPhone()
+    {
+
+    }
+
 }
+

Неке датотеке нису приказане због велике количине промена