[天神模式]删除符合条件的商户绑定的表计关系

This commit is contained in:
2023-07-28 17:29:41 +08:00
parent 18d48c7fea
commit 1dd5f1049d
2 changed files with 50 additions and 6 deletions

View File

@@ -104,3 +104,27 @@ func (gm _GMService) DeleteReports(pid string, reports []string) error {
tx.Commit(ctx)
return nil
}
func (gm _GMService) DeleteTenementMeterRelations(pId string, tId []string, mId []string) error {
gm.l.Info("删除商户表记关系", zap.String("tenement", pId))
ctx, cancel := global.TimeoutContext(10)
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, tId, 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))
tx.Rollback(ctx)
return err
}
return nil
}