enhance(report):批量导入预置的维护费功能,会提前删除之前导入的内容。

This commit is contained in:
徐涛
2022-08-21 21:31:10 +08:00
parent ea929fd106
commit f7c639cba0
2 changed files with 11 additions and 3 deletions

View File

@@ -220,13 +220,21 @@ func (_ReportService) CreateTemporaryWillDilutedMaintenanceFee(fee model.WillDil
return err
}
func (_ReportService) BatchSaveMaintenanceFee(fees []model.WillDilutedFee) error {
func (_ReportService) BatchSaveMaintenanceFee(reportId string, fees []model.WillDilutedFee) error {
tx := global.DBConn.NewSession()
if err := tx.Begin(); err != nil {
return err
}
defer tx.Close()
_, err := tx.Insert(fees)
// 首先删除所有预定义的部分条件是指定报表IDSourceID不为空。
cond := builder.Eq{"report_id": reportId}.And(builder.NotNull{"source_id"})
_, err := tx.Table(new(model.WillDilutedFee)).Where(cond).Delete()
if err != nil {
tx.Rollback()
return err
}
// 然后插入新的记录
_, err = tx.Insert(fees)
if err != nil {
return err
}