|
@@ -191,6 +191,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
orderItem.setCouponAmount(new BigDecimal(0));
|
|
|
}
|
|
|
} else {
|
|
|
+ BigDecimal totalAmount = calcTotalAmount(orderItemList);
|
|
|
// todo 使用优惠券 远程调用获取优惠券金额
|
|
|
// SmsCouponHistoryDetail couponHistoryDetail = getUseCoupon(cartPromotionItemList, orderParam.getCouponId());
|
|
|
// if (couponHistoryDetail == null) {
|
|
@@ -198,14 +199,14 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
// }
|
|
|
//对下单商品的优惠券进行处理
|
|
|
HttpResponseResult<CouponInfoApi> couponInfoApiHttpResponseResult = adminFeignService.queryCouponOrderPageInfo(
|
|
|
- currentMember.getId(), orderParam.getCouponId(), orderParam.getOrderAmount(),
|
|
|
+ currentMember.getId(), orderParam.getCouponId(), totalAmount,
|
|
|
orderParam.getPlatformType());
|
|
|
CouponInfoApi data = couponInfoApiHttpResponseResult.getData();
|
|
|
if(data != null) {
|
|
|
couponAmount = data.getDiscountedPrices();
|
|
|
}
|
|
|
- if (couponAmount.compareTo(orderParam.getOrderAmount()) > 0) {
|
|
|
- couponAmount = orderParam.getOrderAmount();
|
|
|
+ if (couponAmount.compareTo(totalAmount) > 0) {
|
|
|
+ couponAmount = totalAmount;
|
|
|
}
|
|
|
handleCouponAmount(orderItemList, couponAmount);
|
|
|
}
|
|
@@ -494,7 +495,23 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
//解除订单商品库存锁定
|
|
|
if (!CollectionUtils.isEmpty(orderItemList)) {
|
|
|
portalOrderDao.releaseSkuStockLock(orderItemList);
|
|
|
- portalOrderDao.releaseProductStockLock(orderItemList);
|
|
|
+ Map<Long, List<OmsOrderItem>> collect = orderItemList
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.groupingBy(OmsOrderItem::getProductId));
|
|
|
+ List<ProductStock> productStockList = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, List<OmsOrderItem>> entry : collect.entrySet()) {
|
|
|
+ ProductStock stock = new ProductStock();
|
|
|
+ stock.setProductId(entry.getKey());
|
|
|
+ List<OmsOrderItem> value = entry.getValue();
|
|
|
+ if (CollectionUtils.isEmpty(value)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int sum = value.stream().mapToInt(OmsOrderItem::getProductQuantity).sum();
|
|
|
+ stock.setStock(sum);
|
|
|
+ productStockList.add(stock);
|
|
|
+ }
|
|
|
+
|
|
|
+ portalOrderDao.releaseProductStockLock(productStockList);
|
|
|
}
|
|
|
//修改优惠券使用状态
|
|
|
// updateCouponStatus(cancelOrder.getCouponId(), cancelOrder.getMemberId(), 0);
|