| | |
| | | dealBatchMultiFiles(goods, goods.getFileList(), user,false); |
| | | return goods.getId(); |
| | | } |
| | | private void dealDefaultGoodsSku(Goods goods) { |
| | | private Integer dealDefaultGoodsSku(Goods goods) { |
| | | Date date = goods.getEditDate(); |
| | | Integer userId = goods.getEditor(); |
| | | Sku sku = new Sku(); |
| | |
| | | goodsSkuAttr.setGoodsSkuId(goodsSku.getId()); |
| | | goodsSkuAttr.setSkuAttrId(skuAttr.getId()); |
| | | goodsSkuAttrMapper.insert(goodsSkuAttr); |
| | | |
| | | return goodsSku.getId(); |
| | | } |
| | | |
| | | public void dealBatchMultiFiles(Goods goods, List<Multifile> fileList, LoginUserInfo user,boolean update) { |
| | |
| | | goods.setLabels( StringUtils.removeEnd( goods.getLabels().replace(",",","),",")); |
| | | } |
| | | goodsMapper.updateById(goods); |
| | | boolean needUpdatesku = true; |
| | | if(goods.getSkuPrice()!=null){ |
| | | GoodsSku queryGoodsSku=new GoodsSku(); |
| | | queryGoodsSku.setGoodsId(goods.getId()); |
| | | queryGoodsSku.setIsdeleted(Constants.ZERO); |
| | | GoodsSku goodsSku=goodsSkuMapper.selectOne(new QueryWrapper<>(queryGoodsSku).last("limit 1")); |
| | | if(goodsSku !=null && Constants.formatBigdecimal(goodsSku.getPrice()).compareTo(goods.getSkuPrice()) ==0){ |
| | | needUpdatesku = false;//价格未变化无需重新生成供货价 |
| | | } |
| | | } |
| | | //清空原有的sku数据 |
| | | skuMapper.update(null,new UpdateWrapper<Sku>().lambda() |
| | | .set(Sku::getIsdeleted,Constants.ONE) |
| | |
| | | .set(GoodsSku::getIsdeleted,Constants.ONE) |
| | | .eq(GoodsSku::getIsdeleted,Constants.ZERO) |
| | | .eq(GoodsSku::getGoodsId,goods.getId())); |
| | | dealDefaultGoodsSku(goods);//新建sku信息 |
| | | Integer skuId = dealDefaultGoodsSku(goods);//新建sku信息 |
| | | if(needUpdatesku){ //先删除原来的数据 |
| | | shopGoodsRelationMapper.delete(new QueryWrapper<ShopGoodsRelation>().lambda() |
| | | .eq(ShopGoodsRelation::getGoodsId,goods.getId()) |
| | | ); |
| | | }else{ |
| | | //否则更新所有供货价关联关系中的skuID |
| | | shopGoodsRelationMapper.update(null,new UpdateWrapper<ShopGoodsRelation>().lambda() |
| | | .eq(ShopGoodsRelation::getGoodsId,goods.getId()) |
| | | .set(ShopGoodsRelation::getGoodsSkuId,skuId) |
| | | ); |
| | | } |
| | | |
| | | |
| | | |
| | | dealBatchMultiFiles(goods, goods.getFileList(), user,true); |
| | | } |
| | | |
| | |
| | | goodsMapper.goodsPageForShop(pageWrap.toPage(),wrapper,model.getShopId()) ; |
| | | if (!CollectionUtils.isEmpty(page.getRecords())){ |
| | | String preFixPath = systemDictDataBiz.getPreFixPath(Constants.RESOURCE_PATH, Constants.GOODS_FILE); |
| | | |
| | | |
| | | for (GoodsInfoResponse goodsInfoResponse:page.getRecords() |
| | | ) { |
| | | goodsInfoResponse.setImgurl(StringUtils.isNotBlank(goodsInfoResponse.getImgurl())?(preFixPath+goodsInfoResponse.getImgurl()):null); |
| | | //sku基础信息 |
| | | this.getSkuInfo(goodsInfoResponse); |
| | | if(Objects.isNull(model.getShopId())){ |
| | | //sku基础信息 |
| | | this.getSkuInfo(goodsInfoResponse); |
| | | } |
| | | if(StringUtils.isNotBlank(goodsInfoResponse.getBrandIds())){ |
| | | List<Labels> allBrands = labelsMapper.selectList(new QueryWrapper<Labels>().lambda() |
| | | .in(Labels::getId,getNumIdByIdsString(goodsInfoResponse.getBrandIds())) |
| | | .eq(Labels::getType,Constants.LabelsType.APPLICABLE_BRAND.getKey()) |
| | | .eq(Labels::getIsdeleted,Constants.ZERO) |
| | | ); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(allBrands)){ |
| | | goodsInfoResponse.setBrandNames(String.join("/",allBrands.stream().map(i->i.getName()).collect(Collectors.toList()))); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(StringUtils.isNotBlank(model.getGoodsName())&&Objects.nonNull(model.getMemberId())){ |
| | | searchHistoryMapper.delete(new QueryWrapper<SearchHistory>().lambda() |
| | | .eq(SearchHistory::getMemberId,model.getMemberId()) |
| | | .eq(SearchHistory::getContent,model.getGoodsName()) |
| | | ); |
| | | SearchHistory searchHistory = new SearchHistory(); |
| | | searchHistory.setIsdeleted(Constants.ZERO); |
| | | searchHistory.setContent(model.getGoodsName()); |