1.数据报表导出cpu拉高问题修复
2.代客下单相关接口
This commit is contained in:
@@ -465,11 +465,14 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
}
|
||||
}
|
||||
|
||||
tbOrderSalesCountByDayVos.parallelStream().forEach(all -> {
|
||||
tbOrderSalesCountByDayVos.forEach(all -> {
|
||||
List<TbOrderSaleVO> tbOrderSaleVOS = saleOrderMap.get(all.getProductSkuId().toString());
|
||||
if (tbOrderSaleVOS == null) {
|
||||
return;
|
||||
}
|
||||
// List<TbOrderSaleVO> tbOrderSaleVOS = detailRepository.querySaleOrderInfo(new Timestamp(summaryDto.getStartTime().getTime()),
|
||||
// new Timestamp(summaryDto.getEndTime().getTime()), all.getProductId(), all.getProductSkuId(), Integer.valueOf(summaryDto.getShopId()));
|
||||
|
||||
for (TbOrderSaleVO tbOrderSaleVO : tbOrderSaleVOS) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("商品分类", all.getCateName());
|
||||
|
||||
@@ -17,10 +17,7 @@ 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.dto.shoptable.UpdateCartDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.*;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbCashierCartMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbProductMapper;
|
||||
@@ -31,8 +28,10 @@ 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.RedisUtils;
|
||||
import cn.ysk.cashier.utils.ValidationUtil;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.dianguang.cloud.ossservice.model.DateUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -42,6 +41,7 @@ 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.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -73,6 +73,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
private final TbCashierCartRepository cashierCartRepository;
|
||||
private final TbProductMapper productMapper;
|
||||
private final TbCashierCartMapper cashierCartMapper;
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
/**
|
||||
*桌码前缀
|
||||
@@ -302,6 +303,22 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
tbCashierCart.setCategoryId(product.getCategoryId());
|
||||
cashierCartRepository.save(tbCashierCart);
|
||||
}else {
|
||||
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()));
|
||||
|
||||
}
|
||||
|
||||
if (addCartDTO.isGift()) {
|
||||
tbCashierCart.setTotalAmount(BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
tbCashierCart.setIsPack(String.valueOf(addCartDTO.isPack()));
|
||||
tbCashierCart.setIsGift(String.valueOf(addCartDTO.isGift()));
|
||||
tbCashierCart.setTotalNumber(addCartDTO.getNum());
|
||||
tbCashierCart.setNumber(addCartDTO.getNum());
|
||||
// 数量0删除
|
||||
@@ -310,7 +327,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
return null;
|
||||
}
|
||||
tbCashierCart.setUpdatedAt(DateUtil.current());
|
||||
tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice()));
|
||||
cashierCartRepository.save(tbCashierCart);
|
||||
}
|
||||
|
||||
@@ -359,4 +375,77 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
}
|
||||
return cartPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pack(PackCartDTO packCartDTO) {
|
||||
List<TbCashierCart> tbCashierCarts = cashierCartMapper.selectList(new LambdaQueryWrapper<TbCashierCart>().eq(TbCashierCart::getTableId, packCartDTO.getTableId())
|
||||
.eq(TbCashierCart::getShopId, packCartDTO.getShopId())
|
||||
.eq(TbCashierCart::getStatus, "create"));
|
||||
tbCashierCarts.forEach(item -> {
|
||||
if (packCartDTO.getState().equals(0) && item.getIsPack().equals("true")) {
|
||||
item.setIsPack("false");
|
||||
item.setTotalAmount(item.getTotalAmount().subtract(item.getPackFee()));
|
||||
}else {
|
||||
item.setIsPack("true");
|
||||
item.setTotalAmount(item.getTotalAmount().add(item.getPackFee()));
|
||||
}
|
||||
cashierCartMapper.updateById(item);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createOrder(CreateOrderDTO createOrderDTO) {
|
||||
// 生成取餐码
|
||||
String day = DateUtils.getDay();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public synchronized String generateOrderCode(String day, String clientType, String shopId) {
|
||||
String code = redisUtils.get("SHOP:CODE:" + clientType + ":" + shopId + ":" + day)+"";
|
||||
// 使用顺序递增的计数器生成取餐码
|
||||
String orderCode = "";
|
||||
if (StringUtils.isEmpty(code) || "null".equals(code)) {
|
||||
orderCode = "1";
|
||||
redisUtils.set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day,"1");
|
||||
} else {
|
||||
orderCode =String.valueOf(Integer.parseInt(code)+1);
|
||||
}
|
||||
redisUtils.set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "#" + Integer.parseInt(code.replace("#", "")) + 2);
|
||||
boolean flag = redisUtils.setNx("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, orderCode);
|
||||
if (flag){
|
||||
return generateOrderCode(day,clientType,shopId);
|
||||
}
|
||||
// 增加计数器
|
||||
|
||||
return orderCode;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Object getMasterId(Long tableId, Integer shopId) {
|
||||
// String day = DateUtils.getDay();
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// String key="SHOP:CODE:USER:pc" + ":" + shopId + ":" + day + userId;
|
||||
// String userCode = redisUtils.get(key)+"";
|
||||
// if ("1".equals(type)) {
|
||||
// String code = "#" + generateOrderCode(day, clientType, shopId);
|
||||
// redisUtil.saveMessage(key, code);
|
||||
// jsonObject.put("code", code);
|
||||
// } else {
|
||||
// if (StringUtils.isEmpty(userCode)||"null".equals(userCode)||"#null".equals(userCode)) {
|
||||
// String code = "#" + generateOrderCode(day, clientType, shopId);
|
||||
// redisUtil.saveMessage(key, code);
|
||||
// jsonObject.put("code", code);
|
||||
// } else {
|
||||
// jsonObject.put("code", userCode);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public Object getMasterId(Long tableId, Integer shopId) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
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.dto.shoptable.UpdateCartDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.*;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import cn.ysk.cashier.dto.shop.TbShopTableDto;
|
||||
@@ -108,4 +105,10 @@ public interface TbShopTableService {
|
||||
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId);
|
||||
|
||||
TbCashierCart updateCart(UpdateCartDTO updateCartDTO);
|
||||
|
||||
void pack(PackCartDTO packCartDTO);
|
||||
|
||||
Object createOrder(CreateOrderDTO createOrderDTO);
|
||||
|
||||
Object getMasterId(Long tableId, Integer shopId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user