Merge branch '2.2.0-future' into 2.2.0-future-updatetask
Showing
7 changed files
with
108 additions
and
25 deletions
... | @@ -61,4 +61,7 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec | ... | @@ -61,4 +61,7 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec |
61 | " :#{#resources.gender}, NULL, now(), NULL, :#{#resources.tags}, " + | 61 | " :#{#resources.gender}, NULL, now(), NULL, :#{#resources.tags}, " + |
62 | " :#{#resources.description}, :#{#resources.createTime}, now());", nativeQuery = true) | 62 | " :#{#resources.description}, :#{#resources.createTime}, now());", nativeQuery = true) |
63 | void saveByIdManual(@Param("resources") UserAppIdManual userAppIdManual); | 63 | void saveByIdManual(@Param("resources") UserAppIdManual userAppIdManual); |
64 | |||
65 | Optional<UserApp> findByMemberId(Long memberId); | ||
66 | |||
64 | } | 67 | } | ... | ... |
... | @@ -92,4 +92,6 @@ public interface UserAppService { | ... | @@ -92,4 +92,6 @@ public interface UserAppService { |
92 | ResultInfo saveAppAndBindWeixin4Vis(VisUserWeixin resources); | 92 | ResultInfo saveAppAndBindWeixin4Vis(VisUserWeixin resources); |
93 | 93 | ||
94 | ResultInfo saveAppAndBindQq4Vis(VisUserQq resources); | 94 | ResultInfo saveAppAndBindQq4Vis(VisUserQq resources); |
95 | |||
96 | UserAppDTO findByMemberId(Long memberId); | ||
95 | } | 97 | } | ... | ... |
... | @@ -549,6 +549,12 @@ public class UserAppServiceImpl implements UserAppService { | ... | @@ -549,6 +549,12 @@ public class UserAppServiceImpl implements UserAppService { |
549 | return ResultInfo.failure(null); | 549 | return ResultInfo.failure(null); |
550 | } | 550 | } |
551 | 551 | ||
552 | @Override | ||
553 | @Transactional(readOnly = true) | ||
554 | public UserAppDTO findByMemberId(Long memberId) { | ||
555 | UserApp userApp = this.userAppRepository.findByMemberId(memberId).orElseGet(UserApp::new); | ||
556 | return this.userAppMapper.toDto(userApp); | ||
557 | } | ||
552 | 558 | ||
553 | 559 | ||
554 | @Override | 560 | @Override | ... | ... |
... | @@ -242,20 +242,14 @@ public class UserOperationController { | ... | @@ -242,20 +242,14 @@ public class UserOperationController { |
242 | @ApiOperation("app绑定大屏") | 242 | @ApiOperation("app绑定大屏") |
243 | @AnonymousAccess | 243 | @AnonymousAccess |
244 | public ResultInfo appBind(@Validated(value = {BindGroup.class}) @RequestBody BindBean resources) { | 244 | public ResultInfo appBind(@Validated(value = {BindGroup.class}) @RequestBody BindBean resources) { |
245 | log.info("UserOperationController ==> appletBind ==>> param ==> [{}]",resources); | 245 | log.info("app绑定大屏, 参数 appBind# resources ==> {}",resources); |
246 | 246 | ||
247 | Long memberId = resources.getMemberId(); | 247 | Long memberId = resources.getMemberId(); |
248 | if (Objects.isNull(memberId)) { | 248 | if (Objects.isNull(memberId)) { |
249 | return ResultInfo.failure("参数错误,memberId 不存在"); | 249 | return ResultInfo.failure("参数错误, memberId不得为空"); |
250 | } | ||
251 | |||
252 | String platformAccount = resources.getPlatformAccount(); | ||
253 | if (StringUtils.isBlank(platformAccount)) { | ||
254 | return ResultInfo.failure("参数错误,大屏账号不存在"); | ||
255 | } | 250 | } |
256 | 251 | ||
257 | boolean result = this.userOperationService.appBind(resources); | 252 | return this.userOperationService.appBind(resources); |
258 | return ResultInfo.success(result); | ||
259 | } | 253 | } |
260 | 254 | ||
261 | @PostMapping("/appUnbind") | 255 | @PostMapping("/appUnbind") | ... | ... |
... | @@ -124,7 +124,7 @@ public interface UserOperationService { | ... | @@ -124,7 +124,7 @@ public interface UserOperationService { |
124 | * @param resources | 124 | * @param resources |
125 | * @return | 125 | * @return |
126 | */ | 126 | */ |
127 | boolean appBind(BindBean resources); | 127 | ResultInfo appBind(BindBean resources); |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * | 130 | * | ... | ... |
... | @@ -204,7 +204,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -204,7 +204,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
204 | BeanUtils.copyProperties(pointsAvailableDTO, _tempPoints); | 204 | BeanUtils.copyProperties(pointsAvailableDTO, _tempPoints); |
205 | BeanUtils.copyProperties(tempPoints, _tempPoints); | 205 | BeanUtils.copyProperties(tempPoints, _tempPoints); |
206 | _tempPoints.setPoints(-(Math.abs(points))); | 206 | _tempPoints.setPoints(-(Math.abs(points))); |
207 | Long totalPoints = currentPoints + tempPoints.getPoints(); | 207 | Long totalPoints = currentPoints - points; |
208 | 208 | ||
209 | this.doInsertTrPointsDetail(memberId, memberCode, _tempPoints, currentPoints, totalPoints); | 209 | this.doInsertTrPointsDetail(memberId, memberCode, _tempPoints, currentPoints, totalPoints); |
210 | } | 210 | } | ... | ... |
... | @@ -1272,7 +1272,6 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1272,7 +1272,6 @@ public class UserOperationServiceImpl implements UserOperationService { |
1272 | // 更新大屏账户 | 1272 | // 更新大屏账户 |
1273 | this.userTvService.doUpdatePriorityMemberCode(userTv); | 1273 | this.userTvService.doUpdatePriorityMemberCode(userTv); |
1274 | 1274 | ||
1275 | |||
1276 | userTvDTO.setPriorityMemberCode(memberDTO.getCode()); | 1275 | userTvDTO.setPriorityMemberCode(memberDTO.getCode()); |
1277 | } | 1276 | } |
1278 | 1277 | ||
... | @@ -1318,8 +1317,98 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1318,8 +1317,98 @@ public class UserOperationServiceImpl implements UserOperationService { |
1318 | } | 1317 | } |
1319 | 1318 | ||
1320 | @Override | 1319 | @Override |
1321 | public boolean appBind(BindBean resources) { | 1320 | public ResultInfo appBind(BindBean resources) { |
1322 | return this.minaBind(resources); | 1321 | Long memberId = resources.getMemberId(); |
1322 | |||
1323 | String platformAccount = resources.getPlatformAccount(); | ||
1324 | |||
1325 | // 大屏账户 | ||
1326 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
1327 | log.info("查询大屏账号信息, appBind# userTvDTO ==>> {}", userTvDTO); | ||
1328 | // 账户是否存在 | ||
1329 | if (Objects.isNull(userTvDTO.getId())) { | ||
1330 | log.error("大屏账号信息不存在, appBind# platformAccount ==> {}",platformAccount); | ||
1331 | return ResultInfo.failure("大屏账号信息不存在, 请检查数据"); | ||
1332 | } | ||
1333 | |||
1334 | // app账户 | ||
1335 | if (Objects.nonNull(memberId)) { | ||
1336 | UserAppDTO userAppDTO = this.userAppService.findByMemberId(memberId); | ||
1337 | log.info("检查app账号是否存在, appBind# userAppDTO ==>> {}", userAppDTO); | ||
1338 | // 账户是否存在 | ||
1339 | if (Objects.isNull(userAppDTO.getId())) { | ||
1340 | log.error("通过会员id无法找到对应的app账号, appBind# memberId ==> {}", memberId); | ||
1341 | return ResultInfo.failure("app账号不存在,请检查数据"); | ||
1342 | } | ||
1343 | } | ||
1344 | |||
1345 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
1346 | log.info("检查会员是否存在, appBind# memberDTO ==>> {}", memberDTO); | ||
1347 | if (Objects.nonNull(memberDTO.getId())) { | ||
1348 | Long userIptvId = memberDTO.getUserIptvId(); | ||
1349 | if (Objects.nonNull(userIptvId)) { | ||
1350 | log.error("该会员已绑定,appBind# 会员id ==> {} | 绑定的大屏账号id ==>> ", memberDTO.getId(), userIptvId); | ||
1351 | return ResultInfo.failure(GlobeExceptionMsg.ALREADY_BIND); | ||
1352 | } | ||
1353 | } else { | ||
1354 | log.error("会员信息不存在,请检查数据, appBind# memberId ==>> {}", memberId); | ||
1355 | return ResultInfo.failure("会员信息不存在,请检查数据"); | ||
1356 | } | ||
1357 | |||
1358 | // 主账户 | ||
1359 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); | ||
1360 | |||
1361 | if (StringUtils.isBlank(priorityMemberCode)) { | ||
1362 | priorityMemberCode = memberDTO.getCode(); | ||
1363 | log.info("大屏账号为绑定主账号,开始设置主会员 priorityMemberCode ==>> {}", priorityMemberCode); | ||
1364 | UserTv userTv = new UserTv(); | ||
1365 | userTv.setId(userTvDTO.getId()); | ||
1366 | userTv.setPriorityMemberCode(priorityMemberCode); | ||
1367 | // 更新大屏账户 | ||
1368 | this.userTvService.doUpdatePriorityMemberCode(userTv); | ||
1369 | |||
1370 | userTvDTO.setPriorityMemberCode(memberDTO.getCode()); | ||
1371 | } | ||
1372 | |||
1373 | Member member = new Member(); | ||
1374 | member.setId(memberDTO.getId()); | ||
1375 | member.setCode(memberDTO.getCode()); | ||
1376 | String platform = userTvDTO.getPlatform(); | ||
1377 | // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 | ||
1378 | Integer bindIptvPlatformType = 0; | ||
1379 | // 联通 | ||
1380 | if (UserConstant.platform_lt.contains(platform)) { | ||
1381 | bindIptvPlatformType = PLATFORM_LIST[3]; | ||
1382 | } | ||
1383 | // 移动 | ||
1384 | if (UserConstant.platform_yd.contains(platform)) { | ||
1385 | bindIptvPlatformType = PLATFORM_LIST[2]; | ||
1386 | } | ||
1387 | // 电信 | ||
1388 | if (UserConstant.platform_dx.contains(platform)) { | ||
1389 | bindIptvPlatformType = PLATFORM_LIST[1]; | ||
1390 | } | ||
1391 | member.setUserIptvId(userTvDTO.getId()); | ||
1392 | member.setBindIptvTime(TimestampUtil.now()); | ||
1393 | member.setBindIptvPlatformType(bindIptvPlatformType); | ||
1394 | log.info("修改小屏会员对应的绑定关系,member ==>> {}", member); | ||
1395 | // 修改会员信息 | ||
1396 | this.memberService.doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(member); | ||
1397 | |||
1398 | memberDTO.setPlatformAccount(platformAccount); | ||
1399 | log.info("发送绑定消息至大屏,memberDTO ==>> {} || userTvDTO ==>> {}", memberDTO, userTvDTO); | ||
1400 | // 同步至iptv | ||
1401 | ((UserOperationServiceImpl)AopContext.currentProxy()) | ||
1402 | .asyncMinaBind(new MemberAndUserTvDTO(memberDTO, userTvDTO)); | ||
1403 | |||
1404 | UserTvSimpleDTO userTvSimpleDTO = this.userTvService.findSimpleByPlatformAccount(platformAccount); | ||
1405 | if (Objects.nonNull(userTvSimpleDTO.getPlatformAccount()) && StringUtils.isBlank(userTvSimpleDTO.getPriorityMemberCode())) { | ||
1406 | userTvSimpleDTO.setPriorityMemberCode(priorityMemberCode); | ||
1407 | JSONObject hashMap = JSONObject.parseObject(JSON.toJSONString(userTvSimpleDTO), JSONObject.class); | ||
1408 | this.redisUtils.set(RedisKeyConstants.cacheVisUserByPlatformAccount + "::" + platformAccount, hashMap); | ||
1409 | } | ||
1410 | |||
1411 | return ResultInfo.success(true); | ||
1323 | } | 1412 | } |
1324 | 1413 | ||
1325 | /** | 1414 | /** |
... | @@ -1397,17 +1486,6 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1397,17 +1486,6 @@ public class UserOperationServiceImpl implements UserOperationService { |
1397 | return userTvDTO; | 1486 | return userTvDTO; |
1398 | } | 1487 | } |
1399 | 1488 | ||
1400 | |||
1401 | private void updateUserTvSimplePriorityMemberCodeRedis(String platformAccount, String priorityMemberCode){ | ||
1402 | // 修改缓存中MemberSimple的大屏主账号信息,因为执行任务之前会去检查主会员d | ||
1403 | UserTvSimpleDTO userTvSimpleDTO = this.userTvService.findSimpleByPlatformAccount(platformAccount); | ||
1404 | if (Objects.nonNull(userTvSimpleDTO.getPlatformAccount()) && StringUtils.isBlank(userTvSimpleDTO.getPriorityMemberCode())) { | ||
1405 | userTvSimpleDTO.setPriorityMemberCode(priorityMemberCode); | ||
1406 | JSONObject hashMap = JSONObject.parseObject(JSON.toJSONString(userTvSimpleDTO), JSONObject.class); | ||
1407 | this.redisUtils.set(RedisKeyConstants.cacheVisUserByPlatformAccount + "::" + platformAccount, hashMap); | ||
1408 | } | ||
1409 | } | ||
1410 | |||
1411 | /** | 1489 | /** |
1412 | * | 1490 | * |
1413 | * @param unionId 身份唯一标识 | 1491 | * @param unionId 身份唯一标识 | ... | ... |
-
Please register or sign in to post a comment