feat:参照研听的基础工程
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
import '../../../common/domain/metal_type.dart';
|
||||
|
||||
enum AssetCategory {
|
||||
bar('金条'),
|
||||
necklace('项链'),
|
||||
ring('戒指'),
|
||||
bracelet('手镯'),
|
||||
bean('金豆'),
|
||||
earring('耳环'),
|
||||
silverware('银饰'),
|
||||
platinumPiece('铂金件');
|
||||
|
||||
const AssetCategory(this.label);
|
||||
|
||||
final String label;
|
||||
}
|
||||
|
||||
enum HoldingStatus { active, sold, gifted }
|
||||
|
||||
class GoldAssetHolding {
|
||||
const GoldAssetHolding({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.metal,
|
||||
required this.category,
|
||||
required this.purity,
|
||||
required this.purityLabel,
|
||||
required this.weightGram,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.costAmount,
|
||||
this.purchaseDate,
|
||||
this.channel,
|
||||
this.note,
|
||||
this.status = HoldingStatus.active,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String name;
|
||||
final MetalType metal;
|
||||
final AssetCategory category;
|
||||
final double purity;
|
||||
final String purityLabel;
|
||||
final double weightGram;
|
||||
final double? costAmount;
|
||||
final DateTime? purchaseDate;
|
||||
final String? channel;
|
||||
final String? note;
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final HoldingStatus status;
|
||||
|
||||
double materialValue(double spotPrice) => weightGram * purity * spotPrice;
|
||||
}
|
||||
|
||||
class HoldingValuation {
|
||||
const HoldingValuation({
|
||||
required this.holding,
|
||||
required this.materialValue,
|
||||
required this.todayChange,
|
||||
});
|
||||
|
||||
final GoldAssetHolding holding;
|
||||
final double materialValue;
|
||||
final double todayChange;
|
||||
}
|
||||
|
||||
class MetalBreakdown {
|
||||
const MetalBreakdown({
|
||||
required this.metal,
|
||||
required this.value,
|
||||
required this.weightGram,
|
||||
required this.count,
|
||||
});
|
||||
|
||||
final MetalType metal;
|
||||
final double value;
|
||||
final double weightGram;
|
||||
final int count;
|
||||
}
|
||||
|
||||
class PortfolioSummary {
|
||||
const PortfolioSummary({
|
||||
required this.totalValue,
|
||||
required this.todayChangeAmount,
|
||||
required this.todayChangePercent,
|
||||
required this.totalCost,
|
||||
required this.totalWeightGram,
|
||||
required this.recycleReferenceValue,
|
||||
required this.breakdowns,
|
||||
required this.holdings,
|
||||
});
|
||||
|
||||
final double totalValue;
|
||||
final double todayChangeAmount;
|
||||
final double todayChangePercent;
|
||||
final double totalCost;
|
||||
final double totalWeightGram;
|
||||
final double recycleReferenceValue;
|
||||
final List<MetalBreakdown> breakdowns;
|
||||
final List<HoldingValuation> holdings;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import '../../../common/domain/metal_type.dart';
|
||||
import 'asset_models.dart';
|
||||
|
||||
final mockAssetRepositoryProvider = Provider<MockAssetRepository>(
|
||||
(ref) => MockAssetRepository(),
|
||||
);
|
||||
|
||||
class MockAssetRepository {
|
||||
List<GoldAssetHolding> loadHoldings() {
|
||||
final now = DateTime(2026, 6, 18, 16, 11);
|
||||
return [
|
||||
GoldAssetHolding(
|
||||
id: 'holding_gold_bar_001',
|
||||
name: '投资金条',
|
||||
metal: MetalType.gold,
|
||||
category: AssetCategory.bar,
|
||||
purity: 0.9999,
|
||||
purityLabel: '足金9999',
|
||||
weightGram: 50,
|
||||
costAmount: 43200,
|
||||
purchaseDate: DateTime(2025, 10, 12),
|
||||
channel: '银行',
|
||||
createdAt: now.subtract(const Duration(days: 249)),
|
||||
updatedAt: now,
|
||||
),
|
||||
GoldAssetHolding(
|
||||
id: 'holding_gold_ring_001',
|
||||
name: '素圈戒指',
|
||||
metal: MetalType.gold,
|
||||
category: AssetCategory.ring,
|
||||
purity: 0.999,
|
||||
purityLabel: '足金999',
|
||||
weightGram: 8.6,
|
||||
costAmount: 7820,
|
||||
purchaseDate: DateTime(2024, 12, 4),
|
||||
channel: '金店',
|
||||
createdAt: now.subtract(const Duration(days: 196)),
|
||||
updatedAt: now,
|
||||
),
|
||||
GoldAssetHolding(
|
||||
id: 'holding_platinum_001',
|
||||
name: 'PT950 项链',
|
||||
metal: MetalType.platinum,
|
||||
category: AssetCategory.platinumPiece,
|
||||
purity: 0.95,
|
||||
purityLabel: 'PT950',
|
||||
weightGram: 12.3,
|
||||
costAmount: 5200,
|
||||
purchaseDate: DateTime(2023, 8, 21),
|
||||
channel: '金店',
|
||||
createdAt: now.subtract(const Duration(days: 667)),
|
||||
updatedAt: now,
|
||||
),
|
||||
GoldAssetHolding(
|
||||
id: 'holding_silver_001',
|
||||
name: '银手镯',
|
||||
metal: MetalType.silver,
|
||||
category: AssetCategory.bracelet,
|
||||
purity: 0.999,
|
||||
purityLabel: '999银',
|
||||
weightGram: 31.8,
|
||||
costAmount: 980,
|
||||
purchaseDate: DateTime(2024, 4, 7),
|
||||
channel: '金店',
|
||||
note: '材料价值偏低',
|
||||
createdAt: now.subtract(const Duration(days: 802)),
|
||||
updatedAt: now,
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user