feat: 购物车及订单增加会员价
This commit is contained in:
@@ -34,6 +34,8 @@ public class TbCashierCart implements Serializable {
|
|||||||
private String skuName;
|
private String skuName;
|
||||||
|
|
||||||
private BigDecimal salePrice;
|
private BigDecimal salePrice;
|
||||||
|
// 会员价
|
||||||
|
private BigDecimal memberPrice;
|
||||||
private BigDecimal packFee;
|
private BigDecimal packFee;
|
||||||
|
|
||||||
private Integer number;
|
private Integer number;
|
||||||
@@ -74,6 +76,9 @@ public class TbCashierCart implements Serializable {
|
|||||||
// 使用的优惠券id
|
// 使用的优惠券id
|
||||||
private Integer userCouponId;
|
private Integer userCouponId;
|
||||||
|
|
||||||
|
// 是否是会员
|
||||||
|
private Integer isMember;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public String getSkuName() {
|
public String getSkuName() {
|
||||||
@@ -83,4 +88,13 @@ public class TbCashierCart implements Serializable {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void resetTotalAmount() {
|
||||||
|
if (isMember != null && isMember == 1) {
|
||||||
|
totalAmount = BigDecimal.valueOf(totalNumber).multiply(memberPrice).add(packFee);
|
||||||
|
}else {
|
||||||
|
totalAmount = BigDecimal.valueOf(totalNumber).multiply(salePrice).add(packFee);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.chaozhanggui.system.cashierservice.entity.Enum.PlatformTypeEnum;
|
|||||||
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum;
|
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopWxMsgTypeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.*;
|
import com.chaozhanggui.system.cashierservice.entity.dto.*;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo;
|
import com.chaozhanggui.system.cashierservice.entity.vo.TbUserCouponVo;
|
||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
import com.chaozhanggui.system.cashierservice.mapper.*;
|
import com.chaozhanggui.system.cashierservice.mapper.*;
|
||||||
@@ -209,7 +210,7 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
if (cashierCart.getIsVip().equals((byte) 1)) continue;
|
if (cashierCart.getIsVip().equals((byte) 1)) continue;
|
||||||
if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) {
|
if ((!TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId()) || !ignoreTableFee) && cashierCart.getNumber() > 0) {
|
||||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
amount = amount.add(cashierCart.getTotalAmount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L);
|
redisUtil.saveMessage(tableCartKey, array.toString(), 60 * 60 * 12L);
|
||||||
@@ -410,8 +411,7 @@ public class CartService {
|
|||||||
if (isVip != null && isVip == 1) {
|
if (isVip != null && isVip == 1) {
|
||||||
cashierCart.setTotalAmount(BigDecimal.ZERO);
|
cashierCart.setTotalAmount(BigDecimal.ZERO);
|
||||||
} else {
|
} else {
|
||||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber())
|
cashierCart.resetTotalAmount();
|
||||||
.multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
|
||||||
}
|
}
|
||||||
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
||||||
mpCashierCartMapper.updateById(cashierCart);
|
mpCashierCartMapper.updateById(cashierCart);
|
||||||
@@ -575,6 +575,12 @@ public class CartService {
|
|||||||
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num,
|
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num,
|
||||||
String tableId, String shopId, Integer isVip, String note, boolean isTakeout) throws Exception {
|
String tableId, String shopId, Integer isVip, String note, boolean isTakeout) throws Exception {
|
||||||
try {
|
try {
|
||||||
|
// 查询用户信息
|
||||||
|
TbShopUser shopUser = shopUserMapper.selectByUserIdAndShopId(String.valueOf(userId), shopId);
|
||||||
|
if (shopUser == null) {
|
||||||
|
throw new MsgException("用户不存在");
|
||||||
|
}
|
||||||
|
|
||||||
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
||||||
String key = tableId + "-" + shopId;
|
String key = tableId + "-" + shopId;
|
||||||
TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId));
|
||||||
@@ -602,6 +608,7 @@ public class CartService {
|
|||||||
cashierCart.setNumber(num);
|
cashierCart.setNumber(num);
|
||||||
cashierCart.setTotalNumber(num);
|
cashierCart.setTotalNumber(num);
|
||||||
}
|
}
|
||||||
|
cashierCart.setIsMember(Integer.valueOf(shopUser.getIsVip()));
|
||||||
cashierCart.setNote(note);
|
cashierCart.setNote(note);
|
||||||
cashierCart.setProductId(productId);
|
cashierCart.setProductId(productId);
|
||||||
cashierCart.setSkuId(skuId);
|
cashierCart.setSkuId(skuId);
|
||||||
@@ -621,6 +628,7 @@ public class CartService {
|
|||||||
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
cashierCart.setUpdatedAt(Instant.now().toEpochMilli());
|
||||||
cashierCart.setPackFee(BigDecimal.ZERO);
|
cashierCart.setPackFee(BigDecimal.ZERO);
|
||||||
cashierCart.setRefundNumber(0);
|
cashierCart.setRefundNumber(0);
|
||||||
|
cashierCart.setMemberPrice(productSku.getMemberPrice());
|
||||||
cashierCart.setTradeDay(DateUtils.getDay());
|
cashierCart.setTradeDay(DateUtils.getDay());
|
||||||
// 打包费
|
// 打包费
|
||||||
if (isTakeout && product.getPackFee() != null) {
|
if (isTakeout && product.getPackFee() != null) {
|
||||||
@@ -632,7 +640,7 @@ public class CartService {
|
|||||||
cashierCart.setSalePrice(BigDecimal.ZERO);
|
cashierCart.setSalePrice(BigDecimal.ZERO);
|
||||||
} else {
|
} else {
|
||||||
cashierCart.setIsVip((byte) 0);
|
cashierCart.setIsVip((byte) 0);
|
||||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
|
cashierCart.resetTotalAmount();
|
||||||
}
|
}
|
||||||
cashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue());
|
cashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue());
|
||||||
mpCashierCartMapper.insert(cashierCart);
|
mpCashierCartMapper.insert(cashierCart);
|
||||||
@@ -1193,7 +1201,7 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private OrderCartInfoDTO getCartInfoForOrder(ShopEatTypeInfoDTO shopEatTypeInfoDTO, List<TbCashierCart> allCartList, TbShopTable shopTable) {
|
private OrderCartInfoDTO getCartInfoForOrder(ShopEatTypeInfoDTO shopEatTypeInfoDTO, List<TbCashierCart> allCartList, TbShopTable shopTable, TbShopUser shopUser) {
|
||||||
OrderCartInfoDTO infoDTO = new OrderCartInfoDTO();
|
OrderCartInfoDTO infoDTO = new OrderCartInfoDTO();
|
||||||
// 就餐人数
|
// 就餐人数
|
||||||
ArrayList<Integer> cashierIds = new ArrayList<>();
|
ArrayList<Integer> cashierIds = new ArrayList<>();
|
||||||
@@ -1201,6 +1209,9 @@ public class CartService {
|
|||||||
Integer orderId = null;
|
Integer orderId = null;
|
||||||
for (TbCashierCart tbCashierCart : allCartList) {
|
for (TbCashierCart tbCashierCart : allCartList) {
|
||||||
cashierIds.add(tbCashierCart.getId());
|
cashierIds.add(tbCashierCart.getId());
|
||||||
|
// 设置会员信息及价格
|
||||||
|
tbCashierCart.setIsMember(shopUser.getIsVip().intValue());
|
||||||
|
tbCashierCart.resetTotalAmount();
|
||||||
if (TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) {
|
if (TableConstant.CashierCart.ID.equals(tbCashierCart.getProductId())) {
|
||||||
seatInfo = tbCashierCart;
|
seatInfo = tbCashierCart;
|
||||||
}
|
}
|
||||||
@@ -1274,6 +1285,8 @@ public class CartService {
|
|||||||
if (tbUserInfo == null) {
|
if (tbUserInfo == null) {
|
||||||
MsgException.throwException("生成订单失败");
|
MsgException.throwException("生成订单失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 用户信息
|
||||||
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
||||||
|
|
||||||
// 获取当前下单次数和用餐类型
|
// 获取当前下单次数和用餐类型
|
||||||
@@ -1293,7 +1306,7 @@ public class CartService {
|
|||||||
TbShopTable shopTable = getTableInfoByEatType(shopEatTypeInfoDTO);
|
TbShopTable shopTable = getTableInfoByEatType(shopEatTypeInfoDTO);
|
||||||
|
|
||||||
// 获取详细的购物车信息
|
// 获取详细的购物车信息
|
||||||
OrderCartInfoDTO cartInfoDTO = getCartInfoForOrder(shopEatTypeInfoDTO, cashierCartList, shopTable);
|
OrderCartInfoDTO cartInfoDTO = getCartInfoForOrder(shopEatTypeInfoDTO, cashierCartList, shopTable, tbShopUser);
|
||||||
|
|
||||||
// 获取订单信息
|
// 获取订单信息
|
||||||
TbOrderInfo orderInfo = null;
|
TbOrderInfo orderInfo = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user