Przeglądaj źródła

Merge remote-tracking branch 'origin/sit-three-categories' into sit-three-categories

lyx 5 miesięcy temu
rodzic
commit
ab17ba2c23

+ 21 - 0
alien-entity/src/main/java/shop/alien/entity/store/StoreInfoDraft.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableField;
 import java.io.Serializable;
+import java.util.List;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -187,6 +188,26 @@ public class StoreInfoDraft extends Model<StoreInfoDraft> {
     @TableField("food_licence_url")
     private String foodLicenceUrl;
 
+    @ApiModelProperty(value = "店铺评价")
+    @TableField("store_evaluate")
+    private String storeEvaluate;
+
+    @ApiModelProperty(value = "经营种类名称")
+    @TableField("business_type_name")
+    private String businessTypeName;
+
+    @ApiModelProperty(value = "经营类目名称")
+    @TableField("business_category_name")
+    private String businessCategoryName;
+
+    @ApiModelProperty(value = "其它资质证明(多个URL以逗号分隔,最多9张)")
+    @TableField("other_licenses")
+    private String otherLicenses;
+
+    @ApiModelProperty(value = "其他资质证明图片地址列表(临时字段,用于接收前端数据)")
+    @TableField(exist = false)
+    private List<String> otherQualificationImages;
+
 
     @Override
     protected Serializable pkVal() {

+ 8 - 4
alien-entity/src/main/java/shop/alien/entity/store/StoreStaffConfig.java

@@ -37,14 +37,18 @@ public class StoreStaffConfig extends Model<StoreStaffConfig> {
     @TableField("name")
     private String name;
 
-    @ApiModelProperty(value = "背景图片/视频(存储URL逗号分隔)")
-    @TableField("background_url")
-    private String backgroundUrl;
-
     @ApiModelProperty(value = "头像")
     @TableField("staff_image")
     private String staffImage;
 
+    @ApiModelProperty(value = "视频封面图片(存储URL逗号分隔)")
+    @TableField("video_head_url")
+    private String videoHeadUrl;
+
+    @ApiModelProperty(value = "背景图片/视频(存储URL逗号分隔)")
+    @TableField("background_url")
+    private String backgroundUrl;
+
     // @ApiModelProperty(value = "擅长标签id(字典表proficient_tag的dict_id逗号分隔)----废弃!")
     // @TableField("proficient_id")
     // private String proficientId;

+ 15 - 4
alien-store/src/main/java/shop/alien/store/controller/BarPerformanceController.java

@@ -66,12 +66,23 @@ public class BarPerformanceController {
      */
     @ApiOperation("新增或更新酒吧演出")
     @PostMapping("/saveOrUpdate")
-    public R<Integer> addOrUpdateBarPerformance(@RequestBody BarPerformance barPerformance) {
+    public R<BarPerformance> addOrUpdateBarPerformance(@RequestBody BarPerformance barPerformance) {
         log.info("BarPerformanceController.addOrUpdateBarPerformance?barPerformance={}", barPerformance);
         try {
-            int result = barPerformanceService.addOrUpdateBarPerformance(barPerformance);
-            if (result > 0) {
-                return R.success("操作成功");
+            BarPerformance result = barPerformanceService.addOrUpdateBarPerformance(barPerformance);
+            if (result != null) {
+                // 根据审核状态返回不同的提示信息
+                if (result.getReviewStatus() != null && result.getReviewStatus() == 2) {
+                    // 审核拒绝:数据已保存,但审核未通过
+                    return R.success("数据保存成功,但内容审核未通过:" + 
+                            (result.getRejectReason() != null ? result.getRejectReason() : "内容包含违规信息"));
+                } else if (result.getReviewStatus() != null && result.getReviewStatus() == 1) {
+                    // 审核通过
+                    return R.success("操作成功");
+                } else {
+                    // 其他状态
+                    return R.success("操作成功");
+                }
             } else {
                 return R.fail("操作失败");
             }

+ 3 - 2
alien-store/src/main/java/shop/alien/store/service/BarPerformanceService.java

@@ -25,11 +25,12 @@ public interface BarPerformanceService {
 
     /**
      * 新增或更新酒吧演出
+     * 审核不通过时也会保存数据,但会标记为审核拒绝状态
      *
      * @param barPerformance 演出信息
-     * @return 操作结果
+     * @return 保存后的演出对象(包含ID和审核状态)
      */
-    int addOrUpdateBarPerformance(BarPerformance barPerformance);
+    BarPerformance addOrUpdateBarPerformance(BarPerformance barPerformance);
 
     /**
      * 获取酒吧演出详情

+ 28 - 12
alien-store/src/main/java/shop/alien/store/service/impl/BarPerformanceServiceImpl.java

@@ -53,7 +53,7 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
     }
 
     @Override
-    public int addOrUpdateBarPerformance(BarPerformance barPerformance) {
+    public BarPerformance addOrUpdateBarPerformance(BarPerformance barPerformance) {
         // 1. 演出名称验证:必填且限20字
         if (StringUtils.isEmpty(barPerformance.getPerformanceName())) {
             throw new IllegalArgumentException("演出名称不能为空");
@@ -215,22 +215,23 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
             }
         }
         // 调用AI内容审核接口,文本和图片分开审核
-        // 如果检测到违规内容会抛出异常
+        // 审核失败时保存数据但标记为审核拒绝状态
         AiContentModerationUtil.AuditResult auditResult = aiContentModerationUtil.auditContent(moderationText, imageUrls);
         if (auditResult == null || !auditResult.isPassed()) {
-            // AI审核失败,设置审核状态为2(审核拒绝)并记录拒绝原因
+            // AI审核失败,设置审核状态为2(审核拒绝)并记录拒绝原因,但仍然保存数据
             String failureReason = (auditResult != null && StringUtils.isNotEmpty(auditResult.getFailureReason()))
                     ? auditResult.getFailureReason()
                     : "内容包含违规信息";
             barPerformance.setReviewStatus(2); // 审核拒绝
             barPerformance.setRejectReason(failureReason);
-            log.warn("酒吧演出内容审核失败:{}", failureReason);
-            throw new IllegalArgumentException("内容审核未通过:" + failureReason);
+            log.warn("酒吧演出内容审核失败:{},将保存数据并标记为审核拒绝状态", failureReason);
+            // 不抛出异常,继续保存数据,但reviewStatus已设置为2(审核拒绝)
+        } else {
+            // AI审核通过,设置审核状态为1(审核通过),清除拒绝原因
+            barPerformance.setReviewStatus(1); // 审核通过
+            barPerformance.setRejectReason(null); // 清除拒绝原因
+            log.info("酒吧演出内容审核通过");
         }
-        // AI审核通过,设置审核状态为1(审核通过),清除拒绝原因
-        barPerformance.setReviewStatus(1); // 审核通过
-        barPerformance.setRejectReason(null); // 清除拒绝原因
-        log.info("酒吧演出内容审核通过");
 
         Integer id = barPerformance.getId();
 
@@ -266,7 +267,12 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
             if (barPerformance.getPerformanceWeek() == null) {
                 barPerformance.setPerformanceWeek("");
             }
-            return barPerformanceMapper.insert(barPerformance);
+            int result = barPerformanceMapper.insert(barPerformance);
+            if (result > 0) {
+                // 返回保存后的对象,包含自动生成的ID和审核状态
+                return barPerformance;
+            }
+            return null;
         } else {
             // 更新操作:先查询记录是否存在
             BarPerformance existing = barPerformanceMapper.selectById(id);
@@ -299,10 +305,20 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
                 if (barPerformance.getPerformanceWeek() == null) {
                     barPerformance.setPerformanceWeek("");
                 }
-                return barPerformanceMapper.insert(barPerformance);
+                int result = barPerformanceMapper.insert(barPerformance);
+                if (result > 0) {
+                    // 返回保存后的对象,包含自动生成的ID和审核状态
+                    return barPerformance;
+                }
+                return null;
             } else {
                 // 记录存在,执行更新
-                return barPerformanceMapper.updateById(barPerformance);
+                int result = barPerformanceMapper.updateById(barPerformance);
+                if (result > 0) {
+                    // 返回更新后的对象(重新查询以获取完整信息)
+                    return barPerformanceMapper.selectById(id);
+                }
+                return null;
             }
         }
     }

+ 39 - 8
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -1312,16 +1312,29 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
                 storeInfoDraft.setAdministrativeRegionDistrictName(essentialCityCode3.getAreaName());
             }
         }
-        if (storeInfoDraft.getBusinessLicenseUrl().isEmpty()) {
+        if (StringUtils.isEmpty(storeInfoDraft.getBusinessLicenseUrl())) {
             storeInfoDraft.setBusinessLicenseUrl(null);
         }
-        if (storeInfoDraft.getContractUrl().isEmpty()) {
-            storeInfoDraft.setContractUrl(null);
-        }
-
-        if (storeInfoDraft.getFoodLicenceUrl().isEmpty()) {
-            storeInfoDraft.setFoodLicenceUrl(null);
+        // if (StringUtils.isEmpty(storeInfoDraft.getContractUrl())) {
+        //     storeInfoDraft.setContractUrl(null);
+        // }
+        // if (StringUtils.isEmpty(storeInfoDraft.getFoodLicenceUrl())) {
+        //     storeInfoDraft.setFoodLicenceUrl(null);
+        // }
+        
+        // 处理其他资质证明图片列表(最多9张),转换为逗号分隔的字符串
+        if (!CollectionUtils.isEmpty(storeInfoDraft.getOtherQualificationImages())) {
+            List<String> otherQualificationImages = storeInfoDraft.getOtherQualificationImages();
+            // 限制最多9张
+            int maxCount = Math.min(otherQualificationImages.size(), 9);
+            List<String> limitedImages = otherQualificationImages.subList(0, maxCount);
+            String otherLicensesStr = String.join(",", limitedImages);
+            storeInfoDraft.setOtherLicenses(otherLicensesStr);
+        } else if (storeInfoDraft.getOtherQualificationImages() != null) {
+            // 如果传入空列表,清空 otherLicenses
+            storeInfoDraft.setOtherLicenses(null);
         }
+        
         return storeInfoDraftMapper.insert(storeInfoDraft);
     }
 
@@ -1331,7 +1344,24 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         wrapper.eq(StoreInfoDraft::getStoreUserId, storeUserId);
         wrapper.orderByDesc(StoreInfoDraft::getCreatedTime);
         List<StoreInfoDraft> list = storeInfoDraftMapper.selectList(wrapper);
-        return CollectionUtils.isEmpty(list) ? null : list.get(0);
+        StoreInfoDraft draft = CollectionUtils.isEmpty(list) ? null : list.get(0);
+        
+        // 将 otherLicenses 字段(逗号分隔的字符串)转换为 otherQualificationImages 列表
+        if (draft != null && StringUtils.isNotEmpty(draft.getOtherLicenses())) {
+            String[] urls = draft.getOtherLicenses().split(",");
+            List<String> otherQualificationImages = new ArrayList<>();
+            for (String url : urls) {
+                if (StringUtils.isNotEmpty(url.trim())) {
+                    otherQualificationImages.add(url.trim());
+                }
+            }
+            draft.setOtherQualificationImages(otherQualificationImages);
+        } else if (draft != null) {
+            // 如果 otherLicenses 为空,设置空列表
+            draft.setOtherQualificationImages(new ArrayList<>());
+        }
+        
+        return draft;
     }
 
     @Override
@@ -6770,3 +6800,4 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
 }
 
+

+ 82 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreStaffConfigServiceImpl.java

@@ -192,6 +192,11 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
             updateTitleStaffCount(storeStaffConfig.getTitleId());
         }
 
+        // 处理视频封面生成
+        if (affected > 0 && StringUtils.isNotEmpty(storeStaffConfig.getBackgroundUrl())) {
+            processVideoCovers(storeStaffConfig);
+        }
+
         // 异步调用AI审核
         storeStaffAuditAsyncService.auditStaffContentAsync(staffId, storeStaffConfig);
 
@@ -1764,4 +1769,81 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
             return false;
         }
     }
+
+    /**
+     * 处理视频封面URL生成
+     * 为background_url中的视频文件生成封面URL(通过改变后缀)并保存到video_head_url字段
+     *
+     * @param storeStaffConfig 员工配置信息
+     */
+    private void processVideoCovers(StoreStaffConfig storeStaffConfig) {
+        try {
+            log.info("开始处理视频封面URL生成,staffId={}", storeStaffConfig.getId());
+
+            String backgroundUrl = storeStaffConfig.getBackgroundUrl();
+            if (StringUtils.isEmpty(backgroundUrl)) {
+                return;
+            }
+
+            String[] urls = backgroundUrl.split(",");
+            List<String> videoCoverUrls = new ArrayList<>();
+
+            for (String url : urls) {
+                if (StringUtils.isNotEmpty(url.trim())) {
+                    String trimmedUrl = url.trim();
+                    if (isVideoUrl(trimmedUrl)) {
+                        // 为视频生成封面URL
+                        String coverUrl = generateVideoCover(trimmedUrl);
+                        if (StringUtils.isNotEmpty(coverUrl)) {
+                            videoCoverUrls.add(coverUrl);
+                            log.info("视频封面URL生成成功,视频URL={},封面URL={}", trimmedUrl, coverUrl);
+                        } else {
+                            log.warn("视频封面URL生成失败,视频URL={}", trimmedUrl);
+                        }
+                    }
+                }
+            }
+
+            // 更新video_head_url字段
+            if (!videoCoverUrls.isEmpty()) {
+                String videoHeadUrlStr = String.join(",", videoCoverUrls);
+                StoreStaffConfig updateCover = new StoreStaffConfig();
+                updateCover.setId(storeStaffConfig.getId());
+                updateCover.setVideoHeadUrl(videoHeadUrlStr);
+                storeStaffConfigMapper.updateById(updateCover);
+                log.info("更新视频封面URL成功,staffId={},videoHeadUrl={}", storeStaffConfig.getId(), videoHeadUrlStr);
+            }
+
+        } catch (Exception e) {
+            log.error("处理视频封面URL生成异常,staffId={},异常信息:{}", storeStaffConfig.getId(), e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 为单个视频生成封面URL
+     * 直接通过改变视频URL的后缀来生成封面URL
+     *
+     * @param videoUrl 视频URL
+     * @return 封面图片URL
+     */
+    private String generateVideoCover(String videoUrl) {
+        if (StringUtils.isEmpty(videoUrl)) {
+            return null;
+        }
+
+        try {
+            // 找到最后一个点的位置
+            int lastDotIndex = videoUrl.lastIndexOf('.');
+            if (lastDotIndex == -1) {
+                // 如果没有扩展名,直接添加.jpg
+                return videoUrl + ".jpg";
+            }
+
+            // 替换扩展名为.jpg
+            return videoUrl.substring(0, lastDotIndex) + ".jpg";
+        } catch (Exception e) {
+            log.error("生成视频封面URL异常,videoUrl={},异常信息:{}", videoUrl, e.getMessage(), e);
+            return null;
+        }
+    }
 }