1.查询规格接口同步返回是否售罄
This commit is contained in:
@@ -233,7 +233,8 @@ public class ProductService {
|
|||||||
|
|
||||||
// 重组有效规格数据
|
// 重组有效规格数据
|
||||||
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
|
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
|
||||||
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(querySpecDTO.getProductId());
|
// List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(querySpecDTO.getProductId());
|
||||||
|
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectSku(String.valueOf(querySpecDTO.getProductId()));
|
||||||
|
|
||||||
JSONArray finalSnap = new JSONArray();
|
JSONArray finalSnap = new JSONArray();
|
||||||
// if (tagSnap != null) {
|
// if (tagSnap != null) {
|
||||||
@@ -315,11 +316,17 @@ public class ProductService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<HashMap<String, Object>> specList = new ArrayList<>();
|
ArrayList<HashMap<String, Object>> specList = new ArrayList<>();
|
||||||
|
HashMap<String, TbProductSku> unGroundingMap = new HashMap<>();
|
||||||
tbProductSkus.forEach(item -> {
|
tbProductSkus.forEach(item -> {
|
||||||
HashMap<String, Object> itemMap = new HashMap<>();
|
if (item.getIsGrounding() == 1) {
|
||||||
itemMap.put("specSnap", item.getSpecSnap());
|
HashMap<String, Object> itemMap = new HashMap<>();
|
||||||
itemMap.put("skuId", item.getId());
|
itemMap.put("specSnap", item.getSpecSnap());
|
||||||
specList.add(itemMap);
|
itemMap.put("skuId", item.getId());
|
||||||
|
itemMap.put("info", item);
|
||||||
|
specList.add(itemMap);
|
||||||
|
}else {
|
||||||
|
unGroundingMap.put(item.getSpecSnap(), item);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -329,6 +336,13 @@ public class ProductService {
|
|||||||
for (HashMap<String, Object> spec : specList) {
|
for (HashMap<String, Object> spec : specList) {
|
||||||
if (res.equals(spec.get("specSnap").toString())) {
|
if (res.equals(spec.get("specSnap").toString())) {
|
||||||
spec.put("isGrounding", true);
|
spec.put("isGrounding", true);
|
||||||
|
TbProductSku sku = (TbProductSku) spec.get("info");
|
||||||
|
if (sku != null) {
|
||||||
|
checkPauseSale(tbProduct, new ArrayList<>(Collections.singletonList(sku)), true);
|
||||||
|
spec.put("isPauseSale", tbProduct.getIsPauseSale());
|
||||||
|
}else {
|
||||||
|
spec.put("isPauseSale", 1);
|
||||||
|
}
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -338,6 +352,13 @@ public class ProductService {
|
|||||||
itemMap.put("specSnap", res);
|
itemMap.put("specSnap", res);
|
||||||
itemMap.put("skuId", null);
|
itemMap.put("skuId", null);
|
||||||
itemMap.put("isGrounding", false);
|
itemMap.put("isGrounding", false);
|
||||||
|
TbProductSku sku = unGroundingMap.get("specSnap");
|
||||||
|
if (sku != null) {
|
||||||
|
checkPauseSale(tbProduct, Collections.singletonList(sku), true);
|
||||||
|
itemMap.put("isPauseSale", tbProduct.getIsPauseSale());
|
||||||
|
}else {
|
||||||
|
itemMap.put("isPauseSale", 1);
|
||||||
|
}
|
||||||
otherVal.add(itemMap);
|
otherVal.add(itemMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,7 +408,7 @@ public class ProductService {
|
|||||||
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
||||||
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
||||||
//判断库存及耗材
|
//判断库存及耗材
|
||||||
checkPauseSale(it,tbProductSkus);
|
checkPauseSale(it,tbProductSkus, false);
|
||||||
|
|
||||||
AtomicDouble sum = new AtomicDouble(0.0);
|
AtomicDouble sum = new AtomicDouble(0.0);
|
||||||
BigDecimal lowerPrice = null;
|
BigDecimal lowerPrice = null;
|
||||||
@@ -418,14 +439,23 @@ public class ProductService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPauseSale(TbProduct tbProduct, List<TbProductSku> skus) {
|
public void checkPauseSale(TbProduct tbProduct, List<TbProductSku> skus, boolean isSingle) {
|
||||||
if (tbProduct.getIsStock() == 1) {//库存开关 1开启
|
if (tbProduct.getIsStock() == 1) {//库存开关 1开启
|
||||||
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {//共享库存 1开启
|
if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {//共享库存 1开启
|
||||||
if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) {
|
if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) {
|
||||||
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSingle && tbProduct.getIsPauseSale() == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (isSingle && !skus.stream().filter(res -> res.getIsPauseSale().equals(1)).collect(Collectors.toList()).isEmpty()) {
|
||||||
|
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!tbProduct.getTypeEnum().equals("sku")) {
|
if (!tbProduct.getTypeEnum().equals("sku")) {
|
||||||
if (skus.stream().anyMatch(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0)){
|
if (skus.stream().anyMatch(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0)){
|
||||||
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停
|
||||||
|
|||||||
Reference in New Issue
Block a user