From f1e88066e0af2a0852fe1095da87c04018c9cf5a Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 11 Sep 2023 18:11:05 +0800
Subject: [PATCH] 优惠卷
---
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
index 00f656f..3b9cc1d 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -212,8 +212,10 @@
BigDecimal costAmount = mallGoodsCoupon.getCostAmount();
BigDecimal realAmount = mallGoodsCoupon.getRealAmount();
if(amount.compareTo(costAmount) >= 0){
- amount = amount.subtract(realAmount);
+ amount = (amount.subtract(realAmount).compareTo(BigDecimal.ZERO) > 0 ? amount.subtract(realAmount) : BigDecimal.ZERO);
orderItem.setMemberCouponId(memberCouponId);
+ mallMemberCoupon.setState(2);
+ mallMemberCouponMapper.updateById(mallMemberCoupon);
}
}
orderItem.setAmount(amount);
@@ -224,6 +226,9 @@
orderItem.setGoodsName(sku.getGoodsName());
orderItem.setSkuId(sku.getId());
orderItem.setState(1);
+ if(ObjectUtil.isNotEmpty(addOrderDto.getMemberInviteId())){
+ orderItem.setMemberInviteId(addOrderDto.getMemberInviteId());
+ }
orderItem.setStyleName(sku.getStyleName());
orderItem.setSkuName(sku.getSkuName());
orderItem.setSkuImage(sku.getSkuImage());
@@ -307,6 +312,12 @@
if(1 != skuResult){
throw new FebsException(sku.getSkuName() + "库存不足");
}
+ Long memberCouponId = mallOrderItem.getMemberCouponId();
+ MallMemberCoupon mallMemberCoupon = mallMemberCouponMapper.selectById(memberCouponId);
+ if(ObjectUtil.isNotEmpty(mallMemberCoupon)){
+ mallMemberCoupon.setState(1);
+ mallMemberCouponMapper.updateById(mallMemberCoupon);
+ }
}
}
--
Gitblit v1.9.1