Administrator
2025-07-09 f29586dbcd6af0077af62efa95105ef2350d794b
src/main/java/cc/mrbird/febs/mall/service/impl/ClothesTypeServiceImpl.java
@@ -9,22 +9,25 @@
import cc.mrbird.febs.common.utils.excl.ExcelUtil;
import cc.mrbird.febs.common.utils.excl.ExcelVersion;
import cc.mrbird.febs.common.utils.excl.ResponseHeadUtil;
import cc.mrbird.febs.mall.dto.clothes.AdminClothesDeliverGoodsDto;
import cc.mrbird.febs.mall.dto.clothes.AdminClothesOrderListDto;
import cc.mrbird.febs.mall.dto.clothes.AdminClothesRefundOrderDto;
import cc.mrbird.febs.mall.dto.clothes.AdminClothesTypeInfoDto;
import cc.mrbird.febs.mall.dto.clothes.*;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.*;
import cc.mrbird.febs.mall.service.ClothesTypeService;
import cc.mrbird.febs.mall.service.IApiMallMemberWalletService;
import cc.mrbird.febs.mall.service.IMallMoneyFlowService;
import cc.mrbird.febs.mall.vo.AdminMallOrderInfoVo;
import cc.mrbird.febs.mall.vo.clothes.AdminClothesLocationRemarkVo;
import cc.mrbird.febs.mall.vo.clothes.AdminClothesOrderListVo;
import cc.mrbird.febs.mall.vo.clothes.AdminClothesPatternRemarkVo;
import cc.mrbird.febs.mall.vo.clothes.AdminClothesSocialListVo;
import cc.mrbird.febs.pay.util.WeixinServiceUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -64,6 +67,14 @@
    private final ClothesTypeLocationMapper clothesTypeLocationMapper;
    private final ClothesOrderMapper clothesOrderMapper;
    private final MallExpressInfoMapper mallExpressInfoMapper;
    private final ClothesSocialMapper clothesSocialMapper;
    private final ClothesSocialFileMapper clothesSocialFileMapper;
    private final ClothesSocialMuseMapper clothesSocialMuseMapper;
    private final ClothesSocialCategoryMapper clothesSocialCategoryMapper;
    private final ClothesPatternRemarkMapper clothesPatternRemarkMapper;
    private final ClothesLocationRemarkMapper clothesLocationRemarkMapper;
    private final IApiMallMemberWalletService memberWalletService;
    private final IMallMoneyFlowService mallMoneyFlowService;
    private final XcxProperties xcxProperties = SpringContextHolder.getBean(XcxProperties.class);
@@ -153,6 +164,7 @@
    public FebsResponse sizeAdd(ClothesSize dto) {
        ClothesSize clothesSize = new ClothesSize();
        clothesSize.setName(dto.getName());
        clothesSize.setCode(dto.getCode());
        clothesSize.setOrderNum(dto.getOrderNum());
        clothesSize.setPrice(dto.getPrice());
        clothesSize.setType(dto.getType());
@@ -195,7 +207,7 @@
        ClothesPattern clothesPattern = new ClothesPattern();
        clothesPattern.setName(dto.getName());
        clothesPattern.setCode(dto.getCode());
        clothesPattern.setType(dto.getType());
//        clothesPattern.setType(dto.getType());
        clothesPattern.setPrice(dto.getPrice());
        clothesPattern.setOrderNum(dto.getOrderNum());
        clothesPattern.setImage(dto.getImage());
@@ -218,7 +230,6 @@
                            .set(ClothesPattern::getContent, dto.getContent())
                            .set(ClothesPattern::getOrderNum, dto.getOrderNum())
                            .set(ClothesPattern::getPrice, dto.getPrice())
                            .set(ClothesPattern::getType, dto.getType())
            );
        }
        return new FebsResponse().success().message("操作成功");
