扫码点餐部分 商品循环数据问题
This commit is contained in:
@@ -135,212 +135,21 @@ public class ProductService {
|
|||||||
Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null;
|
Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null;
|
||||||
//招牌菜
|
//招牌菜
|
||||||
List<TbProduct> tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId));
|
List<TbProduct> tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId));
|
||||||
if (ObjectUtil.isNotEmpty(tbProducts) && tbProducts.size() > 0) {
|
concurrentMap.put("hots", handleDate(tbProducts));
|
||||||
tbProducts.parallelStream().forEach(it -> {
|
|
||||||
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
|
|
||||||
it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : "");
|
|
||||||
it.setCartNumber("0");
|
|
||||||
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
|
||||||
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
|
||||||
|
|
||||||
// 上下架对应的sku
|
|
||||||
HashSet<String> specSet = new HashSet<>();
|
|
||||||
AtomicDouble sum = new AtomicDouble(0.0);
|
|
||||||
BigDecimal lowerPrice = null;
|
|
||||||
for (TbProductSku item : tbProductSkus) {
|
|
||||||
if (item.getRealSalesNumber() != null) {
|
|
||||||
sum.addAndGet(item.getRealSalesNumber());
|
|
||||||
}
|
|
||||||
if (lowerPrice == null || lowerPrice.compareTo(item.getSalePrice()) > 0) {
|
|
||||||
lowerPrice = item.getSalePrice();
|
|
||||||
}
|
|
||||||
|
|
||||||
String specSnap = item.getSpecSnap();
|
|
||||||
if (specSnap != null) {
|
|
||||||
specSet.addAll(Arrays.asList(specSnap.split(",")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it.setStockNumber(sum.intValue());
|
|
||||||
if (lowerPrice == null) {
|
|
||||||
lowerPrice = BigDecimal.ZERO;
|
|
||||||
}
|
|
||||||
it.setLowPrice(lowerPrice);
|
|
||||||
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
|
|
||||||
if (tagSnap != null) {
|
|
||||||
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
|
|
||||||
JSONObject snapJSON;
|
|
||||||
JSONArray finalSnap = new JSONArray();
|
|
||||||
for (Object snap : tagSnaps) {
|
|
||||||
snapJSON = (JSONObject) snap;
|
|
||||||
String values = snapJSON.getString("value");
|
|
||||||
String finalValues = "";
|
|
||||||
if (StrUtil.isNotBlank(values)) {
|
|
||||||
String[] valueList = values.split(",");
|
|
||||||
for (String value : valueList) {
|
|
||||||
if (specSet.contains(value)) {
|
|
||||||
finalValues = finalValues + (value) + ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StrUtil.isNotBlank(finalValues)) {
|
|
||||||
finalValues = StrUtil.removeSuffix(finalValues, ",");
|
|
||||||
snapJSON.put("value", finalValues);
|
|
||||||
finalSnap.add(snapJSON);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
skuResult.setTagSnap(finalSnap.toJSONString());
|
|
||||||
}
|
|
||||||
it.setProductSkuResult(skuResult);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
concurrentMap.put("hots", tbProducts);
|
|
||||||
List<TbProductGroup> groupList = tbProductGroupMapper.selectByShopId(shopId, id);
|
List<TbProductGroup> groupList = tbProductGroupMapper.selectByShopId(shopId, id);
|
||||||
if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) {
|
if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) {
|
||||||
//热销
|
//热销
|
||||||
TbProductGroup hot = new TbProductGroup();
|
TbProductGroup hot = new TbProductGroup();
|
||||||
hot.setName("热销");
|
hot.setName("热销");
|
||||||
List<TbProduct> hots = tbProductMapper.selectHot(shopId);
|
List<TbProduct> hots = tbProductMapper.selectHot(shopId);
|
||||||
hots.parallelStream().forEach(it -> {
|
hot.setProducts(handleDate(hots));
|
||||||
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
|
|
||||||
it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : "");
|
|
||||||
it.setCartNumber("0");
|
|
||||||
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
|
||||||
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
|
||||||
|
|
||||||
// 上下架对应的sku
|
|
||||||
HashSet<String> specSet = new HashSet<>();
|
|
||||||
AtomicDouble sum = new AtomicDouble(0.0);
|
|
||||||
BigDecimal lowerPrice = null;
|
|
||||||
for (TbProductSku item : tbProductSkus) {
|
|
||||||
if (item.getRealSalesNumber() != null) {
|
|
||||||
sum.addAndGet(item.getRealSalesNumber());
|
|
||||||
}
|
|
||||||
if (lowerPrice == null || lowerPrice.compareTo(item.getSalePrice()) > 0) {
|
|
||||||
lowerPrice = item.getSalePrice();
|
|
||||||
}
|
|
||||||
|
|
||||||
String specSnap = item.getSpecSnap();
|
|
||||||
if (specSnap != null) {
|
|
||||||
specSet.addAll(Arrays.asList(specSnap.split(",")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it.setStockNumber(sum.intValue());
|
|
||||||
if (lowerPrice == null) {
|
|
||||||
lowerPrice = BigDecimal.ZERO;
|
|
||||||
}
|
|
||||||
it.setLowPrice(lowerPrice);
|
|
||||||
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
|
|
||||||
if (tagSnap != null) {
|
|
||||||
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
|
|
||||||
JSONObject snapJSON;
|
|
||||||
|
|
||||||
JSONArray finalSnap = new JSONArray();
|
|
||||||
|
|
||||||
for (Object snap : tagSnaps) {
|
|
||||||
snapJSON = (JSONObject) snap;
|
|
||||||
String values = snapJSON.getString("value");
|
|
||||||
String finalValues = "";
|
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(values)) {
|
|
||||||
String[] valueList = values.split(",");
|
|
||||||
for (String value : valueList) {
|
|
||||||
if (specSet.contains(value)) {
|
|
||||||
finalValues = finalValues + (value) + ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(finalValues)) {
|
|
||||||
finalValues = StrUtil.removeSuffix(finalValues, ",");
|
|
||||||
snapJSON.put("value", finalValues);
|
|
||||||
finalSnap.add(snapJSON);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
skuResult.setTagSnap(finalSnap.toJSONString());
|
|
||||||
}
|
|
||||||
|
|
||||||
it.setProductSkuResult(skuResult);
|
|
||||||
});
|
|
||||||
hot.setProducts(hots);
|
|
||||||
//商品
|
//商品
|
||||||
groupList.parallelStream().forEach(g -> {
|
groupList.parallelStream().forEach(g -> {
|
||||||
String in = g.getProductIds().substring(1, g.getProductIds().length() - 1);
|
String in = g.getProductIds().substring(1, g.getProductIds().length() - 1);
|
||||||
|
|
||||||
|
|
||||||
if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) {
|
if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) {
|
||||||
// List<TbProduct> products = tbProductMapper.selectByIdIn(in);
|
// List<TbProduct> products = tbProductMapper.selectByIdIn(in);
|
||||||
List<TbProduct> products = tbProductMapper.selectByIdInAndCheck(in);
|
List<TbProduct> products = tbProductMapper.selectByIdInAndCheck(in);
|
||||||
if (ObjectUtil.isNotEmpty(products) && products.size() > 0) {
|
g.setProducts(handleDate(products));
|
||||||
products.parallelStream().forEach(it -> {
|
|
||||||
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
|
|
||||||
it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : "");
|
|
||||||
it.setCartNumber("0");
|
|
||||||
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
|
||||||
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
|
||||||
|
|
||||||
// 上下架对应的sku
|
|
||||||
HashSet<String> specSet = new HashSet<>();
|
|
||||||
AtomicDouble sum = new AtomicDouble(0.0);
|
|
||||||
BigDecimal lowerPrice = null;
|
|
||||||
for (TbProductSku item : tbProductSkus) {
|
|
||||||
if (item.getRealSalesNumber() != null) {
|
|
||||||
sum.addAndGet(item.getRealSalesNumber());
|
|
||||||
}
|
|
||||||
if (lowerPrice == null || lowerPrice.compareTo(item.getSalePrice()) > 0) {
|
|
||||||
lowerPrice = item.getSalePrice();
|
|
||||||
}
|
|
||||||
|
|
||||||
String specSnap = item.getSpecSnap();
|
|
||||||
if (specSnap != null) {
|
|
||||||
specSet.addAll(Arrays.asList(specSnap.split(",")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it.setStockNumber(sum.intValue());
|
|
||||||
if (lowerPrice == null) {
|
|
||||||
lowerPrice = BigDecimal.ZERO;
|
|
||||||
}
|
|
||||||
it.setLowPrice(lowerPrice);
|
|
||||||
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
|
|
||||||
if (tagSnap != null) {
|
|
||||||
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
|
|
||||||
JSONObject snapJSON;
|
|
||||||
|
|
||||||
JSONArray finalSnap = new JSONArray();
|
|
||||||
|
|
||||||
for (Object snap : tagSnaps) {
|
|
||||||
snapJSON = (JSONObject) snap;
|
|
||||||
String values = snapJSON.getString("value");
|
|
||||||
String finalValues = "";
|
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(values)) {
|
|
||||||
String[] valueList = values.split(",");
|
|
||||||
for (String value : valueList) {
|
|
||||||
if (specSet.contains(value)) {
|
|
||||||
finalValues = finalValues + (value) + ",";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(finalValues)) {
|
|
||||||
finalValues = StrUtil.removeSuffix(finalValues, ",");
|
|
||||||
snapJSON.put("value", finalValues);
|
|
||||||
finalSnap.add(snapJSON);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
skuResult.setTagSnap(finalSnap.toJSONString());
|
|
||||||
}
|
|
||||||
|
|
||||||
it.setProductSkuResult(skuResult);
|
|
||||||
});
|
|
||||||
g.setProducts(products);
|
|
||||||
} else {
|
|
||||||
g.setProducts(new ArrayList<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
g.setProducts(new ArrayList<>());
|
g.setProducts(new ArrayList<>());
|
||||||
}
|
}
|
||||||
@@ -353,6 +162,75 @@ public class ProductService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<TbProduct> handleDate(List<TbProduct> products){
|
||||||
|
if (!CollectionUtils.isEmpty(products)) {
|
||||||
|
products.parallelStream().forEach(it -> {
|
||||||
|
TbShopUnit tbShopUnit = unitMapper.selectByPrimaryKey(Integer.valueOf(it.getUnitId()));
|
||||||
|
it.setUnitSnap(tbShopUnit != null ? tbShopUnit.getName() : "");
|
||||||
|
//购物车数量
|
||||||
|
it.setCartNumber("0");
|
||||||
|
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
||||||
|
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
||||||
|
|
||||||
|
// 上下架对应的sku
|
||||||
|
HashSet<String> specSet = new HashSet<>();
|
||||||
|
AtomicDouble sum = new AtomicDouble(0.0);
|
||||||
|
BigDecimal lowerPrice = null;
|
||||||
|
for (TbProductSku item : tbProductSkus) {
|
||||||
|
if (item.getRealSalesNumber() != null) {
|
||||||
|
sum.addAndGet(item.getRealSalesNumber());
|
||||||
|
}
|
||||||
|
if (lowerPrice == null || lowerPrice.compareTo(item.getSalePrice()) > 0) {
|
||||||
|
lowerPrice = item.getSalePrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
String specSnap = item.getSpecSnap();
|
||||||
|
if (specSnap != null) {
|
||||||
|
specSet.addAll(Arrays.asList(specSnap.split(",")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//销量
|
||||||
|
it.setStockNumber(sum.intValue());
|
||||||
|
if (lowerPrice == null) {
|
||||||
|
lowerPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
//售价
|
||||||
|
it.setLowPrice(lowerPrice);
|
||||||
|
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
|
||||||
|
if (tagSnap != null) {
|
||||||
|
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
|
||||||
|
JSONObject snapJSON;
|
||||||
|
JSONArray finalSnap = new JSONArray();
|
||||||
|
for (Object snap : tagSnaps) {
|
||||||
|
snapJSON = (JSONObject) snap;
|
||||||
|
String values = snapJSON.getString("value");
|
||||||
|
String finalValues = "";
|
||||||
|
if (StrUtil.isNotBlank(values)) {
|
||||||
|
String[] valueList = values.split(",");
|
||||||
|
for (String value : valueList) {
|
||||||
|
if (specSet.contains(value)) {
|
||||||
|
finalValues = finalValues + (value) + ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(finalValues)) {
|
||||||
|
finalValues = StrUtil.removeSuffix(finalValues, ",");
|
||||||
|
snapJSON.put("value", finalValues);
|
||||||
|
finalSnap.add(snapJSON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//sku Result
|
||||||
|
skuResult.setTagSnap(finalSnap.toJSONString());
|
||||||
|
}
|
||||||
|
it.setProductSkuResult(skuResult);
|
||||||
|
});
|
||||||
|
return products;
|
||||||
|
}else {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Result queryProductSku(String code, String shopId, String productId, String spec_tag) {
|
public Result queryProductSku(String code, String shopId, String productId, String spec_tag) {
|
||||||
if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(productId)) {
|
if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(productId)) {
|
||||||
return Result.fail("参数错误");
|
return Result.fail("参数错误");
|
||||||
|
|||||||
Reference in New Issue
Block a user