1.小程序上下架sku商品不生效调整
This commit is contained in:
parent
5593670348
commit
f2301ba6ca
|
|
@ -5,6 +5,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbProductSkuWithBLOBs;
|
|||
import com.chaozhanggui.system.cashierservice.entity.vo.HomeVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -38,4 +39,7 @@ public interface TbProductSkuMapper {
|
|||
|
||||
@Update("update tb_product_sku set stock_number=stock_number-#{num} WHERE id=#{id}")
|
||||
int decrStockUnCheck(@Param("id") String id, @Param("num") Integer num);
|
||||
|
||||
@Select("select * from tb_product_sku where is_grounding=1 and is_del=0 and product_id=#{id}")
|
||||
List<TbProductSku> selectGroundingByProId(@Param("id") Integer id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,15 @@ public class TbProductSku implements Serializable {
|
|||
private Integer isPauseSale = 0;
|
||||
private Integer isDel;
|
||||
private Integer isGrounding;
|
||||
private String specSnap;
|
||||
|
||||
public String getSpecSnap() {
|
||||
return specSnap;
|
||||
}
|
||||
|
||||
public void setSpecSnap(String specSnap) {
|
||||
this.specSnap = specSnap;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ package com.chaozhanggui.system.cashierservice.service;
|
|||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
|
||||
|
|
@ -144,7 +146,47 @@ public class ProductService {
|
|||
products.parallelStream().forEach(it -> {
|
||||
Integer sum = tbProductMapper.selectByQcode(code, it.getId(), it.getShopId());
|
||||
it.setCartNumber(sum == null ? "0" : String.valueOf(sum));
|
||||
List<TbProductSku> tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId());
|
||||
TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId());
|
||||
|
||||
HashSet<String> specSet = new HashSet<>();
|
||||
tbProductSkus.forEach(item -> {
|
||||
String specSnap = item.getSpecSnap();
|
||||
if (specSnap != null) {
|
||||
specSet.addAll(Arrays.asList(specSnap.split(",")));
|
||||
}
|
||||
});
|
||||
String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
|
||||
if (tagSnap != null) {
|
||||
JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
|
||||
JSONObject snapJSON;
|
||||
|
||||
JSONArray finalSnap = new JSONArray();
|
||||
String finalValues = "";
|
||||
|
||||
for (Object snap : tagSnaps) {
|
||||
snapJSON = (JSONObject) snap;
|
||||
String values = snapJSON.getString("value");
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue