def 事务(self): try: TeMaList = models.Order.objects.filter(game_uuid="macau_02", issue=self.issue) # 这里大概7000多条数据 int_special_code = int(self.seven) # 核对 with transaction.atomic(): # 启动事务 # 创建保存点 save_id = transaction.savepoint() # 执行核对与存入数据库 for order_obj in TeMaList: if int(order_obj.user_code) == int_special_code: order_res = 1 else: order_res = 0 recode_history_order(order_obj,order_res) # 存入数据库: # 提交从保存点到当前状态的所有数据库事务操作 transaction.savepoint_commit(save_id) except Exception as e: # 回滚到保存点 transaction.savepoint_rollback(save_id) logging_main.check_error.error("特碼" + traceback.format_exc())