Since upgrading from Nop 4.2 to 4.5, many orders partially paid with points were not having their points reduced at all. See example below
https://imgur.com/IRfVirq
Upon looking into it deeper, we noticed that every instance where points were redeemed and then rewarded within the same second - this bug was occurring.
To fix this, we changed some code within GetRewardPointsQueryAsync()
From:
if (!showNotActivated) query = query.Where(historyEntry => historyEntry.CreatedOnUtc < DateTime.UtcNow);
To:
if (!showNotActivated) query = query.Where(historyEntry => historyEntry.CreatedOnUtc <= DateTime.UtcNow);
It seems like before the upgrade to 4.5, our system was never fast enough to created these two records in the same second. After the upgrade, the historyEntry.CreatedOnUtc < wasn't picking up the previous entry since CreatedOnUtc was == to the previous record. Also, not certain if it was something we did or something related to the upgrade, but it seems that milliseconds are now truncated off CreatedOnUtc, which also contributes to the problem.
We were having several orders come through each day without points being deducted, and since we made this code change (two days ago), we haven't had a single problem.
> 1. nopCommerce version
4.5
> 2. Expected behavior
When partially paying with reward points, your points should be deducted to zero, then set to however many points you earned from the remainder of the transaction.
> 3. Actual behavior
When partially paying with reward points, the user gets to keep those points and is additionally rewarded however many they earned from the remainder of the transaction.
> 4. Steps to reproduce the problem
Partially pay for an order with reward points. Make sure that you'll still earn some points from the remainder of the transaction. If the system is fast enough to deduct + reward points within the same second, the bug will occur.
> 5. Any private modifications you made to your nopCommerce
Yes, but nothing related to the checkout/reward system that would effect this.
Also, while I'm here, I'd like to report one other problem (not exactly a bug) we've experienced since upgrading to 4.5..... we run a high volume download-only site and our site was being slowed to a halt 15+ times every day. We came to find out that in 4.5, user downloads were causing our CPU usage to blast up to 100%, making our site un-usable. We ended up implementing downloads from azure blob storage instead of directly from the database, and that fixed the problem. Strangely, we didn't have an issue with 4.2. Maybe streaming downloads directly from the database is handled differently in .NET 6? Not sure. Also note that our file sizes range between 1MB or about 15MB maximum