Administrator
2025-07-25 56e264287413217c07b8f5cd7759a41bb4ba81e4
src/main/java/cc/mrbird/febs/mall/service/impl/ClothesTypeServiceImpl.java
@@ -2,14 +2,31 @@
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.StateUpDownEnum;
import cc.mrbird.febs.mall.dto.clothes.AdminClothesTypeInfoDto;
import cc.mrbird.febs.common.enumerates.*;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.properties.XcxProperties;
import cc.mrbird.febs.common.utils.SpringContextHolder;
import cc.mrbird.febs.common.utils.excl.ExcelSheetPO;
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.*;
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.*;
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.JSON;
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;
@@ -17,12 +34,18 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@@ -42,6 +65,24 @@
    private final ClothesTypeClothMapper clothesTypeClothMapper;
    private final ClothesTypePatternMapper clothesTypePatternMapper;
    private final ClothesTypeLocationMapper clothesTypeLocationMapper;
    private final ClothesOrderMapper clothesOrderMapper;
    private final ClothesOrderItemMapper clothesOrderItemMapper;
    private final MallExpressInfoMapper mallExpressInfoMapper;
    private final ClothesSocialMapper clothesSocialMapper;
    private final ClothesSocialFileMapper clothesSocialFileMapper;
    private final ClothesSocialMuseMapper clothesSocialMuseMapper;
    private final ClothesSocialCategoryMapper clothesSocialCategoryMapper;
    private final ClothesMemberStatureMapper clothesMemberStatureMapper;
    private final ClothesPatternRemarkMapper clothesPatternRemarkMapper;
    private final ClothesLocationRemarkMapper clothesLocationRemarkMapper;
    private final ClothesSocialCommentMapper clothesSocialCommentMapper;
    private final IApiMallMemberWalletService memberWalletService;
    private final IMallMoneyFlowService mallMoneyFlowService;
    private final XcxProperties xcxProperties = SpringContextHolder.getBean(XcxProperties.class);
    @Autowired
    private WeixinServiceUtil weixinServiceUtil;
    @Override
    public IPage<ClothesType> adminTypeList(ClothesType dto, QueryRequest request) {
@@ -126,6 +167,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());
@@ -168,11 +210,15 @@
        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());
        clothesPattern.setContent(dto.getContent());
        clothesPattern.setBoxWidth(dto.getBoxWidth());
        clothesPattern.setBoxHeight(dto.getBoxHeight());
        clothesPattern.setLeftPercent(dto.getLeftPercent());
        clothesPattern.setTopPercent(dto.getTopPercent());
        clothesPatternMapper.insert(clothesPattern);
        return new FebsResponse().success().message("操作成功");
    }
@@ -191,7 +237,11 @@
                            .set(ClothesPattern::getContent, dto.getContent())
                            .set(ClothesPattern::getOrderNum, dto.getOrderNum())
                            .set(ClothesPattern::getPrice, dto.getPrice())
                            .set(ClothesPattern::getType, dto.getType())
                            .set(ClothesPattern::getBoxHeight, dto.getBoxHeight())
                            .set(ClothesPattern::getBoxWidth, dto.getBoxWidth())
                            .set(ClothesPattern::getLeftPercent, dto.getLeftPercent())
                            .set(ClothesPattern::getTopPercent, dto.getTopPercent())
            );
        }
        return new FebsResponse().success().message("操作成功");
@@ -214,6 +264,10 @@
        clothesLocation.setContent(dto.getContent());
        clothesLocation.setPrice(dto.getPrice());
        clothesLocation.setOrderNum(dto.getOrderNum());
        clothesLocation.setBoxHeight(dto.getBoxHeight());
        clothesLocation.setBoxWidth(dto.getBoxWidth());
        clothesLocation.setLeftPercent(dto.getLeftPercent());
        clothesLocation.setTopPercent(dto.getTopPercent());
        clothesLocationMapper.insert(clothesLocation);
        return new FebsResponse().success().message("操作成功");
    }
