Files
billai/server/model/bill.go
cheliangzhao eb76c3a8dc fix: 修复微信账单金额解析问题(半角¥符号支持)
- 修复 parse_amount 函数同时支持全角¥和半角¥
- 新增 MonthRangePicker 日期选择组件
- 新增 /api/monthly-stats 接口获取月度统计
- 分析页面月度趋势使用全量数据
- 新增健康检查路由
2026-01-10 19:21:24 +08:00

48 lines
3.1 KiB
Go

package model
import (
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// RawBill 原始账单记录(存储上传的原始数据)
type RawBill struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
BillType string `bson:"bill_type" json:"bill_type"` // 账单类型: alipay/wechat
SourceFile string `bson:"source_file" json:"source_file"` // 来源文件名
UploadBatch string `bson:"upload_batch" json:"upload_batch"` // 上传批次(时间戳)
RowIndex int `bson:"row_index" json:"row_index"` // 原始行号
RawData map[string]interface{} `bson:"raw_data" json:"raw_data"` // 原始字段数据
CreatedAt time.Time `bson:"created_at" json:"created_at"` // 创建时间
}
// CleanedBill 清洗后账单记录(标准化后的数据)
type CleanedBill struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
BillType string `bson:"bill_type" json:"bill_type"` // 账单类型: alipay/wechat
TransactionID string `bson:"transaction_id" json:"transaction_id"` // 交易订单号(用于去重)
MerchantOrderNo string `bson:"merchant_order_no" json:"merchant_order_no"` // 商家订单号(用于去重)
Time time.Time `bson:"time" json:"time"` // 交易时间
Category string `bson:"category" json:"category"` // 交易分类
Merchant string `bson:"merchant" json:"merchant"` // 交易对方
Description string `bson:"description" json:"description"` // 商品说明
IncomeExpense string `bson:"income_expense" json:"income_expense"` // 收/支
Amount float64 `bson:"amount" json:"amount"` // 金额
PayMethod string `bson:"pay_method" json:"pay_method"` // 支付方式
Status string `bson:"status" json:"status"` // 交易状态
Remark string `bson:"remark" json:"remark"` // 备注
ReviewLevel string `bson:"review_level" json:"review_level"` // 复核等级: HIGH/LOW/空
CreatedAt time.Time `bson:"created_at" json:"created_at"` // 创建时间
UpdatedAt time.Time `bson:"updated_at" json:"updated_at"` // 更新时间
SourceFile string `bson:"source_file" json:"source_file"` // 来源文件名
UploadBatch string `bson:"upload_batch" json:"upload_batch"` // 上传批次(时间戳)
}
// MonthlyStat 月度统计数据
type MonthlyStat struct {
Month string `bson:"month" json:"month"` // 月份 YYYY-MM
Expense float64 `bson:"expense" json:"expense"` // 月支出总额
Income float64 `bson:"income" json:"income"` // 月收入总额
}