def buy_a_for_value(product_listA, give_product, bean):
    """

    :param product_listA: 所有买A赠A的商品列表
    :param bean 活动
    :return: [商品循环值,赠品循环值 ,最大赠数]

    """
    sum_pro = 0
    give_pro_sum = 0
    cursor_max_times = 0
    for_pro = 0
    for_give_pro = 0
    give_pro_number = 0
    value_num = 0
    if bean.value_num == 0:
        value_num = 1
    if bean.max_times == 0:
        bean.max_times = 1
    value_num = bean.value_num
    for product in product_listA:
        sum_pro += product.notOccupiedThree()
    while True:
        if cursor_max_times == bean.max_times:
            return for_pro, for_give_pro, give_pro_number
        if not sum_pro - value_num >= 0:
            return for_pro, for_give_pro, give_pro_number
        sum_pro -= value_num
        for_pro += value_num
        if not sum_pro - bean.give_value >= 0:
            for_give_pro += sum_pro
            give_pro_number += bean.give_value
            return for_pro, for_give_pro, give_pro_number
        sum_pro -= bean.give_value
        for_give_pro += bean.give_value
        give_pro_number += bean.give_value
        cursor_max_times += 1
