外带默认打包费

This commit is contained in:
2024-09-27 11:03:55 +08:00
parent 8f4719bb04
commit fcf6582e9f
2 changed files with 34 additions and 8 deletions

View File

@@ -286,7 +286,7 @@ public class CartService {
if (Objects.isNull(array) || array.isEmpty()) {
if (type == 1) {
TbCashierCart cashierCart = addCart(productId, skuId,
jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip, note);
jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip, note, shopEatTypeInfoDTO.isTakeout());
jsonArray.add(cashierCart);
cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
cashierCartArrayList.add(cashierCart);
@@ -309,9 +309,17 @@ public class CartService {
continue;
}
// 设置备注
cashierCart.setNote(note);
if (cashierCart.getNumber() > 0) {
// 设置备注
cashierCart.setNote(note);
// 设置打包费
if (shopEatTypeInfoDTO.isTakeout()) {
// 打包费
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
cashierCart.setPackFee(product.getPackFee() != null ?
product.getPackFee().multiply(BigDecimal.valueOf(buyNum)) : BigDecimal.ZERO);
}
if (isVip == 1) {
cashierCart.setTotalAmount(BigDecimal.ZERO);
} else {
@@ -331,7 +339,7 @@ public class CartService {
}
if (flag && type == 1) {
TbCashierCart cashierCart = addCart(productId, skuId,
jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip, note);
jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip, note, shopEatTypeInfoDTO.isTakeout());
jsonArray.add(cashierCart);
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
}
@@ -339,7 +347,7 @@ public class CartService {
} else {
if (type == 1) {
TbCashierCart cashierCart = addCart(productId, skuId,
jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip, note);
jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip, note, shopEatTypeInfoDTO.isTakeout());
jsonArray.add(cashierCart);
cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
cashierCartArrayList.add(cashierCart);
@@ -503,7 +511,7 @@ public class CartService {
}
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num,
String tableId, String shopId,Integer isVip, String note) throws Exception{
String tableId, String shopId,Integer isVip, String note, boolean isTakeout) throws Exception{
try {
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
String key = tableId + "-" + shopId;
@@ -561,6 +569,10 @@ public class CartService {
cashierCart.setPackFee(BigDecimal.ZERO);
cashierCart.setRefundNumber(0);
cashierCart.setTradeDay(DateUtils.getDay());
// 打包费
if (isTakeout && product.getPackFee() != null) {
cashierCart.setPackFee(product.getPackFee().multiply(BigDecimal.valueOf(num)));
}
if(isVip==1){
cashierCart.setIsVip(Byte.parseByte("1"));
cashierCart.setTotalAmount(BigDecimal.ZERO);
@@ -638,7 +650,9 @@ public class CartService {
queryWrapper.eq(TbCashierCart::getUserId, userId);
// 台桌点单
} else {
queryWrapper.eq(TbCashierCart::getTableId, tableId);
queryWrapper.and(q -> {
q.eq(TbCashierCart::getTableId, tableId).or().eq(TbCashierCart::getUserId, userId);
});
shopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, tableId));
@@ -680,6 +694,18 @@ public class CartService {
for (TbCashierCart cart : cashierCartList) {
// 设置用餐类型
cart.setUseType(shopEatTypeInfoDTO.getUseType());
// 设置打包费
if (shopEatTypeInfoDTO.isTakeout()) {
cart.setTableId("");
// 打包费
TbProduct product = productMapper.selectById(Integer.valueOf(cart.getProductId()));
cart.setPackFee(product.getPackFee() != null ?
product.getPackFee().multiply(BigDecimal.valueOf(cart.getNumber())) : BigDecimal.ZERO);
}else {
cart.setTableId(tableId);
cart.setPackFee(BigDecimal.ZERO);
}
if (cart.getIsVip().equals((byte) 1)) {
if (isVip) {
int i1 = activateInRecordService.queryByVipIdAndShopIdAndProId(

View File

@@ -897,7 +897,7 @@ public class ProductService {
.eq(TbCashierCart::getProductId, "-999")
.eq(TbCashierCart::getSkuId, "-999")
.eq(TbCashierCart::getStatus, "create")
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -3).getTime())
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
.and(r -> r.eq(TbCashierCart::getUserId, choseCountDTO.getUserId()).or().isNull(TbCashierCart::getUserId))
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
.eq(TbCashierCart::getTableId, choseCountDTO.getTableId());