Closed daiagou closed 1 year ago
In what scenario would this happen?
What's the expected behavior?
Sorry, I may not have explained it clearly. Let me add. The scenario is as follows: When a customer places an order, we want to determine whether the user's balance is sufficient to place the order. At this point, we saw a service ('popstore.CartServices.get#OrderInfoInternal') that calculated totalUnpaid, so we reused it. As a result, there was a problem online later. After investigation, it was found that the total Unpaid calculated by this service was not accurate. He only calculated the amount of the first orderPart and did not calculate the total amount of all orderParts in the entire order. Assuming there are one order, it has two orderParts, with a total amount of 0.1 and 100, and a user balance of 50, theoretically the customer should not be able to place an order. However, because the total Unpaid calculated by this service only includes orderPart 01, it is mistakenly assumed that the total amount is only 0.1. So the customer can place the order. This doesn't seem quite right.
This should be filed under the PopRestStore component where the service lives, it is outside the scope of moqui-framework.
In general it is better to use the services in mantle-usl. They are designed for more general use and have gone through far more testing and production use than the service in the PopRestStore which were written only for that application and it has seen less testing and production use.
The code is in: https://github.com/moqui/PopRestStore/blob/master/service/popstore/CartServices.xml
totalUnpaid = (orderPart.partTotal ?: 0.0) - (paymentsTotal ?: 0.0)
Write a dead orderPartList [0] here, so multiple orderparts will not be processed correctly.