|
|
@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.qniao.dam.api.command.order.user.request.UserSubmitSiteActivityOrderDto; |
|
|
import com.qniao.dam.api.command.order.user.request.UserSubmitSiteActivityOrderDto; |
|
|
import com.qniao.dam.api.command.order.user.response.UserSubmitOrderVo; |
|
|
import com.qniao.dam.api.command.order.user.response.UserSubmitOrderVo; |
|
|
import com.qniao.dam.application.service.product.ProductApplicationService; |
|
|
import com.qniao.dam.application.service.product.ProductApplicationService; |
|
|
|
|
|
import com.qniao.dam.domain.aggregate.activity.entity.Activity; |
|
|
import com.qniao.dam.domain.aggregate.activity.entity.ActivityProduct; |
|
|
import com.qniao.dam.domain.aggregate.activity.entity.ActivityProduct; |
|
|
|
|
|
import com.qniao.dam.domain.aggregate.activity.repository.ActivityRepository; |
|
|
import com.qniao.dam.domain.aggregate.marriagebounty.entity.MarriageBountyOrder; |
|
|
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.entity.MarriageBountyOrderReward; |
|
|
import com.qniao.dam.domain.aggregate.order.entity.Order; |
|
|
import com.qniao.dam.domain.aggregate.order.entity.Order; |
|
|
@ -77,6 +79,8 @@ public class OrderApplicationService { |
|
|
@Resource |
|
|
@Resource |
|
|
private SiteActivityDao siteActivityDao; |
|
|
private SiteActivityDao siteActivityDao; |
|
|
@Resource |
|
|
@Resource |
|
|
|
|
|
private ActivityRepository activityRepository; |
|
|
|
|
|
@Resource |
|
|
private RightQueryService rightQueryService; |
|
|
private RightQueryService rightQueryService; |
|
|
|
|
|
|
|
|
@Value("${marriage_bounty_meeting_quantity:5}") |
|
|
@Value("${marriage_bounty_meeting_quantity:5}") |
|
|
@ -264,27 +268,44 @@ public class OrderApplicationService { |
|
|
MarriageInformation marriageInformation = marriageInformationDao.selectById(dto.getMiId()); |
|
|
MarriageInformation marriageInformation = marriageInformationDao.selectById(dto.getMiId()); |
|
|
Product product = productQueryService.querySiteActivityBy(dto.getSiteActivityId(), marriageInformation.getGenderCode()); |
|
|
Product product = productQueryService.querySiteActivityBy(dto.getSiteActivityId(), marriageInformation.getGenderCode()); |
|
|
SiteActivity siteActivity = siteActivityDao.selectById(dto.getSiteActivityId()); |
|
|
SiteActivity siteActivity = siteActivityDao.selectById(dto.getSiteActivityId()); |
|
|
Order order = Order.build(userId, dto.getMiId(), OrderBelongingEnum.CUSTOMER, marriageInformation.getNickName(), OrderTypeEnum.NORMAL); |
|
|
|
|
|
|
|
|
Order order = null; |
|
|
PaymentOrder paymentOrder = null; |
|
|
PaymentOrder paymentOrder = null; |
|
|
if (dto.getOpenVip()) { |
|
|
if (dto.getOpenVip()) { |
|
|
//开通会员送活动 |
|
|
//开通会员送活动 |
|
|
|
|
|
|
|
|
|
|
|
order = new Order(); |
|
|
|
|
|
order.setUserId(userId); |
|
|
|
|
|
order.setMiId(dto.getMiId()); |
|
|
|
|
|
order.setActivityId(siteActivity.getVpiActivityId()); |
|
|
|
|
|
order.setGroupType(1); |
|
|
|
|
|
Activity activity = activityRepository.load(siteActivity.getVpiActivityId()); |
|
|
|
|
|
List<OrderItem> orderItemList = new ArrayList<>(); |
|
|
|
|
|
activity.getActivityProductList().forEach(activityProduct -> { |
|
|
|
|
|
OrderItem orderItem = new OrderItem(); |
|
|
|
|
|
orderItem.setProductSpecId(activityProduct.getProductSpecId()); |
|
|
|
|
|
orderItem.setQuantity(1); |
|
|
|
|
|
orderItemList.add(orderItem); |
|
|
|
|
|
}); |
|
|
|
|
|
order.setOrderItemList(orderItemList); |
|
|
|
|
|
//1. 填充订单信息 + 同类型权益,不同规格,限制购买和提醒 |
|
|
|
|
|
fillOrderInfo(order); |
|
|
} else { |
|
|
} else { |
|
|
//是否vip |
|
|
//是否vip |
|
|
boolean vip = rightQueryService.checkUserVipRight(userId, dto.getMiId()).getVip(); |
|
|
boolean vip = rightQueryService.checkUserVipRight(userId, dto.getMiId()).getVip(); |
|
|
//报名参加活动 |
|
|
//报名参加活动 |
|
|
|
|
|
order = Order.build(userId, dto.getMiId(), OrderBelongingEnum.CUSTOMER, marriageInformation.getNickName(), OrderTypeEnum.NORMAL); |
|
|
ProductSpec productSpec = product.getProductSpecList().get(0); |
|
|
ProductSpec productSpec = product.getProductSpecList().get(0); |
|
|
OrderItem orderItem = OrderItem.build(productSpec.getProductId(), productSpec.getId(), product.getProductType(), product.getMainCategory(), product.getSubCategory(), |
|
|
OrderItem orderItem = OrderItem.build(productSpec.getProductId(), productSpec.getId(), product.getProductType(), product.getMainCategory(), product.getSubCategory(), |
|
|
product.getProductTitle(), siteActivity.calculateFee(GenderEnum.get(marriageInformation.getGenderCode()), vip), 1); |
|
|
product.getProductTitle(), siteActivity.calculateFee(GenderEnum.get(marriageInformation.getGenderCode()), vip), 1); |
|
|
order.setOrderItemList(Collections.singletonList(orderItem)); |
|
|
order.setOrderItemList(Collections.singletonList(orderItem)); |
|
|
//2. 订单金额计算 |
|
|
|
|
|
countOrderAmount(order); |
|
|
|
|
|
//3. 设置订单号 |
|
|
|
|
|
order.setOrderCode(snowFlakeUtil.getSnowflakeOrderCode()); |
|
|
|
|
|
//4. 组织付款单信息 |
|
|
|
|
|
paymentOrder = makePaymentOrder(order); |
|
|
|
|
|
submitSiteActivityOrderDomainService.handle(order, paymentOrder, dto.getSiteActivityId()); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
//2. 订单金额计算 |
|
|
|
|
|
countOrderAmount(order); |
|
|
|
|
|
//3. 设置订单号 |
|
|
|
|
|
order.setOrderCode(snowFlakeUtil.getSnowflakeOrderCode()); |
|
|
|
|
|
//4. 组织付款单信息 |
|
|
|
|
|
paymentOrder = makePaymentOrder(order); |
|
|
|
|
|
submitOrderDomainService.handle(order, paymentOrder); |
|
|
|
|
|
submitSiteActivityOrderDomainService.handle(order, paymentOrder, dto.getSiteActivityId(), dto.getOpenVip()); |
|
|
return new UserSubmitOrderVo(order.getId(), paymentOrder.getId()); |
|
|
return new UserSubmitOrderVo(order.getId(), paymentOrder.getId()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |