1.通知中心相关接口

2.代客下单
This commit is contained in:
2024-08-12 14:55:21 +08:00
parent 220c717085
commit 0e9996bcf0
40 changed files with 1355 additions and 59 deletions

View File

@@ -352,7 +352,7 @@ public class StockServiceImpl implements StockService {
TbProductSku tbProductSku = tbProductSkuRepository.findById(Integer.valueOf(updateValueVO.getTargetId())).orElse(null);
// 推送微信操作消息
if (product != null && tbProductSku != null) {
wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭sku售罄: " : "开启sku售罄: ") + product.getName() + "/"+ tbProductSku.getSpecSnap());
wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭售罄: " : "开启售罄: ") + product.getName() + "/"+ tbProductSku.getSpecSnap(), Integer.valueOf(updateValueVO.getShopId()));
}else {
log.warn("推送微信操作消息失败未查询到商品信息skuId: {}", updateValueVO.getTargetId());
}
@@ -368,7 +368,7 @@ public class StockServiceImpl implements StockService {
TbProduct product1 = tbProductRepository.selectBySkuId(Integer.valueOf(updateValueVO.getTargetId()));
// 推送微信操作消息
if (product1 != null) {
wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭售罄: " : "开启售罄: ") + product1.getName());
wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭售罄: " : "开启售罄: ") + product1.getName(), Integer.valueOf(updateValueVO.getShopId()));
}else {
log.warn("推送微信操作消息失败未查询到商品信息skuId: {}", updateValueVO.getTargetId());
}
@@ -410,7 +410,7 @@ public class StockServiceImpl implements StockService {
TbProduct product = tbProductRepository.selectByShopIdAndId(Integer.parseInt(tbProductSku.getProductId()), String.valueOf(shopId));
// 推送微信操作消息
wxMsgUtils.aboardOperationMsg((isGrounding ? "上架商品: " : "下架商品: ") + product.getName());
wxMsgUtils.aboardOperationMsg((isGrounding ? "上架商品: " : "下架商品: ") + product.getName(), shopId);
// 共享库存下架所有sku
if (product.getIsDistribute().equals(1)) {
tbProductSkuRepository.updateGroundingByProId(product.getId().toString(), isGrounding ? 1 : 0);

View File

@@ -96,18 +96,22 @@ public class TbProductGroupServiceImpl implements TbProductGroupService {
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TbProductGroup resources) {
TbProductGroup tbProductGroup = tbProductGroupRepository.findById(resources.getId()).orElseGet(TbProductGroup::new);
// TbProductGroup byName = tbProductGroupRepository.findByName(resources.getName(), resources.getShopId());
// if (byName != null){
// throw new BadRequestException("名称重复");
// }
// 推送微信操作消息
if (!tbProductGroup.getIsShow().equals(resources.getIsShow())) {
wxMsgUtils.aboardOperationMsg((resources.getIsShow() == 0 ? "关闭分组: " : "开启分组: ") + tbProductGroup.getName(), resources.getShopId());
}
tbProductGroup.setUpdatedAt(Instant.now().toEpochMilli());
ValidationUtil.isNull( tbProductGroup.getId(),"TbProductGroup","id",resources.getId());
tbProductGroup.copy(resources);
tbProductGroupRepository.save(tbProductGroup);
// 推送微信操作消息
wxMsgUtils.aboardOperationMsg((resources.getIsShow() == 0 ? "关闭分组: " : "开启分组: ") + tbProductGroup.getName());
}
@Transactional(rollbackFor = Exception.class)

View File

@@ -2,6 +2,7 @@ package cn.ysk.cashier.service.impl.productimpl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.dto.TbPlatformDictDto;
import cn.ysk.cashier.dto.product.TbProductDto;
import cn.ysk.cashier.dto.product.TbProductQueryCriteria;
@@ -11,6 +12,7 @@ import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mapper.product.TbProductMapper;
import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
import cn.ysk.cashier.mybatis.entity.TagProductDepts;
import cn.ysk.cashier.mybatis.mapper.TbProducSkutMapper;
import cn.ysk.cashier.mybatis.service.TagProductDeptsService;
import cn.ysk.cashier.pojo.product.*;
import cn.ysk.cashier.pojo.shop.TbPurchaseNotice;
@@ -25,6 +27,9 @@ import cn.ysk.cashier.service.shop.TbCouponCategoryService;
import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.vo.TbProductVo;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -70,6 +75,10 @@ public class TbProductServiceImpl implements TbProductService {
private final TbPlatformDictService tbPlatformDictService;
private final TagProductDeptsService tagProductService;
private final TbPurchaseNoticeRepository noticeRepository;
private final TbProducSkutMapper producSkutMapper;
private final cn.ysk.cashier.mybatis.mapper.TbProductMapper productMapper;
private final TbProductSkuResultRepository productSkuResultRepository;
private final RedisUtils redisUtils;
@@ -695,4 +704,111 @@ public class TbProductServiceImpl implements TbProductService {
tbProductSkuRepository.incrStock(productSkuId, Double.valueOf(num));
}
}
@Override
public Object activateProduct(Integer page, Integer size, Integer categoryId, Integer shopId, Integer productId) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbProduct> page1 = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size);
QueryWrapper<TbProduct> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("is_del", 0)
.eq("shop_id", shopId)
.eq("is_delete", 0)
.eq("status", 1)
.eq("is_pause_sale", 0);
// 查询skuResult
ArrayList<Map<String, Object>> infoList = new ArrayList<>();
if (categoryId != null) {
queryWrapper.eq("category_id", categoryId);
}
if (productId != null) {
queryWrapper.eq("id", productId);
}
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbProduct> tbProductPage = productMapper.selectPage(page1, queryWrapper);
tbProductPage.getRecords().stream().parallel().forEach(item -> {
TbProductSkuResult skuResult = productSkuResultRepository.findById(item.getId()).orElse(null);
List<TbProductSku> tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper<TbProductSku>().eq(TbProductSku::getIsDel, 0)
.eq(TbProductSku::getIsPauseSale, 0)
.eq(TbProductSku::getProductId, item.getId())
.eq(TbProductSku::getIsGrounding, 1)
.select(TbProductSku::getId, TbProductSku::getSpecSnap, TbProductSku::getStockNumber, TbProductSku::getSalePrice, TbProductSku::getSuit));
String tagSnap = null;
if (skuResult != null) {
tagSnap = skuResult.getTagSnap();
}
List<String> result = new ArrayList<>();
if (StrUtil.isNotBlank(tagSnap)) {
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
List<List<String>> valuesList = new ArrayList<>();
// 提取所有 value 的列表
for (int i = 0; i < tagSnaps.size(); i++) {
JSONObject jsonObject = tagSnaps.getJSONObject(i);
String[] values = jsonObject.getString("value").split(",");
valuesList.add(Arrays.asList(values));
}
// 生成所有可能的排列组合
generateCombinations(valuesList, 0, new ArrayList<>(), result);
}
ArrayList<Map<String, Object>> specList = new ArrayList<>();
tbProductSkus.forEach(item2 -> {
Map<String, Object> itemMap = BeanUtil.beanToMap(item2, false, true);
if (item.getIsDistribute().equals(1)) {
itemMap.put("stockNumber", item.getStockNumber());
}else {
itemMap.put("stockNumber", item2.getStockNumber());
}
specList.add(itemMap);
});
ArrayList<HashMap<String, Object>> otherVal = new ArrayList<>();
for (String res : result) {
boolean found = false;
for (Map<String, Object> spec : specList) {
if (res.equals(spec.get("specSnap").toString())) {
spec.put("isGrounding", true);
found = true;
break;
}
}
if (!found) {
HashMap<String, Object> itemMap = new HashMap<>();
itemMap.put("specSnap", res);
itemMap.put("skuId", null);
itemMap.put("isGrounding", false);
otherVal.add(itemMap);
}
}
specList.addAll(otherVal);
Map<String, Object> map = BeanUtil.beanToMap(item, false, false);
map.put("skuResult", skuResult);
map.put("specList", specList);
infoList.add(map);
});
Map<String, Object> map = BeanUtil.beanToMap(tbProductPage, false, false);
map.put("records", infoList);
return map;
}
private static void generateCombinations(List<List<String>> valuesList, int index, List<String> current, List<String> result) {
if (index == valuesList.size()) {
result.add(String.join(",", current));
return;
}
for (String value : valuesList.get(index)) {
current.add(value);
generateCombinations(valuesList, index + 1, current, result);
current.remove(current.size() - 1); // 回溯
}
}
}

