Commit d7fea15b d7fea15b583ccaddc1d9ecdd95f2360a1e5d80a8 by xianghan

1.优化

1 parent 053fb7e1
...@@ -16,6 +16,8 @@ import java.io.Serializable; ...@@ -16,6 +16,8 @@ import java.io.Serializable;
16 @Data 16 @Data
17 public class UserWeixinDTO implements Serializable { 17 public class UserWeixinDTO implements Serializable {
18 18
19 private String memberCode;
20
19 /** ID */ 21 /** ID */
20 private Long id; 22 private Long id;
21 23
...@@ -94,13 +96,18 @@ public class UserWeixinDTO implements Serializable { ...@@ -94,13 +96,18 @@ public class UserWeixinDTO implements Serializable {
94 /** 授权时间 */ 96 /** 授权时间 */
95 private Timestamp authTime; 97 private Timestamp authTime;
96 98
99 /** */
97 private Integer gender; 100 private Integer gender;
98 101
102 /** */
99 private String country; 103 private String country;
100 104
105 /** */
101 private String province; 106 private String province;
102 107
108 /** */
103 private String city; 109 private String city;
104 110
111 /** */
105 private Integer sex; 112 private Integer sex;
106 } 113 }
......
...@@ -218,35 +218,49 @@ public class UserOperationController { ...@@ -218,35 +218,49 @@ public class UserOperationController {
218 218
219 // 保存大小屏信息到redis同时返回小屏信息 219 // 保存大小屏信息到redis同时返回小屏信息
220 UserWeixinDTO userWeixinDTO = this.userOperationService.saveUserInfo(data); 220 UserWeixinDTO userWeixinDTO = this.userOperationService.saveUserInfo(data);
221
222 // 小屏账号不存在
223 if (Objects.isNull(userWeixinDTO) || Objects.isNull(userWeixinDTO.getId())) {
224
225 result = UNSUBSCRIBE;
226 resultList.add(result);
227 resultList.add(platformAccount1);
228 log.info("saveUserInfo ==>> result ==>> [{}]",resultList);
229 return ResultInfo.success(resultList);
230
231 } else {
232
233 // 账号存在,未关注
234 if (userWeixinDTO.getStatus() != SUBSCRIBE_STATUS) {
235 result = UNSUBSCRIBE;
236 }
237
221 // 小屏会员 238 // 小屏会员
222 MemberDTO memberDTO = this.memberService.findById(userWeixinDTO.getMemberId()); 239 MemberDTO memberDTO = this.memberService.findById(userWeixinDTO.getMemberId());
223 // 小屏用户不存在或者关注状态为未关注(0),返回未关注
224 if (Objects.isNull(userWeixinDTO) || Objects.isNull(userWeixinDTO.getId()) || userWeixinDTO.getStatus() != SUBSCRIBE_STATUS) {
225 result = UNSUBSCRIBE;
226 240
227 if (Objects.nonNull(memberDTO)) { 241 if (Objects.nonNull(memberDTO)) {
242
228 // 检查是否绑定,返回绑定的大屏账户 243 // 检查是否绑定,返回绑定的大屏账户
229 UserTvDTO userTvDTO = this.userOperationService.checkBind(memberDTO); 244 UserTvDTO userTvDTO = this.userOperationService.checkBind(memberDTO);
230 if (Objects.nonNull(userTvDTO)) { 245 if (Objects.nonNull(userTvDTO)) {
246 // 绑定的大屏账号
231 platformAccount1 = userTvDTO.getPlatformAccount(); 247 platformAccount1 = userTvDTO.getPlatformAccount();
232 } 248 }
233 249
234 } else { 250 } else {
251
252 // 数据异常,没有会员
235 log.info("userWeixinDTO ==>> [{}]",userWeixinDTO); 253 log.info("userWeixinDTO ==>> [{}]",userWeixinDTO);
236 throw new EntityNotFoundException(MemberDTO.class,"code","member is null !!"); 254 throw new EntityNotFoundException(MemberDTO.class,"code","member is null !!");
237 }
238 255
239 resultList.add(result);
240 resultList.add(platformAccount1);
241 log.info("saveUserInfo ==>> result ==>> [{}]",resultList);
242 return ResultInfo.success(resultList);
243 } 256 }
244 257
245 /***************************************************************************************/ 258 // 关注
246
247 // 关注未绑定
248 if (result.equalsIgnoreCase(SUBSCRIBE)) { 259 if (result.equalsIgnoreCase(SUBSCRIBE)) {
249 260
261 // 未绑定
262 if (StringUtils.isBlank(platformAccount1)) {
263
250 // redis中的大小屏信息 264 // redis中的大小屏信息
251 String content = (String) this.redisUtils.get(RedisKeyUtil.genSeSuSubscribeKey(unionid)); 265 String content = (String) this.redisUtils.get(RedisKeyUtil.genSeSuSubscribeKey(unionid));
252 JSONObject iptvUserInfo = JSONObject.parseObject(content); 266 JSONObject iptvUserInfo = JSONObject.parseObject(content);
...@@ -270,20 +284,22 @@ public class UserOperationController { ...@@ -270,20 +284,22 @@ public class UserOperationController {
270 String image = RestTemplateClient.chooseImage(imageEncode, "image"); 284 String image = RestTemplateClient.chooseImage(imageEncode, "image");
271 memberDTO.setAvatarUrl(StringUtils.isNotBlank(image) == true ? image:headimgurlDecode); 285 memberDTO.setAvatarUrl(StringUtils.isNotBlank(image) == true ? image:headimgurlDecode);
272 } 286 }
273 }catch (Exception e) { 287 } catch (Exception e) {
274 log.info("头像解析失败!!!"); 288 log.info("头像解析失败!!!");
275 e.printStackTrace(); 289 e.printStackTrace();
276 } 290 }
277 291
278 // 大小屏绑定,如果已经绑定了别的大屏,则不进行处理,返回已绑定的大屏信息 292 // 大小屏绑定,如果已经绑定了别的大屏,则不进行处理,返回已绑定的大屏信息
279 // 已绑定的大屏信息
280 UserTvDTO userTvDTO = this.userOperationService.bind(memberDTO, platformAccount); 293 UserTvDTO userTvDTO = this.userOperationService.bind(memberDTO, platformAccount);
281 if (userTvDTO != null) { 294 if (userTvDTO != null) {
282 platformAccount1 = userTvDTO.getPlatformAccount(); 295 platformAccount1 = userTvDTO.getPlatformAccount();
283 } 296 }
284 297
285 } 298 }
286 /****************************************************************************************/ 299
300 }
301
302 }
287 303
288 resultList.add(result); 304 resultList.add(result);
289 resultList.add(platformAccount1); 305 resultList.add(platformAccount1);
......
...@@ -106,21 +106,15 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -106,21 +106,15 @@ public class UserOperationServiceImpl implements UserOperationService {
106 @AsyncMqSend 106 @AsyncMqSend
107 public void asyncMemberAndUserTv4Iptv(MemberAndUserTvDTO memberAndUserTv) {} 107 public void asyncMemberAndUserTv4Iptv(MemberAndUserTvDTO memberAndUserTv) {}
108 @AsyncMqSend 108 @AsyncMqSend
109 public void asyncWeixin(UserWeixinDTO weixinDTO) { 109 public void asyncWeixin(UserWeixinDTO weixinDTO) {}
110 messageProducer.sendMessage(JSON.toJSONString(weixinDTO));
111 }
112 @AsyncMqSend 110 @AsyncMqSend
113 public void asyncUserTv(UserTvDTO userTvDTO) { 111 public void asyncUserTv(UserTvDTO userTvDTO) {}
114 messageProducer.sendMessage(JSON.toJSONString(userTvDTO));
115 }
116 @AsyncMqSend 112 @AsyncMqSend
117 public void asyncMember(MemberDTO memberDTO) { 113 public void asyncAppletBind(MemberAndUserTvDTO memberAndUserTvDTO) {}
118 messageProducer.sendMessage(JSON.toJSONString(memberDTO)); 114 @AsyncMqSend
119 } 115 public void asyncUnbind(MemberAndUserTvDTO memberAndUserTvDTO) {}
120 116 @AsyncMqSend
121 117 public void asyncUnsubscribe(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {}
122 @Autowired
123 private MessageProducer messageProducer;
124 118
125 /** 119 /**
126 * 创建大屏账户同时创建会员 120 * 创建大屏账户同时创建会员
...@@ -197,7 +191,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -197,7 +191,7 @@ public class UserOperationServiceImpl implements UserOperationService {
197 resources.setMemberId(_userWeixinDTO.getMemberId()); 191 resources.setMemberId(_userWeixinDTO.getMemberId());
198 UserWeixin userWeixin = UserWeixinBuilder.build(resources); 192 UserWeixin userWeixin = UserWeixinBuilder.build(resources);
199 UserWeixinDTO weixinDTO = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode()); 193 UserWeixinDTO weixinDTO = this.createWeixinUser(userWeixin, memberDTO.getId(), memberDTO.getCode());
200 194 weixinDTO.setMemberCode(memberDTO.getCode());
201 // 同步至iptv 195 // 同步至iptv
202 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncWeixin(weixinDTO); 196 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncWeixin(weixinDTO);
203 197
...@@ -291,6 +285,8 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -291,6 +285,8 @@ public class UserOperationServiceImpl implements UserOperationService {
291 285
292 UserWeixin userWeixin = new UserWeixin(); 286 UserWeixin userWeixin = new UserWeixin();
293 BeanUtils.copyProperties(resources,userWeixin); 287 BeanUtils.copyProperties(resources,userWeixin);
288 userWeixin.setStatus(SUBSCRIBE_STATUS);
289
294 // 创建小屏账户同时创建会员 290 // 创建小屏账户同时创建会员
295 this.createWeixinUserAndMember(userWeixin); 291 this.createWeixinUserAndMember(userWeixin);
296 292
...@@ -300,7 +296,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -300,7 +296,7 @@ public class UserOperationServiceImpl implements UserOperationService {
300 UserWeixinDTO _userWeixinDTO = this.doUpdateUserWeiXinStatus(userWeixinDTO, SUBSCRIBE_STATUS); 296 UserWeixinDTO _userWeixinDTO = this.doUpdateUserWeiXinStatus(userWeixinDTO, SUBSCRIBE_STATUS);
301 297
302 // 同步至iptv 298 // 同步至iptv
303 this.asyncWeixin(_userWeixinDTO); 299 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncWeixin(_userWeixinDTO);
304 } 300 }
305 301
306 // 大屏信息 302 // 大屏信息
...@@ -356,11 +352,13 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -356,11 +352,13 @@ public class UserOperationServiceImpl implements UserOperationService {
356 MemberDTO _memberDTO = this.doUpdateMemberVip(memberDTO, 0); 352 MemberDTO _memberDTO = this.doUpdateMemberVip(memberDTO, 0);
357 353
358 // 同步至iptv 354 // 同步至iptv
359 this.asyncMemberAndUserWeixin4Iptv(new MemberAndWeixinUserDTO(memberDTO, userWeixinDTO)); 355 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnsubscribe(new MemberAndWeixinUserDTO(_memberDTO, userWeixinDTO));
360 356
361 return true; 357 return true;
362 } 358 }
363 359
360
361
364 /** 362 /**
365 * 更新大屏信息,同时判断是否已经关注,如果关注了则不跳转H5页面 363 * 更新大屏信息,同时判断是否已经关注,如果关注了则不跳转H5页面
366 * @param data 364 * @param data
...@@ -409,7 +407,6 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -409,7 +407,6 @@ public class UserOperationServiceImpl implements UserOperationService {
409 this.findMemberByCode(memberCode); 407 this.findMemberByCode(memberCode);
410 408
411 String platformAccount = resources.getPlatformAccount(); 409 String platformAccount = resources.getPlatformAccount();
412 this.findByPlatformAccount(platformAccount);
413 410
414 UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); 411 UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount);
415 412
...@@ -428,7 +425,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -428,7 +425,7 @@ public class UserOperationServiceImpl implements UserOperationService {
428 UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberCode, "manual"); 425 UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberCode, "manual");
429 426
430 // 同步至iptv 427 // 同步至iptv
431 this.asyncUserTv(_userTvDTO); 428 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTv(_userTvDTO);
432 } 429 }
433 430
434 /** 431 /**
...@@ -452,9 +449,10 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -452,9 +449,10 @@ public class UserOperationServiceImpl implements UserOperationService {
452 UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId()); 449 UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId());
453 450
454 // 同步至iptv 451 // 同步至iptv
455 this.asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); 452 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnbind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO));
456 } 453 }
457 454
455
458 @Override 456 @Override
459 public boolean deleteAllCollection(String content) { 457 public boolean deleteAllCollection(String content) {
460 try { 458 try {
...@@ -699,7 +697,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -699,7 +697,7 @@ public class UserOperationServiceImpl implements UserOperationService {
699 MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); 697 MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO);
700 698
701 // 同步至iptv 699 // 同步至iptv
702 this.asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); 700 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncAppletBind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO));
703 701
704 return true; 702 return true;
705 } 703 }
...@@ -780,7 +778,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -780,7 +778,7 @@ public class UserOperationServiceImpl implements UserOperationService {
780 MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); 778 MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO);
781 779
782 // 同步至iptv 780 // 同步至iptv
783 this.asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); 781 ((UserOperationServiceImpl)AopContext.currentProxy()).asyncAppletBind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO));
784 782
785 return null; 783 return null;
786 } 784 }
...@@ -898,16 +896,6 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -898,16 +896,6 @@ public class UserOperationServiceImpl implements UserOperationService {
898 } 896 }
899 897
900 /** 898 /**
901 *
902 * @param memberCode
903 * @return
904 */
905 private UserTvDTO findByPriorityMemberCode(String memberCode) {
906 UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode);
907 return userTvDTO;
908 }
909
910 /**
911 * 设置主会员 899 * 设置主会员
912 * @description 检查大屏账户有没有绑定小屏会员,如果没有绑定就将当前会员的code保存到大屏账户中 900 * @description 检查大屏账户有没有绑定小屏会员,如果没有绑定就将当前会员的code保存到大屏账户中
913 * @param userTvDTO 901 * @param userTvDTO
...@@ -927,7 +915,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -927,7 +915,7 @@ public class UserOperationServiceImpl implements UserOperationService {
927 userTvDTO.setPriorityMemberCode(memberCode); 915 userTvDTO.setPriorityMemberCode(memberCode);
928 916
929 UserTv userTv = new UserTv(); 917 UserTv userTv = new UserTv();
930 BeanUtils.copyProperties(userTvDTO,userTv); 918 BeanUtils.copyProperties(userTvDTO, userTv);
931 UserTvDTO _userTvDTO = this.updateUserTv(userTv); 919 UserTvDTO _userTvDTO = this.updateUserTv(userTv);
932 920
933 return _userTvDTO; 921 return _userTvDTO;
...@@ -951,7 +939,15 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -951,7 +939,15 @@ public class UserOperationServiceImpl implements UserOperationService {
951 UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode); 939 UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode);
952 if (Objects.nonNull(userTvDTO)) { 940 if (Objects.nonNull(userTvDTO)) {
953 941
954 List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id); 942 userTvDTO.setPriorityMemberCode(null);
943 UserTv userTv = new UserTv();
944 BeanUtils.copyProperties(userTvDTO,userTv);
945
946 UserTvDTO _userTvDTO = this.userTvService.update(userTv);
947
948 return _userTvDTO;
949
950 /*List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id);
955 if (CollectionUtils.isNotEmpty(memberDTOList)) { 951 if (CollectionUtils.isNotEmpty(memberDTOList)) {
956 952
957 // 过滤解绑的会员 953 // 过滤解绑的会员
...@@ -984,7 +980,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -984,7 +980,7 @@ public class UserOperationServiceImpl implements UserOperationService {
984 UserTvDTO _userTvDTO = this.userTvService.unbindPriorityMemberCode(userTv); 980 UserTvDTO _userTvDTO = this.userTvService.unbindPriorityMemberCode(userTv);
985 981
986 return _userTvDTO; 982 return _userTvDTO;
987 } 983 }*/
988 984
989 } 985 }
990 986
......