forked from free-lancers/electricity_bill_calc_service
[天神模式]删除符合条件表计完成
This commit is contained in:
@@ -149,7 +149,7 @@ func (gm _GMService) DeleteEnterprises(uid string) error {
|
||||
for _, pid := range parks {
|
||||
err = repository.GMRepository.DeleteInvoices(ctx, tx, pid)
|
||||
err = repository.GMRepository.DeleteMeterBinding(ctx, tx, pid, []string{})
|
||||
err = repository.GMRepository.DeleteMeterPookings(ctx, tx, pid)
|
||||
err = repository.GMRepository.DeleteMeterPoolings(ctx, tx, pid)
|
||||
err = repository.GMRepository.DeleteTenements(ctx, tx, pid)
|
||||
err = repository.GMRepository.DeleteMeters(ctx, tx, pid)
|
||||
err = repository.GMRepository.DeleteReports(ctx, tx, pid)
|
||||
@@ -189,6 +189,39 @@ func (gm _GMService) DeleteMeterPooling(pId string, mId []string) error {
|
||||
tx.Rollback(ctx)
|
||||
return err
|
||||
}
|
||||
err = tx.Commit(ctx)
|
||||
if err != nil {
|
||||
gm.l.Error("未能成功提交数据库事务。", zap.Error(err))
|
||||
tx.Rollback(ctx)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gm _GMService) DeleteMeters(pId string, mId []string) error {
|
||||
ctx, cancel := global.TimeoutContext()
|
||||
defer cancel()
|
||||
tx, err := global.DB.Begin(ctx)
|
||||
if err != nil {
|
||||
gm.l.Error("开启数据库事务失败。", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
if err := repository.GMRepository.DeleteMeterBinding(ctx, tx, pId, []string{}, mId); err != nil {
|
||||
gm.l.Error("删除指定园区中的表计和商户的绑定关系", zap.Error(err))
|
||||
tx.Rollback(ctx)
|
||||
return err
|
||||
}
|
||||
if err := repository.GMRepository.DeleteMeterPoolings(ctx, tx, pId, mId); err != nil {
|
||||
gm.l.Error("无法删除指定表记公摊关系。", zap.Error(err))
|
||||
tx.Rollback(ctx)
|
||||
return err
|
||||
}
|
||||
if err := repository.GMRepository.DeleteMeters(ctx, tx, pId, mId); err != nil {
|
||||
gm.l.Error("删除指定园区中符合条件的表计。", zap.Error(err))
|
||||
tx.Rollback(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
err = tx.Commit(ctx)
|
||||
if err != nil {
|
||||
gm.l.Error("未能成功提交数据库事务。", zap.Error(err))
|
||||
|
Reference in New Issue
Block a user