View File

@@ -0,0 +1,139 @@
package cn.ysk.cashier.service.impl.shopimpl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.ysk.cashier.dto.shop.ShopInfoUpdateDTO;
import cn.ysk.cashier.dto.shop.ShopMsgRemoveDTO;
import cn.ysk.cashier.dto.shop.ShopMsgStateDTO;
import cn.ysk.cashier.mybatis.entity.TbShopMsgState;
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
import cn.ysk.cashier.mybatis.mapper.TbShopOpenIdMapper;
import cn.ysk.cashier.mybatis.service.TbShopMsgStateService;
import cn.ysk.cashier.pojo.shop.TbFullShopId;
import cn.ysk.cashier.service.shop.MsgService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@Service
public class MsgServiceImpl implements MsgService {
private final TbShopOpenIdMapper shopOpenIdMapper;
private final TbShopMsgStateService shopMsgStateService;
public MsgServiceImpl(TbShopOpenIdMapper shopOpenIdMapper, TbShopMsgStateService shopMsgStateService) {
this.shopOpenIdMapper = shopOpenIdMapper;
this.shopMsgStateService = shopMsgStateService;
}
@Override
public Page<TbFullShopId> all(Integer page, Integer size, Integer shopId, String nickName, String openId, Integer state, Integer type) {
LambdaQueryWrapper<TbShopOpenId> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TbShopOpenId::getShopId, shopId);
return shopOpenIdMapper.selectAll(shopId, nickName, openId, new Page<>(page, size));
}
@Override
public Optional<Boolean> updateShopState(ShopMsgStateDTO shopMsgStateDTO) {
TbShopOpenId shopOpenId = new TbShopOpenId();
shopOpenId.setStatus(shopMsgStateDTO.getState());
LambdaQueryWrapper<TbShopOpenId> queryWrapper = new LambdaQueryWrapper<TbShopOpenId>().eq(TbShopOpenId::getShopId, shopMsgStateDTO.getShopId());
if (shopMsgStateDTO.getType() != null) {
queryWrapper.eq(TbShopOpenId::getType, shopMsgStateDTO.getType());
}
if (shopMsgStateDTO.getType() == null) {
shopMsgStateDTO.setType(-1);
}
TbShopMsgState msgState = shopMsgStateService.lambdaQuery().eq(TbShopMsgState::getType, shopMsgStateDTO.getType())
.eq(TbShopMsgState::getShopId, shopMsgStateDTO.getShopId()).one();
if (msgState == null) {
msgState = new TbShopMsgState();
msgState.setShopId(shopMsgStateDTO.getShopId());
msgState.setCreateTime(DateUtil.date().toInstant());
msgState.setState(shopMsgStateDTO.getType());
shopMsgStateService.save(msgState);
}else {
shopMsgStateService.lambdaUpdate().eq(TbShopMsgState::getShopId, shopMsgStateDTO.getShopId())
.eq(TbShopMsgState::getType, shopMsgStateDTO.getType())
.set(TbShopMsgState::getState, shopMsgStateDTO.getState())
.set(TbShopMsgState::getUpdateTime, DateUtil.date().toInstant()).update();
}
return Optional.of(shopOpenIdMapper.update(shopOpenId, queryWrapper) > 0);
}
@Override
public Optional<Boolean> removeSubUser(ShopMsgRemoveDTO shopMsgRemoveDTO) {
int delete = shopOpenIdMapper.delete(new LambdaQueryWrapper<TbShopOpenId>().eq(TbShopOpenId::getShopId, shopMsgRemoveDTO.getShopId())
.eq(TbShopOpenId::getOpenId, shopMsgRemoveDTO.getOpenId()));
return Optional.of(delete > 0);
}
@Override
public Optional<Boolean> updateInfo(ShopInfoUpdateDTO shopInfoUpdateDTO) {
TbShopOpenId shopOpenId = new TbShopOpenId();
if (StrUtil.isNotBlank(shopInfoUpdateDTO.getNote())) {
shopOpenId.setNote(shopInfoUpdateDTO.getNote());
}
if (shopInfoUpdateDTO.getState() != null) {
shopOpenId.setStatus(shopInfoUpdateDTO.getState());
}
if (shopInfoUpdateDTO.getType() != null) {
shopOpenId.setType(shopInfoUpdateDTO.getType());
}
if (StrUtil.isNotBlank(shopInfoUpdateDTO.getNickName())) {
shopOpenId.setNickname(shopInfoUpdateDTO.getNickName());
}
if (StrUtil.isNotBlank(shopInfoUpdateDTO.getAvatar())) {
shopOpenId.setAvatar(shopInfoUpdateDTO.getAvatar());
}
if (BeanUtil.isNotEmpty(shopOpenId)) {
shopOpenIdMapper.update(shopOpenId, new LambdaQueryWrapper<TbShopOpenId>()
.eq(TbShopOpenId::getOpenId, shopInfoUpdateDTO.getOpenId())
.eq(TbShopOpenId::getType, shopInfoUpdateDTO.getType())
.eq(TbShopOpenId::getShopId, shopInfoUpdateDTO.getShopId()));
}
return Optional.of( true);
}
private static final HashMap<String, String> MSG_TYPE = new HashMap<>();
static {
MSG_TYPE.put("0", "stockState");
MSG_TYPE.put("1", "conState");
MSG_TYPE.put("2", "opeState");
MSG_TYPE.put("-1", "allState");
}
@Override
public HashMap<String, Object> getInfo(Integer shopId, Integer type) {
List<TbShopMsgState> list = shopMsgStateService.lambdaQuery().eq(TbShopMsgState::getShopId, shopId).list();
HashMap<String, Object> data = new HashMap<>();
MSG_TYPE.forEach((k, v) -> {
TbShopMsgState have = null;
for (TbShopMsgState tbShopMsgState : list) {
if (tbShopMsgState.getType().equals(Integer.valueOf(k))) {
have = tbShopMsgState;
break;
}
}
if (have == null) {
TbShopMsgState msgState = new TbShopMsgState();
msgState.setShopId(shopId);
msgState.setCreateTime(DateUtil.date().toInstant());
msgState.setType(Integer.valueOf(k));
msgState.setState(0);
shopMsgStateService.save(msgState);
}
data.put(v, have != null ? have.getState() : 0);
});
return data;
}
}

