doum
昨天 82203a196fa700adfc379b2b453b2266266c940c
server/dmmall_service/src/main/java/com/doumee/service/business/impl/LabelsServiceImpl.java
@@ -31,6 +31,7 @@
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
@@ -64,6 +65,7 @@
    private GoodsAdminJoinMapper goodsAdminJoinMapper;
    @Override
    @Transactional
    public Integer create(Labels labels) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        labels.setCreator(user.getId());
@@ -79,18 +81,22 @@
        }*/
        labelsMapper.insert(labels);
        if(Constants.equalsInteger(labels.getType(),Constants.LabelsType.BIG_AREA.getKey())
        if((Constants.equalsInteger(labels.getType(),Constants.LabelsType.BIG_AREA.getKey())
                ||Constants.equalsInteger(labels.getType(),Constants.LabelsType.YUN_FEE.getKey()))
                && labels.getAreaIdList()!=null
                &&labels.getAreaIdList().size()>0){
            areasMapper.update(null,new UpdateWrapper<Areas>().lambda()
                    .set(Areas::getBigAreaId,labels.getId())
                    .in(Areas::getId,labels.getAreaIdList()));
                        .set(Constants.equalsInteger(labels.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getYunFeeId,labels.getId())
                        .set(Constants.equalsInteger(labels.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getBigAreaId,labels.getId())
                        .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();
        }
        return labels.getId();
    }
    @Override
    @Transactional
    public void deleteById(Integer id) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        Labels query= labelsJoinMapper.selectById(id);
@@ -113,10 +119,13 @@
        labels.setEditDate(new Date());
        labels.setEditor(user.getId());
        labelsMapper.updateById(labels);
        if(query!=null && Constants.equalsInteger(query.getType(),Constants.LabelsType.BIG_AREA.getKey())){
        if(query!=null &&( Constants.equalsInteger(query.getType(),Constants.LabelsType.BIG_AREA.getKey())
        || Constants.equalsInteger(query.getType(),Constants.LabelsType.YUN_FEE.getKey()))){
            int num =  areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                    .set(Areas::getBigAreaId, null)
                    .eq(Areas::getBigAreaId, labels.getId()));
                    .set(Constants.equalsInteger(query.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getBigAreaId, null)
                    .eq(Constants.equalsInteger(query.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getBigAreaId, labels.getId())
                    .set(Constants.equalsInteger(query.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getYunFeeId, null)
                    .eq(Constants.equalsInteger(query.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getYunFeeId, labels.getId()));
            if(num>0){
                areasService.cacheData();
            }
@@ -135,6 +144,7 @@
    }
    @Override
    @Transactional
    public void deleteByIdInBatch(List<Integer> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return;
@@ -151,6 +161,9 @@
            num +=  areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                    .set(Areas::getBigAreaId, null)
                    .eq(Areas::getBigAreaId, labels.getId()));
            num +=  areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                    .set(Areas::getYunFeeId, null)
                    .eq(Areas::getYunFeeId, labels.getId()));
        }
        if(num>0){
            areasService.cacheData();
@@ -158,6 +171,7 @@
    }
    @Override
    @Transactional
    public void updateById(Labels labels) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        labels.setEditDate(new Date());
@@ -170,17 +184,22 @@
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        labelsMapper.updateById(labels);
        if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())){
        if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())
            ||Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey())){
            //先清空原来所有绑定的数据
           int num =  areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                    .set(Areas::getBigAreaId, null)
                    .eq(Areas::getBigAreaId, labels.getId()));
                    .set(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getBigAreaId, null)
                    .eq(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getBigAreaId, labels.getId())
                    .set(Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getYunFeeId, null)
                    .eq(Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getYunFeeId, labels.getId()));
            if( labels.getAreaIdList()!=null
                    &&labels.getAreaIdList().size()>0){
                //设置最新绑定的数据
                num +=   areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                        .set(Areas::getBigAreaId, labels.getId())
                        .in(Areas::getId, labels.getAreaIdList()));
                        .set(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getBigAreaId, labels.getId())
                        .in(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getId, labels.getAreaIdList())
                        .set(Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getYunFeeId, labels.getId())
                        .in(Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getId, labels.getAreaIdList()));
            }
            if(num>0){
                areasService.cacheData();
@@ -210,18 +229,21 @@
    @Override
    public Labels findById(Integer id) {
        Labels labels=   labelsMapper.selectById(id);
        if(labels != null){
        Labels model=   labelsMapper.selectById(id);
        if(model != null){
            String resourcePath=systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode();
            getLablesIcon(labels,resourcePath);
            if(Constants.equalsInteger(labels.getType(),Constants.LabelsType.BIG_AREA.getKey())){
            getLablesIcon(model,resourcePath);
            if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())
                    ||Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey())){
                //如果是大区信息,查询所有绑定额省份信息
                labels.setAreaList(areasMapper.selectList(new LambdaQueryWrapper<Areas>()
                model.setAreaList(areasMapper.selectList(new LambdaQueryWrapper<Areas>()
                        .eq(Areas::getIsdeleted,Constants.ZERO)
                        .eq(Areas::getBigAreaId,labels.getId())));
                        .eq(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getBigAreaId,model.getId())
                        .eq(Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getYunFeeId,model.getId())));
            }
        }
        return labels;
        return model;
    }
    @Override
@@ -255,11 +277,13 @@
                    .orderByAsc(Labels::getSortnum));
        }
        for(Labels model:list){
            if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())){
            if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())
            ||Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey())){
                //如果是大区信息,查询所有绑定额省份信息
                model.setAreaList(areasMapper.selectList(new LambdaQueryWrapper<Areas>()
                        .eq(Areas::getIsdeleted,Constants.ZERO)
                        .eq(Areas::getBigAreaId,model.getId())));
                        .eq(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getBigAreaId,model.getId())
                        .eq(Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getYunFeeId,model.getId())));
            }
            if(Constants.equalsInteger(labels.getType(),Constants.LabelsType.APPLICABLE_BRAND.getKey())
                    &&Constants.equalsInteger(model.getType(),Constants.LabelsType.APPLICABLE_BRAND.getKey())){
@@ -333,11 +357,13 @@
               if(StringUtils.isNotBlank(model.getImgurl())){
                   model.setImgFullurl(path + model.getImgurl());
               }
               if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())){
               if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())
                        || Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey())){
                    //如果是大区信息,查询所有绑定额省份信息
                    model.setAreaList(areasMapper.selectList(new LambdaQueryWrapper<Areas>()
                            .eq(Areas::getIsdeleted,Constants.ZERO)
                            .eq(Areas::getBigAreaId,model.getId())));
                            .eq(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey()),Areas::getBigAreaId,model.getId())
                            .eq(Constants.equalsInteger(model.getType(),Constants.LabelsType.YUN_FEE.getKey()),Areas::getYunFeeId,model.getId())));
               }
            }
        }