doum
2025-12-11 3cd92951fd2a67a02e649a870d100b3e8776ae11
server/dmmall_service/src/main/java/com/doumee/service/business/impl/LabelsServiceImpl.java
@@ -18,12 +18,14 @@
import com.doumee.dao.business.model.Goods;
import com.doumee.dao.business.model.Labels;
import com.doumee.dao.web.response.LabelsResponse;
import com.doumee.service.business.AreasService;
import com.doumee.service.business.LabelsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
@@ -54,6 +56,8 @@
    private AreasMapper areasMapper;
    @Autowired
    private AreasService areasService;
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
@@ -64,6 +68,8 @@
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        labels.setCreator(user.getId());
        labels.setCreateDate(new Date());
        labels.setEditor(user.getId());
        labels.setEditDate(labels.getCreateDate());
        labels.setIsdeleted(Constants.ZERO);
        labels.setStatus(Constants.ZERO);
    /*  if(labels.getParentId()!=null){
@@ -79,6 +85,7 @@
            areasMapper.update(null,new UpdateWrapper<Areas>().lambda()
                    .set(Areas::getBigAreaId,labels.getId())
                    .in(Areas::getId,labels.getAreaIdList()));
            areasService.cacheData();
        }
        return labels.getId();
    }
@@ -106,6 +113,15 @@
        labels.setEditDate(new Date());
        labels.setEditor(user.getId());
        labelsMapper.updateById(labels);
        if(query!=null && Constants.equalsInteger(query.getType(),Constants.LabelsType.BIG_AREA.getKey())){
            int num =  areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                    .set(Areas::getBigAreaId, null)
                    .eq(Areas::getBigAreaId, labels.getId()));
            if(num>0){
                areasService.cacheData();
            }
        }
    }
    @Override
@@ -125,13 +141,20 @@
        }
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        Labels labels=new Labels();
        ids.stream().forEach(s->{
        int num =0;
        for(Integer s : ids){
            labels.setId(s);
            labels.setIsdeleted(Constants.ONE);
            labels.setEditDate(new Date());
            labels.setEditor(user.getId());
            labelsMapper.updateById(labels);
        });
            num +=  areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                    .set(Areas::getBigAreaId, null)
                    .eq(Areas::getBigAreaId, labels.getId()));
        }
        if(num>0){
            areasService.cacheData();
        }
    }
    @Override
@@ -149,15 +172,18 @@
        labelsMapper.updateById(labels);
        if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())){
            //先清空原来所有绑定的数据
            areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
           int num =  areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                    .set(Areas::getBigAreaId, null)
                    .eq(Areas::getBigAreaId, labels.getId()));
            if( labels.getAreaIdList()!=null
                    &&labels.getAreaIdList().size()>0){
                //设置最新绑定的数据
                areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                num +=   areasMapper.update(null, new UpdateWrapper<Areas>().lambda()
                        .set(Areas::getBigAreaId, labels.getId())
                        .in(Areas::getId, labels.getAreaIdList()));
            }
            if(num>0){
                areasService.cacheData();
            }
        }
    }
@@ -264,12 +290,17 @@
        IPage<Labels> result =  labelsJoinMapper.selectJoinPage(page,Labels.class, queryWrapper);
     /*   String resourcePath=systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode();*/
        if(org.apache.commons.collections.CollectionUtils.isNotEmpty(result.getRecords())){
            String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()
                    + systemDictDataBiz.queryByCode(Constants.OSS,Constants.LABELS_IMG).getCode();
            for(Labels model:result.getRecords()){
               if(model.getParentId()==null){
                   model.setTypeLevel(0);
               }else{
                   model.setTypeLevel(1);
               }
               if(StringUtils.isNotBlank(model.getImgurl())){
                   model.setImgFullurl(path + model.getImgurl());
               }
               if(Constants.equalsInteger(model.getType(),Constants.LabelsType.BIG_AREA.getKey())){
                    //如果是大区信息,查询所有绑定额省份信息
                    model.setAreaList(areasMapper.selectList(new LambdaQueryWrapper<Areas>()