View File

@@ -15,10 +15,25 @@
*/
package cn.ysk.cashier.service.impl.shopimpl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.ysk.cashier.dto.shoptable.AddCartDTO;
import cn.ysk.cashier.dto.shoptable.ClearCartDTO;
import cn.ysk.cashier.dto.shoptable.RemoveCartDTO;
import cn.ysk.cashier.exception.BadRequestException;
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
import cn.ysk.cashier.mybatis.mapper.TbProductMapper;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.product.TbProduct;
import cn.ysk.cashier.pojo.product.TbProductSku;
import cn.ysk.cashier.pojo.shop.TbShopTable;
import cn.ysk.cashier.repository.order.TbCashierCartRepository;
import cn.ysk.cashier.repository.product.TbProductRepository;
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
import cn.ysk.cashier.utils.ValidationUtil;
import cn.ysk.cashier.utils.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dianguang.cloud.ossservice.model.DateUtils;
import lombok.RequiredArgsConstructor;
import cn.ysk.cashier.repository.shop.TbShopTableRepository;
import cn.ysk.cashier.service.shop.TbShopTableService;
@@ -26,12 +41,14 @@ import cn.ysk.cashier.dto.shop.TbShopTableDto;
import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria;
import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import cn.ysk.cashier.utils.QueryHelp;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.*;
import java.io.IOException;
@@ -50,6 +67,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
private final TbShopTableRepository tbShopTableRepository;
private final TbShopTableMapper tbShopTableMapper;
private final TbProductRepository productRepository;
private final TbProductSkuRepository productSkuRepository;
private final TbCashierCartRepository cashierCartRepository;
private final TbProductMapper productMapper;
private final TbCashierCartMapper cashierCartMapper;
/**
*桌码前缀
@@ -79,14 +101,18 @@ public class TbShopTableServiceImpl implements TbShopTableService {
criteria.setAreaId(null);
}
List<TbShopTable> tbShopTableList = tbShopTableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder));
ArrayList<Map<String, Object>> infoList = new ArrayList<>();
for (TbShopTable date : tbShopTableList) {
Map<String, Object> itemMap = BeanUtil.beanToMap(date, false, false);
if (!"".equals(date.getQrcode())){
date.setQrcode(QRCODE+date.getQrcode().trim());
itemMap.put("qrcode",QRCODE+date.getQrcode().trim());
itemMap.put("tableId",date.getQrcode());
}
infoList.add(itemMap);
}
int i = tbShopTableRepository.countAllByShopId(criteria.getShopId());
HashMap<String, Object> map = new HashMap<>();
map.put("content",tbShopTableList);
map.put("content",infoList);
map.put("total",i);
return map;
}
@@ -174,4 +200,112 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
FileUtil.downloadExcel(list, response);
}
@Override
public void addCartForUser(AddCartDTO addCartDTO) {
TbProductSku productSku = productMapper.selectSkuByIdAndShopId(addCartDTO.getShopId(), addCartDTO.getSkuId());
TbProduct product = productMapper.selectByIdAndShopId(addCartDTO.getShopId(), addCartDTO.getProductId());
if (product == null || productSku == null) {
throw new BadRequestException("商品不存在或已下架, id: " + addCartDTO.getSkuId());
}
if ((product.getIsDistribute().equals(1) && product.getStockNumber() < 1 )
|| (!product.getIsDistribute().equals(1) && productSku.getStockNumber() < 1)
) {
throw new BadRequestException("商品库存不足");
}
TbShopTable shopTable = tbShopTableRepository.findByQrcode(addCartDTO.getTableId());
if (shopTable == null) {
throw new BadRequestException("桌码不存在,桌码" + addCartDTO.getTableId());
}
TbCashierCart tbCashierCart = cashierCartRepository.selectActivateBySkuId(String.valueOf(addCartDTO.getSkuId()), String.valueOf(addCartDTO.getShopId()), Long.valueOf(addCartDTO.getTableId()));
// 首次加入
if (tbCashierCart == null) {
tbCashierCart = new TbCashierCart();
tbCashierCart.setCoverImg(product.getCoverImg());
tbCashierCart.setCreatedAt(System.currentTimeMillis());
tbCashierCart.setIsSku(product.getTypeEnum());
tbCashierCart.setTableId(Long.valueOf(addCartDTO.getTableId()));
tbCashierCart.setName(product.getName());
tbCashierCart.setProductId(String.valueOf(product.getId()));
tbCashierCart.setSalePrice(productSku.getSalePrice());
tbCashierCart.setSkuId(productSku.getId().toString());
tbCashierCart.setShopId(String.valueOf(addCartDTO.getShopId()));
tbCashierCart.setTradeDay(DateUtils.getDay());
tbCashierCart.setStatus("create");
tbCashierCart.setIsPack(String.valueOf(false));
tbCashierCart.setIsGift(String.valueOf(false));
tbCashierCart.setSalePrice(productSku.getSalePrice());
tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice()));
if (!addCartDTO.isPack()){
tbCashierCart.setPackFee(BigDecimal.ZERO);
}else {
tbCashierCart.setPackFee(new BigDecimal(addCartDTO.getNum()).multiply(product.getPackFee()));
tbCashierCart.setTotalAmount(tbCashierCart.getTotalAmount().add(tbCashierCart.getPackFee()));
}
tbCashierCart.setTotalNumber(addCartDTO.getNum());
tbCashierCart.setNumber(addCartDTO.getNum());
tbCashierCart.setCategoryId(product.getCategoryId());
cashierCartRepository.save(tbCashierCart);
}else {
tbCashierCart.setTotalNumber(addCartDTO.getNum());
tbCashierCart.setNumber(addCartDTO.getNum());
// 数量0删除
if (tbCashierCart.getNumber() == 0) {
cashierCartRepository.deleteById(tbCashierCart.getId());
return;
}
tbCashierCart.setUpdatedAt(DateUtil.current());
tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice()));
cashierCartRepository.save(tbCashierCart);
}
}
@Override
public void removeCart(RemoveCartDTO removeCartDTO) {
cashierCartRepository.deleteByIdAndShopId(String.valueOf(removeCartDTO.getShopId()), removeCartDTO.getCartId(), removeCartDTO.getTableId());
}
@Override
public void clearCart(ClearCartDTO clearCartDTO) {
tbShopTableRepository.deleteByTableIdAndShopId(clearCartDTO.getTableId(), clearCartDTO.getShopId());
}
@Override
public com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> cartPage = cashierCartMapper.selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size), new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getStatus, "create")
.eq(TbCashierCart::getShopId, shopId));
List<TbCashierCart> records = cartPage.getRecords();
ArrayList<Integer> skuIds = new ArrayList<>();
records.forEach(item -> {
skuIds.add(Integer.valueOf(item.getSkuId()));
});
if (!skuIds.isEmpty()) {
List<TbProductSku> skuList = productSkuRepository.findAllById(skuIds);
HashMap<String, TbProductSku> skuMap = new HashMap<>();
skuList.forEach(item -> skuMap.put(item.getId().toString(), item));
ArrayList<Map<String, Object>> infos = new ArrayList<>();
records.forEach(item -> {
Map<String, Object> map = BeanUtil.beanToMap(item, false, false);
TbProductSku tbProductSku = skuMap.get(item.getSkuId());
map.put("specSnap", tbProductSku != null ? tbProductSku.getSpecSnap() : null);
infos.add(map);
});
com.baomidou.mybatisplus.extension.plugins.pagination.Page copyPage = BeanUtil.copyProperties(cartPage, com.baomidou.mybatisplus.extension.plugins.pagination.Page.class);
copyPage.setRecords(infos);
return copyPage;
}
return cartPage;
}
}

View File

@@ -104,4 +104,6 @@ public interface TbProductService {
* @param num 数量
*/
void returnStockByPro(Integer productId, Integer productSkuId, Integer num);
Object activateProduct(Integer page, Integer size, Integer categoryId, Integer shopId, Integer productId);
}

