Administrator
2025-07-22 317bb4aefb93d4e3797b8a3fd1ac9e82665beb48
src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesServiceImpl.java
@@ -2,6 +2,7 @@
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.enumerates.ClothesEnum;
import cc.mrbird.febs.common.enumerates.SocialPatternLocationTypeEnum;
import cc.mrbird.febs.common.enumerates.StateUpDownEnum;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.LoginUserUtil;
@@ -23,9 +24,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@@ -46,6 +45,8 @@
    private final ClothesTypeArtMapper clothesTypeArtMapper;
    private final ClothesMemberStatureMapper clothesMemberStatureMapper;
    private final ClothesOrderDraftMapper clothesOrderDraftMapper;
    private final ClothesPatternRemarkMapper clothesPatternRemarkMapper;
    private final ClothesLocationRemarkMapper clothesLocationRemarkMapper;
    @Override
    public FebsResponse clothesType() {
@@ -89,6 +90,7 @@
            apiClothesTypeVo.setPatternState(clothesType.getPatternState());
            apiClothesTypeVo.setLocationState(clothesType.getLocationState());
            apiClothesTypeVo.setSizeState(clothesType.getSizeState());
            apiClothesTypeVo.setCarriageRuleId(10L);
        }
        return new FebsResponse().success().data(apiClothesTypeVo);
@@ -129,6 +131,7 @@
            List<ClothesSize> clothesSizes = clothesSizeMapper.selectList(
                    Wrappers.lambdaQuery(ClothesSize.class)
                            .in(ClothesSize::getId, collect)
                    .orderByAsc(ClothesSize::getOrderNum)
            );
@@ -261,6 +264,28 @@
    }
    @Override
    public FebsResponse statureUpdateState(ApiClothesMemberStatureUpdateStateDto dto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        ClothesMemberStature clothesMemberStature = clothesMemberStatureMapper.selectById(dto.getId());
        if (ObjectUtil.isNotEmpty(clothesMemberStature)){
            clothesMemberStature.setState(dto.getState());
            clothesMemberStatureMapper.updateById(clothesMemberStature);
            if(ClothesEnum.UP.getCode() == dto.getState()){
                clothesMemberStatureMapper.update(null,
                        Wrappers.lambdaUpdate(ClothesMemberStature.class)
                                .set(ClothesMemberStature::getState, ClothesEnum.DOWN.getCode())
                                .eq(ClothesMemberStature::getMemberId, memberId)
                                .ne(ClothesMemberStature::getId, clothesMemberStature.getId())
                                .eq(ClothesMemberStature::getDelFlag, ClothesEnum.DOWN.getCode())
                );
            }
        }
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse statureDel(ApiClothesMemberStatureInfoDto dto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        clothesMemberStatureMapper.update(null,
@@ -298,23 +323,6 @@
        }
        clothesOrderDraft.setSizeId(sizeId);
        Long patternId = ObjectUtil.defaultIfNull(dto.getPatternId(),0L);
        ClothesPattern pattern = clothesPatternMapper.selectById(patternId);
        if (ObjectUtil.isNull(pattern)){
            throw new FebsException("请选择图案");
        }
        clothesOrderDraft.setPatternId(patternId);
        if(StrUtil.isNotBlank(dto.getPatternRemark())){
            clothesOrderDraft.setPatternRemark(dto.getPatternRemark());
        }
        Long locationId = ObjectUtil.defaultIfNull(dto.getLocationId(),0L);
        ClothesLocation clothesLocation = clothesLocationMapper.selectById(locationId);
        if (ObjectUtil.isNull(clothesLocation)){
            throw new FebsException("请选择图案位置");
        }
        clothesOrderDraft.setLocationId(locationId);
        Long clothId = ObjectUtil.defaultIfNull(dto.getClothId(),0L);
        ClothesCloth clothesCloth = clothesClothMapper.selectById(clothId);
        if (ObjectUtil.isNull(clothesCloth)){
@@ -331,13 +339,58 @@
        Long statureId = ObjectUtil.defaultIfNull(dto.getStatureId(),0L);
        ClothesMemberStature clothesMemberStature = clothesMemberStatureMapper.selectById(statureId);
        if (ObjectUtil.isNull(clothesMemberStature)){
            throw new FebsException("请选择身材数据");
        if (ObjectUtil.isNotNull(clothesMemberStature)){
            clothesOrderDraft.setStatureId(clothesMemberStature.getId());
        }
        clothesOrderDraft.setStatureId(clothesMemberStature.getId());
        clothesOrderDraftMapper.insert(clothesOrderDraft);
        List<ApiPatternAddDto> patternList = dto.getPatternList();
        if (CollUtil.isNotEmpty(patternList)){
            for (ApiPatternAddDto patternAddDto : patternList){
                Long patternId = patternAddDto.getPatternId();
                String patternRemark = patternAddDto.getPatternRemark();
                ClothesPatternRemark clothesPatternRemark = new ClothesPatternRemark();
                clothesPatternRemark.setMemberId(memberId);
                clothesPatternRemark.setType(SocialPatternLocationTypeEnum.DRAFT.getValue());
                clothesPatternRemark.setSourceId(clothesOrderDraft.getId());
                clothesPatternRemark.setPatternId(patternId);
                clothesPatternRemark.setRemark(patternRemark);
                clothesPatternRemarkMapper.insert(clothesPatternRemark);
            }
        }
        List<ApiLocationAddDto> locationList = dto.getLocationList();
        if (CollUtil.isNotEmpty(locationList)){
            for (ApiLocationAddDto locationAddDto : locationList){
                Long locationId = locationAddDto.getLocationId();
                String patternRemark = locationAddDto.getPatternRemark();
                ClothesLocationRemark clothesLocationRemark = new ClothesLocationRemark();
                clothesLocationRemark.setMemberId(memberId);
                clothesLocationRemark.setType(SocialPatternLocationTypeEnum.DRAFT.getValue());
                clothesLocationRemark.setSourceId(clothesOrderDraft.getId());
                clothesLocationRemark.setLocationId(locationId);
                clothesLocationRemark.setRemark(patternRemark);
                clothesLocationRemarkMapper.insert(clothesLocationRemark);
            }
        }
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse findDraftCnt() {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        Integer integer = clothesOrderDraftMapper.selectCount(
                Wrappers.lambdaQuery(ClothesOrderDraft.class)
                        .eq(ClothesOrderDraft::getMemberId, memberId)
                        .eq(ClothesOrderDraft::getDelFlag, ClothesEnum.DOWN.getCode())
        );
        Map<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("draftCnt", integer);
        return new FebsResponse().success().data(objectObjectHashMap);
    }
}