fix(order): multiply draft weight by product count#403
Open
Ibochkarev wants to merge 3 commits into
Open
Conversation
OrderDraftManager::recalculate summed unit weight only, so draft msOrder.weight disagreed with cart status and undercharged weight-based delivery. Aggregate via OrderService with weight × count.
Wire draft, finalize, manager recalculate, and OrdersController through OrderService::aggregateProductsTotals so weight×count lives in one place. Also round totals to 6 decimals like the former manager helper.
Member
Author
Thermo-nuclear follow-upСделано:
Не трогал: |
Draft recalculate persists via msOnBefore/SaveOrder on save — do not invent unregistered recalculate events. Invoke the already-registered msOnBeforeGetOrderCost / msOnGetOrderCost from OrderCostCalculator::getTotalCost.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
OrderDraftManager::recalculateсуммировал unit weight без× count, поэтомуmsOrder.weightрасходился сcart.status.total_weightи занижал доставку по весу.Исправление и сопутствующее:
OrderService::aggregateProductsTotals()считаетweight × count(и linecostбез повторного умножения), draft recalculate пишет эти totals в заказ.OrderFinalizeService,ManagerOrderCostRecalculator::calculateProductTotals,OrdersController::recalculateOrderTotals; totals округляются до 6 знаков.msOnBeforeSaveOrder/msOnSaveOrderприsave(). Зарегистрированные, но мёртвыеmsOnBeforeGetOrderCost/msOnGetOrderCostподключены вOrderCostCalculator::getTotalCost(путь чтения стоимости, как в MS2).Тип изменений
Связанные Issues
Closes #375
Как это было протестировано?
Gate E (exit codes):
php -lOrderDraftManager / OrderService / OrderFinalizeService / ManagerOrderCostRecalculator / OrdersController / OrderCostCalculator / OrderDraftWeightTest → 0php core/components/minishop3/tests/OrderDraftWeightTest.php→ 0 (OK)× count→ fail (expected 3.0, actual 1.0); с фиксом → 0Конфигурация тестирования:
fix/issue-375-draft-weight-countСкриншоты (если применимо)
Чеклист
Дополнительные заметки
msOnBeforeSaveOrder/msOnSaveOrder. Корректировка отображаемой стоимости:msOnBeforeGetOrderCost/msOnGetOrderCost(теперь реально вызываются изgetTotalCost).OrderService::updateProducts(тамprice × count, неcost) и cart status (другой слой данных).