View File

@@ -0,0 +1,23 @@
package cn.ysk.cashier.service.shop;
import cn.ysk.cashier.dto.shop.ShopInfoUpdateDTO;
import cn.ysk.cashier.dto.shop.ShopMsgRemoveDTO;
import cn.ysk.cashier.dto.shop.ShopMsgStateDTO;
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
import cn.ysk.cashier.pojo.shop.TbFullShopId;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.HashMap;
import java.util.Optional;
public interface MsgService {
Page<TbFullShopId> all(Integer page, Integer size, Integer shopId, String nickName, String openId, Integer state, Integer type);
Optional<Boolean> updateShopState(ShopMsgStateDTO shopMsgStateDTO);
Optional<Boolean> removeSubUser(ShopMsgRemoveDTO shopMsgRemoveDTO);
Optional<Boolean> updateInfo(ShopInfoUpdateDTO shopInfoUpdateDTO);
HashMap<String, Object> getInfo(Integer shopId, Integer type);
}

View File

@@ -15,9 +15,14 @@
*/
package cn.ysk.cashier.service.shop;
import cn.ysk.cashier.dto.shoptable.AddCartDTO;
import cn.ysk.cashier.dto.shoptable.ClearCartDTO;
import cn.ysk.cashier.dto.shoptable.RemoveCartDTO;
import cn.ysk.cashier.pojo.order.TbCashierCart;
import cn.ysk.cashier.pojo.shop.TbShopTable;
import cn.ysk.cashier.dto.shop.TbShopTableDto;
import cn.ysk.cashier.dto.shop.TbShopTableQueryCriteria;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
@@ -92,4 +97,12 @@ public interface TbShopTableService {
* @throws IOException /
*/
void download(List<TbShopTableDto> all, HttpServletResponse response) throws IOException;
void addCartForUser(AddCartDTO addCartDTO);
void removeCart(RemoveCartDTO removeCartDTO);
void clearCart(ClearCartDTO clearCartDTO);
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId);
}