2 İşlemeler 57501c29dc ... 888923409c

Yazar SHA1 Mesaj Tarih
  刘云鑫 888923409c feat:申诉导出 2 hafta önce
  刘云鑫 1ec03e9355 feat:查看申诉详情 2 hafta önce

+ 20 - 4
alien-entity/src/main/java/shop/alien/entity/store/excelVo/util/ExcelGenerator.java

@@ -3,22 +3,38 @@ package shop.alien.entity.store.excelVo.util;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
 import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 import java.io.*;
 import java.io.*;
 import java.lang.reflect.Field;
 import java.lang.reflect.Field;
 import java.net.URL;
 import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.List;
 import java.util.List;
 
 
 public class ExcelGenerator {
 public class ExcelGenerator {
 
 
+    private static final Logger log = LoggerFactory.getLogger(ExcelGenerator.class);
+
+    /**
+     * 生成 Excel 到本地路径。会在写入前确保父目录存在(含 Linux 生产环境;旧实现仅在 Windows 下 mkdirs,
+     * 导致如 /usr/local/alien/file/excel/generate/ 未预先创建时出现 FileNotFoundException)。
+     */
     public static <T> String generateExcel(String filePath, List<T> dataList, Class<T> clazz) throws IOException {
     public static <T> String generateExcel(String filePath, List<T> dataList, Class<T> clazz) throws IOException {
         String osName = System.getProperty("os.name").toLowerCase();
         String osName = System.getProperty("os.name").toLowerCase();
         if (osName.contains("win")) {
         if (osName.contains("win")) {
             filePath = "c:/" + filePath;
             filePath = "c:/" + filePath;
-            String substring = filePath.substring(0, filePath.lastIndexOf("/"));
-            File dir = new File(substring);
-            if (!dir.exists()) {
-                dir.mkdirs();
+        }
+        Path outputPath = Paths.get(filePath);
+        Path parentDirectory = outputPath.getParent();
+        if (parentDirectory != null) {
+            try {
+                Files.createDirectories(parentDirectory);
+            } catch (IOException e) {
+                log.error("创建 Excel 输出目录失败, filePath={}, parentDirectory={}", filePath, parentDirectory, e);
+                throw e;
             }
             }
         }
         }
         // 创建一个新的工作簿
         // 创建一个新的工作簿

+ 8 - 0
alien-entity/src/main/java/shop/alien/mapper/LifeAppealManageMapper.java

@@ -41,4 +41,12 @@ public interface LifeAppealManageMapper extends BaseMapper<LifeAppealManage> {
             @Param("appealType") String appealType,
             @Param("appealType") String appealType,
             @Param("storeContact") String storeContact);
             @Param("storeContact") String storeContact);
 
 
+    /**
+     * 平台申诉管理:根据评论申诉主键 id 查询单条详情(与列表查询字段一致)
+     *
+     * @param id store_comment_appeal.id
+     * @return 申诉详情,不存在时返回 null
+     */
+    LifeAppealManageVo getAppealDetailById(@Param("id") Integer id);
+
 }
 }

+ 47 - 0
alien-entity/src/main/resources/mapper/LifeAppealManageMapper.xml

@@ -74,4 +74,51 @@
         appeal.created_time DESC
         appeal.created_time DESC
     </select>
     </select>
 
 
+    <!-- 与 getAppealManagement 同字段,按评论申诉主键查单条,供平台端详情 -->
+    <select id="getAppealDetailById" resultType="shop.alien.entity.store.vo.LifeAppealManageVo">
+        SELECT
+        appeal.id,
+        appeal.store_id,
+        store.store_name,
+        su.`name` AS store_contact,
+        lu.user_phone AS user_phone,
+        store.store_tel AS store_phone,
+        `comment`.comment_content AS customer_report,
+        appeal.appeal_reason,
+        appeal.appeal_status AS appeal_type,
+        si.img_url as appeal_image,
+        sg.img_url AS commentImage,
+        CASE
+        appeal.appeal_status
+        WHEN 0 THEN
+        "待处理"
+        WHEN 1 THEN
+        "成功"
+        WHEN 2 THEN
+        "失败"
+        END AS appeal_type_name,
+        `comment`.business_type,
+        CASE
+        `comment`.business_type
+        WHEN 1 THEN
+        "订单评论"
+        WHEN 2 THEN
+        "动态社区评论"
+        WHEN 3 THEN
+        "活动评论"
+        END AS business_type_name,
+        appeal.created_time AS appeal_time
+        FROM
+        store_comment_appeal appeal
+        LEFT JOIN store_info store ON appeal.store_id = store.id
+        LEFT JOIN store_user su ON su.store_id = store.id and su.delete_flag = 0
+        LEFT JOIN store_comment `comment` ON `comment`.id = appeal.comment_id
+        LEFT JOIN life_user lu ON `comment`.user_id = lu.id
+        LEFT JOIN store_img si ON appeal.img_id = si.id
+        LEFT JOIN store_img sg ON sg.id = `comment`.img_id
+        WHERE
+        appeal.id = #{id}
+        LIMIT 1
+    </select>
+
 </mapper>
 </mapper>

+ 13 - 0
alien-store/src/main/java/shop/alien/store/controller/LifeAppealManageController.java

@@ -124,4 +124,17 @@ public class LifeAppealManageController {
         String s = lifeAppealManageService.appealsExport(appealType, storeName, storePhone);
         String s = lifeAppealManageService.appealsExport(appealType, storeName, storePhone);
         return R.data(s);
         return R.data(s);
     }
     }
