领取优惠券操作

This commit is contained in:
19991905653
2024-04-15 14:36:46 +08:00
parent f203d7bccc
commit 2cd2ef8c07
6 changed files with 225 additions and 11 deletions

View File

@@ -213,7 +213,7 @@ public class CartService {
BigDecimal packAMount = BigDecimal.ZERO;
BigDecimal originAmount = BigDecimal.ZERO;
BigDecimal saleAmount = BigDecimal.ZERO;
String couponId = jsonObject.getString("couponsId");
String couponId = "";
BigDecimal couponAmount = BigDecimal.ZERO;
Map<Integer, TbProductSku> skuMap = new HashMap<>();
List<TbOrderDetail> orderDetails = new ArrayList<>();
@@ -270,7 +270,9 @@ public class CartService {
//生成订单
TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId);
String isBuyYhq = "false";
String isuseYhq = "false";
if (jsonObject.containsKey("isYhq") && jsonObject.getString("isYhq").equals("1")) {
couponId =jsonObject.getString("couponsId");
//1:购买优惠券0自己持有优惠券
Integer couponsId = jsonObject.getInteger("couponsId");
if (jsonObject.getString("isBuyYhq").equals("1")) {
@@ -342,7 +344,7 @@ public class CartService {
userCouponsMapper.updateByPrimaryKeySelective(userCoupons);
couponAmount = userCoupons.getCouponsAmount();
}
isuseYhq = "true";
}
if (Objects.nonNull(orderInfo)) {
@@ -370,6 +372,7 @@ public class CartService {
orderInfo.setFreightAmount(BigDecimal.ZERO);
orderInfo.setProductAmount(saleAmount);
orderInfo.setIsBuyCoupon(isBuyYhq);
orderInfo.setIsUseCoupon(isuseYhq);
orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
} else {
orderInfo = getOrder(totalAmount, packAMount, shopTable, tbMerchantAccount.getId().toString(), jsonObject, originAmount);
@@ -377,6 +380,7 @@ public class CartService {
orderInfo.setUserCouponId(couponId);
orderInfo.setOriginAmount(originAmount);
orderInfo.setIsBuyCoupon(isBuyYhq);
orderInfo.setIsUseCoupon(isuseYhq);
orderInfo.setUserCouponAmount(couponAmount);
orderInfoMapper.insert(orderInfo);
orderId = orderInfo.getId();