| | |
| | | .set(Goods::getEditor,user.getId()) |
| | | .set(Goods::getStatus,Constants.ONE ) |
| | | .in(Goods::getId,idList)); |
| | | |
| | | //批量下架 sku数据 |
| | | goodsSkuMapper.update(null,new UpdateWrapper<GoodsSku>().lambda() |
| | | .set(GoodsSku::getEditDate,new Date() ) |
| | | .set(GoodsSku::getEditor,user.getId()) |
| | | .set(GoodsSku::getStatus,Constants.ONE ) |
| | | .eq(GoodsSku::getIsdeleted,Constants.ZERO) |
| | | .in(GoodsSku::getGoodsId,idList)); |
| | | return; |
| | | }else{ |
| | | //批量上架 sku数据 |
| | | goodsSkuMapper.update(null,new UpdateWrapper<GoodsSku>().lambda() |
| | | .set(GoodsSku::getEditDate,new Date() ) |
| | | .set(GoodsSku::getEditor,user.getId()) |
| | | .set(GoodsSku::getStatus,Constants.ZERO ) |
| | | .eq(GoodsSku::getIsdeleted,Constants.ZERO) |
| | | .in(GoodsSku::getGoodsId,idList)); |
| | | } |
| | | long shopNum = shopMapper.selectCount(new QueryWrapper<Shop>().lambda() |
| | | .eq(Shop::getIsdeleted,Constants.ZERO) |
| | |
| | | public List<Goods> findList(Goods goods) { |
| | | QueryWrapper<Goods> wrapper = new QueryWrapper<>(goods); |
| | | wrapper.lambda() |
| | | .in(goods.getIdList() != null && goods.getIdList().size()>0, Goods::getId, goods.getIdList()) |
| | | .eq( Goods::getIsdeleted, Constants.ZERO); |
| | | .in(goods.getIdList() != null && goods.getIdList().size()>0, Goods::getId, goods.getIdList()) |
| | | .like(goods.getZhuanquId()!=null,Goods::getZhuanquIds,"["+goods.getZhuanquId()+"]") |
| | | .eq( Goods::getIsdeleted, Constants.ZERO); |
| | | return goodsMapper.selectList(wrapper); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<GoodsInfoResponse> getGoodsPage(PageWrap<GoodsRequest> pageWrap) { |
| | | public IPage<Goods> getGoodsPage(PageWrap<GoodsRequest> pageWrap) { |
| | | GoodsRequest model = pageWrap.getModel(); |
| | | QueryWrapper<GoodsRequest> wrapper = new QueryWrapper<GoodsRequest>() |
| | | .eq("g.ISDELETED",Constants.ZERO) |
| | | MPJLambdaWrapper<Goods> wrapper = new MPJLambdaWrapper<Goods>() |
| | | .selectAll(Goods.class) |
| | | .select(" ifnull(( select min(gs.PRICE) from goods_sku gs where gs.GOODS_ID = t.id ),0) ",Goods::getMinPrice) |
| | | .leftJoin(SystemUser.class, SystemUser::getId, Goods::getCreator) |
| | | .eq(Goods::getIsdeleted,Constants.ZERO) |
| | | .eq(!Objects.isNull(model) && Objects.nonNull(model.getCategoryId()), |
| | | "g.CATEGORY_ID", model.getCategoryId()) |
| | | Goods::getCategoryId, model.getCategoryId()) |
| | | //适用品牌 适用系列 |
| | | .apply(!Objects.isNull(model) && Objects.nonNull(model.getApplicableBrandId()), |
| | | " find_in_set( '["+model.getApplicableBrandId()+"]' , g.BRAND_IDS ) ") |
| | | " find_in_set( '["+model.getApplicableBrandId()+"]' , t.BRAND_IDS ) ") |
| | | .apply(!Objects.isNull(model) && Objects.nonNull(model.getSeriesBrandId()), |
| | | " find_in_set( '["+model.getSeriesBrandId()+"]' , g.SERIAL_IDS ) ") |
| | | .eq("g.STATUS", Constants.ZERO) |
| | | .like(StringUtils.isNotBlank(model.getGoodsName()),"g.NAME",model.getGoodsName()); |
| | | " find_in_set( '["+model.getSeriesBrandId()+"]' , t.SERIAL_IDS ) ") |
| | | .apply(!Objects.isNull(model) && Objects.nonNull(model.getQualityId()), |
| | | " find_in_set( '["+model.getQualityId()+"]' , t.ZHUANQU_IDS ) ") |
| | | .eq(Goods::getStatus, Constants.ZERO) |
| | | .like(StringUtils.isNotBlank(model.getGoodsName()),Goods::getName,model.getGoodsName()); |
| | | if(Objects.nonNull(model.getShopId())){ |
| | | wrapper.select(" ifnull( ( select sgr.PRICE from shop_goods_relation sgr where sgr.GOODS_ID = t.ID and sgr.ISDELETED = 0 and sgr.`STATUS` = 0 and sgr.SHOP_ID = "+model.getShopId()+" ) ,0) ",Goods::getExFactoryPrice); |
| | | wrapper.select(" ifnull(( select sum(gd.GOODS_NUM) from goodsorder_detail gd inner join goodsorder go on gd.ORDER_ID = go.id where gd.GOODS_ID = t.`id` and go.DISTRIBUTION_SHOP_ID = "+model.getShopId()+" ),0) ",Goods::getRealSaleNum); |
| | | |
| | | if(Objects.nonNull(model.getSortInfo())){ |
| | | //排序方式:0=综合排序;1=销量由低到高 ;2=价格由低到高;3=销量由高到低;4=价格由高到低 |
| | | if(Constants.equalsInteger(model.getSortInfo(),Constants.ZERO)){ |
| | | wrapper.orderByDesc("g.CREATE_DATE"); |
| | | }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"); |
| | | } |
| | | } |
| | | IPage<GoodsInfoResponse> page = |
| | | Objects.isNull(model.getShopId())? |
| | | goodsMapper.goodsPage(pageWrap.toPage(),wrapper) |
| | | : |
| | | goodsMapper.goodsPageForShop(pageWrap.toPage(),wrapper,model.getShopId()) ; |
| | | }else{ |
| | | wrapper.select(" (( select ifnull(sum(GOODS_NUM),0) from goodsorder_detail gd where gd.GOODS_ID = t.id )) ",Goods::getRealSaleNum); |
| | | } |
| | | |
| | | if(Objects.nonNull(model.getSortInfo())){ |
| | | //排序方式:0=综合排序;1=销量由低到高 ;2=价格由低到高;3=销量由高到低;4=价格由高到低 |
| | | if(Constants.equalsInteger(model.getSortInfo(),Constants.ZERO)){ |
| | | wrapper.orderByDesc("t.CREATE_DATE"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.ONE)){ |
| | | wrapper.orderByAsc("realSaleNum"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.TWO)){ |
| | | wrapper.orderByAsc("t.price"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.THREE)){ |
| | | wrapper.orderByDesc("realSaleNum"); |
| | | }else if(Constants.equalsInteger(model.getSortInfo(),Constants.FOUR)){ |
| | | wrapper.orderByDesc("t.price"); |
| | | } |
| | | } |
| | | IPage<Goods> page = |
| | | goodsMapper.selectJoinPage(pageWrap.toPage(), Goods.class, wrapper); |
| | | if (!CollectionUtils.isEmpty(page.getRecords())){ |
| | | String preFixPath = systemDictDataBiz.getPreFixPath(Constants.RESOURCE_PATH, Constants.GOODS_FILE); |
| | | |
| | | |
| | | for (GoodsInfoResponse goodsInfoResponse:page.getRecords() |
| | | ) { |
| | | for (Goods goodsInfoResponse:page.getRecords()) { |
| | | goodsInfoResponse.setImgurl(StringUtils.isNotBlank(goodsInfoResponse.getImgurl())?(preFixPath+goodsInfoResponse.getImgurl()):null); |
| | | if(Objects.isNull(model.getShopId())){ |
| | | //sku基础信息 |
| | |
| | | * @param goodsResponse |
| | | * @return |
| | | */ |
| | | public void getSkuInfo(GoodsInfoResponse goodsResponse) { |
| | | public void getSkuInfo(Goods goodsResponse) { |
| | | |
| | | List<GoodsSkuResponse> goodsSkuResponseList = goodsSkuMapper.getSkuResponseList(goodsResponse.getId()); |
| | | |
| | | // 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) { |
| | | goodsSkuResponse.setStock(Objects.isNull(goodsSkuResponse.getStock())?Constants.ZERO:goodsSkuResponse.getStock()); |
| | | // if(StringUtils.isBlank(goodsSkuResponse.getImgurl())){ |
| | | // goodsSkuResponse.setImgurl(fullUrl + goodsSkuResponse.getGoodsImgUrl()); |
| | | // }else{ |
| | | // goodsSkuResponse.setImgurl(fullUrl + goodsSkuResponse.getImgurl()); |
| | | // } |
| | | // //处理数据下标 |
| | | // String goodsSkuName = goodsSkuResponse.getName(); |
| | | // List<String> strList = Arrays.asList(goodsSkuName.split(";")); |
| | | // StringBuffer indexData = new StringBuffer(); |
| | | // for (int i = 0; i < strList.size(); i++) { |
| | | // //查询sku信息 |
| | | // Sku sku = skuMapper.selectOne(new QueryWrapper<Sku>() |
| | | // .eq("GOODS_ID",goodsResponse.getId()) |
| | | // .eq("SORTNUM",i) |
| | | // .last(" limit 1 ") |
| | | // ); |
| | | // if(Objects.isNull(sku)){ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"SKU信息异常,请刷新查看"); |
| | | // } |
| | | // //查询SKU_ATTR |
| | | // SkuAttr skuAttr = skuAttrMapper.selectOne(new QueryWrapper<SkuAttr>() |
| | | // .eq("SKU_ID",sku.getId()) |
| | | // .eq("NAME",strList.get(i)) |
| | | // .last(" limit 1 ") |
| | | // ); |
| | | // if(Objects.isNull(skuAttr)){ |
| | | // throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"SKU信息异常,请刷新查看"); |
| | | // } |
| | | // 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.setStock(sumStock); |
| | | goodsResponse.setRealSaleNum(goodsResponse.getRealSaleNum()+sumStock); |
| | | goodsResponse.setGoodsSkuResponseList(goodsSkuResponseList); |
| | | //Sku基础信息 |
| | | List<SkuResponse> skuResponseList = skuMapper.getSkuResponseList(goodsResponse.getId()); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public GoodsInfoResponse getGoodsInfo(Integer goodsId,Integer memberId) { |
| | | public Goods getGoodsInfo(Integer goodsId,Integer memberId) { |
| | | String fullUrl = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+ |
| | | systemDictDataBiz.queryByCode(Constants.OSS,Constants.GOODS_FILE).getCode(); |
| | | GoodsInfoResponse goodsResponse = goodsMapper.getGoodsInfo(goodsId); |
| | | // GoodsInfoResponse goodsResponse = goodsMapper.getGoodsInfo(goodsId); |
| | | Goods goodsResponse = goodsMapper.selectOne( |
| | | new MPJLambdaWrapper<Goods>() |
| | | .selectAll(Goods.class) |
| | | .select(" (( select ifnull(sum(GOODS_NUM),0) from goodsorder_detail gd where gd.GOODS_ID = t.id )) ",Goods::getRealSaleNum) |
| | | .select(" ifnull(( select min(gs.PRICE) from goods_sku gs where gs.GOODS_ID = t.id ),0) ",Goods::getMinPrice) |
| | | .select(" ifnull(( select min(gs.SHOW_PRICE) from goods_sku gs where gs.GOODS_ID = t.id ),0) ",Goods::getLinePrice) |
| | | .leftJoin(SystemUser.class, SystemUser::getId, Goods::getCreator) |
| | | // .eq(Goods::getIsdeleted,Constants.ZERO) |
| | | // .eq(Goods::getStatus, Constants.ZERO) |
| | | .eq(Goods::getId,goodsId) |
| | | .last("limit 1") |
| | | ); |
| | | if(Objects.isNull(goodsResponse)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY); |
| | | } |