+
+    /**
+     * 根据申诉主键查询详情(平台申诉管理列表同维度的单条数据)。
+     *
+     * @param id 评论申诉主键,对应列表中的记录 id
+     */
+    @ApiOperation("根据id查询申诉详情")
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "申诉id(store_comment_appeal 主键)", dataType = "Integer", paramType = "query", required = true)})
+    @GetMapping("/getAppealDetail")
+    public R<LifeAppealManageVo> getAppealDetail(@RequestParam("id") Integer id) {
+        log.info("LifeAppealManageController.getAppealDetail?id={}", id);
+        return lifeAppealManageService.getAppealDetailById(id);
+    }
 }
 }

+ 23 - 0
alien-store/src/main/java/shop/alien/store/service/LifeAppealManageService.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -18,6 +19,7 @@ import shop.alien.entity.store.dto.LifeAppealManageDto;
 import shop.alien.entity.store.excelVo.LifeAppealManageExcelVo;
 import shop.alien.entity.store.excelVo.LifeAppealManageExcelVo;
 import shop.alien.entity.store.excelVo.StoreInfoExcelVo;
 import shop.alien.entity.store.excelVo.StoreInfoExcelVo;
 import shop.alien.entity.store.excelVo.util.ExcelGenerator;
 import shop.alien.entity.store.excelVo.util.ExcelGenerator;
+import shop.alien.entity.result.R;
 import shop.alien.entity.store.vo.LifeAppealManageVo;
 import shop.alien.entity.store.vo.LifeAppealManageVo;
 import shop.alien.mapper.LifeAppealManageMapper;
 import shop.alien.mapper.LifeAppealManageMapper;
 import shop.alien.mapper.LifeNoticeMapper;
 import shop.alien.mapper.LifeNoticeMapper;
@@ -36,6 +38,7 @@ import java.util.UUID;
 /**
 /**
  * 申诉管理
  * 申诉管理
  */
  */
+@Slf4j
 @Service
 @Service
 @RequiredArgsConstructor
 @RequiredArgsConstructor
 public class LifeAppealManageService {
 public class LifeAppealManageService {
@@ -160,4 +163,24 @@ public class LifeAppealManageService {
         String url = aliOSSUtil.uploadFile(new File(filePath), "excel/" + fileName + ".xlsx");
         String url = aliOSSUtil.uploadFile(new File(filePath), "excel/" + fileName + ".xlsx");
         return url;
         return url;
     }
     }
+
+    /**
+     * 平台端:根据申诉主键查询详情(与「获取申诉列表」同一数据源 store_comment_appeal)。
+     *
+     * @param id 评论申诉表主键 {@code store_comment_appeal.id}
+     * @return 成功返回详情;id 为空或记录不存在返回失败信息
+     */
+    public R<LifeAppealManageVo> getAppealDetailById(Integer id) {
+        if (id == null) {
+            log.warn("LifeAppealManageService.getAppealDetailById: 申诉ID为空");
+            return R.fail("申诉ID不能为空");
+        }
+        LifeAppealManageVo appealDetail = lifeAppealManageMapper.getAppealDetailById(id);
+        if (appealDetail == null) {
+            log.info("LifeAppealManageService.getAppealDetailById: 未找到记录, id={}", id);
+            return R.fail("申诉记录不存在");
+        }
+        log.info("LifeAppealManageService.getAppealDetailById: 查询成功, id={}, storeId={}", id, appealDetail.getStoreId());
+        return R.data(appealDetail);
+    }
 }
 }