From 49b750e1aff47e0b128941c91503abe6234d9281 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Thu, 24 Jul 2025 01:18:01 +0800 Subject: [PATCH] bindFace --- .../com/ycwl/basic/mapper/OrderMapper.java | 2 ++ .../com/ycwl/basic/mapper/SourceMapper.java | 2 ++ .../com/ycwl/basic/mapper/VideoMapper.java | 2 ++ .../ycwl/basic/service/pc/FaceService.java | 2 +- .../service/pc/impl/FaceServiceImpl.java | 32 +++++++++++++++++-- src/main/resources/mapper/OrderMapper.xml | 5 +++ src/main/resources/mapper/SourceMapper.xml | 5 +++ src/main/resources/mapper/VideoMapper.xml | 5 +++ 8 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/ycwl/basic/mapper/OrderMapper.java b/src/main/java/com/ycwl/basic/mapper/OrderMapper.java index afc534b..f6b0886 100644 --- a/src/main/java/com/ycwl/basic/mapper/OrderMapper.java +++ b/src/main/java/com/ycwl/basic/mapper/OrderMapper.java @@ -55,4 +55,6 @@ public interface OrderMapper { OrderEntity queryTypeOrder(Long userId, Long scenicId, int orderType, Integer priceConfigId); OrderEntity getUserOrderItem(Long userId, Long scenicId, int orderType, Long configId, Integer goodsType, Long goodsId); + + int updateMemberIdByFaceId(OrderEntity orderEntity); } diff --git a/src/main/java/com/ycwl/basic/mapper/SourceMapper.java b/src/main/java/com/ycwl/basic/mapper/SourceMapper.java index b664447..6fde6b0 100644 --- a/src/main/java/com/ycwl/basic/mapper/SourceMapper.java +++ b/src/main/java/com/ycwl/basic/mapper/SourceMapper.java @@ -83,4 +83,6 @@ public interface SourceMapper { void addSourceWatermark(Long sourceId, Long faceId, String type, String url); int deleteUselessSource(); + + int updateMemberIdByFaceId(Long faceId, Long memberId); } diff --git a/src/main/java/com/ycwl/basic/mapper/VideoMapper.java b/src/main/java/com/ycwl/basic/mapper/VideoMapper.java index 886f6cf..8b4b7c4 100644 --- a/src/main/java/com/ycwl/basic/mapper/VideoMapper.java +++ b/src/main/java/com/ycwl/basic/mapper/VideoMapper.java @@ -56,4 +56,6 @@ public interface VideoMapper { int deleteNotBuyFaceRelations(Long userId, Long faceId); int deleteUselessVideo(); + + int updateMemberIdByFaceId(Long faceId, Long memberId); } diff --git a/src/main/java/com/ycwl/basic/service/pc/FaceService.java b/src/main/java/com/ycwl/basic/service/pc/FaceService.java index 5360dd4..d6339d2 100644 --- a/src/main/java/com/ycwl/basic/service/pc/FaceService.java +++ b/src/main/java/com/ycwl/basic/service/pc/FaceService.java @@ -37,5 +37,5 @@ public interface FaceService { ApiResponse> contentListUseDefaultFace(); - void bindFace(Long faceId, Long userId); + void bindFace(Long faceId, Long memberId); } 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 2b28a44..25292ef 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 @@ -14,6 +14,7 @@ import com.ycwl.basic.mapper.StatisticsMapper; import com.ycwl.basic.mapper.FaceMapper; import com.ycwl.basic.mapper.TemplateMapper; import com.ycwl.basic.mapper.VideoMapper; +import com.ycwl.basic.mapper.OrderMapper; import com.ycwl.basic.model.mobile.face.FaceRecognizeResp; import com.ycwl.basic.model.mobile.order.IsBuyRespVO; import com.ycwl.basic.model.mobile.scenic.content.ContentPageVO; @@ -28,6 +29,7 @@ import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity; import com.ycwl.basic.model.pc.source.entity.SourceEntity; 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.video.entity.MemberVideoEntity; import com.ycwl.basic.model.pc.video.entity.VideoEntity; @@ -102,6 +104,8 @@ public class FaceServiceImpl implements FaceService { private TemplateBiz templateBiz; @Autowired private DeviceRepository deviceRepository; + @Autowired + private OrderMapper orderMapper; @Override public ApiResponse> pageQuery(FaceReqQuery faceReqQuery) { @@ -493,8 +497,32 @@ public class FaceServiceImpl implements FaceService { } @Override - public void bindFace(Long faceId, Long userId) { - + public void bindFace(Long faceId, Long memberId) { + FaceEntity face = faceRepository.getFace(faceId); + if (face == null) { + throw new BaseException("人脸数据不存在"); + } + + Long currentMemberId = face.getMemberId(); + if (currentMemberId.equals(memberId)) { + return; + } + + FaceEntity updateFace = new FaceEntity(); + updateFace.setId(faceId); + updateFace.setMemberId(memberId); + faceMapper.update(updateFace); + + sourceMapper.updateMemberIdByFaceId(faceId, memberId); + + videoMapper.updateMemberIdByFaceId(faceId, memberId); + + OrderEntity orderUpdate = new OrderEntity(); + orderUpdate.setFaceId(faceId); + orderUpdate.setMemberId(memberId); + orderMapper.updateMemberIdByFaceId(orderUpdate); + + faceRepository.clearFaceCache(faceId); } diff --git a/src/main/resources/mapper/OrderMapper.xml b/src/main/resources/mapper/OrderMapper.xml index aa8526a..410d043 100644 --- a/src/main/resources/mapper/OrderMapper.xml +++ b/src/main/resources/mapper/OrderMapper.xml @@ -517,4 +517,9 @@ and oi.goods_id = #{goodsId} + + update `order` + set member_id = #{memberId} + where face_id = #{faceId} + \ No newline at end of file diff --git a/src/main/resources/mapper/SourceMapper.xml b/src/main/resources/mapper/SourceMapper.xml index cfe1545..5ec92fd 100644 --- a/src/main/resources/mapper/SourceMapper.xml +++ b/src/main/resources/mapper/SourceMapper.xml @@ -242,4 +242,9 @@ and ms.face_id = #{faceId} and ms.type = #{type} + + update member_source + set member_id = #{memberId} + where face_id = #{faceId} + diff --git a/src/main/resources/mapper/VideoMapper.xml b/src/main/resources/mapper/VideoMapper.xml index b9c78cd..858b89f 100644 --- a/src/main/resources/mapper/VideoMapper.xml +++ b/src/main/resources/mapper/VideoMapper.xml @@ -165,4 +165,9 @@ from video where id = #{id} + + update member_video + set member_id = #{memberId} + where face_id = #{faceId} + \ No newline at end of file