use of com.xatu.gmall.entity.PmsProductSaleAttr in project GMall by 18391713434.
the class SpuServiceImpl method spuSaleAttrList.
public List<PmsProductSaleAttr> spuSaleAttrList(String spuId) {
List<PmsProductSaleAttr> pmsProductSaleAttrList = saleAttrMapper.selectList(new QueryWrapper<PmsProductSaleAttr>().eq("product_id", spuId));
for (PmsProductSaleAttr pmsProductSaleAttr : pmsProductSaleAttrList) {
List<PmsProductSaleAttrValue> pmsProductSaleAttrValueList = saleAttrValueMapper.selectList(new QueryWrapper<PmsProductSaleAttrValue>().eq("product_id", spuId).eq("sale_attr_id", pmsProductSaleAttr.getSaleAttrId()));
pmsProductSaleAttr.setSpuSaleAttrValueList(pmsProductSaleAttrValueList);
}
return pmsProductSaleAttrList;
}
use of com.xatu.gmall.entity.PmsProductSaleAttr in project GMall by 18391713434.
the class ItemController method item.
@RequestMapping("{skuId}.html")
public String item(@PathVariable String skuId, ModelMap map) {
// sku对象
PmsSkuInfo pmsSkuInfo = skuService.getSkuById(skuId);
map.put("skuInfo", pmsSkuInfo);
// 销售属性列表
List<PmsProductSaleAttr> pmsProductSaleAttrs = spuService.spuSaleAttrListCheckBySku(pmsSkuInfo.getSpuId(), pmsSkuInfo.getId());
map.put("spuSaleAttrListCheckBySku", pmsProductSaleAttrs);
// 查询当前sku的spu的其他sku的集合的hash表
List<PmsSkuInfo> pmsSkuInfos = skuService.getSkuSaleAttrValueListBySpu(pmsSkuInfo.getSpuId());
HashMap<String, Long> skuSaleAttrHash = new HashMap<>();
for (PmsSkuInfo skuInfo : pmsSkuInfos) {
String k = "";
Long v = skuInfo.getId();
List<PmsSkuSaleAttrValue> skuSaleAttrValueList = skuInfo.getSkuSaleAttrValueList();
for (PmsSkuSaleAttrValue skuSaleAttrValue : skuSaleAttrValueList) {
k += skuSaleAttrValue.getSaleAttrValueId() + "|";
}
skuSaleAttrHash.put(k, v);
}
// 将sku的销售属性hash表放到页面
String skuSaleAttrHashJsonStr = JSON.toJSONString(skuSaleAttrHash);
map.put("skuSaleAttrHashJsonStr", skuSaleAttrHashJsonStr);
return "item";
}
use of com.xatu.gmall.entity.PmsProductSaleAttr in project GMall by 18391713434.
the class SpuServiceImpl method saveSpuInfo.
public void saveSpuInfo(PmsProductInfo pmsProductInfo) {
spuMapper.insert(pmsProductInfo);
Long id = pmsProductInfo.getId();
List<PmsProductSaleAttr> spuSaleAttrList = pmsProductInfo.getSpuSaleAttrList();
for (PmsProductSaleAttr pmsProductSaleAttr : spuSaleAttrList) {
// 添加SPU单元的销售属性
pmsProductSaleAttr.setProductId(id);
saleAttrMapper.insert(pmsProductSaleAttr);
// 添加SPU单元的销售属性值
List<PmsProductSaleAttrValue> spuSaleAttrValueList = pmsProductSaleAttr.getSpuSaleAttrValueList();
for (PmsProductSaleAttrValue pmsProductSaleAttrValue : spuSaleAttrValueList) {
pmsProductSaleAttrValue.setProductId(id);
saleAttrValueMapper.insert(pmsProductSaleAttrValue);
}
}
// 添加SPU单元的图片集合
List<PmsProductImage> spuImageList = pmsProductInfo.getSpuImageList();
for (PmsProductImage pmsProductImage : spuImageList) {
pmsProductImage.setProductId(pmsProductInfo.getId());
imageMapper.insert(pmsProductImage);
}
}
Aggregations