| | |
| | | |
| | | 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; |
| | | import cc.mrbird.febs.mall.dto.clothes.*; |
| | | import cc.mrbird.febs.mall.entity.*; |
| | |
| | | import cc.mrbird.febs.mall.vo.clothes.*; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | private final ClothesTypePatternMapper clothesTypePatternMapper; |
| | | private final ClothesTypeSizeMapper clothesTypeSizeMapper; |
| | | private final ClothesSizeMapper clothesSizeMapper; |
| | | private final ClothesPatternMapper clothesPatternMapper; |
| | | private final ClothesLocationMapper clothesLocationMapper; |
| | | private final ClothesClothMapper clothesClothMapper; |
| | | private final ClothesArtMapper clothesArtMapper; |
| | | private final ClothesTypeLocationMapper clothesTypeLocationMapper; |
| | | private final ClothesTypeArtMapper clothesTypeArtMapper; |
| | | private final ClothesMemberStatureMapper clothesMemberStatureMapper; |
| | | private final ClothesOrderDraftMapper clothesOrderDraftMapper; |
| | | private final ClothesPatternRemarkMapper clothesPatternRemarkMapper; |
| | | private final ClothesLocationRemarkMapper clothesLocationRemarkMapper; |
| | | |
| | | @Override |
| | | public FebsResponse clothesType() { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse statureDel(ApiClothesMemberStatureInfoDto dto) { |
| | | |
| | | public FebsResponse statureUpdateState(ApiClothesMemberStatureUpdateStateDto dto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | clothesMemberStatureMapper.delete( |
| | | 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, |
| | | Wrappers.lambdaUpdate(ClothesMemberStature.class) |
| | | .set(ClothesMemberStature::getDelFlag, ClothesEnum.UP.getCode()) |
| | | .eq(ClothesMemberStature::getId, dto.getId()) |
| | | .eq(ClothesMemberStature::getMemberId, memberId) |
| | | .eq(ClothesMemberStature::getDelFlag, ClothesEnum.DOWN.getCode()) |
| | | ); |
| | | |
| | | return new FebsResponse().success().message("操作成功"); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public FebsResponse draftSave(ApiMyDraftSaveDto dto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | |
| | | ClothesOrderDraft clothesOrderDraft = new ClothesOrderDraft(); |
| | | clothesOrderDraft.setMemberId(memberId); |
| | | |
| | | Long typeId = ObjectUtil.defaultIfNull(dto.getTypeId(),0L); |
| | | ClothesType clothesType = clothesTypeMapper.selectById(typeId); |
| | | if (ObjectUtil.isNull(clothesType)){ |
| | | throw new FebsException("请选择商品"); |
| | | } |
| | | if (ClothesEnum.UP.getCode() != clothesType.getState()){ |
| | | throw new FebsException("商品已下架"); |
| | | } |
| | | clothesOrderDraft.setTypeId(typeId); |
| | | |
| | | Long sizeId = ObjectUtil.defaultIfNull(dto.getSizeId(),0L); |
| | | ClothesSize clothesSize = clothesSizeMapper.selectById(sizeId); |
| | | if (ObjectUtil.isNull(clothesSize)){ |
| | | throw new FebsException("请选择尺码"); |
| | | } |
| | | clothesOrderDraft.setSizeId(sizeId); |
| | | |
| | | Long clothId = ObjectUtil.defaultIfNull(dto.getClothId(),0L); |
| | | ClothesCloth clothesCloth = clothesClothMapper.selectById(clothId); |
| | | if (ObjectUtil.isNull(clothesCloth)){ |
| | | throw new FebsException("请选择布料"); |
| | | } |
| | | clothesOrderDraft.setClothId(clothId); |
| | | |
| | | Long artId = ObjectUtil.defaultIfNull(dto.getArtId(),0L); |
| | | ClothesArt clothesArt = clothesArtMapper.selectById(artId); |
| | | if (ObjectUtil.isNull(clothesArt)){ |
| | | throw new FebsException("请选择工艺"); |
| | | } |
| | | clothesOrderDraft.setArtId(artId); |
| | | |
| | | Long statureId = ObjectUtil.defaultIfNull(dto.getStatureId(),0L); |
| | | ClothesMemberStature clothesMemberStature = clothesMemberStatureMapper.selectById(statureId); |
| | | if (ObjectUtil.isNotNull(clothesMemberStature)){ |
| | | 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("操作成功"); |
| | | } |
| | | } |