From 397ff71e0ceb5a9c1cd096030906f93a9b387570 Mon Sep 17 00:00:00 2001 From: Derran Date: Tue, 6 Aug 2024 10:27:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=82=AC=E8=B5=8F=E6=8B=9B=E4=BA=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...MarriageBountyOrderApplicationService.java | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/marriagebounty/MarriageBountyOrderApplicationService.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/marriagebounty/MarriageBountyOrderApplicationService.java index 2c9020e..776c65b 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/marriagebounty/MarriageBountyOrderApplicationService.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/application/service/marriagebounty/MarriageBountyOrderApplicationService.java @@ -65,33 +65,8 @@ public class MarriageBountyOrderApplicationService extends BaseApplicationServic Order order = orderRepository.load(orderId); MarriageBountyOrder marriageBountyOrder; marriageBountyOrder = marriageBountyOrderQueryService.queryBy(order.getUserId(), order.getMiId(), - MarriageBountyOrderStatusEnum.INIT, MarriageBountyOrderPaymentStatusEnum.INIT); + MarriageBountyOrderStatusEnum.MATCHMAKING, MarriageBountyOrderPaymentStatusEnum.PAID); if (Objects.nonNull(marriageBountyOrder)) { - //订单关系 - MarriageBountyOrderRel orderRel = MarriageBountyOrderRel.build(orderId, order.getSettlementAmount()); - marriageBountyOrder.setOrderRelList(Collections.singletonList(orderRel)); - //悬赏招亲订单奖励 - List orderRewardList = new ArrayList<>(); - //悬赏招亲订单产品记录 - MarriageBountyOrderProductRecord productRecord = new MarriageBountyOrderProductRecord(); - order.getOrderItemList().forEach(orderItem -> { - ProductSpec productSpec = productSpecDao.selectById(orderItem.getProductSpecId()); - productRecord.getProductSpecRecordList().add(MarriageBountyOrderProductSpecRecord.build( - orderItem.getSubCategory(), productSpec.getUnitOriginalPrice(), productSpec.getUnitOriginalPrice())); - if (ProductSubCategoryEnum.MARRIAGE_BOUNTY_MEETING_FEE.equals(orderItem.getSubCategory())) { - orderRewardList.addAll(MarriageBountyOrderReward.build(ProductSubCategoryEnum.MARRIAGE_BOUNTY_MEETING_FEE, orderItem.getUnitSettlementPrice(), orderItem.getQuantity())); - } else if (ProductSubCategoryEnum.MARRIAGE_BOUNTY_RESULT_GIFT.equals(orderItem.getSubCategory())) { - orderRewardList.addAll(MarriageBountyOrderReward.build(ProductSubCategoryEnum.MARRIAGE_BOUNTY_RESULT_GIFT, orderItem.getUnitSettlementPrice(), orderItem.getQuantity())); - } - }); - marriageBountyOrder.setOrderRewardList(orderRewardList); - marriageBountyOrder.setInsertOrderRewardList(orderRewardList); - marriageBountyOrder.calculateRewardAmount(); - productRecord.setRewardAmount(marriageBountyOrder.getRewardAmount()); - marriageBountyOrder.setProductRecordList(Collections.singletonList(productRecord)); - BaseDomainEvent event = marriageBountyOrderAggregate.create(marriageBountyOrder); - this.sendEvent(event); - } else { marriageBountyOrder = marriageBountyOrderQueryService.queryBy(order.getUserId(), order.getMiId(), MarriageBountyOrderStatusEnum.MATCHMAKING, MarriageBountyOrderPaymentStatusEnum.PAID); if (Objects.nonNull(marriageBountyOrder)) { @@ -122,6 +97,35 @@ public class MarriageBountyOrderApplicationService extends BaseApplicationServic marriageBountyOrder.setProductRecordList(Collections.singletonList(productRecord)); marriageBountyOrderAggregate.update(marriageBountyOrder); } + } else { + marriageBountyOrder = marriageBountyOrderQueryService.queryBy(order.getUserId(), order.getMiId(), + MarriageBountyOrderStatusEnum.INIT, MarriageBountyOrderPaymentStatusEnum.INIT); + if (Objects.nonNull(marriageBountyOrder)) { + //订单关系 + MarriageBountyOrderRel orderRel = MarriageBountyOrderRel.build(orderId, order.getSettlementAmount()); + marriageBountyOrder.setOrderRelList(Collections.singletonList(orderRel)); + //悬赏招亲订单奖励 + List orderRewardList = new ArrayList<>(); + //悬赏招亲订单产品记录 + MarriageBountyOrderProductRecord productRecord = new MarriageBountyOrderProductRecord(); + order.getOrderItemList().forEach(orderItem -> { + ProductSpec productSpec = productSpecDao.selectById(orderItem.getProductSpecId()); + productRecord.getProductSpecRecordList().add(MarriageBountyOrderProductSpecRecord.build( + orderItem.getSubCategory(), productSpec.getUnitOriginalPrice(), productSpec.getUnitOriginalPrice())); + if (ProductSubCategoryEnum.MARRIAGE_BOUNTY_MEETING_FEE.equals(orderItem.getSubCategory())) { + orderRewardList.addAll(MarriageBountyOrderReward.build(ProductSubCategoryEnum.MARRIAGE_BOUNTY_MEETING_FEE, orderItem.getUnitSettlementPrice(), orderItem.getQuantity())); + } else if (ProductSubCategoryEnum.MARRIAGE_BOUNTY_RESULT_GIFT.equals(orderItem.getSubCategory())) { + orderRewardList.addAll(MarriageBountyOrderReward.build(ProductSubCategoryEnum.MARRIAGE_BOUNTY_RESULT_GIFT, orderItem.getUnitSettlementPrice(), orderItem.getQuantity())); + } + }); + marriageBountyOrder.setOrderRewardList(orderRewardList); + marriageBountyOrder.setInsertOrderRewardList(orderRewardList); + marriageBountyOrder.calculateRewardAmount(); + productRecord.setRewardAmount(marriageBountyOrder.getRewardAmount()); + marriageBountyOrder.setProductRecordList(Collections.singletonList(productRecord)); + BaseDomainEvent event = marriageBountyOrderAggregate.create(marriageBountyOrder); + this.sendEvent(event); + } } }