* @return the {@link OfferAudit}s that were persisted
*/
protected List<OfferAudit> saveOfferIds(Set<Offer> offers, Map<Offer, OfferCode> offerToCodeMapping, Order order) {
List<OfferAudit> audits = new ArrayList<OfferAudit>(offers.size());
for (Offer offer : offers) {
OfferAudit audit = offerAuditService.create();
audit.setCustomerId(order.getCustomer().getId());
audit.setOfferId(offer.getId());
audit.setOrderId(order.getId());
//add the code that was used to obtain the offer to the audit context
OfferCode codeUsedToRetrieveOffer = offerToCodeMapping.get(offer);
if (codeUsedToRetrieveOffer != null) {
audit.setOfferCodeId(codeUsedToRetrieveOffer.getId());
}
audit.setRedeemedDate(SystemTime.asDate());
audit = offerAuditService.save(audit);
audits.add(audit);
}
return audits;