-1

My question is: How I can limit an user to do an action a limited amount of times every week ?

My case is the following:

I have my products and I am offering an option for every user to ask for a refund if the product is not good. The problem is that many users abuse this action and is time consuming for me to check every product and every user that asks for a refund so I want to limit every user to be able to ask for a refund only 3 times a week but I don't know how.

I have a table named refunds_count that looks like this

ID || userid || product_id || date
----------------------------------
1  || 7      || 9          || 2016-03-9 12:33:22
2  || 7      || 10         || 2016-03-13 14:40:10
3  || 7      || 11         || 2016-03-13 16:42:15

So the user with ID 7 has already two refund requests this week and I don't know how to compare this data to see if the user has made 3 requests already this week

4

1 回答 1

0
SELECT userid
FROM refunds_count t
WHERE week(now()) = week(t.date)
GROUP BY userid
HAVING COUNT(*) >= 3

这将提供本周已进行 3 次退款的所有用户的列表。

您可以在退款系统中最后过滤这些用户,例如

WHERE userid NOT IN(...the query here...)
于 2016-03-13T13:58:20.110 回答