You've already forked FrameTour-BE
C a c h e
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package com.ycwl.basic.constant;
|
||||
|
||||
public class ShareParkingSpaceRedisKeyConstant {
|
||||
// 更改数量时候的锁
|
||||
public final static String UPDATE_NUMBER_LOCK_KEY="ShareParking:updateNumberLockKey";
|
||||
// 地上车位
|
||||
public final static String GROUND_PARKING_SPACE_NUMBER="ShareParking:groundParkingSpaceNumber";
|
||||
// 地下车位数
|
||||
public final static String UNDERGROUND_PARKING_SPACE_NUMBER="ShareParking:undergroundParkingSpaceNumber";
|
||||
// 每日开放预约时间
|
||||
public final static String OPEN_TIME="ShareParking:openTime";
|
||||
// 预约后当日车辆最晚停留时间
|
||||
public final static String RESIDENCE_TIME="ShareParking:residenceTime";
|
||||
//取消时间
|
||||
public final static String CANCEL_TIME="ShareParking:cancelTime";
|
||||
//支付时间
|
||||
public final static String PAY_TIME="ShareParking:payTime";
|
||||
}
|
@@ -69,7 +69,7 @@ public interface SourceMapper {
|
||||
List<SourceEntity> listVideoByFaceRelation(Long memberId, Long faceId);
|
||||
|
||||
List<SourceEntity> listImageByFaceRelation(Long memberId, Long faceId);
|
||||
List<MemberSourceEntity> listByFaceRelation(Long memberId, Long faceId, Integer type);
|
||||
List<MemberSourceEntity> listByFaceRelation(Long faceId, Integer type);
|
||||
|
||||
SourceEntity getEntity(Long id);
|
||||
|
||||
|
@@ -38,7 +38,7 @@ public interface VideoMapper {
|
||||
|
||||
MemberVideoEntity queryRelationByMemberTask(Long userId, Long taskId);
|
||||
List<MemberVideoEntity> listRelationByTask(Long taskId);
|
||||
List<MemberVideoEntity> listRelationByFace(Long userId, Long faceId);
|
||||
List<MemberVideoEntity> listRelationByFace(Long faceId);
|
||||
List<MemberVideoEntity> listRelationByFaceAndTemplate(Long faceId, Long templateId);
|
||||
|
||||
List<TaskEntity> listTaskByScenicRelation(Long userId, Long scenicId);
|
||||
|
@@ -25,6 +25,7 @@ public class TemplateRespVO {
|
||||
*/
|
||||
// 模版名称
|
||||
private String name;
|
||||
private String group;
|
||||
/**
|
||||
* 父模版ID
|
||||
*/
|
||||
|
@@ -0,0 +1,113 @@
|
||||
package com.ycwl.basic.repository;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
||||
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
|
||||
import com.ycwl.basic.utils.JacksonUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
public class MemberRelationRepository {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private VideoMapper videoMapper;
|
||||
|
||||
@Autowired
|
||||
private SourceMapper sourceMapper;
|
||||
|
||||
public static final String MEMBER_RELATION_BY_FACE_CACHE_KEY = "member_relation:face:%d:v";
|
||||
public static final String MEMBER_RELATION_BY_FACE_TEMPLATE_CACHE_KEY = "member_relation:face:%d:v:template:%d";
|
||||
public static final String MEMBER_SOURCE_BY_FACE_TYPE_CACHE_KEY = "member_relation:face:%d:s:type:%d";
|
||||
|
||||
public List<MemberVideoEntity> listRelationByFace(Long faceId) {
|
||||
String cacheKey = String.format(MEMBER_RELATION_BY_FACE_CACHE_KEY, faceId);
|
||||
|
||||
if (redisTemplate.hasKey(cacheKey)) {
|
||||
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
||||
return JacksonUtil.fromJson(cacheValue, new TypeReference<List<MemberVideoEntity>>() {});
|
||||
}
|
||||
|
||||
List<MemberVideoEntity> result = videoMapper.listRelationByFace(faceId);
|
||||
if (result != null) {
|
||||
redisTemplate.opsForValue().set(cacheKey, JacksonUtil.toJson(result), 1, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<MemberVideoEntity> listRelationByFaceAndTemplate(Long faceId, Long templateId) {
|
||||
String cacheKey = String.format(MEMBER_RELATION_BY_FACE_TEMPLATE_CACHE_KEY, faceId, templateId);
|
||||
|
||||
if (redisTemplate.hasKey(cacheKey)) {
|
||||
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
||||
return JacksonUtil.fromJson(cacheValue, new TypeReference<List<MemberVideoEntity>>() {});
|
||||
}
|
||||
|
||||
List<MemberVideoEntity> result = videoMapper.listRelationByFaceAndTemplate(faceId, templateId);
|
||||
if (result != null) {
|
||||
redisTemplate.opsForValue().set(cacheKey, JacksonUtil.toJson(result), 1, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<MemberSourceEntity> listSourceByFaceRelation(Long faceId, Integer type) {
|
||||
String cacheKey = String.format(MEMBER_SOURCE_BY_FACE_TYPE_CACHE_KEY, faceId, type);
|
||||
|
||||
if (redisTemplate.hasKey(cacheKey)) {
|
||||
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
|
||||
return JacksonUtil.fromJson(cacheValue, new TypeReference<List<MemberSourceEntity>>() {});
|
||||
}
|
||||
|
||||
List<MemberSourceEntity> result = sourceMapper.listByFaceRelation(faceId, type);
|
||||
if (result != null) {
|
||||
redisTemplate.opsForValue().set(cacheKey, JacksonUtil.toJson(result), 1, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void clearCacheByFace(Long faceId) {
|
||||
String pattern = "member_relation:face:" + faceId + ":*";
|
||||
Set<String> keys = redisTemplate.keys(pattern);
|
||||
if (keys != null && !keys.isEmpty()) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearVCacheByFace(Long faceId) {
|
||||
String pattern = "member_relation:face:" + faceId + ":v:*";
|
||||
Set<String> keys = redisTemplate.keys(pattern);
|
||||
if (keys != null && !keys.isEmpty()) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSCacheByFace(Long faceId) {
|
||||
String pattern = "member_relation:face:" + faceId + ":s:*";
|
||||
Set<String> keys = redisTemplate.keys(pattern);
|
||||
if (keys != null && !keys.isEmpty()) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllCache() {
|
||||
String pattern = "member_relation:*";
|
||||
Set<String> keys = redisTemplate.keys(pattern);
|
||||
if (keys != null && !keys.isEmpty()) {
|
||||
redisTemplate.delete(keys);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -33,6 +33,8 @@ public class SourceRepository {
|
||||
private TemplateRepository templateRepository;
|
||||
@Autowired
|
||||
private DeviceRepository deviceRepository;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
|
||||
public void addSource(SourceEntity source) {
|
||||
sourceMapper.add(source);
|
||||
@@ -46,6 +48,7 @@ public class SourceRepository {
|
||||
memberSource.setOrderId(orderId);
|
||||
memberSource.setIsBuy(1);
|
||||
sourceMapper.updateRelation(memberSource);
|
||||
memberRelationRepository.clearSCacheByFace(faceId);
|
||||
}
|
||||
|
||||
public void setUserNotBuyItem(Long memberId, int type, Long faceId) {
|
||||
@@ -56,6 +59,7 @@ public class SourceRepository {
|
||||
memberSource.setOrderId(null);
|
||||
memberSource.setIsBuy(0);
|
||||
sourceMapper.updateRelation(memberSource);
|
||||
memberRelationRepository.clearSCacheByFace(faceId);
|
||||
}
|
||||
|
||||
public boolean getUserIsBuy(Long userId, int type, Long faceId) {
|
||||
|
@@ -2,8 +2,6 @@ package com.ycwl.basic.repository;
|
||||
|
||||
import com.ycwl.basic.biz.PriceBiz;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyBatchRespVO;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.pricing.dto.DiscountDetectionContext;
|
||||
import com.ycwl.basic.pricing.dto.VoucherInfo;
|
||||
import com.ycwl.basic.pricing.enums.VoucherDiscountType;
|
||||
import com.ycwl.basic.pricing.service.IVoucherService;
|
||||
@@ -36,6 +34,8 @@ public class VideoRepository {
|
||||
private PriceBiz priceBiz;
|
||||
@Autowired
|
||||
private IVoucherService iVoucherService;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
|
||||
public VideoEntity getVideo(Long videoId) {
|
||||
if (redisTemplate.hasKey(String.format(VIDEO_CACHE_KEY, videoId))) {
|
||||
@@ -84,6 +84,12 @@ public class VideoRepository {
|
||||
memberVideo.setIsBuy(1);
|
||||
memberVideo.setOrderId(orderId);
|
||||
videoMapper.updateRelation(memberVideo);
|
||||
|
||||
// 清理视频关系缓存
|
||||
MemberVideoEntity existingVideo = videoMapper.queryUserVideo(memberId, videoId);
|
||||
if (existingVideo != null && existingVideo.getFaceId() != null) {
|
||||
memberRelationRepository.clearVCacheByFace(existingVideo.getFaceId());
|
||||
}
|
||||
}
|
||||
|
||||
public void setUserNotBuyItem(Long memberId, Long videoId) {
|
||||
@@ -93,6 +99,12 @@ public class VideoRepository {
|
||||
memberVideo.setIsBuy(0);
|
||||
memberVideo.setOrderId(null);
|
||||
videoMapper.updateRelation(memberVideo);
|
||||
|
||||
// 清理视频关系缓存
|
||||
MemberVideoEntity existingVideo = videoMapper.queryUserVideo(memberId, videoId);
|
||||
if (existingVideo != null && existingVideo.getFaceId() != null) {
|
||||
memberRelationRepository.clearVCacheByFace(existingVideo.getFaceId());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getUserIsBuy(Long userId, Long videoId) {
|
||||
@@ -133,7 +145,4 @@ public class VideoRepository {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<MemberVideoEntity> getVideoByFaceAndTemplateId(Long memberId, Long faceId, String templateId) {
|
||||
return videoMapper.userFaceTemplateVideo(memberId, faceId, Long.valueOf(templateId));
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.ycwl.basic.integration.common.manager.ScenicConfigManager;
|
||||
import com.ycwl.basic.integration.scenic.dto.scenic.ScenicV2DTO;
|
||||
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
||||
import com.ycwl.basic.repository.MemberRelationRepository;
|
||||
import com.ycwl.basic.utils.JacksonUtil;
|
||||
import com.ycwl.basic.biz.CouponBiz;
|
||||
import com.ycwl.basic.biz.OrderBiz;
|
||||
@@ -105,6 +107,8 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
private TemplateBiz templateBiz;
|
||||
@Autowired
|
||||
private VideoUpdateConfig videoUpdateConfig;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
|
||||
public ApiResponse<List<GoodsPageVO>> goodsList(GoodsReqQuery query) {
|
||||
Long scenicId = query.getScenicId();
|
||||
@@ -362,7 +366,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
response.setStatus(2);
|
||||
return response;
|
||||
}
|
||||
List<MemberVideoEntity> taskList = videoMapper.listRelationByFace(userId, faceId);
|
||||
List<MemberVideoEntity> taskList = videoMapper.listRelationByFace(faceId);
|
||||
if (faceCutStatus != 1 && taskList.isEmpty()) {
|
||||
// 视频切成了能够获取视频的状态,但是没有任务,还是显示正在处理
|
||||
response.setStatus(0);
|
||||
@@ -404,7 +408,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
return response;
|
||||
}
|
||||
// 重查一下
|
||||
taskList = videoMapper.listRelationByFace(userId, faceId);
|
||||
taskList = videoMapper.listRelationByFace(faceId);
|
||||
MemberVideoEntity lastVideo = taskList.getLast();
|
||||
if (null == lastVideo.getVideoId()) {
|
||||
response.setTemplateId(lastVideo.getTemplateId());
|
||||
@@ -779,14 +783,8 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
if (face == null) {
|
||||
return 0;
|
||||
}
|
||||
Integer sourceType = query.getSourceType();
|
||||
SourceReqQuery sourceReqQuery = new SourceReqQuery();
|
||||
sourceReqQuery.setScenicId(face.getScenicId());
|
||||
sourceReqQuery.setIsBuy(query.getIsBuy());
|
||||
sourceReqQuery.setMemberId(face.getMemberId());
|
||||
sourceReqQuery.setType(sourceType);
|
||||
sourceReqQuery.setFaceId(query.getFaceId());
|
||||
return sourceMapper.countUser(sourceReqQuery);
|
||||
List<MemberSourceEntity> memberSourceEntities = memberRelationRepository.listSourceByFaceRelation(face.getId(), query.getSourceType());
|
||||
return memberSourceEntities.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -25,12 +25,10 @@ import com.ycwl.basic.model.mobile.goods.VideoTaskStatusVO;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.model.mobile.scenic.content.ContentPageVO;
|
||||
import com.ycwl.basic.model.mobile.statistic.req.StatisticsRecordAddReq;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity;
|
||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||
import com.ycwl.basic.model.pc.face.req.FaceReqQuery;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
import com.ycwl.basic.model.pc.faceSample.entity.FaceSampleEntity;
|
||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||
import com.ycwl.basic.model.pc.mp.MpConfigEntity;
|
||||
import com.ycwl.basic.integration.common.manager.ScenicConfigManager;
|
||||
import com.ycwl.basic.model.pc.project.resp.ProjectRespVO;
|
||||
@@ -40,13 +38,16 @@ import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
import com.ycwl.basic.model.pc.order.entity.OrderEntity;
|
||||
import com.ycwl.basic.model.pc.task.entity.TaskEntity;
|
||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
|
||||
import com.ycwl.basic.model.repository.TaskUpdateResult;
|
||||
import com.ycwl.basic.model.task.resp.SearchFaceRespVo;
|
||||
import com.ycwl.basic.repository.DeviceRepository;
|
||||
import com.ycwl.basic.repository.FaceRepository;
|
||||
import com.ycwl.basic.repository.MemberRelationRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
import com.ycwl.basic.repository.VideoRepository;
|
||||
import com.ycwl.basic.repository.VideoTaskRepository;
|
||||
import com.ycwl.basic.service.mobile.GoodsService;
|
||||
@@ -75,7 +76,6 @@ import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -134,6 +134,10 @@ public class FaceServiceImpl implements FaceService {
|
||||
private GoodsService goodsService;
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
@Autowired
|
||||
private TemplateRepository templateRepository;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<FaceRespVO>> pageQuery(FaceReqQuery faceReqQuery) {
|
||||
@@ -341,7 +345,8 @@ public class FaceServiceImpl implements FaceService {
|
||||
|
||||
// 保存关联关系并创建任务
|
||||
sourceMapper.addRelations(memberSourceEntityList);
|
||||
taskTaskService.autoCreateTaskByFaceId(face.getId());
|
||||
memberRelationRepository.clearSCacheByFace(faceId);
|
||||
taskTaskService.autoCreateTaskByFaceId(faceId);
|
||||
|
||||
log.info("人脸匹配完成:faceId={}, 匹配样本数={}, 关联源文件数={}, 免费数={}",
|
||||
faceId, sampleListIds.size(), memberSourceEntityList.size(), freeSourceIds.size());
|
||||
@@ -652,14 +657,32 @@ public class FaceServiceImpl implements FaceService {
|
||||
|
||||
@Override
|
||||
public List<ContentPageVO> faceContentList(Long faceId) {
|
||||
FaceRespVO faceRespVO = faceMapper.getById(faceId);
|
||||
if (faceRespVO == null) {
|
||||
FaceEntity face = faceRepository.getFace(faceId);
|
||||
if (face == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Long userId = faceRespVO.getMemberId();
|
||||
List<ContentPageVO> contentList = templateMapper.listFor(faceRespVO.getScenicId());
|
||||
contentList.forEach(contentPageVO -> {
|
||||
List<MemberVideoEntity> memberVideoEntityList = videoMapper.userFaceTemplateVideo(userId, faceId, contentPageVO.getTemplateId());
|
||||
Long userId = face.getMemberId();
|
||||
List<TemplateRespVO> templateList = templateRepository.getTemplateListByScenicId(face.getScenicId());
|
||||
List<ContentPageVO> contentList = templateList.stream().map(template -> {
|
||||
/// select t.id templateId, t.scenic_id, t.`group`, t.`name`, pid, t.cover_url templateCoverUrl,
|
||||
/// 0 as sourceType, sort,
|
||||
/// t.create_time, t.price
|
||||
/// from template t
|
||||
/// where t.scenic_id = #{scenicId} and pid = 0 and t.status = 1
|
||||
/// order by sort
|
||||
ContentPageVO content = new ContentPageVO();
|
||||
content.setTemplateId(template.getId());
|
||||
content.setScenicId(template.getScenicId());
|
||||
content.setGroup(template.getGroup());
|
||||
content.setName(template.getName());
|
||||
content.setTemplateCoverUrl(template.getCoverUrl());
|
||||
content.setSourceType(0);
|
||||
content.setSort(template.getSort());
|
||||
content.setGoodsType(0);
|
||||
content.setScenicName(template.getScenicName());
|
||||
return content;
|
||||
}).peek(contentPageVO -> {
|
||||
List<MemberVideoEntity> memberVideoEntityList = memberRelationRepository.listRelationByFaceAndTemplate(faceId, contentPageVO.getTemplateId());
|
||||
contentPageVO.setGoodsType(0);
|
||||
contentPageVO.setContentType(1);
|
||||
contentPageVO.setSort(contentPageVO.getSort());
|
||||
@@ -696,10 +719,10 @@ public class FaceServiceImpl implements FaceService {
|
||||
if (buy.isBuy()) {
|
||||
contentPageVO.setIsBuy(1);
|
||||
}
|
||||
});
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
SourceReqQuery sourceReqQuery = new SourceReqQuery();
|
||||
sourceReqQuery.setScenicId(faceRespVO.getScenicId());
|
||||
sourceReqQuery.setScenicId(face.getScenicId());
|
||||
sourceReqQuery.setFaceId(faceId);
|
||||
sourceReqQuery.setMemberId(userId);
|
||||
//查询源素材
|
||||
@@ -710,8 +733,8 @@ public class FaceServiceImpl implements FaceService {
|
||||
sourceImageContent.setName("照片集");
|
||||
sourceVideoContent.setSort(9999);
|
||||
sourceImageContent.setSort(9999);
|
||||
sourceVideoContent.setScenicId(faceRespVO.getScenicId());
|
||||
sourceImageContent.setScenicId(faceRespVO.getScenicId());
|
||||
sourceVideoContent.setScenicId(face.getScenicId());
|
||||
sourceImageContent.setScenicId(face.getScenicId());
|
||||
sourceVideoContent.setGoodsType(1);
|
||||
sourceImageContent.setGoodsType(2);
|
||||
sourceVideoContent.setContentType(2);
|
||||
@@ -720,9 +743,9 @@ public class FaceServiceImpl implements FaceService {
|
||||
sourceImageContent.setLockType(-1);
|
||||
sourceVideoContent.setGroup("直出原片");
|
||||
sourceImageContent.setGroup("直出原片");
|
||||
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(faceRespVO.getScenicId());
|
||||
ScenicConfigManager scenicConfig = scenicRepository.getScenicConfigManager(face.getScenicId());
|
||||
if (!Boolean.TRUE.equals(scenicConfig.getBoolean("disable_source_image"))) {
|
||||
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, faceRespVO.getScenicId(), 2, faceId);
|
||||
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, face.getScenicId(), 2, faceId);
|
||||
sourceImageContent.setSourceType(isBuyRespVO.getGoodsType());
|
||||
sourceImageContent.setContentId(isBuyRespVO.getGoodsId());
|
||||
if (isBuyRespVO.isBuy()) {
|
||||
@@ -730,7 +753,7 @@ public class FaceServiceImpl implements FaceService {
|
||||
} else {
|
||||
sourceImageContent.setIsBuy(0);
|
||||
}
|
||||
List<MemberSourceEntity> relations = sourceMapper.listByFaceRelation(faceRespVO.getMemberId(), faceId, 2);
|
||||
List<MemberSourceEntity> relations = memberRelationRepository.listSourceByFaceRelation(faceId, 2);
|
||||
if (!relations.isEmpty()) {
|
||||
sourceImageContent.setLockType(-1);
|
||||
} else {
|
||||
@@ -741,7 +764,7 @@ public class FaceServiceImpl implements FaceService {
|
||||
contentList.add(sourceImageContent);
|
||||
}
|
||||
if (!Boolean.TRUE.equals(scenicConfig.getBoolean("disable_source_video"))) {
|
||||
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, faceRespVO.getScenicId(), 1, faceId);
|
||||
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, face.getScenicId(), 1, faceId);
|
||||
sourceVideoContent.setSourceType(isBuyRespVO.getGoodsType());
|
||||
sourceVideoContent.setContentId(isBuyRespVO.getGoodsId());
|
||||
if (isBuyRespVO.isBuy()) {
|
||||
@@ -749,7 +772,7 @@ public class FaceServiceImpl implements FaceService {
|
||||
} else {
|
||||
sourceVideoContent.setIsBuy(0);
|
||||
}
|
||||
List<MemberSourceEntity> relations = sourceMapper.listByFaceRelation(faceRespVO.getMemberId(), faceId, 1);
|
||||
List<MemberSourceEntity> relations = memberRelationRepository.listSourceByFaceRelation(faceId, 1);
|
||||
if (!relations.isEmpty()) {
|
||||
sourceVideoContent.setLockType(-1);
|
||||
} else {
|
||||
@@ -885,8 +908,8 @@ public class FaceServiceImpl implements FaceService {
|
||||
sourceReqQuery.setMemberId(face.getMemberId());
|
||||
sourceReqQuery.setFaceId(faceId);
|
||||
sourceReqQuery.setType(2);
|
||||
Integer countUser = sourceMapper.countUser(sourceReqQuery);
|
||||
if (countUser != null && countUser > 0) {
|
||||
List<MemberSourceEntity> countUser = memberRelationRepository.listSourceByFaceRelation(faceId, 2);
|
||||
if (countUser != null && !countUser.isEmpty()) {
|
||||
statusResp.setStep2Status(true);
|
||||
} else {
|
||||
statusResp.setStep2Status(false);
|
||||
@@ -1089,7 +1112,8 @@ public class FaceServiceImpl implements FaceService {
|
||||
face.getMemberId(), sampleListIds, false);
|
||||
|
||||
sourceMapper.addRelations(memberSourceEntityList);
|
||||
taskTaskService.autoCreateTaskByFaceId(face.getId());
|
||||
memberRelationRepository.clearSCacheByFace(faceId);
|
||||
taskTaskService.autoCreateTaskByFaceId(faceId);
|
||||
|
||||
log.info("自定义人脸匹配完成:faceId={}, 匹配样本数={}, 关联源文件数={}, 免费数={}",
|
||||
faceId, sampleListIds.size(), memberSourceEntityList.size(), freeSourceIds.size());
|
||||
|
@@ -51,6 +51,7 @@ import com.ycwl.basic.model.wx.WXPayOrderReqVO;
|
||||
import com.ycwl.basic.pay.adapter.IPayAdapter;
|
||||
import com.ycwl.basic.pay.entity.PayResponse;
|
||||
import com.ycwl.basic.repository.FaceRepository;
|
||||
import com.ycwl.basic.repository.MemberRelationRepository;
|
||||
import com.ycwl.basic.repository.PriceRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
@@ -135,6 +136,8 @@ public class OrderServiceImpl implements OrderService {
|
||||
private IVoucherService iVoucherService;
|
||||
@Autowired
|
||||
private ICouponService iCouponService;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<OrderRespVO>> pageQuery(OrderReqQuery query) {
|
||||
@@ -760,7 +763,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
return ApiResponse.fail("您无权购买此内容!");
|
||||
}
|
||||
// 找下有没有照片
|
||||
List<MemberSourceEntity> photoList = sourceMapper.listByFaceRelation(userId, batchOrderReqVO.getFaceId(), 2);
|
||||
List<MemberSourceEntity> photoList = memberRelationRepository.listSourceByFaceRelation(batchOrderReqVO.getFaceId(), 2);
|
||||
if (photoList.isEmpty()) {
|
||||
log.info("请先游玩后再来购买商品!");
|
||||
return ApiResponse.fail("请先游玩后再来购买商品!");
|
||||
@@ -843,7 +846,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
Long goodsId = switch (productItem.getProductType()) {
|
||||
case PHOTO_SET, RECORDING_SET -> face.getId();
|
||||
case VLOG_VIDEO -> {
|
||||
List<MemberVideoEntity> videos = videoRepository.getVideoByFaceAndTemplateId(face.getMemberId(), face.getId(), productItem.getProductId());
|
||||
List<MemberVideoEntity> videos = memberRelationRepository.listRelationByFaceAndTemplate(face.getId(), Long.valueOf(productItem.getProductId()));
|
||||
yield videos.getFirst().getVideoId();
|
||||
}
|
||||
default -> 0L;
|
||||
|
@@ -3,6 +3,7 @@ package com.ycwl.basic.service.task.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.ycwl.basic.integration.common.manager.DeviceConfigManager;
|
||||
import com.ycwl.basic.integration.common.manager.ScenicConfigManager;
|
||||
import com.ycwl.basic.repository.MemberRelationRepository;
|
||||
import com.ycwl.basic.utils.JacksonUtil;
|
||||
import com.aliyuncs.facebody.model.v20191230.SearchFaceRequest;
|
||||
import com.ycwl.basic.biz.OrderBiz;
|
||||
@@ -81,6 +82,8 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
@Autowired
|
||||
@Lazy
|
||||
private ScenicService scenicService;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
|
||||
private IAcsClient getClient() {
|
||||
AliFaceBodyAdapter use = (AliFaceBodyAdapter) FaceBodyFactory.use();
|
||||
@@ -151,6 +154,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
}
|
||||
}
|
||||
sourceMapper.addRelations(memberSourceEntityList);
|
||||
memberRelationRepository.clearSCacheByFace(faceId);
|
||||
VideoPieceGetter.Task task = new VideoPieceGetter.Task();
|
||||
task.faceId = faceEntity.getId();
|
||||
task.faceSampleIds = sampleListIds;
|
||||
|
@@ -5,22 +5,20 @@ import cn.hutool.crypto.digest.MD5;
|
||||
import com.ycwl.basic.integration.common.manager.DeviceConfigManager;
|
||||
import com.ycwl.basic.integration.common.manager.RenderWorkerConfigManager;
|
||||
import com.ycwl.basic.integration.common.manager.ScenicConfigManager;
|
||||
import com.ycwl.basic.repository.MemberRelationRepository;
|
||||
import com.ycwl.basic.repository.SourceRepository;
|
||||
import com.ycwl.basic.utils.JacksonUtil;
|
||||
import com.ycwl.basic.biz.OrderBiz;
|
||||
import com.ycwl.basic.biz.TaskStatusBiz;
|
||||
import com.ycwl.basic.biz.TemplateBiz;
|
||||
import com.ycwl.basic.constant.StorageConstant;
|
||||
import com.ycwl.basic.constant.TaskConstant;
|
||||
import com.ycwl.basic.mapper.FaceMapper;
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.mapper.MemberMapper;
|
||||
import com.ycwl.basic.mapper.SourceMapper;
|
||||
import com.ycwl.basic.mapper.TaskMapper;
|
||||
import com.ycwl.basic.mapper.TemplateMapper;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
import com.ycwl.basic.model.pc.faceSample.entity.FaceSampleEntity;
|
||||
@@ -69,8 +67,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@@ -129,6 +125,8 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
@Autowired
|
||||
private SourceRepository sourceRepository;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
|
||||
private RenderWorkerEntity getWorker(@NonNull WorkerAuthReqVo req) {
|
||||
String accessKey = req.getAccessKey();
|
||||
@@ -423,6 +421,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
}
|
||||
}
|
||||
videoMapper.addRelation(memberVideoEntity);
|
||||
memberRelationRepository.clearVCacheByFace(faceId);
|
||||
|
||||
// 只有在非强制创建时才更新切割任务状态
|
||||
if (!forceCreate) {
|
||||
@@ -511,6 +510,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
}
|
||||
}
|
||||
videoMapper.updateRelationWhenTaskSuccess(taskId, video.getId(), isBuy);
|
||||
memberRelationRepository.clearVCacheByFace(task.getFaceId());
|
||||
Thread.ofVirtual().start(() -> sendVideoGeneratedServiceNotification(taskId));
|
||||
}
|
||||
|
||||
|
@@ -18,10 +18,10 @@ import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity;
|
||||
import com.ycwl.basic.integration.device.service.DeviceIntegrationService;
|
||||
import com.ycwl.basic.integration.device.dto.device.DeviceV2DTO;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
|
||||
import com.ycwl.basic.model.pc.source.entity.SourceEntity;
|
||||
import com.ycwl.basic.repository.FaceRepository;
|
||||
import com.ycwl.basic.repository.MemberRelationRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
import com.ycwl.basic.storage.StorageFactory;
|
||||
@@ -43,7 +43,6 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -81,6 +80,8 @@ public class VideoPieceGetter {
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private DeviceIntegrationService deviceIntegrationService;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
|
||||
@Data
|
||||
public static class Task {
|
||||
@@ -240,7 +241,7 @@ public class VideoPieceGetter {
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(face.getScenicId());
|
||||
if (scenicConfig != null) {
|
||||
// 免费送
|
||||
List<MemberSourceEntity> sourceEntities = sourceMapper.listByFaceRelation(face.getScenicId(), face.getId(), 1);
|
||||
List<MemberSourceEntity> sourceEntities = memberRelationRepository.listSourceByFaceRelation(face.getId(), 1);
|
||||
if (sourceEntities.stream().noneMatch(item -> Integer.valueOf(1).equals(item.getIsFree()))) {
|
||||
List<Long> freeSourceRelationIds = new ArrayList<>();
|
||||
if (scenicConfig.getVideoFreeNum() != null && scenicConfig.getVideoFreeNum() > 0) {
|
||||
@@ -344,6 +345,7 @@ public class VideoPieceGetter {
|
||||
videoSource.setIsBuy(0);
|
||||
}
|
||||
sourceMapper.addRelation(videoSource);
|
||||
memberRelationRepository.clearSCacheByFace(task.faceId);
|
||||
}
|
||||
sourceMapper.add(sourceEntity);
|
||||
videoReUploader.addTask(sourceEntity.getId());
|
||||
@@ -377,6 +379,7 @@ public class VideoPieceGetter {
|
||||
}
|
||||
videoSource.setSourceId(source.getId());
|
||||
sourceMapper.addRelation(videoSource);
|
||||
memberRelationRepository.clearSCacheByFace(task.faceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,9 @@ import com.ycwl.basic.model.pc.face.req.FaceReqQuery;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicReqQuery;
|
||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
import com.ycwl.basic.service.pc.FaceService;
|
||||
import com.ycwl.basic.service.task.impl.TaskTaskServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -41,6 +43,8 @@ public class VideoTaskGenerator {
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private FaceService faceService;
|
||||
@Autowired
|
||||
private TemplateRepository templateRepository;
|
||||
|
||||
@Scheduled(cron = "0 0 * * * *")
|
||||
public void generateVideoTask() {
|
||||
@@ -68,8 +72,8 @@ public class VideoTaskGenerator {
|
||||
return;
|
||||
}
|
||||
// 定时逻辑
|
||||
List<ContentPageVO> contentList = templateMapper.listFor(scenicId);
|
||||
if (contentList.isEmpty()) {
|
||||
List<TemplateRespVO> templateList = templateRepository.getTemplateListByScenicId(scenicId);
|
||||
if (templateList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
FaceReqQuery faceReqQuery = new FaceReqQuery();
|
||||
@@ -81,8 +85,8 @@ public class VideoTaskGenerator {
|
||||
faceService.matchFaceId(face.getId(), false);
|
||||
if (Integer.valueOf(3).equals(scenicConfig.getBookRoutine())) {
|
||||
// 全部生成
|
||||
contentList.forEach(content -> {
|
||||
Long templateId = content.getTemplateId();
|
||||
templateList.forEach(content -> {
|
||||
Long templateId = content.getId();
|
||||
boolean canAutoGenerate = templateBiz.determineTemplateCanAutoGenerate(templateId, face.getId(), false);
|
||||
if (canAutoGenerate) {
|
||||
log.info("task callback: 自动生成");
|
||||
@@ -92,7 +96,7 @@ public class VideoTaskGenerator {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Long templateId = contentList.getFirst().getTemplateId();
|
||||
Long templateId = templateList.getFirst().getId();
|
||||
boolean canAutoGenerate = templateBiz.determineTemplateCanAutoGenerate(templateId, face.getId(), false);
|
||||
if (canAutoGenerate) {
|
||||
log.info("task callback: 自动生成");
|
||||
|
@@ -237,8 +237,7 @@
|
||||
<select id="listByFaceRelation" resultType="com.ycwl.basic.model.pc.source.entity.MemberSourceEntity">
|
||||
select *
|
||||
from member_source ms
|
||||
where ms.member_id = #{memberId}
|
||||
and ms.face_id = #{faceId}
|
||||
where ms.face_id = #{faceId}
|
||||
<if test="type!=null">and ms.type = #{type} </if>
|
||||
</select>
|
||||
<update id="updateMemberIdByFaceId">
|
||||
|
@@ -130,7 +130,7 @@
|
||||
<select id="listRelationByFace" resultType="com.ycwl.basic.model.pc.video.entity.MemberVideoEntity">
|
||||
select mv.*
|
||||
from member_video mv
|
||||
where mv.member_id = #{userId} and mv.face_id = #{faceId}
|
||||
where mv.face_id = #{faceId}
|
||||
</select>
|
||||
<select id="listRelationByTask" resultType="com.ycwl.basic.model.pc.video.entity.MemberVideoEntity">
|
||||
select mv.*
|
||||
|
Reference in New Issue
Block a user