def METHOD_NAME(cls, values, op_type):
    """By django model field looking up syntax, loop values and check the
    condition if there is a multi-tables query.
    :param cls: table model class
    :type cls: subclass of django.db.models.Model
    :param values: fields in where condition.
    :type values: dict
    :param int op_type: the operation type.
    :return: QuerySet
    :rtype: django.db.models.query.QuerySet
    """
    flag = False
    for field in values.keys():
        if "__" in field:
            if _need_distinct_m2m_rows(cls, field.split("__")):
                flag = True
                break
    qs = cls.objects.filter(**values)
    if op_type == COUNT_DISTINCT:
        if flag:
            return qs.aggregate(Count("pk", distinct=True))["pk__count"]
        else:
            return qs.count()
    elif op_type == QUERY_DISTINCT:
        return qs.distinct() if flag else qs
    else:
        raise TypeError("Not implement op type %s" % op_type)