1.代客下单 添加购物车新增单品备注

This commit is contained in:
SongZhang 2024-09-12 14:38:45 +08:00
parent 5c2b995d1f
commit 0f9c370118
5 changed files with 22 additions and 10 deletions

View File

@ -25,5 +25,5 @@ public class AddCartDTO {
private boolean isPack; private boolean isPack;
private boolean isGift; private boolean isGift;
private Integer cartId; private Integer cartId;
private String note;
} }

View File

@ -157,6 +157,8 @@ public class TbCashierCart implements Serializable {
private String skuName; private String skuName;
@Column(name = "`place_num`") @Column(name = "`place_num`")
private Integer placeNum; private Integer placeNum;
@Column(name = "`note`")
private String note;
public void copy(TbCashierCart source){ public void copy(TbCashierCart source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));

View File

@ -113,6 +113,9 @@ public class TbOrderDetail implements Serializable {
@ApiModelProperty(value = "place_num") @ApiModelProperty(value = "place_num")
private Integer placeNum; private Integer placeNum;
@Column(name = "`note`")
private String note;
public void copy(TbOrderDetail source){ public void copy(TbOrderDetail source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
} }

View File

@ -28,7 +28,6 @@ import cn.ysk.cashier.enums.ShopWxMsgTypeEnum;
import cn.ysk.cashier.enums.TableStateEnum; import cn.ysk.cashier.enums.TableStateEnum;
import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.entity.TbShopOpenId; import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
import cn.ysk.cashier.mybatis.mapper.*; import cn.ysk.cashier.mybatis.mapper.*;
import cn.ysk.cashier.mybatis.service.MpShopTableService; import cn.ysk.cashier.mybatis.service.MpShopTableService;
import cn.ysk.cashier.pojo.TbShopPayType; import cn.ysk.cashier.pojo.TbShopPayType;
@ -49,7 +48,6 @@ import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
import cn.ysk.cashier.service.impl.TbPayServiceImpl; import cn.ysk.cashier.service.impl.TbPayServiceImpl;
import cn.ysk.cashier.utils.*; import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.vo.PendingCountVO; import cn.ysk.cashier.vo.PendingCountVO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -72,12 +70,12 @@ import org.springframework.data.domain.Pageable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.sql.Timestamp;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -437,9 +435,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
tbCashierCart.setTotalNumber(addCartDTO.getNum()); tbCashierCart.setTotalNumber(addCartDTO.getNum());
tbCashierCart.setNumber(addCartDTO.getNum()); tbCashierCart.setNumber(addCartDTO.getNum());
tbCashierCart.setCategoryId(product.getCategoryId()); tbCashierCart.setCategoryId(product.getCategoryId());
tbCashierCart.setNote(addCartDTO.getNote());
cashierCartRepository.save(tbCashierCart); cashierCartRepository.save(tbCashierCart);
} else { } else {
tbCashierCart.setNote(addCartDTO.getNote());
tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice())); tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice()));
if (!addCartDTO.isPack()) { if (!addCartDTO.isPack()) {
@ -619,7 +619,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
} }
@Override @Override
public com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> getCart(Long tableId, Integer page, public Map<String, Object> getCart(Long tableId, Integer page,
Integer size, Integer shopId, Integer vipUserId, String masterId) { Integer size, Integer shopId, Integer vipUserId, String masterId) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>() LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getTableId, tableId) .eq(TbCashierCart::getTableId, tableId)
@ -653,6 +653,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}); });
AtomicReference<TbCashierCart> mealCashierCart = new AtomicReference<>();
if (!skuIds.isEmpty()) { if (!skuIds.isEmpty()) {
List<TbProductSku> skuList = productSkuRepository.findAllById(skuIds); List<TbProductSku> skuList = productSkuRepository.findAllById(skuIds);
HashMap<String, TbProductSku> skuMap = new HashMap<>(); HashMap<String, TbProductSku> skuMap = new HashMap<>();
@ -660,6 +661,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
ArrayList<Map<String, Object>> infos = new ArrayList<>(); ArrayList<Map<String, Object>> infos = new ArrayList<>();
records.forEach(item -> { records.forEach(item -> {
if (item.getProductId().equals("-999")) {
mealCashierCart.set(item);
return;
}
Map<String, Object> map = BeanUtil.beanToMap(item, false, false); Map<String, Object> map = BeanUtil.beanToMap(item, false, false);
TbProductSku tbProductSku = skuMap.get(item.getSkuId()); TbProductSku tbProductSku = skuMap.get(item.getSkuId());
map.put("specSnap", tbProductSku != null ? tbProductSku.getSpecSnap() : null); map.put("specSnap", tbProductSku != null ? tbProductSku.getSpecSnap() : null);
@ -681,10 +686,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
list.add(item); list.add(item);
}); });
copyPage.setRecords(list); copyPage.setRecords(list);
return copyPage; Map<String, Object> map = BeanUtil.beanToMap(copyPage, false, false);
map.put("seatFee", mealCashierCart);
return map;
} }
return cartPage; return BeanUtil.beanToMap(cartPage);
} }
@Override @Override
@ -1051,6 +1058,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
orderDetail.setProductSkuName(productSku.getSpecSnap()); orderDetail.setProductSkuName(productSku.getSpecSnap());
} }
orderDetail.setNote(cashierCart.getNote());
orderDetail.setCreateTime(DateUtil.date().toTimestamp()); orderDetail.setCreateTime(DateUtil.date().toTimestamp());
orderDetail.setNum(cashierCart.getNumber()); orderDetail.setNum(cashierCart.getNumber());
orderDetail.setPrice(cashierCart.getSalePrice()); orderDetail.setPrice(cashierCart.getSalePrice());

View File

@ -21,7 +21,6 @@ import cn.ysk.cashier.pojo.shop.TbShopTable;
import cn.ysk.cashier.dto.shop.TbShopTableDto; import cn.ysk.cashier.dto.shop.TbShopTableDto;
import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria; import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
@ -105,7 +104,7 @@ public interface TbShopTableService {
void clearCart(ClearCartDTO clearCartDTO); void clearCart(ClearCartDTO clearCartDTO);
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId, String masterId); Map<String, Object> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId, String masterId);
TbCashierCart updateCart(UpdateCartDTO updateCartDTO); TbCashierCart updateCart(UpdateCartDTO updateCartDTO);