1.同步master,修复添加观影记录时同样的观影记录重复添加的bug
Showing
1 changed file
with
50 additions
and
42 deletions
| ... | @@ -695,25 +695,33 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -695,25 +695,33 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 695 | String platformAccount = resources.getPlatformAccount(); | 695 | String platformAccount = resources.getPlatformAccount(); |
| 696 | String memberCode = resources.getMemberCode(); | 696 | String memberCode = resources.getMemberCode(); |
| 697 | 697 | ||
| 698 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | ||
| 699 | |||
| 700 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); | 698 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); |
| 701 | if (Objects.isNull(userTvDTO)) | 699 | log.info("大屏解绑,通过大屏账号查询大屏账号信息,结果 userTvDTO ==>> {}", userTvDTO); |
| 700 | if (Objects.isNull(userTvDTO.getId())) | ||
| 702 | throw new EntityNotFoundException(UserTvDTO.class, "PlatformAccount", GlobeExceptionMsg.IPTV_IS_NULL); | 701 | throw new EntityNotFoundException(UserTvDTO.class, "PlatformAccount", GlobeExceptionMsg.IPTV_IS_NULL); |
| 703 | 702 | ||
| 703 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | ||
| 704 | log.info("大屏解绑,通过会员code查询会员信息,结果memberDTO==>>{}", memberDTO); | ||
| 705 | |||
| 706 | |||
| 704 | // 解绑(置空大屏信息) | 707 | // 解绑(置空大屏信息) |
| 705 | MemberDTO _memberDTO = this.minaUnbind_(this.findMemberByCode(memberCode)); | 708 | log.info("开始置空会员的user_iptv_id ==>> {}", memberDTO); |
| 709 | MemberDTO _memberDTO = this.minaUnbind_(memberDTO); | ||
| 706 | if (Objects.isNull(_memberDTO)) { | 710 | if (Objects.isNull(_memberDTO)) { |
| 707 | _memberDTO = memberDTO; | 711 | _memberDTO = memberDTO; |
| 708 | } | 712 | } |
| 713 | log.info("会员信息置空大屏的结果,_memberDTO ==>> {}", _memberDTO); | ||
| 709 | 714 | ||
| 710 | // 置空主账号 | 715 | // 置空主账号 |
| 716 | log.info("开始置空大屏账号的主会员priorityMemberCode"); | ||
| 711 | UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId(), autoModel, bindMemberCode); | 717 | UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId(), autoModel, bindMemberCode); |
| 712 | if (Objects.isNull(_userTvDTO)){ | 718 | if (Objects.isNull(_userTvDTO)){ |
| 713 | _userTvDTO = userTvDTO; | 719 | _userTvDTO = userTvDTO; |
| 714 | } | 720 | } |
| 721 | log.info("大屏账号置空主会员的结果,_userTvDTO ==>> {}", _userTvDTO); | ||
| 715 | 722 | ||
| 716 | // 同步至iptv | 723 | // 同步至iptv |
| 724 | log.info("开始同步解绑,参数 ==>> {} ",new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); | ||
| 717 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnbind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); | 725 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnbind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); |
| 718 | } | 726 | } |
| 719 | 727 | ||
| ... | @@ -819,9 +827,9 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -819,9 +827,9 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 819 | //处理接口调用 中文不显示问题 | 827 | //处理接口调用 中文不显示问题 |
| 820 | content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8))); | 828 | content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8))); |
| 821 | 829 | ||
| 822 | log.info("receive addCollection add message, content {}", content); | ||
| 823 | |||
| 824 | JSONObject jsonObject = JSONObject.parseObject(content); | 830 | JSONObject jsonObject = JSONObject.parseObject(content); |
| 831 | log.info("receive addCollection add message, content {}", jsonObject); | ||
| 832 | |||
| 825 | String platformAccount = jsonObject.getString("platformAccount"); | 833 | String platformAccount = jsonObject.getString("platformAccount"); |
| 826 | String data = jsonObject.getString("data"); | 834 | String data = jsonObject.getString("data"); |
| 827 | 835 | ||
| ... | @@ -830,6 +838,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -830,6 +838,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 830 | 838 | ||
| 831 | 839 | ||
| 832 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | 840 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); |
| 841 | log.info("大屏账号信息 userTvDTO ==>> {}", userTvDTO); | ||
| 833 | 842 | ||
| 834 | Long tvUserId = userTvDTO.getId(); | 843 | Long tvUserId = userTvDTO.getId(); |
| 835 | List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class); | 844 | List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class); |
| ... | @@ -849,7 +858,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -849,7 +858,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 849 | 858 | ||
| 850 | UserCollection userCollection = this.userCollectionService | 859 | UserCollection userCollection = this.userCollectionService |
| 851 | .findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName()); | 860 | .findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName()); |
| 852 | 861 | log.info("收藏夹信息,大屏账号(uc_user_tv)id ==>> {} || 收藏夹name ==>> {} || 收藏夹type ==>> {}", tvUserId, | |
| 862 | userCollectionMq.getName(), userCollectionMq.getType()); | ||
| 853 | 863 | ||
| 854 | if (Objects.isNull(userCollection.getId())) { | 864 | if (Objects.isNull(userCollection.getId())) { |
| 855 | userCollection.setAppId(userCollectionMq.getAppId()) | 865 | userCollection.setAppId(userCollectionMq.getAppId()) |
| ... | @@ -869,7 +879,11 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -869,7 +879,11 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 869 | .findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(), | 879 | .findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(), |
| 870 | userCollectionDetail.getDetailType(), userCollection.getId()); | 880 | userCollectionDetail.getDetailType(), userCollection.getId()); |
| 871 | 881 | ||
| 882 | log.info("检查观影记录是否存在,内容id ==>> {} || 内容type ==>> {} || 收藏夹id ==>> {}", userCollectionDetail.getDetailId(), | ||
| 883 | userCollectionDetail.getDetailType(), userCollection.getId()); | ||
| 884 | |||
| 872 | if (CollectionUtils.isEmpty(userCollectionDetailOptional)) { | 885 | if (CollectionUtils.isEmpty(userCollectionDetailOptional)) { |
| 886 | log.info("观影记录不存在,直接新增"); | ||
| 873 | 887 | ||
| 874 | userCollectionDetail.setId(null) | 888 | userCollectionDetail.setId(null) |
| 875 | .setUserCollectionId(userCollection.getId()); | 889 | .setUserCollectionId(userCollection.getId()); |
| ... | @@ -877,39 +891,21 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -877,39 +891,21 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 877 | 891 | ||
| 878 | } else { | 892 | } else { |
| 879 | 893 | ||
| 880 | for (UserCollectionDetail collectionDetail : userCollectionDetailOptional) { | ||
| 881 | //观影记录同一天只存一条记录 | 894 | //观影记录同一天只存一条记录 |
| 882 | boolean sameDay = DateUtil.isSameDay(new Date(collectionDetail.getCreateTime().getTime()), new Date()); | 895 | boolean sameDay = DateUtil.isSameDay(new Date(userCollectionDetail.getCreateTime().getTime()), new Date()); |
| 883 | if (sameDay) { | 896 | if (sameDay) { |
| 884 | continue; | 897 | log.info("传过来的观影时间 ==>> {} 和今天的时间 ==>> {} 相同,修改观影记录,id ==>> {}",userCollectionDetail.getCreateTime().getTime(), |
| 885 | } else { | 898 | new Date(), userCollectionDetailOptional.get(0).getId()); |
| 886 | userCollectionDetail.setId(null) | 899 | userCollectionDetail.setId(userCollectionDetailOptional.get(0).getId()) |
| 887 | .setUserCollectionId(userCollection.getId()); | 900 | .setUserCollectionId(userCollection.getId()); |
| 888 | userCollectionDetailRepository.save(userCollectionDetail); | 901 | userCollectionDetailRepository.save(userCollectionDetail); |
| 889 | continue; | ||
| 890 | } | ||
| 891 | |||
| 892 | } | ||
| 893 | |||
| 894 | } | ||
| 895 | /*if (userCollectionDetailOptional.isPresent()) { | ||
| 896 | //观影记录同一天只存一条记录 | ||
| 897 | boolean sameDay = DateUtil.isSameDay(new Date(userCollectionDetailOptional.get().getCreateTime().getTime()), new Date()); | ||
| 898 | if (sameDay) { | ||
| 899 | userCollectionDetail.setId(userCollectionDetailOptional.get().getId()); | ||
| 900 | userCollectionDetailRepository.save(userCollectionDetail); | ||
| 901 | } else { | 902 | } else { |
| 902 | 903 | log.info("传过来的观影时间 ==>> {} 和今天的时间 ==>> {} 不相同,不做处理", userCollectionDetail.getCreateTime().getTime(), | |
| 904 | new Date().toInstant().getEpochSecond()); | ||
| 903 | continue; | 905 | continue; |
| 904 | } | 906 | } |
| 905 | 907 | ||
| 906 | } else { | 908 | } |
| 907 | |||
| 908 | userCollectionDetail.setId(null) | ||
| 909 | .setUserCollectionId(userCollection.getId()); | ||
| 910 | userCollectionDetailRepository.save(userCollectionDetail); | ||
| 911 | }*/ | ||
| 912 | |||
| 913 | 909 | ||
| 914 | } | 910 | } |
| 915 | } | 911 | } |
| ... | @@ -1256,17 +1252,23 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1256,17 +1252,23 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1256 | private UserTvDTO resetMainAccount(String memberCode, Long id, Boolean autoModel, String bindMemberCode) { | 1252 | private UserTvDTO resetMainAccount(String memberCode, Long id, Boolean autoModel, String bindMemberCode) { |
| 1257 | 1253 | ||
| 1258 | UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode); | 1254 | UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode); |
| 1259 | if (Objects.nonNull(userTvDTO)) { | 1255 | log.info("大屏解绑,重置大屏账号的主会员,查看当前会员是否是主账号 ==>>memberCode ==>> {} || 大屏账号 ==>> userTvDTO ==>> {}", userTvDTO); |
| 1260 | 1256 | if (Objects.nonNull(userTvDTO.getId())) { | |
| 1257 | log.info("主账号存在"); | ||
| 1261 | if (StringUtils.isBlank(bindMemberCode)) { | 1258 | if (StringUtils.isBlank(bindMemberCode)) { |
| 1262 | |||
| 1263 | // 有其他绑定的小程序会员,排除自己 | 1259 | // 有其他绑定的小程序会员,排除自己 |
| 1264 | List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id); | 1260 | /*List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id); |
| 1261 | log.info("后台指定一个默认主会员,通过大屏id查询到的绑定的小屏会员memberDTOList ==>> {}", memberDTOList); | ||
| 1265 | if (!CollectionUtils.isEmpty(memberDTOList)) { | 1262 | if (!CollectionUtils.isEmpty(memberDTOList)) { |
| 1266 | 1263 | ||
| 1264 | Long memberId = userTvDTO.getMemberId(); | ||
| 1265 | MemberDTO memberDTO1 = this.memberService.findById(memberId); | ||
| 1266 | |||
| 1267 | List<MemberDTO> collect = | 1267 | List<MemberDTO> collect = |
| 1268 | memberDTOList.stream().filter(memberDTO -> | 1268 | memberDTOList.stream().filter(memberDTO -> |
| 1269 | !memberDTO.getCode().equalsIgnoreCase(memberCode)).collect(Collectors.toList()); | 1269 | !memberDTO.getCode().equalsIgnoreCase(memberCode) && |
| 1270 | !memberDTO.getCode().equalsIgnoreCase(memberDTO1.getCode())).collect(Collectors.toList()); | ||
| 1271 | log.info("过滤掉当前需要解绑的会员以及绑定的大屏会员之后剩余的会员列表 ==>> {}", memberDTOList); | ||
| 1270 | 1272 | ||
| 1271 | if (!CollectionUtils.isEmpty(collect)) { | 1273 | if (!CollectionUtils.isEmpty(collect)) { |
| 1272 | 1274 | ||
| ... | @@ -1280,6 +1282,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1280,6 +1282,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1280 | 1282 | ||
| 1281 | // 绑定新的主账号 | 1283 | // 绑定新的主账号 |
| 1282 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTOList.get(0).getCode(), "manual"); | 1284 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTOList.get(0).getCode(), "manual"); |
| 1285 | log.info("绑定新的主账号 ==>> _userTvDTO ==>> {}", _userTvDTO); | ||
| 1283 | 1286 | ||
| 1284 | return _userTvDTO; | 1287 | return _userTvDTO; |
| 1285 | 1288 | ||
| ... | @@ -1287,12 +1290,19 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1287,12 +1290,19 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1287 | 1290 | ||
| 1288 | } else { | 1291 | } else { |
| 1289 | 1292 | ||
| 1293 | log.info("无其他绑定的小屏会员信息 "); | ||
| 1290 | // 绑定新的主账号 | 1294 | // 绑定新的主账号 |
| 1291 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, null, "manual"); | 1295 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, null, "manual"); |
| 1292 | 1296 | log.info("绑定新的主账号 ==>> _userTvDTO ==>> {}", _userTvDTO); | |
| 1293 | return _userTvDTO; | 1297 | return _userTvDTO; |
| 1294 | 1298 | ||
| 1295 | } | 1299 | }*/ |
| 1300 | |||
| 1301 | log.info("无其他绑定的小屏会员信息 "); | ||
| 1302 | // 绑定新的主账号 | ||
| 1303 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, null, "manual"); | ||
| 1304 | log.info("绑定新的主账号 ==>> _userTvDTO ==>> {}", _userTvDTO); | ||
| 1305 | return _userTvDTO; | ||
| 1296 | 1306 | ||
| 1297 | } else { | 1307 | } else { |
| 1298 | 1308 | ||
| ... | @@ -1326,6 +1336,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1326,6 +1336,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1326 | memberDTOS.setUserIptvId(null); | 1336 | memberDTOS.setUserIptvId(null); |
| 1327 | memberDTOS.setBindIptvPlatformType(null); | 1337 | memberDTOS.setBindIptvPlatformType(null); |
| 1328 | BeanUtils.copyProperties(memberDTOS, member); | 1338 | BeanUtils.copyProperties(memberDTOS, member); |
| 1339 | log.info("大屏绑定,置空绑定的大屏信息, member ==>> {}", member); | ||
| 1329 | MemberDTO memberDTO = this.memberService.update(member); | 1340 | MemberDTO memberDTO = this.memberService.update(member); |
| 1330 | return memberDTO; | 1341 | return memberDTO; |
| 1331 | } | 1342 | } |
| ... | @@ -1549,15 +1560,12 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1549,15 +1560,12 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1549 | 1560 | ||
| 1550 | @Override | 1561 | @Override |
| 1551 | public UserTvDTO updateUserTv(UserTv resources) { | 1562 | public UserTvDTO updateUserTv(UserTv resources) { |
| 1552 | |||
| 1553 | UserTvDTO userTvDTO = this.userTvService.update(resources); | 1563 | UserTvDTO userTvDTO = this.userTvService.update(resources); |
| 1554 | Long memberId = userTvDTO.getMemberId(); | 1564 | Long memberId = userTvDTO.getMemberId(); |
| 1555 | |||
| 1556 | if (Objects.nonNull(memberId)) { | 1565 | if (Objects.nonNull(memberId)) { |
| 1557 | MemberDTO memberDTO = this.memberService.findById(memberId); | 1566 | MemberDTO memberDTO = this.memberService.findById(memberId); |
| 1558 | resources.setMemberCode(memberDTO.getCode()); | 1567 | resources.setMemberCode(memberDTO.getCode()); |
| 1559 | } | 1568 | } |
| 1560 | |||
| 1561 | // 同步至iptv | 1569 | // 同步至iptv |
| 1562 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTv(userTvDTO); | 1570 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTv(userTvDTO); |
| 1563 | return userTvDTO; | 1571 | return userTvDTO; | ... | ... |
-
Please register or sign in to post a comment