1.优化
Showing
3 changed files
with
62 additions
and
35 deletions
... | @@ -12,5 +12,7 @@ public class BindBean extends WeiXinUserBean { | ... | @@ -12,5 +12,7 @@ public class BindBean extends WeiXinUserBean { |
12 | @NotNull(message = "platformAccount can't be null" , groups = {BindGroup.class}) | 12 | @NotNull(message = "platformAccount can't be null" , groups = {BindGroup.class}) |
13 | private String platformAccount; | 13 | private String platformAccount; |
14 | 14 | ||
15 | private String memberCode; | ||
16 | |||
15 | 17 | ||
16 | } | 18 | } | ... | ... |
... | @@ -198,10 +198,12 @@ public class UserOperationController { | ... | @@ -198,10 +198,12 @@ public class UserOperationController { |
198 | if (Objects.nonNull(iptvUserInfo)) { | 198 | if (Objects.nonNull(iptvUserInfo)) { |
199 | 199 | ||
200 | subscribeBean.setIptvUserInfo(iptvUserInfo); | 200 | subscribeBean.setIptvUserInfo(iptvUserInfo); |
201 | 201 | Object sourceInfo1 = iptvUserInfo.get("sourceInfo"); | |
202 | String sourceInfo = iptvUserInfo.get("sourceInfo").toString(); | 202 | if (Objects.nonNull(sourceInfo1)) { |
203 | if (StringUtils.isNotBlank(sourceInfo)) | 203 | String sourceInfo = sourceInfo1.toString(); |
204 | subscribeBean.setSourceInfo(sourceInfo); | 204 | if (StringUtils.isNotBlank(sourceInfo)) |
205 | subscribeBean.setSourceInfo(sourceInfo); | ||
206 | } | ||
205 | 207 | ||
206 | String headimgurl = iptvUserInfo.get("headimgurl").toString(); | 208 | String headimgurl = iptvUserInfo.get("headimgurl").toString(); |
207 | String nickname = iptvUserInfo.get("nickname").toString(); | 209 | String nickname = iptvUserInfo.get("nickname").toString(); |
... | @@ -213,7 +215,8 @@ public class UserOperationController { | ... | @@ -213,7 +215,8 @@ public class UserOperationController { |
213 | 215 | ||
214 | if (StringUtils.isNotBlank(headimgurl)) { | 216 | if (StringUtils.isNotBlank(headimgurl)) { |
215 | String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8"); | 217 | String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8"); |
216 | subscribeBean.setHeadimgurl(headimgurlDecode); | 218 | String headImgUrl = this.downloadWeixinImge(headimgurlDecode); |
219 | subscribeBean.setHeadimgurl(headImgUrl); | ||
217 | } | 220 | } |
218 | 221 | ||
219 | } else { | 222 | } else { |
... | @@ -449,11 +452,16 @@ public class UserOperationController { | ... | @@ -449,11 +452,16 @@ public class UserOperationController { |
449 | log.info("UserOperationController ==> changeMainAccount ==>> param ==> [{}]",resources); | 452 | log.info("UserOperationController ==> changeMainAccount ==>> param ==> [{}]",resources); |
450 | 453 | ||
451 | Long memberId = resources.getMemberId(); | 454 | Long memberId = resources.getMemberId(); |
455 | String memberCode = resources.getMemberCode(); | ||
456 | if (StringUtils.isBlank(memberCode) && Objects.nonNull(memberId)) { | ||
457 | memberCode = this.memberService.findCodeById(memberId); | ||
458 | } | ||
452 | String platformAccount = resources.getPlatformAccount(); | 459 | String platformAccount = resources.getPlatformAccount(); |
453 | String code = this.memberService.findCodeById(memberId); | 460 | if (StringUtils.isBlank(platformAccount)) |
461 | throw new BadRequestException(GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL); | ||
454 | 462 | ||
455 | UserTv userTv = new UserTv(); | 463 | UserTv userTv = new UserTv(); |
456 | userTv.setMemberCode(code); | 464 | userTv.setMemberCode(memberCode); |
457 | userTv.setPlatformAccount(platformAccount); | 465 | userTv.setPlatformAccount(platformAccount); |
458 | this.userOperationService.changeMainAccount(userTv); | 466 | this.userOperationService.changeMainAccount(userTv); |
459 | 467 | ... | ... |
... | @@ -411,10 +411,11 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -411,10 +411,11 @@ public class UserOperationServiceImpl implements UserOperationService { |
411 | String headImgUrl = resources.getHeadimgurl(); | 411 | String headImgUrl = resources.getHeadimgurl(); |
412 | 412 | ||
413 | // 小屏账户 | 413 | // 小屏账户 |
414 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); | 414 | UserWeixinDTO _userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); |
415 | 415 | ||
416 | MemberDTO memberDTO = null; | 416 | MemberDTO memberDTO = null; |
417 | if (Objects.isNull(userWeixinDTO.getId())) { | 417 | if (Objects.isNull(_userWeixinDTO.getId()) || StringUtils.isBlank(_userWeixinDTO.getUnionid()) || |
418 | Objects.isNull(_userWeixinDTO.getMemberId())) { | ||
418 | 419 | ||
419 | UserWeixin userWeixin = new UserWeixin(); | 420 | UserWeixin userWeixin = new UserWeixin(); |
420 | BeanUtils.copyProperties(resources,userWeixin); | 421 | BeanUtils.copyProperties(resources,userWeixin); |
... | @@ -429,7 +430,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -429,7 +430,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
429 | } else { | 430 | } else { |
430 | 431 | ||
431 | // 修改微信账户关注状态 | 432 | // 修改微信账户关注状态 |
432 | UserWeixinDTO _userWeixinDTO = this.doUpdateUserWeiXinStatus(userWeixinDTO, SUBSCRIBE_STATUS); | 433 | _userWeixinDTO = this.doUpdateUserWeiXinStatus(_userWeixinDTO, SUBSCRIBE_STATUS); |
433 | 434 | ||
434 | // 小屏会员 | 435 | // 小屏会员 |
435 | memberDTO = this.findMemberByAppIdAndOpenId(appId,openId); | 436 | memberDTO = this.findMemberByAppIdAndOpenId(appId,openId); |
... | @@ -448,22 +449,21 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -448,22 +449,21 @@ public class UserOperationServiceImpl implements UserOperationService { |
448 | } | 449 | } |
449 | 450 | ||
450 | } | 451 | } |
452 | } | ||
451 | 453 | ||
452 | // 修改会员信息 | 454 | // 修改会员信息 |
453 | MemberDTO _memberDTO1 = this.doUpdateMemberByMemberDTO(memberDTO); | 455 | MemberDTO _memberDTO1 = this.doUpdateMemberByMemberDTO(memberDTO); |
454 | // 同步至iptv | 456 | // 同步至iptv |
455 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncSubscribe(new MemberAndWeixinUserDTO(_memberDTO1, _userWeixinDTO)); | 457 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncSubscribe(new MemberAndWeixinUserDTO(_memberDTO1, _userWeixinDTO)); |
456 | 458 | ||
457 | // 大屏信息 | 459 | // 大屏信息 |
458 | JSONObject iptvUserInfo = resources.getIptvUserInfo(); | 460 | JSONObject iptvUserInfo = resources.getIptvUserInfo(); |
459 | if (Objects.nonNull(iptvUserInfo)) { | 461 | if (Objects.nonNull(iptvUserInfo)) { |
460 | 462 | ||
461 | // 大屏账户 | 463 | // 大屏账户 |
462 | String platformAccount = iptvUserInfo.getString("platformAccount"); | 464 | String platformAccount = iptvUserInfo.getString("platformAccount"); |
463 | // 绑定 | 465 | // 绑定 |
464 | this.bind(memberDTO, platformAccount); | 466 | this.bind(memberDTO, platformAccount); |
465 | |||
466 | } | ||
467 | 467 | ||
468 | } | 468 | } |
469 | 469 | ||
... | @@ -663,7 +663,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -663,7 +663,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
663 | String platformAccount = resources.getPlatformAccount(); | 663 | String platformAccount = resources.getPlatformAccount(); |
664 | String memberCode = resources.getMemberCode(); | 664 | String memberCode = resources.getMemberCode(); |
665 | 665 | ||
666 | this.memberService.findByCode(memberCode); | 666 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); |
667 | 667 | ||
668 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); | 668 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); |
669 | if (Objects.isNull(userTvDTO)) | 669 | if (Objects.isNull(userTvDTO)) |
... | @@ -671,9 +671,15 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -671,9 +671,15 @@ public class UserOperationServiceImpl implements UserOperationService { |
671 | 671 | ||
672 | // 解绑(置空大屏信息) | 672 | // 解绑(置空大屏信息) |
673 | MemberDTO _memberDTO = this.minaUnbind_(this.findMemberByCode(memberCode)); | 673 | MemberDTO _memberDTO = this.minaUnbind_(this.findMemberByCode(memberCode)); |
674 | if (Objects.isNull(_memberDTO)) { | ||
675 | _memberDTO = memberDTO; | ||
676 | } | ||
674 | 677 | ||
675 | // 置空主账号 | 678 | // 置空主账号 |
676 | UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId(), autoModel, bindMemberCode); | 679 | UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId(), autoModel, bindMemberCode); |
680 | if (Objects.isNull(_userTvDTO)){ | ||
681 | _userTvDTO = userTvDTO; | ||
682 | } | ||
677 | 683 | ||
678 | // 同步至iptv | 684 | // 同步至iptv |
679 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnbind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); | 685 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnbind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); |
... | @@ -1007,6 +1013,9 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1007,6 +1013,9 @@ public class UserOperationServiceImpl implements UserOperationService { |
1007 | 1013 | ||
1008 | // 大屏是否绑定主账号,如果绑定了主账户则不操作大屏账户表 | 1014 | // 大屏是否绑定主账号,如果绑定了主账户则不操作大屏账户表 |
1009 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTO.getCode(), "auto"); | 1015 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTO.getCode(), "auto"); |
1016 | if (Objects.isNull(_userTvDTO)) { | ||
1017 | _userTvDTO = userTvDTO; | ||
1018 | } | ||
1010 | // 修改会员 | 1019 | // 修改会员 |
1011 | MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); | 1020 | MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); |
1012 | 1021 | ||
... | @@ -1176,22 +1185,30 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1176,22 +1185,30 @@ public class UserOperationServiceImpl implements UserOperationService { |
1176 | 1185 | ||
1177 | if (StringUtils.isBlank(bindMemberCode)) { | 1186 | if (StringUtils.isBlank(bindMemberCode)) { |
1178 | 1187 | ||
1179 | // 有其他绑定的小程序会员 | 1188 | // 有其他绑定的小程序会员,排除自己 |
1180 | List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id); | 1189 | List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id); |
1181 | if (!CollectionUtils.isEmpty(memberDTOList)) { | 1190 | if (!CollectionUtils.isEmpty(memberDTOList)) { |
1182 | 1191 | ||
1183 | // 按绑定时间倒排 | 1192 | List<MemberDTO> collect = |
1184 | memberDTOList.sort(new Comparator<MemberDTO>() { | 1193 | memberDTOList.stream().filter(memberDTO -> |
1185 | @Override | 1194 | !memberDTO.getCode().equalsIgnoreCase(memberCode)).collect(Collectors.toList()); |
1186 | public int compare(MemberDTO memberDTO, MemberDTO t1) { | ||
1187 | return t1.getBindIptvTime().compareTo(memberDTO.getBindIptvTime()); | ||
1188 | } | ||
1189 | }); | ||
1190 | 1195 | ||
1191 | // 绑定新的主账号 | 1196 | if (!CollectionUtils.isEmpty(collect)) { |
1192 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTOList.get(0).getCode(), "manual"); | ||
1193 | 1197 | ||
1194 | return _userTvDTO; | 1198 | // 按绑定时间倒排 |
1199 | collect.sort(new Comparator<MemberDTO>() { | ||
1200 | @Override | ||
1201 | public int compare(MemberDTO memberDTO, MemberDTO t1) { | ||
1202 | return t1.getBindIptvTime().compareTo(memberDTO.getBindIptvTime()); | ||
1203 | } | ||
1204 | }); | ||
1205 | |||
1206 | // 绑定新的主账号 | ||
1207 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberDTOList.get(0).getCode(), "manual"); | ||
1208 | |||
1209 | return _userTvDTO; | ||
1210 | |||
1211 | } | ||
1195 | 1212 | ||
1196 | } else { | 1213 | } else { |
1197 | 1214 | ... | ... |
-
Please register or sign in to post a comment