doum
11 小时以前 f93f02d8cc15732652c751f69e7319858ca6f0a4
server/dmmall_service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
@@ -372,6 +372,7 @@
        if(goodsSkuList==null || goodsSkuList.size() == 0){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "商品尚未设置零售价,请先设置价格! ");
        }
        List<Integer> idList2 = new ArrayList<>();
        for(Goods param: list){
            Goods goods = getGoodsFromListById(param.getId(),goodsList,goodsSkuList);
            if(goods ==null ){
@@ -379,25 +380,47 @@
            }
            //如果是上架
            goods.setGoodsSkuList(goodsSkuList);
            boolean s =true;
            if(goods.getSkuPrice() == null || goods.getSkuPrice().compareTo(new BigDecimal(0)) <=0){
                //默认sku信息
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), goods.getName()+":商品商品尚未设置零售价,无法上架");
                s =false;
                if(idList.size()==1) {
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), goods.getName()+":商品商品尚未设置零售价,无法上架");
                }
            }
            if(Constants.formatLongNum(goods.getPricedShopNum()) <= shopNum){
            if(Constants.formatLongNum(goods.getPricedShopNum()) < shopNum){
                //默认sku信息
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), goods.getName()+":有未设置供货价的经销商,无法上架");
                s =false;
                if(idList.size()==1){
                  throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), goods.getName()+":有未设置供货价的经销商,无法上架");
                }
            }
            if(s){
                idList2.add(param.getId());
            }
        }
        goodsMapper.update(null,new UpdateWrapper<Goods>().lambda()
                .set(Goods::getEditDate,new Date() )
                .set(Goods::getEditor,user.getId())
                .set(Goods::getStatus,Constants.ZERO )
                .in(Goods::getId,idList));
        int successNum = 0;
        if(idList2.size()>0){
            successNum = goodsMapper.update(null,new UpdateWrapper<Goods>().lambda()
                    .set(Goods::getEditDate,new Date() )
                    .set(Goods::getEditor,user.getId())
                    .set(Goods::getStatus,Constants.ZERO )
                    .in(Goods::getId,idList2));
        }
        if(successNum != idList.size()){
            if( idList.size()>1){
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "成功上架商品数:【"+successNum+"】,上架失败:【"+(idList.size()-successNum)+"】个商品,请确保待上架商品的均销售价和供货价已设置");
            }else {
                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode()," 上架失败");
            }
        }
    }
    private Goods getGoodsFromListById(Integer id, List<Goods> goodsList, List<GoodsSku> skuList) {
        for(Goods model: goodsList){
            if(Constants.equalsObject(model.getIdList(),id)){
            if(Constants.equalsInteger(model.getId(),id)){
                for(GoodsSku sku :skuList){
                    if(Constants.equalsInteger(sku.getGoodsId(),id)){
                        model.setSkuPrice(sku.getPrice());