1.修改大屏侧小屏解绑和换绑的逻辑
Showing
6 changed files
with
88 additions
and
22 deletions
... | @@ -78,4 +78,6 @@ public interface MemberService { | ... | @@ -78,4 +78,6 @@ public interface MemberService { |
78 | * @param resources | 78 | * @param resources |
79 | */ | 79 | */ |
80 | MemberDTO doUpdateMemberExpAndLevel(Member resources); | 80 | MemberDTO doUpdateMemberExpAndLevel(Member resources); |
81 | |||
82 | MemberDTO unbindUserIpTv(Member member); | ||
81 | } | 83 | } | ... | ... |
... | @@ -9,6 +9,8 @@ import com.topdraw.business.module.member.repository.MemberRepository; | ... | @@ -9,6 +9,8 @@ import com.topdraw.business.module.member.repository.MemberRepository; |
9 | import com.topdraw.business.module.member.service.MemberService; | 9 | import com.topdraw.business.module.member.service.MemberService; |
10 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 10 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
11 | import com.topdraw.business.module.member.service.mapper.MemberMapper; | 11 | import com.topdraw.business.module.member.service.mapper.MemberMapper; |
12 | import com.topdraw.business.module.user.iptv.service.UserTvService; | ||
13 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | ||
12 | import com.topdraw.exception.BadRequestException; | 14 | import com.topdraw.exception.BadRequestException; |
13 | import com.topdraw.exception.GlobeExceptionMsg; | 15 | import com.topdraw.exception.GlobeExceptionMsg; |
14 | import com.topdraw.utils.ValidationUtil; | 16 | import com.topdraw.utils.ValidationUtil; |
... | @@ -33,6 +35,8 @@ import java.util.Objects; | ... | @@ -33,6 +35,8 @@ import java.util.Objects; |
33 | public class MemberServiceImpl implements MemberService { | 35 | public class MemberServiceImpl implements MemberService { |
34 | 36 | ||
35 | @Autowired | 37 | @Autowired |
38 | private UserTvService userTvService; | ||
39 | @Autowired | ||
36 | private MemberMapper memberMapper; | 40 | private MemberMapper memberMapper; |
37 | @Autowired | 41 | @Autowired |
38 | private MemberRepository memberRepository; | 42 | private MemberRepository memberRepository; |
... | @@ -109,6 +113,12 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -109,6 +113,12 @@ public class MemberServiceImpl implements MemberService { |
109 | } | 113 | } |
110 | 114 | ||
111 | @Override | 115 | @Override |
116 | public MemberDTO unbindUserIpTv(Member member) { | ||
117 | Member _member = this.save(member); | ||
118 | return this.memberMapper.toDto(_member); | ||
119 | } | ||
120 | |||
121 | @Override | ||
112 | @Transactional(rollbackFor = Exception.class) | 122 | @Transactional(rollbackFor = Exception.class) |
113 | public MemberDTO create(Member resources) { | 123 | public MemberDTO create(Member resources) { |
114 | 124 | ||
... | @@ -141,10 +151,22 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -141,10 +151,22 @@ public class MemberServiceImpl implements MemberService { |
141 | 151 | ||
142 | log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); | 152 | log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); |
143 | try { | 153 | try { |
154 | |||
144 | MemberDTO memberDTO = this.checkMember(resources); | 155 | MemberDTO memberDTO = this.checkMember(resources); |
145 | resources.setId(memberDTO.getId()); | 156 | resources.setId(memberDTO.getId()); |
146 | resources.setCode(memberDTO.getCode()); | 157 | resources.setCode(memberDTO.getCode()); |
147 | resources.setCreateTime(memberDTO.getCreateTime()); | 158 | resources.setCreateTime(memberDTO.getCreateTime()); |
159 | |||
160 | String platformAccount = resources.getPlatformAccount(); | ||
161 | if (StringUtils.isNotBlank(platformAccount)) { | ||
162 | if (Objects.nonNull(resources.getUserIptvId())){ | ||
163 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
164 | resources.setUserIptvId(userTvDTO.getId()); | ||
165 | } | ||
166 | } else { | ||
167 | resources.setUserIptvId(memberDTO.getUserIptvId()); | ||
168 | } | ||
169 | |||
148 | Member _member = this.save(resources); | 170 | Member _member = this.save(resources); |
149 | return this.memberMapper.toDto(_member); | 171 | return this.memberMapper.toDto(_member); |
150 | 172 | ... | ... |
... | @@ -7,11 +7,11 @@ import com.topdraw.business.module.user.iptv.repository.UserTvRepository; | ... | @@ -7,11 +7,11 @@ import com.topdraw.business.module.user.iptv.repository.UserTvRepository; |
7 | import com.topdraw.business.module.user.iptv.service.UserTvService; | 7 | import com.topdraw.business.module.user.iptv.service.UserTvService; |
8 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 8 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
9 | import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper; | 9 | import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper; |
10 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | ||
11 | import com.topdraw.exception.EntityNotFoundException; | 10 | import com.topdraw.exception.EntityNotFoundException; |
12 | import com.topdraw.exception.GlobeExceptionMsg; | 11 | import com.topdraw.exception.GlobeExceptionMsg; |
13 | import com.topdraw.utils.ValidationUtil; | 12 | import com.topdraw.utils.ValidationUtil; |
14 | import org.apache.commons.lang3.StringUtils; | 13 | import org.apache.commons.lang3.StringUtils; |
14 | import org.springframework.beans.BeanUtils; | ||
15 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
16 | import org.springframework.dao.EmptyResultDataAccessException; | 16 | import org.springframework.dao.EmptyResultDataAccessException; |
17 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
... | @@ -96,9 +96,23 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -96,9 +96,23 @@ public class UserTvServiceImpl implements UserTvService { |
96 | @Override | 96 | @Override |
97 | @Transactional(rollbackFor = Exception.class) | 97 | @Transactional(rollbackFor = Exception.class) |
98 | public UserTvDTO update(UserTv resources) { | 98 | public UserTvDTO update(UserTv resources) { |
99 | UserTv userTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new); | 99 | String platformAccount = resources.getPlatformAccount(); |
100 | ValidationUtil.isNull(userTv.getId(),"UserTv","id",resources.getId()); | 100 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); |
101 | userTv.copy(resources); | 101 | |
102 | UserTv userTv = new UserTv(); | ||
103 | BeanUtils.copyProperties(userTvDTO, userTv); | ||
104 | |||
105 | userTv.setId(userTvDTO.getId()); | ||
106 | userTv.setPlatformAccount(userTvDTO.getPlatformAccount()); | ||
107 | userTv.setMemberId(userTvDTO.getMemberId()); | ||
108 | |||
109 | String priorityMemberCode = resources.getPriorityMemberCode(); | ||
110 | if (StringUtils.isNotBlank(priorityMemberCode)){ | ||
111 | userTv.setPriorityMemberCode(priorityMemberCode); | ||
112 | } else { | ||
113 | userTv.setPriorityMemberCode(userTvDTO.getPriorityMemberCode()); | ||
114 | } | ||
115 | |||
102 | UserTv _userTv = this.userTvRepository.save(userTv); | 116 | UserTv _userTv = this.userTvRepository.save(userTv); |
103 | return this.userTvMapper.toDto(_userTv); | 117 | return this.userTvMapper.toDto(_userTv); |
104 | } | 118 | } |
... | @@ -106,10 +120,7 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -106,10 +120,7 @@ public class UserTvServiceImpl implements UserTvService { |
106 | @Override | 120 | @Override |
107 | @Transactional(rollbackFor = Exception.class) | 121 | @Transactional(rollbackFor = Exception.class) |
108 | public void unbindPriorityMemberCode(UserTv resources) { | 122 | public void unbindPriorityMemberCode(UserTv resources) { |
109 | UserTv UserTv = this.userTvRepository.findById(resources.getId()).orElseGet(com.topdraw.business.module.user.iptv.domain.UserTv::new); | 123 | this.userTvRepository.save(resources); |
110 | ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId()); | ||
111 | UserTv.copy(resources); | ||
112 | this.userTvRepository.save(UserTv); | ||
113 | } | 124 | } |
114 | 125 | ||
115 | @Override | 126 | @Override | ... | ... |
1 | package com.topdraw.business.module.user.weixin.service.impl; | 1 | package com.topdraw.business.module.user.weixin.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.module.member.service.MemberService; | ||
4 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
3 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 5 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
4 | import com.topdraw.business.module.user.weixin.domain.UserWeixinBuilder; | 6 | import com.topdraw.business.module.user.weixin.domain.UserWeixinBuilder; |
5 | import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository; | 7 | import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository; |
... | @@ -14,6 +16,9 @@ import org.springframework.transaction.annotation.Propagation; | ... | @@ -14,6 +16,9 @@ import org.springframework.transaction.annotation.Propagation; |
14 | import org.springframework.transaction.annotation.Transactional; | 16 | import org.springframework.transaction.annotation.Transactional; |
15 | import org.springframework.util.Assert; | 17 | import org.springframework.util.Assert; |
16 | 18 | ||
19 | import javax.validation.constraints.NotNull; | ||
20 | import java.util.Objects; | ||
21 | |||
17 | /** | 22 | /** |
18 | * @author XiangHan | 23 | * @author XiangHan |
19 | * @date 2021-12-16 | 24 | * @date 2021-12-16 |
... | @@ -23,8 +28,9 @@ import org.springframework.util.Assert; | ... | @@ -23,8 +28,9 @@ import org.springframework.util.Assert; |
23 | public class UserWeixinServiceImpl implements UserWeixinService { | 28 | public class UserWeixinServiceImpl implements UserWeixinService { |
24 | 29 | ||
25 | @Autowired | 30 | @Autowired |
31 | private MemberService memberService; | ||
32 | @Autowired | ||
26 | private UserWeixinRepository userWeixinRepository; | 33 | private UserWeixinRepository userWeixinRepository; |
27 | |||
28 | @Autowired | 34 | @Autowired |
29 | private UserWeixinMapper userWeixinMapper; | 35 | private UserWeixinMapper userWeixinMapper; |
30 | 36 | ||
... | @@ -38,6 +44,11 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -38,6 +44,11 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
38 | @Override | 44 | @Override |
39 | @Transactional(rollbackFor = Exception.class) | 45 | @Transactional(rollbackFor = Exception.class) |
40 | public UserWeixin create(UserWeixin resources) { | 46 | public UserWeixin create(UserWeixin resources) { |
47 | MemberDTO memberDTO = memberService.findByCode(resources.getMemberCode()); | ||
48 | if (Objects.nonNull(memberDTO)) { | ||
49 | Long id = memberDTO.getId(); | ||
50 | resources.setMemberId(id); | ||
51 | } | ||
41 | UserWeixin build = UserWeixinBuilder.build(resources); | 52 | UserWeixin build = UserWeixinBuilder.build(resources); |
42 | this.userWeixinRepository.save(build); | 53 | this.userWeixinRepository.save(build); |
43 | return resources; | 54 | return resources; |
... | @@ -46,6 +57,13 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -46,6 +57,13 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
46 | @Override | 57 | @Override |
47 | @Transactional(rollbackFor = Exception.class) | 58 | @Transactional(rollbackFor = Exception.class) |
48 | public void update(UserWeixin resources) { | 59 | public void update(UserWeixin resources) { |
60 | |||
61 | String appid = resources.getAppid(); | ||
62 | String openid = resources.getOpenid(); | ||
63 | UserWeixinDTO userWeixinDTO = this.findFirstByAppIdAndOpenId(appid, openid); | ||
64 | resources.setId(userWeixinDTO.getId()); | ||
65 | resources.setMemberId(userWeixinDTO.getMemberId()); | ||
66 | |||
49 | UserWeixin UserWeixin = this.userWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new); | 67 | UserWeixin UserWeixin = this.userWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new); |
50 | ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId()); | 68 | ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId()); |
51 | UserWeixin.copy(resources); | 69 | UserWeixin.copy(resources); | ... | ... |
... | @@ -200,16 +200,30 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -200,16 +200,30 @@ public class UserOperationServiceImpl implements UserOperationService { |
200 | 200 | ||
201 | String platformAccount = userTvDTO.getPlatformAccount(); | 201 | String platformAccount = userTvDTO.getPlatformAccount(); |
202 | UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | 202 | UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); |
203 | if (Objects.nonNull(_userTvDTO)) { | ||
204 | 203 | ||
205 | // | 204 | _userTvDTO.setPriorityMemberCode(null); |
206 | this.updateUserTv(_userTvDTO, userTvDTO); | 205 | // |
206 | this.unbindPriorityMemberCode(_userTvDTO); | ||
207 | 207 | ||
208 | String code = memberDTO.getCode(); | 208 | String code = memberDTO.getCode(); |
209 | MemberDTO _memberDTO = this.memberService.findByCode(code); | 209 | MemberDTO _memberDTO = this.memberService.findByCode(code); |
210 | this.updateMember(_memberDTO, memberDTO); | 210 | this.unbindUserIpTv(_memberDTO); |
211 | } | 211 | |
212 | } | ||
212 | 213 | ||
214 | private void unbindUserIpTv(MemberDTO memberDTO) { | ||
215 | memberDTO.setUserIptvId(null); | ||
216 | memberDTO.setBindIptvPlatformType(null); | ||
217 | memberDTO.setBindIptvTime(null); | ||
218 | Member member = new Member(); | ||
219 | BeanUtils.copyProperties(memberDTO, member); | ||
220 | this.memberService.unbindUserIpTv(member); | ||
221 | } | ||
222 | |||
223 | private void unbindPriorityMemberCode(UserTvDTO userTvDTO) { | ||
224 | UserTv userTv = new UserTv(); | ||
225 | BeanUtils.copyProperties(userTvDTO, userTv); | ||
226 | this.userTvService.unbindPriorityMemberCode(userTv); | ||
213 | } | 227 | } |
214 | 228 | ||
215 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) | 229 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) |
... | @@ -298,14 +312,11 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -298,14 +312,11 @@ public class UserOperationServiceImpl implements UserOperationService { |
298 | 312 | ||
299 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) | 313 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) |
300 | public void asyncUserTv(UserTvDTO userTvDTO) { | 314 | public void asyncUserTv(UserTvDTO userTvDTO) { |
315 | log.info("asyncUserTv ==>> userTvDTO ==>> {}", userTvDTO); | ||
301 | String platformAccount = userTvDTO.getPlatformAccount(); | 316 | String platformAccount = userTvDTO.getPlatformAccount(); |
302 | UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | 317 | UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); |
303 | if (Objects.nonNull(_userTvDTO)) { | 318 | log.info("db result ==>> _userTvDTO ==>> {}", _userTvDTO); |
304 | Long id = _userTvDTO.getId(); | 319 | this.updateUserTv(_userTvDTO, userTvDTO); |
305 | userTvDTO.setId(id); | ||
306 | this.updateUserTv(_userTvDTO, userTvDTO); | ||
307 | } | ||
308 | |||
309 | } | 320 | } |
310 | 321 | ||
311 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) | 322 | @Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) |
... | @@ -521,6 +532,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -521,6 +532,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
521 | 532 | ||
522 | UserTv userTv = new UserTv(); | 533 | UserTv userTv = new UserTv(); |
523 | BeanUtils.copyProperties(userTvDTO, userTv); | 534 | BeanUtils.copyProperties(userTvDTO, userTv); |
535 | log.info("updateUserTv ==>> userTv ==>> {}" , userTv); | ||
524 | this.userTvService.update(userTv); | 536 | this.userTvService.update(userTv); |
525 | } | 537 | } |
526 | } | 538 | } | ... | ... |
-
Please register or sign in to post a comment