feat: 新增交易服务和AI记账服务,实现交易的创建、验证及账户余额更新逻辑。
This commit is contained in:
@@ -462,8 +462,9 @@ func (s *LLMService) ParseIntent(ctx context.Context, text string, history []Cha
|
||||
1. 金额:提取数字,如"6元"=6,"十五"=15
|
||||
2. 分类:根据内容推断,如"奶茶/咖啡/吃饭"=餐饮,"打车/地铁"=交通,"买衣服"=购物
|
||||
3. 类型:默认expense(支出),除非明确说"收入/工资/奖金/红包"
|
||||
4. 日期:默认使用今天的日期(%s),除非用户明确指定其他日期
|
||||
5. 备注:提取关键描述
|
||||
4. 金额:提取明确的数字。如果用户未提及具体金额(如只说"想吃炸鸡"),amount字段必须返回 0
|
||||
5. 日期:默认使用今天的日期(%s),除非用户明确指定其他日期
|
||||
6. 备注:提取关键描述
|
||||
|
||||
直接返回JSON,不要解释:
|
||||
{"amount":数字,"category":"分类","type":"expense或income","note":"备注","date":"YYYY-MM-DD","message":"简短确认"}
|
||||
@@ -1257,7 +1258,7 @@ func (s *AIBookkeepingService) getDefaultCategory(userID uint, txType string) (*
|
||||
// getMissingFields returns list of missing required fields
|
||||
func (s *AIBookkeepingService) getMissingFields(params *AITransactionParams) []string {
|
||||
var missing []string
|
||||
if params.Amount == nil {
|
||||
if params.Amount == nil || *params.Amount <= 0 {
|
||||
missing = append(missing, "amount")
|
||||
}
|
||||
if params.CategoryID == nil && params.Category == "" {
|
||||
|
||||
Reference in New Issue
Block a user