From 04f674fc0a2f07346fa3eeeba86ce43f435251e0 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期一, 11 八月 2025 16:57:12 +0800
Subject: [PATCH] 首页视频修改

---
 framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java |  133 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 127 insertions(+), 6 deletions(-)

diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java
index 8465e1b..f5f756c 100644
--- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java
@@ -15,9 +15,7 @@
 import cn.lili.common.security.context.UserContext;
 import cn.lili.common.security.enums.UserEnums;
 import cn.lili.modules.goods.entity.dos.*;
-import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
-import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
-import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
+import cn.lili.modules.goods.entity.dto.*;
 import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
 import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
 import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
@@ -47,9 +45,12 @@
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -57,6 +58,9 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URLEncoder;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -122,6 +126,9 @@
 
     @Autowired
     private Cache<GoodsVO> cache;
+
+    @Autowired
+    private GoodsService goodsService;
 
     @Autowired
     private COSUtil cosUtil;
@@ -218,10 +225,11 @@
         if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) {
             goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList()));
         }
+        Goods previousGoods = this.getById(goodsId);
         //淇敼鍟嗗搧
         this.updateById(goods);
         //淇敼鍟嗗搧sku淇℃伅
-        this.goodsSkuService.update(goods, goodsOperationDTO);
+        this.goodsSkuService.update(goods, goodsOperationDTO,previousGoods);
         //娣诲姞鐩稿唽
         if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) {
             this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId());
@@ -310,9 +318,91 @@
         return this.page(PageUtil.initPage(goodsSearchParams), goodsSearchParams.queryWrapper());
     }
 
+    @Override
+    public void queryExportGoods(HttpServletResponse response, GoodsSearchParams searchParams) {
+        List<Goods> list = this.list(searchParams.queryWrapper());
+
+        XSSFWorkbook workbook = initGoodsExportData(list);
+        try {
+            // 璁剧疆鍝嶅簲澶�
+            String fileName = URLEncoder.encode("鍟嗗搧娓呭崟", "UTF-8");
+            response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
+
+            ServletOutputStream out = response.getOutputStream();
+            workbook.write(out);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                workbook.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+    }
+    private XSSFWorkbook initGoodsExportData(List<Goods> list) {
+        List<GoodsExportDTO> goodsExportDTOs = new ArrayList<>();
+        for (Goods goods : list) {
+            GoodsExportDTO goodsExportDTO = new GoodsExportDTO();
+            BeanUtils.copyProperties(goods, goodsExportDTO);
+            goodsExportDTOs.add(goodsExportDTO);
+        }
+
+        XSSFWorkbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet("鍟嗗搧娓呭崟");
+        Row header = sheet.createRow(0);
+        String[] headers = {"鍟嗗搧鍚嶇О", "鍟嗗搧缂栧彿", "浠锋牸", "閿�鍞ā寮�", "鍟嗗搧绫诲瀷", "鐘舵��", "瀹℃牳鐘舵��", "搴楅摵鍚嶇О"};
+        for (int i = 0; i < headers.length; i++) {
+            Cell cell = header.createCell(i);
+            cell.setCellValue(headers[i]);
+        }
+        for (int i = 0; i < goodsExportDTOs.size(); i++) {
+            GoodsExportDTO goodsExportDTO = goodsExportDTOs.get(i);
+            Row row = sheet.createRow(i + 1);
+            row.createCell(0).setCellValue(goodsExportDTO.getGoodsName());
+            row.createCell(1).setCellValue(goodsExportDTO.getId());
+            row.createCell(2).setCellValue(goodsExportDTO.getPrice());
+            if ("RETAIL".equals(goodsExportDTO.getSalesModel())) {
+                row.createCell(3).setCellValue("闆跺敭");
+            } else if ("WHOLESALE".equals(goodsExportDTO.getSalesModel())) {
+                row.createCell(3).setCellValue("鎵瑰彂");
+            } else if ("PRESALE".equals(goodsExportDTO.getSalesModel())) {
+                row.createCell(3).setCellValue("棰勫敭");
+            } else {
+                row.createCell(3).setCellValue("鍏朵粬绫诲瀷");
+            }
+
+            if ("PHYSICAL_GOODS".equals(goodsExportDTO.getGoodsType())) {
+                row.createCell(4).setCellValue("瀹炵墿鍟嗗搧");
+            } else if ("VIRTUAL_GOODS".equals(goodsExportDTO.getGoodsType())) {
+                row.createCell(4).setCellValue("铏氭嫙鍟嗗搧");
+            } else {
+                row.createCell(4).setCellValue("鐢靛瓙鍗″埜");
+            }
+
+            if ("DOWN".equals(goodsExportDTO.getMarketEnable())) {
+                row.createCell(5).setCellValue("涓嬫灦");
+            } else if ("UPPER".equals(goodsExportDTO.getMarketEnable())) {
+                row.createCell(5).setCellValue("涓婃灦");
+            }
+
+            if ("TOBEAUDITED".equals(goodsExportDTO.getAuthFlag())) {
+                row.createCell(6).setCellValue("寰呭鏍�");
+            } else if ("PASS".equals(goodsExportDTO.getAuthFlag())) {
+                row.createCell(6).setCellValue("閫氳繃");
+            } else if ("REFUSE".equals(goodsExportDTO.getAuthFlag())) {
+                row.createCell(6).setCellValue("鎷掔粷");
+            }
+            row.createCell(7).setCellValue(goodsExportDTO.getStoreName());
+
+        }
+        return workbook;
+    }
     /**
      * 鍟嗗搧鏌ヨ
-     *
+     *g
      * @param goodsSearchParams 鏌ヨ鍙傛暟
      * @return 鍟嗗搧淇℃伅
      */
@@ -418,6 +508,36 @@
         queryWrapper.in(Goods::getId, goodsIds);
         List<Goods> goodsList = this.list(queryWrapper);
         this.updateGoodsStatus(goodsIds, goodsStatusEnum, goodsList);
+        return result;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean goodsSort(GoodsSortDTO req) {
+        boolean result;
+        //妫�娴嬬鐞嗗憳鏉冮檺
+        this.checkManagerAuthority();
+        LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(Goods::getGoodsSort,req.getSort());
+        updateWrapper.eq(Goods::getId, req.getGoodsId());
+        //鏌ヨ鍑烘瘮褰撳墠鎺掑簭澶х殑鍟嗗搧
+        LambdaQueryWrapper<Goods> query = Wrappers.<Goods>lambdaQuery();
+        query.gt(Goods::getGoodsSort,req.getSort());
+        List<Goods> goods = goodsService.list(query);
+        List<String> goodsIds = new ArrayList<>();
+        if (goods != null && !goods.isEmpty()) {
+         //閫傞厤娌℃湁鎺掑簭鐨勫晢鍝佹帓搴忓瓧娈典负null
+            goods.forEach(item -> {
+                if (item.getGoodsSort() != null) {
+                    item.setGoodsSort(item.getGoodsSort() + 1);
+                    goodsIds.add(item.getId());
+                }
+            });
+            goodsService.updateBatchById(goods);
+        }
+        result = this.update(updateWrapper);
+        goodsIds.add(req.getGoodsId());
+        this.updateEsGoods(goodsIds);
         return result;
     }
 
@@ -570,6 +690,7 @@
         this.baseMapper.addGoodsCommentNum(commentNum, goodsId);
     }
 
+
     /**
      * 鏇存柊鍟嗗搧鐘舵��
      *

--
Gitblit v1.8.0