@@ -732,4 +743,371 @@
                        .eq(ClothesOrder::getId, clothesOrder.getId())
        );
    }
    @Override
    public IPage<AdminClothesSocialListVo> getSocialListInPage(AdminClothesSocialListDto dto, QueryRequest request) {
        Page<AdminClothesSocialListVo> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<AdminClothesSocialListVo> vos = clothesSocialMapper.selectSocialListInPage(page, dto);
        return vos;
    }
    @Override
    public FebsResponse socialState(Long id, Integer state) {
        ClothesSocial clothesSocial = clothesSocialMapper.selectById(id);
        if(ObjectUtil.isNull(clothesSocial)){
            throw new RuntimeException("内容不存在");
        }
        clothesSocialMapper.update(
                null,
                Wrappers.lambdaUpdate(ClothesSocial.class)
                .set(ClothesSocial::getState, state)
                .eq(ClothesSocial::getId, id)
        );
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse socialHotState(Long id, Integer state) {
        ClothesSocial clothesSocial = clothesSocialMapper.selectById(id);
        if(ObjectUtil.isNull(clothesSocial)){
            throw new RuntimeException("内容不存在");
        }
        clothesSocialMapper.update(
                null,
                Wrappers.lambdaUpdate(ClothesSocial.class)
                        .set(ClothesSocial::getHotState, state)
                        .eq(ClothesSocial::getId, id)
        );
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse socialDelete(Long id) {
        ClothesSocial clothesSocial = clothesSocialMapper.selectById(id);
        if(ObjectUtil.isNull(clothesSocial)){
            throw new RuntimeException("内容不存在");
        }
        clothesSocialMapper.update(
                null,
                Wrappers.lambdaUpdate(ClothesSocial.class)
                        .set(ClothesSocial::getDelFlag, ClothesEnum.UP.getCode())
                        .eq(ClothesSocial::getId, id)
        );
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public List<ClothesSocialCategory> allGroup() {
        List<ClothesSocialCategory> list =
                clothesSocialCategoryMapper.selectList(
                        Wrappers.lambdaQuery(ClothesSocialCategory.class)
                                .eq(ClothesSocialCategory::getState, ClothesEnum.UP.getCode())
                                .eq(ClothesSocialCategory::getDeleteFlag, ClothesEnum.DOWN.getCode())
                                .orderByDesc(ClothesSocialCategory::getOrderCnt)
                );
        if(CollUtil.isNotEmpty(list)){
            return list;
        }
        return Collections.emptyList();
    }
    @Override
    public IPage<ClothesSocialCategory> getGroupList(AdminClothesSocialCategoryDto dto, QueryRequest request) {
        Page<ClothesSocialCategory> page = new Page<>(request.getPageNum(), request.getPageSize());
        LambdaQueryWrapper<ClothesSocialCategory> queryWrapper = new LambdaQueryWrapper<>();
        if(StrUtil.isNotEmpty(dto.getName())){
            queryWrapper.like(ClothesSocialCategory::getName,dto.getName());
        }
        if(ObjectUtil.isNotEmpty(dto.getStatus())){
            queryWrapper.eq(ClothesSocialCategory::getState,dto.getStatus());
        }
        if(ObjectUtil.isNotEmpty(dto.getHotState())){
            queryWrapper.eq(ClothesSocialCategory::getHotState,dto.getHotState());
        }
        queryWrapper.eq(ClothesSocialCategory::getDeleteFlag, ClothesEnum.DOWN.getCode());
        queryWrapper.orderByAsc(ClothesSocialCategory::getOrderCnt);
        Page<ClothesSocialCategory> pages = clothesSocialCategoryMapper.selectPage(page, queryWrapper);
        return pages;
    }
    @Override
    public FebsResponse addGroup(AdminClothesCategoryAddDto dto) {
        ClothesSocialCategory entity = new ClothesSocialCategory();
        entity.setName(dto.getName());
        entity.setOrderCnt(dto.getOrderCnt());
        clothesSocialCategoryMapper.insert(entity);
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse groupDelete(Long id) {
        ClothesSocialCategory vo = clothesSocialCategoryMapper.selectById(id);
        vo.setDeleteFlag(ClothesEnum.UP.getCode());
        clothesSocialCategoryMapper.updateById(vo);
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse groupUpdate(AdminClothesCategoryUpdateDto dto) {
        ClothesSocialCategory vo = clothesSocialCategoryMapper.selectById(dto.getId());
        vo.setName(dto.getName());
        vo.setOrderCnt(dto.getOrderCnt());
        clothesSocialCategoryMapper.updateById(vo);
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse groupState(Long id, Integer type) {
        ClothesSocialCategory vo = clothesSocialCategoryMapper.selectById(id);
        if(ClothesEnum.UP.getCode() == vo.getDeleteFlag()){
            throw new RuntimeException("该分组已删除,无法操作");
        }
        if(type == 1){
            vo.setHotState(vo.getHotState() == ClothesEnum.UP.getCode() ? ClothesEnum.DOWN.getCode() : ClothesEnum.UP.getCode());
        }
        if(type == 2){
            vo.setState(vo.getState() == ClothesEnum.UP.getCode() ? ClothesEnum.DOWN.getCode() : ClothesEnum.UP.getCode());
        }
        clothesSocialCategoryMapper.updateById(vo);
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse socialAdd(ClothesSocial dto) {
        if(ObjectUtil.isEmpty(dto.getMemberId())){
            throw new RuntimeException("请选择发布人");
        }
        if(ObjectUtil.isEmpty(dto.getCategoryId())){
            throw new RuntimeException("请选择分类");
        }
        ClothesSocial entity = new ClothesSocial();
        BeanUtil.copyProperties(dto, entity);
        clothesSocialMapper.insert(entity);
        String thumbs = dto.getThumbs();
        if (StrUtil.isNotEmpty(thumbs)) {
            List<String> list = StrUtil.splitTrim(thumbs, ",");
            if (CollUtil.isNotEmpty(list)) {
                int i = 1;
                for (String img : list) {
                    ClothesSocialFile clothesSocialFile = new ClothesSocialFile();
                    clothesSocialFile.setSocialId(entity.getId());
                    clothesSocialFile.setFileUrl(img);
                    clothesSocialFile.setSeq(i);
                    clothesSocialFileMapper.insert(clothesSocialFile);
                    i++;
                }
            }
        }
        if(ObjectUtil.isNotNull(dto.getTypeId())){
            ClothesSocialMuse clothesSocialMuse = new ClothesSocialMuse();
            clothesSocialMuse.setSocialId(entity.getId());
            clothesSocialMuse.setTypeId(dto.getTypeId());
            clothesSocialMuseMapper.insert(clothesSocialMuse);
        }
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse socialUpdate(ClothesSocial dto) {
        ClothesSocial entity = clothesSocialMapper.selectById(dto.getId());
        if(ObjectUtil.isNull(entity)){
            throw new RuntimeException("内容不存在,无法操作");
        }
        if(ObjectUtil.isNull(dto.getTypeId())){
            throw new RuntimeException("请选择设计类型");
        }
        entity.setCategoryId(dto.getCategoryId());
        entity.setMemberId(dto.getMemberId());
        entity.setName(dto.getName());
        entity.setContent(dto.getContent());
        entity.setIndexFile(dto.getIndexFile());
        entity.setOrderCnt(dto.getOrderCnt());
        clothesSocialMapper.updateById(entity);
        clothesSocialFileMapper.delete(
                Wrappers.lambdaQuery(ClothesSocialFile.class)
                .eq(ClothesSocialFile::getSocialId, entity.getId())
                );
        String thumbs = dto.getThumbs();
        if (StrUtil.isNotEmpty(thumbs)) {
            List<String> list = StrUtil.splitTrim(thumbs, ",");
            if (CollUtil.isNotEmpty(list)) {
                int i = 1;
                for (String img : list) {
                    ClothesSocialFile clothesSocialFile = new ClothesSocialFile();
                    clothesSocialFile.setSocialId(entity.getId());
                    clothesSocialFile.setFileUrl(img);
                    clothesSocialFile.setSeq(i);
                    clothesSocialFileMapper.insert(clothesSocialFile);
                    i++;
                }
            }
        }
        ClothesSocialMuse clothesSocialMuse = new ClothesSocialMuse();
        clothesSocialMuse.setSocialId(entity.getId());
        clothesSocialMuse.setTypeId(dto.getTypeId());
        clothesSocialMuseMapper.insert(clothesSocialMuse);
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public List<ClothesType> allType() {
        List<ClothesType> list =
                clothesTypeMapper.selectList(
                        Wrappers.lambdaQuery(ClothesType.class)
                                .eq(ClothesType::getState, ClothesEnum.UP.getCode())
                );
        if(CollUtil.isNotEmpty(list)){
            return list;
        }
        return Collections.emptyList();
    }
    @Override
    public List<ClothesCloth> allCloth(Long typeId) {
        List<ClothesTypeCloth> entities = clothesTypeClothMapper.selectList(
                Wrappers.lambdaQuery(ClothesTypeCloth.class)
                        .eq(ClothesTypeCloth::getTypeId, typeId)
        );
        if(CollUtil.isNotEmpty(entities)){
            Set<Long> ids = entities.stream().map(ClothesTypeCloth::getClothId).collect(Collectors.toSet());
            return clothesClothMapper.selectBatchIds(ids);
        }
        return Collections.emptyList();
    }
    @Override
    public List<ClothesPattern> allPattern(Long typeId) {
        List<ClothesTypePattern> entities = clothesTypePatternMapper.selectList(
                Wrappers.lambdaQuery(ClothesTypePattern.class)
                        .eq(ClothesTypePattern::getTypeId, typeId)
        );
        if(CollUtil.isNotEmpty(entities)){
            Set<Long> ids = entities.stream().map(ClothesTypePattern::getPatternId).collect(Collectors.toSet());
            return clothesPatternMapper.selectBatchIds(ids);
        }
        return Collections.emptyList();
    }
    @Override
    public List<ClothesLocation> allLocation(Long typeId) {
        List<ClothesTypeLocation> entities = clothesTypeLocationMapper.selectList(
                Wrappers.lambdaQuery(ClothesTypeLocation.class)
                        .eq(ClothesTypeLocation::getTypeId, typeId)
        );
        if(CollUtil.isNotEmpty(entities)){
            Set<Long> ids = entities.stream().map(ClothesTypeLocation::getLocationId).collect(Collectors.toSet());
            return clothesLocationMapper.selectBatchIds(ids);
        }
        return Collections.emptyList();
    }
    @Override
    public List<ClothesSize> allSize(Long typeId) {
        List<ClothesTypeSize> entities = clothesTypeSizeMapper.selectList(
                Wrappers.lambdaQuery(ClothesTypeSize.class)
                        .eq(ClothesTypeSize::getTypeId, typeId)
        );
        if(CollUtil.isNotEmpty(entities)){
            Set<Long> ids = entities.stream().map(ClothesTypeSize::getSizeId).collect(Collectors.toSet());
            return clothesSizeMapper.selectBatchIds(ids);
        }
        return Collections.emptyList();
    }
    @Override
    public List<ClothesArt> allArt(Long typeId) {
        List<ClothesTypeArt> entities = clothesTypeArtMapper.selectList(
                Wrappers.lambdaQuery(ClothesTypeArt.class)
                        .eq(ClothesTypeArt::getTypeId, typeId)
        );
        if(CollUtil.isNotEmpty(entities)){
            Set<Long> ids = entities.stream().map(ClothesTypeArt::getArtId).collect(Collectors.toSet());
            return clothesArtMapper.selectBatchIds(ids);
        }
        return Collections.emptyList();
    }
    @Override
    public FebsResponse socialMuseUpdate(ClothesSocialMuse dto) {
        Long id = dto.getId();
        ClothesSocialMuse entity = clothesSocialMuseMapper.selectById(id);
        if(ObjectUtil.isNotNull(entity)){
            entity.setClothId(dto.getClothId());
            entity.setSizeId(dto.getSizeId());
            entity.setArtId(dto.getArtId());
            clothesSocialMuseMapper.updateById(entity);
        }
        Long socialId = entity.getSocialId();
        ClothesSocial clothesSocial = clothesSocialMapper.selectById(socialId);
        List<AdminClothesPatternRemarkVo> patternData = dto.getPatternData();
        if(CollUtil.isNotEmpty(patternData)){
            Set<Long> patternIds = patternData.stream().map(AdminClothesPatternRemarkVo::getPatternId).collect(Collectors.toSet());
            clothesPatternRemarkMapper.delete(
                    Wrappers.lambdaQuery(ClothesPatternRemark.class)
                            .eq(ClothesPatternRemark::getType, SocialPatternLocationTypeEnum.MUSE.getValue())
                            .eq(ClothesPatternRemark::getSourceId, id)
                            .in(ClothesPatternRemark::getPatternId, patternIds)
            );
            for (AdminClothesPatternRemarkVo pattern : patternData) {
                ClothesPatternRemark clothesPatternRemark = new ClothesPatternRemark();
                clothesPatternRemark.setMemberId(clothesSocial.getMemberId());
                clothesPatternRemark.setType(SocialPatternLocationTypeEnum.MUSE.getValue());
                clothesPatternRemark.setSourceId(entity.getId());
                clothesPatternRemark.setPatternId(pattern.getPatternId());
                Map<String,String> remarkMap = new HashMap<>();
                remarkMap.put("file",pattern.getSkuPatternImage());
                remarkMap.put("text",pattern.getPatternText());
                clothesPatternRemark.setRemark(JSONUtil.parse(remarkMap).toString());
                clothesPatternRemarkMapper.insert(clothesPatternRemark);
            }
        }
        List<AdminClothesLocationRemarkVo> locationData = dto.getLocationData();
        if(CollUtil.isNotEmpty(locationData)){
            Set<Long> locationIds = locationData.stream().map(AdminClothesLocationRemarkVo::getLocationId).collect(Collectors.toSet());
            clothesLocationRemarkMapper.delete(
                    Wrappers.lambdaQuery(ClothesLocationRemark.class)
                            .eq(ClothesLocationRemark::getType, SocialPatternLocationTypeEnum.MUSE.getValue())
                            .eq(ClothesLocationRemark::getSourceId, id)
                            .in(ClothesLocationRemark::getLocationId, locationIds)
            );
            for (AdminClothesLocationRemarkVo location : locationData) {
                ClothesLocationRemark clothesLocationRemark = new ClothesLocationRemark();
                clothesLocationRemark.setMemberId(clothesSocial.getMemberId());
                clothesLocationRemark.setType(SocialPatternLocationTypeEnum.MUSE.getValue());
                clothesLocationRemark.setSourceId(entity.getId());
                clothesLocationRemark.setLocationId(location.getLocationId());
                Map<String,String> remarkMap = new HashMap<>();
                remarkMap.put("file",location.getSkuLocationImage());
                remarkMap.put("text",location.getLocationText());
                clothesLocationRemark.setRemark(JSONUtil.parse(remarkMap).toString());
                clothesLocationRemarkMapper.insert(clothesLocationRemark);
            }
        }
        return new FebsResponse().success().message("操作成功");
    }
}