|
@@ -123,16 +123,16 @@ func (s *StoreEntry) CalvingCreate(ctx context.Context, req *pasturePb.EventCalv
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- newCow := model.NewCalfCow(cow.Id, cow.LastBullNumber, newCalvingCalf)
|
|
|
- if err = tx.Create(newCow).Error; err != nil {
|
|
|
+ newCalfCow := model.NewCalfCow(cow.NeckRingNumber, cow.LastBullNumber, newCalvingCalf)
|
|
|
+ if err = tx.Create(newCalfCow).Error; err != nil {
|
|
|
return xerr.WithStack(err)
|
|
|
}
|
|
|
- if err = tx.Model(new(model.CalvingCalf)).Where("id = ?", newCalvingCalf.Id).Update("cow_id", newCow.Id).Error; err != nil {
|
|
|
+ if err = tx.Model(new(model.CalvingCalf)).Where("id = ?", newCalvingCalf.Id).Update("cow_id", newCalfCow.Id).Error; err != nil {
|
|
|
return xerr.WithStack(err)
|
|
|
}
|
|
|
|
|
|
// 犊牛日志
|
|
|
- cowLogs := s.SubmitEventLog(ctx, userModel.AppPasture.Id, newCow, pasturePb.EventType_Birth, pasturePb.ExposeEstrusType_Invalid, calf)
|
|
|
+ cowLogs := s.SubmitEventLog(ctx, userModel.AppPasture.Id, newCalfCow, pasturePb.EventType_Birth, pasturePb.ExposeEstrusType_Invalid, calf)
|
|
|
if err = tx.Table(cowLogs.TableName()).Create(cowLogs).Error; err != nil {
|
|
|
return xerr.WithStack(err)
|
|
|
}
|