1.优化
Showing
3 changed files
with
71 additions
and
4 deletions
| ... | @@ -360,6 +360,16 @@ public class UserOperationController { | ... | @@ -360,6 +360,16 @@ public class UserOperationController { |
| 360 | 360 | ||
| 361 | /******************************************************* IPTV ************************************/ | 361 | /******************************************************* IPTV ************************************/ |
| 362 | 362 | ||
| 363 | @PostMapping(value = "/updateUserTv") | ||
| 364 | @ApiOperation("修改大屏账号") | ||
| 365 | @AnonymousAccess | ||
| 366 | public ResultInfo updateUserTv(@Validated(value = {UpdateGroup.class}) @RequestBody UserTv resources) { | ||
| 367 | log.info("UserOperationController ==> updateUserTv ==>> param ==> [{}]",resources); | ||
| 368 | |||
| 369 | UserTvDTO result = this.userOperationService.updateUserTv(resources); | ||
| 370 | return ResultInfo.success(result); | ||
| 371 | } | ||
| 372 | |||
| 363 | @PostMapping(value = "/createTvUserAndMember") | 373 | @PostMapping(value = "/createTvUserAndMember") |
| 364 | @ApiOperation("保存大屏账户同时创建会员信息") | 374 | @ApiOperation("保存大屏账户同时创建会员信息") |
| 365 | @AnonymousAccess | 375 | @AnonymousAccess | ... | ... |
| ... | @@ -159,4 +159,11 @@ public interface UserOperationService { | ... | @@ -159,4 +159,11 @@ public interface UserOperationService { |
| 159 | * @param resources | 159 | * @param resources |
| 160 | */ | 160 | */ |
| 161 | UserWeixinDTO updateWeixin(UserWeixin resources); | 161 | UserWeixinDTO updateWeixin(UserWeixin resources); |
| 162 | |||
| 163 | /** | ||
| 164 | * | ||
| 165 | * @param resources | ||
| 166 | * @return | ||
| 167 | */ | ||
| 168 | UserTvDTO updateUserTv(UserTv resources); | ||
| 162 | } | 169 | } | ... | ... |
| ... | @@ -36,6 +36,7 @@ import com.topdraw.config.RedisKeyUtil; | ... | @@ -36,6 +36,7 @@ import com.topdraw.config.RedisKeyUtil; |
| 36 | import com.topdraw.exception.BadRequestException; | 36 | import com.topdraw.exception.BadRequestException; |
| 37 | import com.topdraw.exception.EntityNotFoundException; | 37 | import com.topdraw.exception.EntityNotFoundException; |
| 38 | import com.topdraw.exception.GlobeExceptionMsg; | 38 | import com.topdraw.exception.GlobeExceptionMsg; |
| 39 | import com.topdraw.util.Base64Util; | ||
| 39 | import com.topdraw.util.TimestampUtil; | 40 | import com.topdraw.util.TimestampUtil; |
| 40 | import com.topdraw.utils.QueryHelp; | 41 | import com.topdraw.utils.QueryHelp; |
| 41 | import com.topdraw.utils.RedisUtils; | 42 | import com.topdraw.utils.RedisUtils; |
| ... | @@ -51,6 +52,7 @@ import org.springframework.stereotype.Service; | ... | @@ -51,6 +52,7 @@ import org.springframework.stereotype.Service; |
| 51 | import org.springframework.transaction.annotation.Propagation; | 52 | import org.springframework.transaction.annotation.Propagation; |
| 52 | import org.springframework.transaction.annotation.Transactional; | 53 | import org.springframework.transaction.annotation.Transactional; |
| 53 | import org.springframework.util.Assert; | 54 | import org.springframework.util.Assert; |
| 55 | import org.springframework.util.Base64Utils; | ||
| 54 | import org.springframework.util.CollectionUtils; | 56 | import org.springframework.util.CollectionUtils; |
| 55 | 57 | ||
| 56 | import java.util.*; | 58 | import java.util.*; |
| ... | @@ -120,17 +122,25 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -120,17 +122,25 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 120 | @Override | 122 | @Override |
| 121 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 123 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
| 122 | public UserTvDTO createTvUserAndMember(UserTv resources) { | 124 | public UserTvDTO createTvUserAndMember(UserTv resources) { |
| 125 | |||
| 126 | boolean flag = false; | ||
| 127 | |||
| 123 | // 大屏账户 | 128 | // 大屏账户 |
| 124 | String platformAccount = resources.getPlatformAccount(); | 129 | String platformAccount = resources.getPlatformAccount(); |
| 125 | 130 | ||
| 126 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | 131 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); |
| 127 | 132 | ||
| 133 | // 无账号 | ||
| 128 | if (Objects.isNull(userTvDTO)) { | 134 | if (Objects.isNull(userTvDTO)) { |
| 129 | 135 | ||
| 136 | String platformAccountEncode = platformAccount; | ||
| 137 | if (flag) { | ||
| 138 | platformAccountEncode = Base64Utils.encodeToString(platformAccount.getBytes()); | ||
| 139 | } | ||
| 130 | // x_member | 140 | // x_member |
| 131 | Member member = | 141 | Member member = |
| 132 | MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_VIS, | 142 | MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_VIS, |
| 133 | null, platformAccount, 0); | 143 | null, platformAccountEncode, 0); |
| 134 | MemberDTO memberDTO = this.createMember(member); | 144 | MemberDTO memberDTO = this.createMember(member); |
| 135 | 145 | ||
| 136 | if (Objects.nonNull(memberDTO)) { | 146 | if (Objects.nonNull(memberDTO)) { |
| ... | @@ -147,11 +157,38 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -147,11 +157,38 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 147 | 157 | ||
| 148 | throw new EntityNotFoundException(MemberDTO.class, "code", GlobeExceptionMsg.MEMBER_ID_IS_NULL); | 158 | throw new EntityNotFoundException(MemberDTO.class, "code", GlobeExceptionMsg.MEMBER_ID_IS_NULL); |
| 149 | 159 | ||
| 160 | // 有账号 | ||
| 161 | } else { | ||
| 162 | |||
| 163 | Long memberId = userTvDTO.getMemberId(); | ||
| 164 | // 有会员 | ||
| 165 | if (Objects.nonNull(memberId)) { | ||
| 166 | return userTvDTO; | ||
| 167 | } | ||
| 168 | |||
| 169 | // 无会员 | ||
| 170 | Member member = | ||
| 171 | MemberBuilder.build(LocalConstants.MEMBER_PLATFORM_TYPE_VIS, | ||
| 172 | null, platformAccount, 0); | ||
| 173 | MemberDTO memberDTO = this.createMember(member); | ||
| 174 | |||
| 175 | if (Objects.nonNull(memberDTO)) { | ||
| 176 | |||
| 177 | userTvDTO.setMemberId(memberDTO.getId()); | ||
| 178 | userTvDTO.setMemberCode(memberDTO.getCode()); | ||
| 179 | UserTv userTv = new UserTv(); | ||
| 180 | BeanUtils.copyProperties(userTvDTO, userTv); | ||
| 181 | |||
| 182 | UserTvDTO userTvDTO1 = this.updateUserTvUnsyncIptv(userTv); | ||
| 183 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(memberDTO, userTvDTO1)); | ||
| 184 | |||
| 185 | return userTvDTO1; | ||
| 186 | } | ||
| 187 | |||
| 150 | } | 188 | } |
| 151 | 189 | ||
| 152 | throw new BadRequestException(GlobeExceptionMsg.ENTITY_ALREADY_EXISTS); | 190 | throw new BadRequestException(GlobeExceptionMsg.ENTITY_ALREADY_EXISTS); |
| 153 | 191 | ||
| 154 | |||
| 155 | } | 192 | } |
| 156 | 193 | ||
| 157 | /** | 194 | /** |
| ... | @@ -998,7 +1035,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -998,7 +1035,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 998 | 1035 | ||
| 999 | UserTv userTv = new UserTv(); | 1036 | UserTv userTv = new UserTv(); |
| 1000 | BeanUtils.copyProperties(userTvDTO, userTv); | 1037 | BeanUtils.copyProperties(userTvDTO, userTv); |
| 1001 | UserTvDTO _userTvDTO = this.updateUserTv(userTv); | 1038 | UserTvDTO _userTvDTO = this.updateUserTvUnsyncIptv(userTv); |
| 1002 | 1039 | ||
| 1003 | return _userTvDTO; | 1040 | return _userTvDTO; |
| 1004 | } | 1041 | } |
| ... | @@ -1008,7 +1045,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1008,7 +1045,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1008 | * @param userTv | 1045 | * @param userTv |
| 1009 | * @return | 1046 | * @return |
| 1010 | */ | 1047 | */ |
| 1011 | private UserTvDTO updateUserTv(UserTv userTv){ | 1048 | private UserTvDTO updateUserTvUnsyncIptv(UserTv userTv){ |
| 1012 | return this.userTvService.update(userTv); | 1049 | return this.userTvService.update(userTv); |
| 1013 | } | 1050 | } |
| 1014 | 1051 | ||
| ... | @@ -1303,4 +1340,17 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1303,4 +1340,17 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1303 | 1340 | ||
| 1304 | return userWeixinDTO; | 1341 | return userWeixinDTO; |
| 1305 | } | 1342 | } |
| 1343 | |||
| 1344 | @Override | ||
| 1345 | public UserTvDTO updateUserTv(UserTv resources) { | ||
| 1346 | UserTvDTO userTvDTO = this.userTvService.update(resources); | ||
| 1347 | Long memberId = userTvDTO.getMemberId(); | ||
| 1348 | if (Objects.nonNull(memberId)) { | ||
| 1349 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
| 1350 | resources.setMemberCode(memberDTO.getCode()); | ||
| 1351 | } | ||
| 1352 | // 同步至iptv | ||
| 1353 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTv(userTvDTO); | ||
| 1354 | return userTvDTO; | ||
| 1355 | } | ||
| 1306 | } | 1356 | } | ... | ... |
-
Please register or sign in to post a comment