diff --git a/src/main/java/com/ycwl/basic/constant/SourceType.java b/src/main/java/com/ycwl/basic/constant/SourceType.java index 5e0cae14..7352446c 100644 --- a/src/main/java/com/ycwl/basic/constant/SourceType.java +++ b/src/main/java/com/ycwl/basic/constant/SourceType.java @@ -16,7 +16,12 @@ public enum SourceType { /** * 图片类型 */ - IMAGE(2, "图片"); + IMAGE(2, "图片"), + + /** + * AI微单类型 + */ + AI_CAM(3, "AI微单"); private final int code; private final String description; @@ -68,4 +73,14 @@ public enum SourceType { public static boolean isImage(Integer code) { return code != null && code == IMAGE.code; } + + /** + * 判断给定的代码是否为AI微单类型 + * + * @param code 类型代码 + * @return true-是AI微单,false-不是AI微单 + */ + public static boolean isAiCam(Integer code) { + return code != null && code == AI_CAM.code; + } } diff --git a/src/main/java/com/ycwl/basic/mapper/SourceMapper.java b/src/main/java/com/ycwl/basic/mapper/SourceMapper.java index ca7b90e5..2c804459 100644 --- a/src/main/java/com/ycwl/basic/mapper/SourceMapper.java +++ b/src/main/java/com/ycwl/basic/mapper/SourceMapper.java @@ -156,4 +156,12 @@ public interface SourceMapper { * @return source实体列表 */ List listByFaceSampleIdsAndType(List faceSampleIds, Integer type); + + /** + * 删除指定faceId和type的member_source关联记录 + * @param faceId 人脸ID + * @param type 素材类型 + * @return 删除的记录数 + */ + int deleteRelationsByFaceIdAndType(Long faceId, Integer type); } diff --git a/src/main/java/com/ycwl/basic/pricing/enums/ProductType.java b/src/main/java/com/ycwl/basic/pricing/enums/ProductType.java index d2cab829..502d2270 100644 --- a/src/main/java/com/ycwl/basic/pricing/enums/ProductType.java +++ b/src/main/java/com/ycwl/basic/pricing/enums/ProductType.java @@ -17,6 +17,7 @@ public enum ProductType { // 照片类 PHOTO("PHOTO", "照片", ProductCategory.PHOTO), PHOTO_SET("PHOTO_SET", "照片集", ProductCategory.PHOTO), + AI_CAM_PHOTO_SET("AI_CAM_PHOTO_SET", "照片集", ProductCategory.PHOTO), PHOTO_LOG("PHOTO_LOG", "pLog图", ProductCategory.PHOTO), // 视频类(素材视频) diff --git a/src/main/java/com/ycwl/basic/service/mobile/impl/AppAiCamServiceImpl.java b/src/main/java/com/ycwl/basic/service/mobile/impl/AppAiCamServiceImpl.java index f77aba7f..0725fefa 100644 --- a/src/main/java/com/ycwl/basic/service/mobile/impl/AppAiCamServiceImpl.java +++ b/src/main/java/com/ycwl/basic/service/mobile/impl/AppAiCamServiceImpl.java @@ -183,6 +183,10 @@ public class AppAiCamServiceImpl implements AppAiCamService { throw new IllegalArgumentException("Face未关联会员: faceId=" + faceId); } + // 删除该faceId对应的旧的type=3关系 + int deleted = sourceMapper.deleteRelationsByFaceIdAndType(faceId, AI_CAM_SOURCE_TYPE); + log.info("删除faceId={}的旧AI相机关联记录: {}条", faceId, deleted); + // 构建MemberSourceEntity列表 List relations = sourceIds.stream().map(sourceId -> { MemberSourceEntity entity = new MemberSourceEntity(); @@ -197,6 +201,9 @@ public class AppAiCamServiceImpl implements AppAiCamService { }).collect(Collectors.toList()); // 批量插入 - return sourceMapper.addRelations(relations); + int inserted = sourceMapper.addRelations(relations); + log.info("为faceId={}添加新AI相机关联记录: {}条", faceId, inserted); + + return inserted; } } diff --git a/src/main/java/com/ycwl/basic/service/mobile/impl/GoodsServiceImpl.java b/src/main/java/com/ycwl/basic/service/mobile/impl/GoodsServiceImpl.java index bea75219..325397c5 100644 --- a/src/main/java/com/ycwl/basic/service/mobile/impl/GoodsServiceImpl.java +++ b/src/main/java/com/ycwl/basic/service/mobile/impl/GoodsServiceImpl.java @@ -127,6 +127,8 @@ public class GoodsServiceImpl implements GoodsService { goodsNamePrefix = "录像"; } else if (sourceType == 2) { goodsNamePrefix = "图片"; + } else if (sourceType == 3) { + goodsNamePrefix = "微单"; } else { goodsNamePrefix = "其他类型"; } diff --git a/src/main/java/com/ycwl/basic/service/pc/impl/FaceServiceImpl.java b/src/main/java/com/ycwl/basic/service/pc/impl/FaceServiceImpl.java index 1cd4f6c7..55936f21 100644 --- a/src/main/java/com/ycwl/basic/service/pc/impl/FaceServiceImpl.java +++ b/src/main/java/com/ycwl/basic/service/pc/impl/FaceServiceImpl.java @@ -536,20 +536,28 @@ public class FaceServiceImpl implements FaceService { List sourceList = sourceMapper.queryByRelation(sourceReqQuery); ContentPageVO sourceVideoContent = new ContentPageVO(); ContentPageVO sourceImageContent = new ContentPageVO(); + ContentPageVO sourceAiCamContent = new ContentPageVO(); sourceVideoContent.setName("录像集"); sourceImageContent.setName("照片集"); + sourceAiCamContent.setName("AI微单"); sourceVideoContent.setSort(9999); sourceImageContent.setSort(9999); + sourceAiCamContent.setSort(9999); sourceVideoContent.setScenicId(face.getScenicId()); sourceImageContent.setScenicId(face.getScenicId()); + sourceAiCamContent.setScenicId(face.getScenicId()); sourceVideoContent.setGoodsType(1); sourceImageContent.setGoodsType(2); + sourceAiCamContent.setGoodsType(3); sourceVideoContent.setContentType(2); sourceImageContent.setContentType(2); + sourceAiCamContent.setContentType(2); sourceVideoContent.setLockType(-1); sourceImageContent.setLockType(-1); + sourceAiCamContent.setLockType(-1); sourceVideoContent.setGroup("直出原片"); sourceImageContent.setGroup("直出原片"); + sourceAiCamContent.setGroup("直出原片"); if (!scenicConfigFacade.isDisableSourceImage(face.getScenicId())) { IsBuyRespVO isBuyRespVO = orderBiz.isBuy(face.getScenicId(), userId, faceId, SourceType.IMAGE.getCode(), faceId); sourceImageContent.setSourceType(isBuyRespVO.getGoodsType()); @@ -588,18 +596,40 @@ public class FaceServiceImpl implements FaceService { sourceVideoContent.setFreeCount((int) freeCount); contentList.add(sourceVideoContent); } + // AI微单:只有存在type=3的数据时才添加 + boolean hasAiCam = sourceList.stream().anyMatch(source -> source.getType() == 3); + if (hasAiCam) { + IsBuyRespVO isBuyRespVO = orderBiz.isBuy(face.getScenicId(), userId, faceId, SourceType.AI_CAM.getCode(), faceId); + sourceAiCamContent.setSourceType(isBuyRespVO.getGoodsType()); + sourceAiCamContent.setContentId(isBuyRespVO.getGoodsId()); + if (isBuyRespVO.isBuy()) { + sourceAiCamContent.setIsBuy(1); + } else { + sourceAiCamContent.setIsBuy(0); + } + // AI微单有数据才显示,所以lockType固定为-1 + sourceAiCamContent.setLockType(-1); + List relations = memberRelationRepository.listSourceByFaceRelation(faceId, 3); + long freeCount = relations.stream().filter(entity -> Integer.valueOf(1).equals(entity.getIsFree())).count(); + sourceAiCamContent.setFreeCount((int) freeCount); + contentList.add(sourceAiCamContent); + } sourceList.stream().collect(Collectors.groupingBy(SourceRespVO::getType)).forEach((type, list) -> { if (type == 1) { sourceVideoContent.setSourceType(1); sourceVideoContent.setLockType(-1); sourceVideoContent.setTemplateCoverUrl(list.getFirst().getUrl()); - } else { + } else if (type == 2) { sourceImageContent.setSourceType(2); sourceImageContent.setLockType(-1); sourceImageContent.setTemplateCoverUrl(list.getFirst().getUrl()); if (StringUtils.isBlank(sourceVideoContent.getTemplateCoverUrl())) { sourceVideoContent.setTemplateCoverUrl(list.getFirst().getUrl()); } + } else if (type == 3) { + sourceAiCamContent.setSourceType(13); + sourceAiCamContent.setLockType(-1); + sourceAiCamContent.setTemplateCoverUrl(list.getFirst().getUrl()); } }); return contentList; diff --git a/src/main/resources/mapper/SourceMapper.xml b/src/main/resources/mapper/SourceMapper.xml index 7df2f4d5..a939b6e1 100644 --- a/src/main/resources/mapper/SourceMapper.xml +++ b/src/main/resources/mapper/SourceMapper.xml @@ -496,4 +496,9 @@ AND `type` = #{type} ORDER BY create_time DESC + + + DELETE FROM member_source + WHERE face_id = #{faceId} AND `type` = #{type} +