1.退出大屏账户后,设置默认账户
Showing
1 changed file
with
38 additions
and
0 deletions
... | @@ -33,6 +33,7 @@ import com.topdraw.weixin.util.WeixinUtil; | ... | @@ -33,6 +33,7 @@ import com.topdraw.weixin.util.WeixinUtil; |
33 | import io.swagger.annotations.Api; | 33 | import io.swagger.annotations.Api; |
34 | import io.swagger.annotations.ApiOperation; | 34 | import io.swagger.annotations.ApiOperation; |
35 | import lombok.extern.slf4j.Slf4j; | 35 | import lombok.extern.slf4j.Slf4j; |
36 | import org.apache.commons.collections4.CollectionUtils; | ||
36 | import org.assertj.core.util.Arrays; | 37 | import org.assertj.core.util.Arrays; |
37 | import org.springframework.beans.BeanUtils; | 38 | import org.springframework.beans.BeanUtils; |
38 | import org.springframework.beans.factory.annotation.Autowired; | 39 | import org.springframework.beans.factory.annotation.Autowired; |
... | @@ -44,6 +45,7 @@ import java.io.IOException; | ... | @@ -44,6 +45,7 @@ import java.io.IOException; |
44 | import java.net.URLDecoder; | 45 | import java.net.URLDecoder; |
45 | import java.time.LocalDateTime; | 46 | import java.time.LocalDateTime; |
46 | import java.util.*; | 47 | import java.util.*; |
48 | import java.util.stream.Collectors; | ||
47 | 49 | ||
48 | @Api("账户处理") | 50 | @Api("账户处理") |
49 | @RestController | 51 | @RestController |
... | @@ -166,8 +168,44 @@ public class UserOperationController { | ... | @@ -166,8 +168,44 @@ public class UserOperationController { |
166 | MemberDTO memberDTO = this.memberService.getByCode(memberCode1); | 168 | MemberDTO memberDTO = this.memberService.getByCode(memberCode1); |
167 | String memberCode = memberDTO.getCode(); | 169 | String memberCode = memberDTO.getCode(); |
168 | if (StringUtils.isNotBlank(memberCode)) { | 170 | if (StringUtils.isNotBlank(memberCode)) { |
171 | |||
172 | String platformAccount = userTv.getPlatformAccount(); | ||
173 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
174 | if (Objects.isNull(userTvDTO)) | ||
175 | throw new EntityNotFoundException(UserTvDTO.class,"platformAccount","大屏账户不存在"); | ||
176 | |||
177 | // 解绑 | ||
169 | userTv.setMemberCode(memberCode); | 178 | userTv.setMemberCode(memberCode); |
170 | this.userTvOperationService.unbind(userTv); | 179 | this.userTvOperationService.unbind(userTv); |
180 | |||
181 | // 设置默认账号,以时间最早的为准 | ||
182 | List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(userTvDTO.getId()); | ||
183 | if (CollectionUtils.isNotEmpty(memberDTOList)) { | ||
184 | List<MemberDTO> collect = memberDTOList.stream().filter(memberDTO1 -> !memberDTO1.getCode().equalsIgnoreCase(memberCode1)).collect(Collectors.toList()); | ||
185 | |||
186 | if (CollectionUtils.isNotEmpty(collect) ){ | ||
187 | |||
188 | if(collect.size() > 1) { | ||
189 | collect.sort(new Comparator<MemberDTO>() { | ||
190 | @Override | ||
191 | public int compare(MemberDTO memberDTO, MemberDTO t1) { | ||
192 | return t1.getBindIptvTime().compareTo(memberDTO.getBindIptvTime()); | ||
193 | } | ||
194 | }); | ||
195 | } | ||
196 | |||
197 | // 有其他会员的话,绑定最早的一个会员 | ||
198 | MemberDTO memberDTO1 = collect.get(0); | ||
199 | userTvDTO.setPriorityMemberCode(memberDTO1.getCode()); | ||
200 | BeanUtils.copyProperties(userTvDTO,userTv); | ||
201 | this.userTvService.update(userTv); | ||
202 | } | ||
203 | |||
204 | } | ||
205 | |||
206 | } else { | ||
207 | |||
208 | throw new EntityNotFoundException(MemberDTO.class,"code","会员信息不存在!!"); | ||
171 | } | 209 | } |
172 | 210 | ||
173 | } | 211 | } | ... | ... |
-
Please register or sign in to post a comment