I recommend checking out Bulk Discount Code Generator by Seguno for this functionality. With this app, you can generate sets of unique discount codes with your own set of conditional rules. You can have the discount codes automatically generate themselves or you can create them manually.
Let me know if this helps! If there is anything else I can help you with, please let me know.