diff --git a/src/dto/order/createOrderDto.ts b/src/dto/order/createOrderDto.ts index 0566c76..8e00725 100644 --- a/src/dto/order/createOrderDto.ts +++ b/src/dto/order/createOrderDto.ts @@ -77,6 +77,7 @@ export class CreateOrderDto { this._items = Object.values(groupBy(items, 'productId')).map((group) => ({ productId: group[0].productId, amount: sumBy(group, 'amount'), + plan: group[0].plan, })); this.paymentMethod = paymentMethod; this.paymentStatus = PaymentStatus.pending; diff --git a/src/service/orderService.ts b/src/service/orderService.ts index 99875da..ffc71f0 100644 --- a/src/service/orderService.ts +++ b/src/service/orderService.ts @@ -336,8 +336,12 @@ export class OrderService { const subTotal = sumBy( products, ({ price, amount, plan }) => - price * amount * (plan ? plan.headCount * plan.discount : 1), + Math.round( + price * amount * (plan ? plan.headCount * plan.discount : 1) * 100, + ) / 100, ); + logger.info('totalPrice = ' + totalPrice); + logger.info('subTotal = ' + subTotal); return totalPrice === subTotal; };