领取优惠券操作

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

@@ -0,0 +1,17 @@
package com.chaozhanggui.system.cashierservice.dao;
import com.chaozhanggui.system.cashierservice.entity.TbSplitAccounts;
public interface TbSplitAccountsMapper {
int deleteByPrimaryKey(Integer id);
int insert(TbSplitAccounts record);
int insertSelective(TbSplitAccounts record);
TbSplitAccounts selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(TbSplitAccounts record);
int updateByPrimaryKey(TbSplitAccounts record);
}

View File

@@ -96,6 +96,7 @@ public class TbOrderInfo implements Serializable {
private String tableName;
private String masterId;
private String isBuyCoupon;
private String isUseCoupon;
private Integer totalNumber;
private List<TbOrderDetail> detailList;

View File

@@ -0,0 +1,33 @@
package com.chaozhanggui.system.cashierservice.entity;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class TbSplitAccounts implements Serializable {
private Integer id;
private Integer merchantId;
private Integer shopId;
private BigDecimal couponsPrice;
private BigDecimal conponsAmount;
private BigDecimal originAmount;
private String isSplit;
private BigDecimal orderAmount;
private Date createTime;
private Date splitTime;
private String tradeDay;
private static final long serialVersionUID = 1L;
}

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();