任务时间: 2025年06月13日 13:58:53 CST
任务内容: 为Mex模块增加多币种适配功能,默认使用钻石币种
Mex模块原本只支持单一币种(金币),需要扩展为支持多币种交易,特别是默认使用钻石币种进行交易。
currency_type 字段,默认值为2(钻石)currency_type 字段,默认值为2(钻石)-- 1. 为订单表添加币种字段
ALTER TABLE `kku_mex_orders`
ADD COLUMN `currency_type` int NOT NULL DEFAULT 2 COMMENT '币种类型,关联FUND_CURRENCY_TYPE枚举,默认2为钻石' AFTER `item_id`,
ADD INDEX `idx_currency_type` (`currency_type`) USING BTREE COMMENT '币种类型索引';
-- 2. 为成交记录表添加币种字段
ALTER TABLE `kku_mex_transactions`
ADD COLUMN `currency_type` int NOT NULL DEFAULT 2 COMMENT '币种类型,关联FUND_CURRENCY_TYPE枚举,默认2为钻石' AFTER `item_id`,
ADD INDEX `idx_currency_type` (`currency_type`) USING BTREE COMMENT '币种类型索引';
// 新增的主要方法
- getDefaultCurrency(): 获取默认币种(钻石)
- getDefaultMapping(): 获取默认币种的账户映射
- getAvailableAccountType(): 获取指定币种的可用账户类型
- getFrozenAccountType(): 获取指定币种的冻结账户类型
- isCurrencySupported(): 检查币种是否支持
- getSupportedCurrencies(): 获取所有支持的币种列表
currency_type 字段到 $fillable 数组FUND_CURRENCY_TYPE 类型转换currency_type 字段到 $fillable 数组FUND_CURRENCY_TYPE 类型转换processSellOrder() 方法增加币种参数支持processBuyOrder() 方法增加币种参数支持getWarehouseFundBalance() 方法支持币种参数getRegulationFundBalance() 方法支持币种参数createTransaction() 方法支持币种字段getPrecision() 方法获取精度bcpow('10', $precision) 动态计算转换倍数app/Module/Mex/Logic/FundLogic.php:完善多币种映射app/Module/Mex/Logic/MexAccountLogic.php:支持币种参数app/Module/Mex/Logic/MexTransactionLogic.php:支持币种字段app/Module/Mex/Logic/MexOrderLogic.php:支持币种参数传递app/Module/Mex/Logic/MexMatchLogic.php:支持动态币种和精度处理app/Module/Mex/Services/MexOrderService.php:支持币种参数app/Module/Mex/Models/MexOrder.php:添加币种字段app/Module/Mex/Models/MexTransaction.php:添加币种字段app/Module/Mex/Databases/GenerateSql/mex_orders.sql:更新表结构app/Module/Mex/Databases/GenerateSql/mex_transactions.sql:更新表结构app/Module/Mex/Databases/Migrations/add_currency_fields.sql:迁移脚本app/Module/Mex/Tests/MultiCurrencyTest.php:多币种功能测试类app/Module/Mex/Commands/TestMultiCurrencyCommand.php:测试命令app/Module/Mex/Providers/MexServiceProvider.php:注册测试命令AiWork/记忆习惯.md:更新模块设计记录currency_type 字段php artisan mex:test-multi-currency
本次任务成功为Mex模块增加了完整的多币种适配功能,主要特点:
该功能为Mex模块的多币种交易奠定了坚实基础,后续可以根据业务需求进一步扩展和完善。通过测试验证,多币种适配功能已经完全可用。