From 8b9126da4f6525d15965201459aede4396f1d2f7 Mon Sep 17 00:00:00 2001 From: Derran Date: Sun, 5 May 2024 17:12:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...riageBountyOrderUserCommandController.java | 2 +- .../request/RefundMarriageBountyOrderDto.java | 7 ++-- ...arriageBountyOrderUserQueryController.java | 11 ++++- ...ageBountyOrderPreRefundInfoQueryParam.java | 10 ++--- ...riageBountyOrderProductInfoQueryParam.java | 14 +++++++ ...erGetMarriageBountyOrderProductInfoVo.java | 32 ++++++++++++++ ...MarriageBountyOrderApplicationService.java | 4 +- .../MarriageBountyOrderQueryService.java | 5 ++- .../MarriageBountyOrderQueryServiceImpl.java | 42 ++++++++++++++++++- .../query/product/ProductQueryService.java | 2 + .../product/impl/ProductQueryServiceImpl.java | 1 - 11 files changed, 114 insertions(+), 16 deletions(-) create mode 100644 dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/request/UserGetMarriageBountyOrderProductInfoQueryParam.java create mode 100644 dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/response/UserGetMarriageBountyOrderProductInfoVo.java diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/marriagebounty/user/MarriageBountyOrderUserCommandController.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/marriagebounty/user/MarriageBountyOrderUserCommandController.java index ecc1053..d17dbf3 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/marriagebounty/user/MarriageBountyOrderUserCommandController.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/marriagebounty/user/MarriageBountyOrderUserCommandController.java @@ -21,7 +21,7 @@ public class MarriageBountyOrderUserCommandController { @PostMapping("/refund/marriage-bounty-order") public void refundMarriageBountyOrder(@RequestBody @Validated RefundMarriageBountyOrderDto dto, @RequestParam Long userId) { - marriageBountyOrderApplicationService.refund(userId, dto.getMiId()); + marriageBountyOrderApplicationService.refund(dto.getMarriageBountyOrderId()); } } diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/marriagebounty/user/request/RefundMarriageBountyOrderDto.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/marriagebounty/user/request/RefundMarriageBountyOrderDto.java index 7dda30b..e0c5a66 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/marriagebounty/user/request/RefundMarriageBountyOrderDto.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/command/marriagebounty/user/request/RefundMarriageBountyOrderDto.java @@ -7,7 +7,8 @@ import javax.validation.constraints.NotNull; @Data public class RefundMarriageBountyOrderDto { - @ApiModelProperty("征婚资料标识") - @NotNull(message = "征婚资料标识不能为空") - private Long miId; + + @ApiModelProperty("悬赏招亲唯一标识") + @NotNull(message = "悬赏招亲唯一标识不能为空") + private Long marriageBountyOrderId; } diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/MarriageBountyOrderUserQueryController.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/MarriageBountyOrderUserQueryController.java index d462216..3c6e662 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/MarriageBountyOrderUserQueryController.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/MarriageBountyOrderUserQueryController.java @@ -1,6 +1,8 @@ package com.qniao.dam.api.query.marriagebounty.user; +import com.qniao.dam.api.query.marriagebounty.user.request.UserGetMarriageBountyOrderProductInfoQueryParam; import com.qniao.dam.api.query.marriagebounty.user.request.UserGetMarriageBountyOrderPreRefundInfoQueryParam; +import com.qniao.dam.api.query.marriagebounty.user.response.UserGetMarriageBountyOrderProductInfoVo; import com.qniao.dam.api.query.marriagebounty.user.response.UserGetMarriageBountyOrderPreRefundInfoVo; import com.qniao.dam.query.marriagebounty.MarriageBountyOrderQueryService; import io.swagger.annotations.Api; @@ -18,11 +20,18 @@ public class MarriageBountyOrderUserQueryController { @Resource private MarriageBountyOrderQueryService marriageBountyOrderQueryService; + @GetMapping("get/marriage-bounty-order/product-info") + @ApiOperation("用户获取悬赏招亲订单信息") + public UserGetMarriageBountyOrderProductInfoVo getMarriageBountyOrderProductInfo(@Validated UserGetMarriageBountyOrderProductInfoQueryParam queryParam, + @RequestParam("userId") Long userId) { + return marriageBountyOrderQueryService.getMarriageBountyOrderProductInfo(queryParam.getMarriageBountyOrderId()); + } + @GetMapping("get/marriage-bounty-order/pre-refund-info") @ApiOperation("用户获取悬赏招亲订单预退款信息") public UserGetMarriageBountyOrderPreRefundInfoVo getMarriageBountyOrderPreRefundInfo(@Validated UserGetMarriageBountyOrderPreRefundInfoQueryParam queryParam, @RequestParam("userId") Long userId) { - return marriageBountyOrderQueryService.getMarriageBountyOrderPreRefundInfo(userId, queryParam.getMiId()); + return marriageBountyOrderQueryService.getMarriageBountyOrderPreRefundInfo(queryParam.getMarriageBountyOrderId()); } diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/request/UserGetMarriageBountyOrderPreRefundInfoQueryParam.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/request/UserGetMarriageBountyOrderPreRefundInfoQueryParam.java index 6d80180..43516ae 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/request/UserGetMarriageBountyOrderPreRefundInfoQueryParam.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/request/UserGetMarriageBountyOrderPreRefundInfoQueryParam.java @@ -1,15 +1,15 @@ package com.qniao.dam.api.query.marriagebounty.user.request; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.NotNull; + @Data public class UserGetMarriageBountyOrderPreRefundInfoQueryParam { - @ApiModelProperty("征婚资料标识") - @JsonSerialize(using = ToStringSerializer.class) - private Long miId; + @ApiModelProperty("悬赏招亲唯一标识") + @NotNull(message = "悬赏招亲唯一标识不能为空") + private Long marriageBountyOrderId; } diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/request/UserGetMarriageBountyOrderProductInfoQueryParam.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/request/UserGetMarriageBountyOrderProductInfoQueryParam.java new file mode 100644 index 0000000..60f2a8a --- /dev/null +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/request/UserGetMarriageBountyOrderProductInfoQueryParam.java @@ -0,0 +1,14 @@ +package com.qniao.dam.api.query.marriagebounty.user.request; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class UserGetMarriageBountyOrderProductInfoQueryParam { + + @ApiModelProperty("悬赏招亲唯一标识") + @NotNull(message = "悬赏招亲唯一标识不能为空") + private Long marriageBountyOrderId; +} diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/response/UserGetMarriageBountyOrderProductInfoVo.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/response/UserGetMarriageBountyOrderProductInfoVo.java new file mode 100644 index 0000000..3a20ddf --- /dev/null +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/api/query/marriagebounty/user/response/UserGetMarriageBountyOrderProductInfoVo.java @@ -0,0 +1,32 @@ +package com.qniao.dam.api.query.marriagebounty.user.response; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class UserGetMarriageBountyOrderProductInfoVo { + + @ApiModelProperty("悬赏招亲唯一标识") + @JsonSerialize(using = ToStringSerializer.class) + private Long marriageBountyOrderId; + + @ApiModelProperty("见面费用") + private BigDecimal meetingFee = BigDecimal.ZERO; + + @ApiModelProperty("已用见面次数") + private Integer usedMeetingQuantity = 0; + + @ApiModelProperty("可用见面次数") + private Integer usableMeetingQuantity = 0; + + @ApiModelProperty("结果礼金") + private BigDecimal resultGift = BigDecimal.ZERO; + + @ApiModelProperty("奖励金额") + private BigDecimal rewardAmount; + +} 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 8fc4532..b89323d 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 @@ -112,8 +112,8 @@ public class MarriageBountyOrderApplicationService extends BaseApplicationServic } } - public void refund(Long userId, Long miId) { - UserGetMarriageBountyOrderPreRefundInfoVo preRefundInfoVo = marriageBountyOrderQueryService.getMarriageBountyOrderPreRefundInfo(userId, miId); + public void refund(Long marriageBountyOrderId) { + UserGetMarriageBountyOrderPreRefundInfoVo preRefundInfoVo = marriageBountyOrderQueryService.getMarriageBountyOrderPreRefundInfo(marriageBountyOrderId); if (!preRefundInfoVo.getRefundable()) { throw new BizException("不能发起退款"); } else { diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/marriagebounty/MarriageBountyOrderQueryService.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/marriagebounty/MarriageBountyOrderQueryService.java index 70ab0a0..84b6be8 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/marriagebounty/MarriageBountyOrderQueryService.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/marriagebounty/MarriageBountyOrderQueryService.java @@ -1,6 +1,7 @@ package com.qniao.dam.query.marriagebounty; import com.qniao.dam.api.query.marriagebounty.user.response.UserGetMarriageBountyOrderPreRefundInfoVo; +import com.qniao.dam.api.query.marriagebounty.user.response.UserGetMarriageBountyOrderProductInfoVo; import com.qniao.dam.domain.aggregate.marriagebounty.entity.MarriageBountyOrder; import com.qniao.dam.domian.aggregate.marriagebount.constant.MarriageBountyOrderPaymentStatusEnum; import com.qniao.dam.domian.aggregate.marriagebount.constant.MarriageBountyOrderStatusEnum; @@ -8,7 +9,9 @@ import com.qniao.dam.domian.aggregate.marriagebount.constant.MarriageBountyOrder public interface MarriageBountyOrderQueryService { MarriageBountyOrder queryBy(Long userId, Long miId, MarriageBountyOrderStatusEnum status, MarriageBountyOrderPaymentStatusEnum paymentStatus); - UserGetMarriageBountyOrderPreRefundInfoVo getMarriageBountyOrderPreRefundInfo(Long userId, Long miId); + UserGetMarriageBountyOrderPreRefundInfoVo getMarriageBountyOrderPreRefundInfo(Long marriageBountyOrderId); MarriageBountyOrder queryByOrderRel(Long orderRelId); + + UserGetMarriageBountyOrderProductInfoVo getMarriageBountyOrderProductInfo(Long marriageBountyOrderId); } diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/marriagebounty/impl/MarriageBountyOrderQueryServiceImpl.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/marriagebounty/impl/MarriageBountyOrderQueryServiceImpl.java index 84acd84..12e158c 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/marriagebounty/impl/MarriageBountyOrderQueryServiceImpl.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/marriagebounty/impl/MarriageBountyOrderQueryServiceImpl.java @@ -2,10 +2,13 @@ package com.qniao.dam.query.marriagebounty.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.qniao.dam.api.query.marriagebounty.user.response.UserGetMarriageBountyOrderPreRefundInfoVo; +import com.qniao.dam.api.query.marriagebounty.user.response.UserGetMarriageBountyOrderProductInfoVo; import com.qniao.dam.domain.aggregate.marriagebounty.entity.MarriageBountyOrder; import com.qniao.dam.domain.aggregate.marriagebounty.entity.MarriageBountyOrderReward; import com.qniao.dam.domain.aggregate.marriagebounty.repository.MarriageBountyOrderRepository; import com.qniao.dam.domain.aggregate.marriagebounty.valueobj.MarriageBountyOrderRel; +import com.qniao.dam.domain.aggregate.product.entity.Product; +import com.qniao.dam.domain.aggregate.productspec.entity.ProductSpec; import com.qniao.dam.domian.aggregate.marriagebount.constant.MarriageBountyOrderPaymentStatusEnum; import com.qniao.dam.domian.aggregate.marriagebount.constant.MarriageBountyOrderStatusEnum; import com.qniao.dam.domian.aggregate.product.constant.ProductSubCategoryEnum; @@ -13,10 +16,12 @@ import com.qniao.dam.infrastructure.persistent.dao.domain.MarriageBountyOrderDao import com.qniao.dam.infrastructure.persistent.dao.domain.MarriageBountyOrderRelDao; import com.qniao.dam.infrastructure.persistent.dao.domain.MarriageBountyOrderRewardDao; import com.qniao.dam.query.marriagebounty.MarriageBountyOrderQueryService; +import com.qniao.dam.query.product.ProductQueryService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.math.BigDecimal; +import java.util.List; import java.util.Objects; @Service @@ -30,6 +35,8 @@ public class MarriageBountyOrderQueryServiceImpl implements MarriageBountyOrderQ private MarriageBountyOrderRelDao marriageBountyOrderRelDao; @Resource private MarriageBountyOrderRewardDao marriageBountyOrderRewardDao; + @Resource + private ProductQueryService productQueryService; @Override public MarriageBountyOrder queryBy(Long userId, Long miId, MarriageBountyOrderStatusEnum status, @@ -49,9 +56,9 @@ public class MarriageBountyOrderQueryServiceImpl implements MarriageBountyOrderQ } @Override - public UserGetMarriageBountyOrderPreRefundInfoVo getMarriageBountyOrderPreRefundInfo(Long userId, Long miId) { + public UserGetMarriageBountyOrderPreRefundInfoVo getMarriageBountyOrderPreRefundInfo(Long marriageBountyOrderId) { UserGetMarriageBountyOrderPreRefundInfoVo refundInfoVo = new UserGetMarriageBountyOrderPreRefundInfoVo(); - MarriageBountyOrder marriageBountyOrder = queryBy(userId, miId, MarriageBountyOrderStatusEnum.MATCHMAKING, MarriageBountyOrderPaymentStatusEnum.PAID); + MarriageBountyOrder marriageBountyOrder = marriageBountyOrderRepository.load(marriageBountyOrderId); if (Objects.nonNull(marriageBountyOrder)) { refundInfoVo.setMarriageBountyOrderId(marriageBountyOrder.getId()); BigDecimal refundableMeetingFee = BigDecimal.ZERO; @@ -86,4 +93,35 @@ public class MarriageBountyOrderQueryServiceImpl implements MarriageBountyOrderQ } return marriageBountyOrder; } + + @Override + public UserGetMarriageBountyOrderProductInfoVo getMarriageBountyOrderProductInfo(Long marriageBountyOrderId) { + UserGetMarriageBountyOrderProductInfoVo productInfoVo = null; + MarriageBountyOrder marriageBountyOrder = marriageBountyOrderRepository.load(marriageBountyOrderId); + if (Objects.nonNull(marriageBountyOrder)) { + productInfoVo = new UserGetMarriageBountyOrderProductInfoVo(); + productInfoVo.setMarriageBountyOrderId(marriageBountyOrder.getId()); + productInfoVo.setRewardAmount(marriageBountyOrder.getRewardAmount()); + Product meetingFeeProduct = productQueryService.queryBy(marriageBountyOrder.getUserId(), marriageBountyOrder.getMiId(), ProductSubCategoryEnum.MARRIAGE_BOUNTY_MEETING_FEE); + List meetingFeeProductSpecList = productQueryService.listProductSpecBy(meetingFeeProduct.getId()); + productInfoVo.setMeetingFee(meetingFeeProductSpecList.get(0).getUnitSellingPrice()); + Product resultGiftProduct = productQueryService.queryBy(marriageBountyOrder.getUserId(), marriageBountyOrder.getMiId(), ProductSubCategoryEnum.MARRIAGE_BOUNTY_RESULT_GIFT); + List resultGiftProductSpecList = productQueryService.listProductSpecBy(resultGiftProduct.getId()); + productInfoVo.setResultGift(resultGiftProductSpecList.get(0).getUnitSellingPrice()); + int usedMeetingQuantity = 0; + int usableMeetingQuantity = 0; + for (MarriageBountyOrderReward orderReward : marriageBountyOrder.getOrderRewardList()) { + if (ProductSubCategoryEnum.MARRIAGE_BOUNTY_MEETING_FEE.equals(orderReward.getRewardCategory())) { + if (orderReward.getIsReceive()) { + usedMeetingQuantity++; + } else { + usableMeetingQuantity++; + } + } + } + productInfoVo.setUsedMeetingQuantity(usedMeetingQuantity); + productInfoVo.setUsableMeetingQuantity(usableMeetingQuantity); + } + return productInfoVo; + } } diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/product/ProductQueryService.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/product/ProductQueryService.java index 7c5c7cf..22652f5 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/product/ProductQueryService.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/product/ProductQueryService.java @@ -12,6 +12,7 @@ import com.qniao.dam.domian.aggregate.product.constant.ProductSubCategoryEnum; import com.qniao.dam.domian.aggregate.productspec.constant.ProductSpecTermNameEnum; import com.qniao.framework.utils.PageUtil; +import java.math.BigDecimal; import java.util.List; public interface ProductQueryService { @@ -30,4 +31,5 @@ public interface ProductQueryService { Product queryBy(Long userId, Long miId, ProductSubCategoryEnum subCategory); List listProductSpecBy(Long productId); + } diff --git a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/product/impl/ProductQueryServiceImpl.java b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/product/impl/ProductQueryServiceImpl.java index 196b59a..17c97a9 100644 --- a/dating-agency-mall-server/src/main/java/com/qniao/dam/query/product/impl/ProductQueryServiceImpl.java +++ b/dating-agency-mall-server/src/main/java/com/qniao/dam/query/product/impl/ProductQueryServiceImpl.java @@ -103,7 +103,6 @@ public class ProductQueryServiceImpl implements ProductQueryService { } return productSpecList; } - @Override public ProductSpecTerm getTermByName(List productSpecTermList, ProductSpecTermNameEnum name) { ProductSpecTerm productSpecTerm = null;