Commit a9e603e5 a9e603e513a1e7d1dd6e267b2b8f208752d822bd by xianghan

1.同步master,修复添加观影记录时同样的观影记录重复添加的bug

1 parent 02e78257
......@@ -695,25 +695,33 @@ public class UserOperationServiceImpl implements UserOperationService {
String platformAccount = resources.getPlatformAccount();
String memberCode = resources.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount);
if (Objects.isNull(userTvDTO))
log.info("大屏解绑,通过大屏账号查询大屏账号信息,结果 userTvDTO ==>> {}", userTvDTO);
if (Objects.isNull(userTvDTO.getId()))
throw new EntityNotFoundException(UserTvDTO.class, "PlatformAccount", GlobeExceptionMsg.IPTV_IS_NULL);
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
log.info("大屏解绑,通过会员code查询会员信息,结果memberDTO==>>{}", memberDTO);
// 解绑(置空大屏信息)
MemberDTO _memberDTO = this.minaUnbind_(this.findMemberByCode(memberCode));
log.info("开始置空会员的user_iptv_id ==>> {}", memberDTO);
MemberDTO _memberDTO = this.minaUnbind_(memberDTO);
if (Objects.isNull(_memberDTO)) {
_memberDTO = memberDTO;
}
log.info("会员信息置空大屏的结果,_memberDTO ==>> {}", _memberDTO);
// 置空主账号
log.info("开始置空大屏账号的主会员priorityMemberCode");
UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId(), autoModel, bindMemberCode);
if (Objects.isNull(_userTvDTO)){
_userTvDTO = userTvDTO;
}
log.info("大屏账号置空主会员的结果,_userTvDTO ==>> {}", _userTvDTO);
// 同步至iptv
log.info("开始同步解绑,参数 ==>> {} ",new MemberAndUserTvDTO(_memberDTO, _userTvDTO));
((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnbind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO));
}
......@@ -819,9 +827,9 @@ public class UserOperationServiceImpl implements UserOperationService {
//处理接口调用 中文不显示问题
content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8)));
log.info("receive addCollection add message, content {}", content);
JSONObject jsonObject = JSONObject.parseObject(content);
log.info("receive addCollection add message, content {}", jsonObject);
String platformAccount = jsonObject.getString("platformAccount");
String data = jsonObject.getString("data");
......@@ -830,6 +838,7 @@ public class UserOperationServiceImpl implements UserOperationService {
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
log.info("大屏账号信息 userTvDTO ==>> {}", userTvDTO);
Long tvUserId = userTvDTO.getId();
List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class);
......@@ -849,7 +858,8 @@ public class UserOperationServiceImpl implements UserOperationService {
UserCollection userCollection = this.userCollectionService
.findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName());
log.info("收藏夹信息,大屏账号(uc_user_tv)id ==>> {} || 收藏夹name ==>> {} || 收藏夹type ==>> {}", tvUserId,
userCollectionMq.getName(), userCollectionMq.getType());
if (Objects.isNull(userCollection.getId())) {
userCollection.setAppId(userCollectionMq.getAppId())
......@@ -869,7 +879,11 @@ public class UserOperationServiceImpl implements UserOperationService {
.findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(),
userCollectionDetail.getDetailType(), userCollection.getId());
log.info("检查观影记录是否存在,内容id ==>> {} || 内容type ==>> {} || 收藏夹id ==>> {}", userCollectionDetail.getDetailId(),
userCollectionDetail.getDetailType(), userCollection.getId());
if (CollectionUtils.isEmpty(userCollectionDetailOptional)) {
log.info("观影记录不存在,直接新增");
userCollectionDetail.setId(null)
.setUserCollectionId(userCollection.getId());
......@@ -877,39 +891,21 @@ public class UserOperationServiceImpl implements UserOperationService {
} else {
for (UserCollectionDetail collectionDetail : userCollectionDetailOptional) {
//观影记录同一天只存一条记录
boolean sameDay = DateUtil.isSameDay(new Date(collectionDetail.getCreateTime().getTime()), new Date());
if (sameDay) {
continue;
} else {
userCollectionDetail.setId(null)
.setUserCollectionId(userCollection.getId());
userCollectionDetailRepository.save(userCollectionDetail);
continue;
}
}
}
/*if (userCollectionDetailOptional.isPresent()) {
//观影记录同一天只存一条记录
boolean sameDay = DateUtil.isSameDay(new Date(userCollectionDetailOptional.get().getCreateTime().getTime()), new Date());
boolean sameDay = DateUtil.isSameDay(new Date(userCollectionDetail.getCreateTime().getTime()), new Date());
if (sameDay) {
userCollectionDetail.setId(userCollectionDetailOptional.get().getId());
log.info("传过来的观影时间 ==>> {} 和今天的时间 ==>> {} 相同,修改观影记录,id ==>> {}",userCollectionDetail.getCreateTime().getTime(),
new Date(), userCollectionDetailOptional.get(0).getId());
userCollectionDetail.setId(userCollectionDetailOptional.get(0).getId())
.setUserCollectionId(userCollection.getId());
userCollectionDetailRepository.save(userCollectionDetail);
} else {
log.info("传过来的观影时间 ==>> {} 和今天的时间 ==>> {} 不相同,不做处理", userCollectionDetail.getCreateTime().getTime(),
new Date().toInstant().getEpochSecond());
continue;
}
} else {
userCollectionDetail.setId(null)
.setUserCollectionId(userCollection.getId());
userCollectionDetailRepository.save(userCollectionDetail);
}*/
}
}
}
......@@ -1256,17 +1252,23 @@ public class UserOperationServiceImpl implements UserOperationService {
private UserTvDTO resetMainAccount(String memberCode, Long id, Boolean autoModel, String bindMemberCode) {
UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode);
if (Objects.nonNull(userTvDTO)) {
log.info("大屏解绑,重置大屏账号的主会员,查看当前会员是否是主账号 ==>>memberCode ==>> {} || 大屏账号 ==>> userTvDTO ==>> {}", userTvDTO);
if (Objects.nonNull(userTvDTO.getId())) {
log.info("主账号存在");
if (StringUtils.isBlank(bindMemberCode)) {
// 有其他绑定的小程序会员,排除自己
List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id);
/*List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id);
log.info("后台指定一个默认主会员,通过大屏id查询到的绑定的小屏会员memberDTOList ==>> {}", memberDTOList);
if (!CollectionUtils.isEmpty(memberDTOList)) {
Long memberId = userTvDTO.getMemberId();
MemberDTO memberDTO1 = this.memberService.findById(memberId);
List<MemberDTO> collect =
memberDTOList.stream().filter(memberDTO ->
!memberDTO.getCode().equalsIgnoreCase(memberCode)).collect(Collectors.toList());
!memberDTO.getCode().equalsIgnoreCase(memberCode) &&
!memberDTO.getCode().equalsIgnoreCase(memberDTO1.getCode())).collect(Collectors.toList());
log.info("过滤掉当前需要解绑的会员以及绑定的大屏会员之后剩余的会员列表 ==>> {}", memberDTOList);
if (!CollectionUtils.isEmpty(collect)) {
......@@ -1280,6 +1282,7 @@ public class UserOperationServiceImpl implements UserOperationService {
// 绑定新的主账号
UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTOList.get(0).getCode(), "manual");
log.info("绑定新的主账号 ==>> _userTvDTO ==>> {}", _userTvDTO);
return _userTvDTO;
......@@ -1287,12 +1290,19 @@ public class UserOperationServiceImpl implements UserOperationService {
} else {
log.info("无其他绑定的小屏会员信息 ");
// 绑定新的主账号
UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, null, "manual");
log.info("绑定新的主账号 ==>> _userTvDTO ==>> {}", _userTvDTO);
return _userTvDTO;
}
}*/
log.info("无其他绑定的小屏会员信息 ");
// 绑定新的主账号
UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, null, "manual");
log.info("绑定新的主账号 ==>> _userTvDTO ==>> {}", _userTvDTO);
return _userTvDTO;
} else {
......@@ -1326,6 +1336,7 @@ public class UserOperationServiceImpl implements UserOperationService {
memberDTOS.setUserIptvId(null);
memberDTOS.setBindIptvPlatformType(null);
BeanUtils.copyProperties(memberDTOS, member);
log.info("大屏绑定,置空绑定的大屏信息, member ==>> {}", member);
MemberDTO memberDTO = this.memberService.update(member);
return memberDTO;
}
......@@ -1549,15 +1560,12 @@ public class UserOperationServiceImpl implements UserOperationService {
@Override
public UserTvDTO updateUserTv(UserTv resources) {
UserTvDTO userTvDTO = this.userTvService.update(resources);
Long memberId = userTvDTO.getMemberId();
if (Objects.nonNull(memberId)) {
MemberDTO memberDTO = this.memberService.findById(memberId);
resources.setMemberCode(memberDTO.getCode());
}
// 同步至iptv
((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTv(userTvDTO);
return userTvDTO;
......