@@ -232,6 +286,10 @@
                            .set(ClothesLocation::getPrice, dto.getPrice())
                            .set(ClothesLocation::getImage, dto.getImage())
                            .set(ClothesLocation::getContent, dto.getContent())
                            .set(ClothesLocation::getBoxHeight, dto.getBoxHeight())
                            .set(ClothesLocation::getBoxWidth, dto.getBoxWidth())
                            .set(ClothesLocation::getLeftPercent, dto.getLeftPercent())
                            .set(ClothesLocation::getTopPercent, dto.getTopPercent())
            );
        }
        return new FebsResponse().success().message("操作成功");
@@ -421,4 +479,904 @@
        }
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public IPage<AdminClothesOrderListVo> getOrderListInPage(AdminClothesOrderListDto dto, QueryRequest request) {
        Page<AdminClothesOrderListVo> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<AdminClothesOrderListVo> vos = clothesOrderMapper.selectOrderListInPage(page, dto);
        return vos;
    }
    @Override
    public FebsResponse deliverGoods(AdminClothesDeliverGoodsDto dto) {
        ClothesOrder clothesOrder = clothesOrderMapper.selectById(dto.getId());
        if(ObjectUtil.isNull(clothesOrder)){
            return new FebsResponse().fail().message("订单不存在,刷新后重试");
        }
        Integer status = clothesOrder.getStatus();
        if(ClothesOrderStatusEnum.WAIT_SHIPPING.getValue() != status){
            return new FebsResponse().fail().message("订单不是待发货状态");
        }
        String expressNo = dto.getExpressNo();
        if(StrUtil.isEmpty(expressNo)){
            return new FebsResponse().fail().message("请输入物流单号");
        }
        String expressCom = dto.getExpressCom();
        if(StrUtil.isEmpty(expressCom)){
            return new FebsResponse().fail().message("请输入物流公司");
        }
        MallExpressInfo mallExpressInfo = new MallExpressInfo();
        mallExpressInfo.setMemberId(clothesOrder.getMemberId());
        mallExpressInfo.setOrderId(clothesOrder.getId());
        mallExpressInfo.setOrderNo(clothesOrder.getOrderNo());
        mallExpressInfo.setExpressNo(expressNo);
        mallExpressInfo.setExpressCom(expressCom);
        mallExpressInfoMapper.insert(mallExpressInfo);
        clothesOrderMapper.update(
                null,
                Wrappers.lambdaUpdate(ClothesOrder.class)
                .set(ClothesOrder::getStatus, ClothesOrderStatusEnum.WAIT_FINISH.getValue())
                .set(ClothesOrder::getUpdatedTime, new Date())
                .set(ClothesOrder::getDeliveryState, OrderDeliveryStateEnum.DELIVERY_FINISH.getValue())
                        .eq(ClothesOrder::getId, clothesOrder.getId())
        );
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse deliverGoodsUpdate(AdminClothesDeliverGoodsDto dto) {
        ClothesOrder clothesOrder = clothesOrderMapper.selectById(dto.getId());
        if(ObjectUtil.isNull(clothesOrder)){
            return new FebsResponse().fail().message("订单不存在,刷新后重试");
        }
        Integer status = clothesOrder.getStatus();
        if(ClothesOrderStatusEnum.WAIT_FINISH.getValue() != status){
            return new FebsResponse().fail().message("订单不是待发货状态");
        }
        String expressNo = dto.getExpressNo();
        if(StrUtil.isEmpty(expressNo)){
            return new FebsResponse().fail().message("请输入物流单号");
        }
        String expressCom = dto.getExpressCom();
        if(StrUtil.isEmpty(expressCom)){
            return new FebsResponse().fail().message("请输入物流公司");
        }
        MallExpressInfo mallExpressInfo = mallExpressInfoMapper.selectOne(
                Wrappers.lambdaQuery(MallExpressInfo.class)
                        .eq(MallExpressInfo::getOrderId, clothesOrder.getId())
                        .eq(MallExpressInfo::getOrderNo, clothesOrder.getOrderNo())
                        .last("limit 1")
        );
        if(ObjectUtil.isNull(mallExpressInfo)){
            return new FebsResponse().fail().message("请先发货");
        }
        mallExpressInfoMapper.update(
                null,
                Wrappers.lambdaUpdate(MallExpressInfo.class)
                        .set(MallExpressInfo::getExpressNo, expressNo)
                        .set(MallExpressInfo::getExpressCom, expressCom)
                        .set(MallExpressInfo::getUpdatedTime, new Date())
                        .eq(MallExpressInfo::getId, mallExpressInfo.getId())
        );
        return new FebsResponse().success().message("操作成功");
    }
    private void clothesUpdateStatusAndUpdateTimeById(Long id, Date date, int value) {
        clothesOrderMapper.update(
                null,
                Wrappers.lambdaUpdate(ClothesOrder.class)
                        .set(ClothesOrder::getStatus, value)
                        .set(ClothesOrder::getUpdatedTime, date)
                        .eq(ClothesOrder::getId, id)
        );
    }
    private Boolean weChatRefundOrderEvent(int refundMoney, BigDecimal orderAmount, String orderNo, String refundNo) {
        Boolean flag;
        Boolean debug = xcxProperties.getDebug();
        if (debug) {
            if(orderAmount.compareTo(BigDecimal.ZERO) > 0){
                boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, 1, 1, null);
                flag = b;
            }else{
                flag = true;
            }
        } else {
            if(orderAmount.compareTo(BigDecimal.ZERO) > 0){
                log.info("开始调用退款接口。。。退款编号为{}", refundNo);
                boolean b = weixinServiceUtil.comRefund(orderNo, refundNo, refundMoney, refundMoney, null);
                flag = b;
            }else{
                flag = true;
            }
        }
        return flag;
    }
    @Override
    public FebsResponse refundOrder(AdminClothesRefundOrderDto dto) {
        ClothesOrder clothesOrder = clothesOrderMapper.selectById(dto.getId());
        if(ObjectUtil.isNull(clothesOrder)){
            return new FebsResponse().fail().message("订单不存在,刷新后重试");
        }
        Integer status = clothesOrder.getStatus();
        if(ClothesOrderStatusEnum.WAIT_SHIPPING.getValue() != status){
            return new FebsResponse().fail().message("订单不是待发货状态");
        }
        //退款订单编号
        String orderNo = clothesOrder.getOrderNo();
        //退款退款编号
        String refundNo = clothesOrder.getOrderNo()+"_REFUND_"+clothesOrder.getId();
        //退款订单金额
        BigDecimal orderAmount = clothesOrder.getRealAmount();
        //余额支付退款
        if(ClothesOrderPayTypeEnum.BALANCE.getName().equals(clothesOrder.getPayMethod())){
            log.info("余额支付退款");
            if(orderAmount.compareTo(BigDecimal.ZERO) > 0){
                //更新订单详情
                clothesUpdateStatusAndUpdateTimeById(clothesOrder.getId(),new Date(),ClothesOrderStatusEnum.CANCEL.getValue());
                memberWalletService.add(orderAmount, clothesOrder.getMemberId(), "balance");
                mallMoneyFlowService.addMoneyFlow(
                        clothesOrder.getMemberId(),
                        orderAmount,
                        ScoreFlowTypeEnum.REFUND.getValue(),
                        clothesOrder.getOrderNo(),
                        FlowTypeEnum.BALANCE.getValue(),
                        StrUtil.format(ScoreFlowTypeEnum.REFUND.getDesc(),orderAmount),
                        2
                );
            }
            return new FebsResponse().success().message("退款成功");
        }else if(ClothesOrderPayTypeEnum.WECHAT.getName().equals(clothesOrder.getPayMethod())){
            int refundMoney = orderAmount.multiply(new BigDecimal(100)).intValue();
            Boolean flag = weChatRefundOrderEvent(refundMoney, orderAmount, orderNo, refundNo);
            if(flag){
                if(orderAmount.compareTo(BigDecimal.ZERO) > 0){
                    //更新订单详情
                    clothesUpdateStatusAndUpdateTimeById(clothesOrder.getId(),new Date(),ClothesOrderStatusEnum.CANCEL.getValue());
                    mallMoneyFlowService.addMoneyFlow(
                            clothesOrder.getMemberId(),
                            orderAmount,
                            ScoreFlowTypeEnum.WECHAT_REFUND.getValue(),
                            clothesOrder.getOrderNo(),
                            FlowTypeEnum.BALANCE.getValue(),
                            StrUtil.format(ScoreFlowTypeEnum.WECHAT_REFUND.getDesc(),orderAmount),
                            2
                    );
                }
            }else{
                return new FebsResponse().fail().message("退款失败,请联系客服人员");
            }
        }else{
            return new FebsResponse().fail().message("退款失败,请联系客服人员");
        }
        return new FebsResponse().success().message("退款成功");
    }
    @Override
    public void confirmOrder(long orderId) {
        ClothesOrder clothesOrder = clothesOrderMapper.selectById(orderId);
        if(ObjectUtil.isNotNull(clothesOrder) && ClothesOrderStatusEnum.WAIT_FINISH.getValue() == clothesOrder.getStatus()){
            clothesUpdateStatusAndUpdateTimeById(clothesOrder.getId(),new Date(),ClothesOrderStatusEnum.FINISH.getValue());
        }
    }
    @Override
    public void exportOrderList(List<Long> orderIds, HttpServletResponse response) throws IOException {
        List<ExcelSheetPO> res = new ArrayList<>();
        ExcelSheetPO orderSheet = new ExcelSheetPO();
        String title = "订单列表";
        orderSheet.setSheetName(title);
        orderSheet.setTitle(title);
        String[] header = {"订单ID", "订单编号", "收货姓名", "收货电话", "收货地址", "商品详情", "备注", "物流单号", "物流公司", "物流公司码"};
        orderSheet.setHeaders(header);
        QueryRequest request = new QueryRequest();
        request.setPageNum(1);
        request.setPageSize(9999);
        List<ClothesOrder> dataList = clothesOrderMapper.selectList(
                Wrappers.lambdaQuery(ClothesOrder.class)
                        .in(ClothesOrder::getId, orderIds)
                        .eq(ClothesOrder::getDelFlag, 0)
                        .eq(ClothesOrder::getStatus, ClothesOrderStatusEnum.WAIT_SHIPPING.getValue()));
        Map<Long, ClothesType> longClothesTypeHashMap = new HashMap<>();
        if(CollUtil.isNotEmpty(dataList)){
            Set<Long> typeIds = dataList.stream().map(ClothesOrder::getTypeId).collect(Collectors.toSet());
            List<ClothesType> clothesTypes = clothesTypeMapper.selectList(
                    Wrappers.lambdaQuery(ClothesType.class)
                            .in(ClothesType::getId, typeIds)
            );
            if(CollUtil.isNotEmpty(clothesTypes)){
                //stream操作clothesTypes,返回一个HashMap<Long, ClothesType>, key为clothesType.id, value为clothesType
                longClothesTypeHashMap = clothesTypes.stream().collect(Collectors.toMap(ClothesType::getId, clothesType -> clothesType));
            }
        }
        List<List<Object>> list = new ArrayList<>();
        if (dataList.size() > 0) {
            for (ClothesOrder item : dataList) {
                List<Object> temp = new ArrayList<>();
                temp.add(item.getId());
                temp.add(item.getOrderNo());
                temp.add(item.getName());
                temp.add(item.getPhone());
                temp.add(item.getAddress());
                temp.add(longClothesTypeHashMap.get(item.getTypeId()).getName());
                temp.add(item.getRemark());
                list.add(temp);
            }
        }
        orderSheet.setDataList(list);
        res.add(orderSheet);
        response = ResponseHeadUtil.setExcelHead(response);
        response.setHeader("Content-Disposition",
                "attachment;filename=" + URLEncoder.encode(title + DateUtil.format(new Date(), "yyyyMMDDHHmmss") + ".xlsx".trim(), "UTF-8"));
        OutputStream os = response.getOutputStream();
        ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true);
    }
    @Override
    public void deliverGoodsImport(AdminClothesDeliverGoodsDto dto) {
        ClothesOrder clothesOrder = clothesOrderMapper.selectById(dto.getId());
        if(ObjectUtil.isNull(clothesOrder)){
            return;
        }
        Integer status = clothesOrder.getStatus();
        if(ClothesOrderStatusEnum.WAIT_SHIPPING.getValue() != status){
            return;
        }
        String expressNo = dto.getExpressNo();
        if(StrUtil.isEmpty(expressNo)){
            return;
        }
        String expressCom = dto.getExpressCom();
        if(StrUtil.isEmpty(expressCom)){
            return;
        }
        mallExpressInfoMapper.update(
                null,
                Wrappers.lambdaUpdate(MallExpressInfo.class)
                        .set(MallExpressInfo::getExpressNo, expressNo)
                        .set(MallExpressInfo::getExpressCom, expressCom)
                        .eq(MallExpressInfo::getOrderId, clothesOrder.getId())
                        .eq(MallExpressInfo::getOrderNo, clothesOrder.getOrderNo())
        );
        clothesOrderMapper.update(
                null,
                Wrappers.lambdaUpdate(ClothesOrder.class)
                        .set(ClothesOrder::getStatus, ClothesOrderStatusEnum.WAIT_FINISH.getValue())
                        .set(ClothesOrder::getUpdatedTime, new Date())
                        .set(ClothesOrder::getDeliveryState, OrderDeliveryStateEnum.DELIVERY_ING.getValue())
                        .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 IPage<AdminClothesSocialCommentVo> socialComment(ClothesSocialComment dto, QueryRequest request) {
        Page<AdminClothesSocialCommentVo> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<AdminClothesSocialCommentVo> vos = clothesSocialCommentMapper.selectSocialCommentListInPage(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 commentStateSwitch(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::getCommentState, state)
                        .eq(ClothesSocial::getId, id)
        );
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse showStateSwitch(Long id, Integer state) {
        ClothesSocialComment clothesSocialComment = clothesSocialCommentMapper.selectById(id);
        if(ObjectUtil.isNull(clothesSocialComment)){
            throw new RuntimeException("评论不存在");
        }
        clothesSocialCommentMapper.update(
                null,
                Wrappers.lambdaUpdate(ClothesSocialComment.class)
                        .set(ClothesSocialComment::getShowState, state)
                        .eq(ClothesSocialComment::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());
        entity.setLikeCnt(dto.getLikeCnt());
        entity.setCollectCnt(dto.getCollectCnt());
        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("操作成功");
    }
    @Override
    public FebsResponse printOrder(AdminClothesPrintOrderDto dto) {
        HashMap<String, Object> objectObjectHashMap = new HashMap<>();
        ClothesOrder order = clothesOrderMapper.selectById(dto.getId());
        if (ObjectUtil.isNotNull(order)){
            objectObjectHashMap.put("orderNo", order.getOrderNo());
        }
        ClothesType clothesType = clothesTypeMapper.selectById(order.getTypeId());
        if (ObjectUtil.isNotNull(clothesType)) {
            objectObjectHashMap.put("typeName", clothesType.getName());
            objectObjectHashMap.put("typeFront", clothesType.getImageFront());
            objectObjectHashMap.put("typeBack", clothesType.getImageBack());
        }
        List<ClothesOrderItem> clothesOrderItems = clothesOrderItemMapper.selectList(
                Wrappers.lambdaQuery(ClothesOrderItem.class)
                        .eq(ClothesOrderItem::getOrderId, order.getId())
        );
        if(CollUtil.isNotEmpty(clothesOrderItems)){
            for (ClothesOrderItem item : clothesOrderItems){
                if (ClothesOrderItemEnum.CLOTH.getCode() == item.getType()) {
                    ClothesCloth cloth = clothesClothMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(cloth)) {
                        objectObjectHashMap.put("clothName", cloth.getName());
                        objectObjectHashMap.put("clothCode", cloth.getCode());
                    }
                    continue;
                } else if (ClothesOrderItemEnum.SIZE.getCode() == item.getType()) {
                    ClothesSize size = clothesSizeMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(size)) {
                        objectObjectHashMap.put("sizeName", size.getName());
                        objectObjectHashMap.put("sizeCode", size.getCode());
                    }
                    continue;
                } else if (ClothesOrderItemEnum.LOCATION.getCode() == item.getType()) {
                    ClothesLocation location = clothesLocationMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(location)) {
                        objectObjectHashMap.put("locationName", location.getName());
                        objectObjectHashMap.put("locationCode", location.getCode());
                        JSON parse = JSONUtil.parse(item.getRemark());
                        objectObjectHashMap.put("locationText", parse.getByPath("text", String.class));
                        objectObjectHashMap.put("locationImage", parse.getByPath("file", String.class));
                    }else{
                        objectObjectHashMap.put("locationName", "");
                        objectObjectHashMap.put("locationCode", "");
                        objectObjectHashMap.put("locationText", "");
                        objectObjectHashMap.put("locationImage", "");
                    }
                    continue;
                } else if (ClothesOrderItemEnum.PATTERN.getCode() == item.getType()) {
                    ClothesPattern pattern = clothesPatternMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(pattern)) {
                        objectObjectHashMap.put("patternName", pattern.getName());
                        objectObjectHashMap.put("patternCode", pattern.getCode());
                        JSON parse = JSONUtil.parse(item.getRemark());
                        objectObjectHashMap.put("patternText", parse.getByPath("text", String.class));
                        objectObjectHashMap.put("patternImage", parse.getByPath("file", String.class));
                    }else{
                        objectObjectHashMap.put("patternName", "");
                        objectObjectHashMap.put("patternCode", "");
                        objectObjectHashMap.put("patternText", "");
                        objectObjectHashMap.put("patternImage", "");
                    }
                    continue;
                } else if (ClothesOrderItemEnum.ART.getCode() == item.getType()) {
                    ClothesArt art = clothesArtMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(art)) {
                        objectObjectHashMap.put("artName", art.getName());
                        objectObjectHashMap.put("artCode", art.getCode());
                    }
                    continue;
                } else if (ClothesOrderItemEnum.CUSTOMIZE.getCode() == item.getType()) {
                    ClothesMemberStature clothesMemberStature = clothesMemberStatureMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(clothesMemberStature)) {
                        objectObjectHashMap.put("statureName", clothesMemberStature.getName());
                    }
                    continue;
                } else {
                    continue;
                }
            }
        }
        return new FebsResponse().success().data(objectObjectHashMap);
    }
    @Override
    public AdminClothesPrintOrderVo printOrderEvent(AdminClothesPrintOrderDto dto) {
        AdminClothesPrintOrderVo vo = new AdminClothesPrintOrderVo();
        ClothesOrder order = clothesOrderMapper.selectById(dto.getId());
        if (ObjectUtil.isNotNull(order)){
            vo.setOrderNo(order.getOrderNo());
        }
        ClothesType clothesType = clothesTypeMapper.selectById(order.getTypeId());
        if (ObjectUtil.isNotNull(clothesType)) {
            vo.setTypeName(clothesType.getName());
            vo.setTypeFront(clothesType.getImageFront());
            vo.setTypeBack(clothesType.getImageBack());
        }
        List<ClothesOrderItem> clothesOrderItems = clothesOrderItemMapper.selectList(
                Wrappers.lambdaQuery(ClothesOrderItem.class)
                        .eq(ClothesOrderItem::getOrderId, order.getId())
        );
        if(CollUtil.isNotEmpty(clothesOrderItems)){
            String nullStr = "暂无";
            List<AdminClothesPrintLocationVo> locations = new ArrayList<>();
            List<AdminClothesPrintPatternVo> patterns = new ArrayList<>();
            for (ClothesOrderItem item : clothesOrderItems){
                if (ClothesOrderItemEnum.CLOTH.getCode() == item.getType()) {
                    ClothesCloth cloth = clothesClothMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(cloth)) {
                        vo.setClothCode(cloth.getCode());
                        vo.setClothName(cloth.getName());
                    }else{
                        vo.setClothCode(nullStr);
                        vo.setClothName(nullStr);
                    }
                    continue;
                } else if (ClothesOrderItemEnum.SIZE.getCode() == item.getType()) {
                    ClothesSize size = clothesSizeMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(size)) {
                        vo.setSizeName(size.getName());
                        vo.setSizeCode(size.getCode());
                    }else {
                        vo.setSizeName(nullStr);
                        vo.setSizeCode(nullStr);
                    }
                    continue;
                } else if (ClothesOrderItemEnum.LOCATION.getCode() == item.getType()) {
                    AdminClothesPrintLocationVo locationVo = new AdminClothesPrintLocationVo();
                    ClothesLocation location = clothesLocationMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(location)) {
                        locationVo.setLocationName(location.getName());
                        locationVo.setLocationCode(location.getCode());
                        JSON parse = JSONUtil.parse(item.getRemark());
                        locationVo.setLocationText(parse.getByPath("text", String.class));
                        locationVo.setLocationImage(parse.getByPath("file", String.class));
                    }else{
                        locationVo.setLocationName(nullStr);
                        locationVo.setLocationCode(nullStr);
                        locationVo.setLocationText(nullStr);
                        locationVo.setLocationImage(nullStr);
                    }
                    locations.add(locationVo);
                    vo.setLocations( locations);
                    continue;
                } else if (ClothesOrderItemEnum.PATTERN.getCode() == item.getType()) {
                    AdminClothesPrintPatternVo patternVo = new AdminClothesPrintPatternVo();
                    ClothesPattern pattern = clothesPatternMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(pattern)) {
                        patternVo.setPatternName(pattern.getName());
                        patternVo.setPatternCode(pattern.getCode());
                        JSON parse = JSONUtil.parse(item.getRemark());
                        patternVo.setPatternText(parse.getByPath("text", String.class));
                        patternVo.setPatternImage(parse.getByPath("file", String.class));
                    }else{
                        patternVo.setPatternName(nullStr);
                        patternVo.setPatternCode(nullStr);
                        patternVo.setPatternText(nullStr);
                        patternVo.setPatternImage(nullStr);
                    }
                    patterns.add(patternVo);
                    vo.setPatterns( patterns);
                    continue;
                } else if (ClothesOrderItemEnum.ART.getCode() == item.getType()) {
                    ClothesArt art = clothesArtMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(art)) {
                        vo.setArtName(art.getName());
                        vo.setArtCode(art.getCode());
                    }else{
                        vo.setArtName(nullStr);
                        vo.setArtCode(nullStr);
                    }
                    continue;
                } else if (ClothesOrderItemEnum.CUSTOMIZE.getCode() == item.getType()) {
                    AdminClothesPrintMemberStatureVo memberStature = new AdminClothesPrintMemberStatureVo();
                    ClothesMemberStature clothesMemberStature = clothesMemberStatureMapper.selectById(item.getItemId());
                    if (ObjectUtil.isNotNull(clothesMemberStature)) {
                        memberStature.setName(clothesMemberStature.getName());
                        memberStature.setHeightLine(clothesMemberStature.getHeightLine());
                        memberStature.setBustLine(clothesMemberStature.getBustLine());
                        memberStature.setWaistLine(clothesMemberStature.getWaistLine());
                        memberStature.setWideLine(clothesMemberStature.getWideLine());
                        memberStature.setHipLine(clothesMemberStature.getHipLine());
                    }else{
                        memberStature.setName(nullStr);
                        memberStature.setHeightLine(BigDecimal.ZERO);
                        memberStature.setBustLine(BigDecimal.ZERO);
                        memberStature.setWaistLine(BigDecimal.ZERO);
                        memberStature.setWideLine(BigDecimal.ZERO);
                        memberStature.setHipLine(BigDecimal.ZERO);
                    }
                    vo.setMemberStature(memberStature);
                    continue;
                } else {
                    continue;
                }
            }
        }
        return vo;
    }
}