| | |
| | | */ |
| | | @Override |
| | | public IPage<GoodsInfoResponse> getGoodsPage(PageWrap<GoodsRequest> pageWrap) { |
| | | GoodsRequest model = pageWrap.getModel(); |
| | | |
| | | QueryWrapper<GoodsRequest> wrapper = new QueryWrapper<GoodsRequest>() |
| | | .eq("g.ISDELETED",Constants.ZERO) |
| | | .eq("g.PARENT_CATEGORY_ID",pageWrap.getModel().getParentCategoryId()) |
| | | .eq(!Objects.isNull(pageWrap.getModel()) && Objects.nonNull(pageWrap.getModel().getCategoryId()), |
| | | "g.CATEGORY_ID", pageWrap.getModel().getCategoryId()) |
| | | .eq(!Objects.isNull(model) && Objects.nonNull(model.getCategoryId()), |
| | | "g.CATEGORY_ID", model.getCategoryId()) |
| | | |
| | | //TODO 适用品牌 适用系列 |
| | | // .eq(!Objects.isNull(model) && Objects.nonNull(model.getApplicableBrandId()), |
| | | // "","") |
| | | // .eq(!Objects.isNull(model) && Objects.nonNull(model.getSeriesBrandId()), |
| | | // "","") |
| | | |
| | | .eq("g.STATUS", Constants.ZERO) |
| | | .like(StringUtils.isNotBlank(pageWrap.getModel().getGoodsName()),"g.NAME",pageWrap.getModel().getGoodsName()); |
| | | // .eq(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getType()), "g.TYPE", pageWrap.getModel().getType()); |
| | | .like(StringUtils.isNotBlank(model.getGoodsName()),"g.NAME",model.getGoodsName()); |
| | | |
| | | for(PageWrap.SortData sortData:pageWrap.getSorts1()){ |
| | | if ("CREATE_DATE".equalsIgnoreCase(sortData.getProperty())){ |
| | | if (PageWrap.ASC.equalsIgnoreCase(sortData.getDirection())){ |
| | | wrapper.orderByAsc("g.CREATE_DATE"); |
| | | } |
| | | if(Objects.nonNull(model.getSortInfo())){ |
| | | //排序方式:0=综合排序;1=销量由低到高 ;2=价格由低到高;3=销量由高到低;4=价格由高到低 |
| | | if(Constants.equalsInteger(model.getSortInfo(),Constants.ZERO)){ |
| | | wrapper.orderByDesc("g.CREATE_DATE"); |
| | | |
| | | } |
| | | if ("realSaleNum".equalsIgnoreCase(sortData.getProperty())){ |
| | | |
| | | if (PageWrap.ASC.equalsIgnoreCase(sortData.getDirection())){ |
| | | wrapper.orderByAsc("realSaleNum"); |
| | | } |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.ONE)){ |
| | | wrapper.orderByAsc("realSaleNum"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.TWO)){ |
| | | wrapper.orderByAsc("g.price"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.THREE)){ |
| | | wrapper.orderByDesc("realSaleNum"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.FOUR)){ |
| | | wrapper.orderByDesc("g.price"); |
| | | } |
| | | if ("PRICE".equalsIgnoreCase(sortData.getProperty())){ |
| | | if (PageWrap.ASC.equalsIgnoreCase(sortData.getDirection())){ |
| | | wrapper.orderByAsc("g.PRICE"); |
| | | } |
| | | wrapper.orderByDesc("g.PRICE"); |
| | | } |
| | | |
| | | } |
| | | |
| | | // for(PageWrap.SortData sortData:pageWrap.getSorts1()){ |
| | | // if ("CREATE_DATE".equalsIgnoreCase(sortData.getProperty())){ |
| | | // if (PageWrap.ASC.equalsIgnoreCase(sortData.getDirection())){ |
| | | // wrapper.orderByAsc("g.CREATE_DATE"); |
| | | // } |
| | | // wrapper.orderByDesc("g.CREATE_DATE"); |
| | | // |
| | | // } |
| | | // if ("realSaleNum".equalsIgnoreCase(sortData.getProperty())){ |
| | | // |
| | | // if (PageWrap.ASC.equalsIgnoreCase(sortData.getDirection())){ |
| | | // wrapper.orderByAsc("realSaleNum"); |
| | | // } |
| | | // wrapper.orderByDesc("realSaleNum"); |
| | | // } |
| | | // if ("PRICE".equalsIgnoreCase(sortData.getProperty())){ |
| | | // if (PageWrap.ASC.equalsIgnoreCase(sortData.getDirection())){ |
| | | // wrapper.orderByAsc("g.PRICE"); |
| | | // } |
| | | // wrapper.orderByDesc("g.PRICE"); |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | IPage<GoodsInfoResponse> page = goodsMapper.goodsPage(pageWrap.toPage(),wrapper); |
| | | if (!CollectionUtils.isEmpty(page.getRecords())){ |
| | | String preFixPath = systemDictDataBiz.getPreFixPath(Constants.RESOURCE_PATH, Constants.GOODS_FILE); |
| | | page.getRecords().forEach(s->s.setImgurl(preFixPath+s.getImgurl())); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | String fullUrl = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ |
| | | systemDictDataBiz.queryByCode(Constants.OSS,Constants.GOODS_FILE).getCode(); |
| | | Integer sumStock = Constants.ZERO; |
| | | for (GoodsSkuResponse goodsSkuResponse:goodsSkuResponseList) { |
| | | if(StringUtils.isBlank(goodsSkuResponse.getImgurl())){ |
| | | goodsSkuResponse.setImgurl(fullUrl + goodsSkuResponse.getGoodsImgUrl()); |
| | |
| | | indexData.append("," + ( skuAttr.getSortnum()-1)); |
| | | } |
| | | goodsSkuResponse.setIndexData(indexData.toString().substring(1)); |
| | | sumStock = sumStock + goodsSkuResponse.getStock(); |
| | | } |
| | | |
| | | //真实销量 = realSaleNum - saleNum; |
| | | //真实库存= sumStock - (realSaleNum - saleNum) |
| | | goodsResponse.setStock(sumStock - goodsResponse.getRealSaleNum() + goodsResponse.getSaleNum()); |
| | | goodsResponse.setGoodsSkuResponseList(goodsSkuResponseList); |
| | | //Sku基础信息 |
| | | List<SkuResponse> skuResponseList = skuMapper.getSkuResponseList(goodsResponse.getId()); |
| | |
| | | systemDictDataBiz.queryByCode(Constants.OSS,Constants.GOODS_FILE).getCode(); |
| | | GoodsInfoResponse goodsResponse = goodsMapper.getGoodsInfo(goodsId); |
| | | if(Objects.isNull(goodsResponse)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前专区关联商品已删除"); |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |
| | | goodsResponse.setImgurl(fullUrl + goodsResponse.getImgurl()); |
| | | //查询商品的分类 |
| | |
| | | Constants.GOODS_FILE); |
| | | List<MultiFileDTO> multiFileDTOS = objAllFileUrl.get(Constants.MultiFile.PLATFORM_GOOD_ROTATION.getKey()); |
| | | goodsResponse.setGoodBannerMultiFiles(multiFileDTOS); |
| | | |
| | | return goodsResponse; |
| | | } |
| | | |