doum
15 小时以前 11e35e0257e48667292b4f563ddf6ce02a3a22bb
server/dmmall_service/src/main/java/com/doumee/service/business/impl/LabelsServiceImpl.java
@@ -10,6 +10,8 @@
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.AreasMapper;
import com.doumee.dao.business.GoodsMapper;
import com.doumee.dao.business.GoodsorderMapper;
import com.doumee.dao.business.LabelsMapper;
import com.doumee.dao.business.join.GoodsAdminJoinMapper;
import com.doumee.dao.business.join.LabelsJoinMapper;
@@ -62,7 +64,7 @@
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
    private GoodsAdminJoinMapper goodsAdminJoinMapper;
    private GoodsMapper goodsMapper;
    @Override
    @Transactional
@@ -91,6 +93,17 @@
                        .in(Constants.equalsInteger(labels.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getId,labels.getAreaIdList())
                        .in(Constants.equalsInteger(labels.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getId,labels.getAreaIdList()));
            areasService.cacheData();
        }
        if(Constants.equalsInteger(labels.getType(),Constants.LabelsType.HOMEZHUANQU.getKey())){
            String ids = "["+labels.getId()+"],";
//            goodsMapper.update(null,new UpdateWrapper<Goods>().lambda()
//                    .setSql("zhuanqu_Ids =REPLACE(zhuanqu_Ids, '"+ids+"', '')"));
            if( labels.getApplyIdList()!=null && labels.getApplyIdList().size()>0){
//                List<Goods> goods = goodsMapper.selectList(new QueryWrapper<Goods>().lambda().in(Goods::getId,labels.getApplyIdList() ));
                goodsMapper.update(null,new UpdateWrapper<Goods>().lambda()
                        .setSql("zhuanqu_Ids =concat(ifnull(zhuanqu_Ids,''), '"+ids+"' )")
                        .in(Goods::getId,labels.getApplyIdList() ));
            }
        }
        return labels.getId();
    }
@@ -203,6 +216,16 @@
            }
            if(num>0){
                areasService.cacheData();
            }
        }
        if(Constants.equalsInteger(labels.getType(),Constants.LabelsType.HOMEZHUANQU.getKey())){
            String ids = "["+labels.getId()+"],";
            goodsMapper.update(null,new UpdateWrapper<Goods>().lambda()
                    .setSql("zhuanqu_Ids =REPLACE(zhuanqu_Ids, '"+ids+"', '')"));
            if( labels.getApplyIdList()!=null && labels.getApplyIdList().size()>0){
                goodsMapper.update(null,new UpdateWrapper<Goods>().lambda()
                        .setSql("zhuanqu_Ids =concat(ifnull(zhuanqu_Ids,''), '"+ids+"' )")
                        .in(Goods::getId,labels.getApplyIdList() ));
            }
        }
    }
@@ -470,16 +493,22 @@
    @Override
    public List<LabelsResponse> getGoodsLabelsByType(Integer type) {
    public List<LabelsResponse> getGoodsLabelsByType(Integer type,Integer parentId) {
        LambdaQueryWrapper<Labels> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Labels::getStatus,Constants.ZERO);
        wrapper.eq(Labels::getStatus,Constants.ONE);
        wrapper.eq(Labels::getIsdeleted,Constants.ZERO);
        wrapper.eq(Objects.nonNull(parentId),Labels::getParentId,parentId);
        wrapper.eq(Labels::getType,type);
        wrapper.orderByAsc(Labels::getSortnum,Labels::getCreateDate);
        List<Labels> labels = labelsMapper.selectList(wrapper);
        String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
                + systemDictDataBiz.queryByCode(Constants.OSS,Constants.LABELS_IMG).getCode();
        List<LabelsResponse> collect = labels.stream().map(s -> {
            LabelsResponse labelsResponse = new LabelsResponse();
            BeanUtils.copyProperties(s, labelsResponse);
            if(StringUtils.isNotBlank(s.getImgurl())){
                labelsResponse.setImgUrl(path + s.getImgurl());
            }
            return labelsResponse;
        }).collect(Collectors.toList());
        return collect;