V1.0.2.REALESE
Showing
9 changed files
with
133 additions
and
5 deletions
| ... | @@ -4,6 +4,7 @@ import com.topdraw.business.module.member.domain.Member; | ... | @@ -4,6 +4,7 @@ import com.topdraw.business.module.member.domain.Member; |
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | 4 | import org.springframework.data.jpa.repository.JpaRepository; |
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| 6 | 6 | ||
| 7 | import java.util.List; | ||
| 7 | import java.util.Optional; | 8 | import java.util.Optional; |
| 8 | 9 | ||
| 9 | /** | 10 | /** |
| ... | @@ -13,4 +14,6 @@ import java.util.Optional; | ... | @@ -13,4 +14,6 @@ import java.util.Optional; |
| 13 | public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecificationExecutor<Member> { | 14 | public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecificationExecutor<Member> { |
| 14 | 15 | ||
| 15 | Optional<Member> findFirstByCode(String code); | 16 | Optional<Member> findFirstByCode(String code); |
| 17 | |||
| 18 | List<Member> findByUserIptvId(Long id); | ||
| 16 | } | 19 | } | ... | ... |
| ... | @@ -68,4 +68,6 @@ public interface MemberService { | ... | @@ -68,4 +68,6 @@ public interface MemberService { |
| 68 | * @param member | 68 | * @param member |
| 69 | */ | 69 | */ |
| 70 | void doUpdateMemberPoints(Member member); | 70 | void doUpdateMemberPoints(Member member); |
| 71 | |||
| 72 | List<MemberDTO> findByUserIptvId(Long id); | ||
| 71 | } | 73 | } | ... | ... |
| ... | @@ -179,5 +179,11 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -179,5 +179,11 @@ public class MemberServiceImpl implements MemberService { |
| 179 | } | 179 | } |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | @Override | ||
| 183 | public List<MemberDTO> findByUserIptvId(Long id) { | ||
| 184 | List<Member> memberList = this.memberRepository.findByUserIptvId(id); | ||
| 185 | return memberMapper.toDto(memberList); | ||
| 186 | } | ||
| 187 | |||
| 182 | 188 | ||
| 183 | } | 189 | } | ... | ... |
| ... | @@ -51,5 +51,5 @@ public interface UserCollectionService { | ... | @@ -51,5 +51,5 @@ public interface UserCollectionService { |
| 51 | 51 | ||
| 52 | Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name); | 52 | Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name); |
| 53 | 53 | ||
| 54 | void save(UserCollection userCollection); | 54 | UserCollection save(UserCollection userCollection); |
| 55 | } | 55 | } | ... | ... |
| ... | @@ -111,8 +111,9 @@ public class UserCollectionServiceImpl implements UserCollectionService { | ... | @@ -111,8 +111,9 @@ public class UserCollectionServiceImpl implements UserCollectionService { |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | @Override | 113 | @Override |
| 114 | public void save(UserCollection userCollection) { | 114 | public UserCollection save(UserCollection userCollection) { |
| 115 | 115 | this.userCollectionRepository.save(userCollection); | |
| 116 | return userCollection; | ||
| 116 | } | 117 | } |
| 117 | 118 | ||
| 118 | 119 | ... | ... |
| ... | @@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject; | ... | @@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject; |
| 8 | import com.topdraw.annotation.AnonymousAccess; | 8 | import com.topdraw.annotation.AnonymousAccess; |
| 9 | import com.topdraw.annotation.Log; | 9 | import com.topdraw.annotation.Log; |
| 10 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 10 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 11 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
| 11 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 12 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 12 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 13 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
| 13 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 14 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
| ... | @@ -38,6 +39,7 @@ import org.springframework.web.bind.annotation.*; | ... | @@ -38,6 +39,7 @@ import org.springframework.web.bind.annotation.*; |
| 38 | 39 | ||
| 39 | import java.io.IOException; | 40 | import java.io.IOException; |
| 40 | import java.util.HashMap; | 41 | import java.util.HashMap; |
| 42 | import java.util.List; | ||
| 41 | import java.util.Map; | 43 | import java.util.Map; |
| 42 | import java.util.Objects; | 44 | import java.util.Objects; |
| 43 | 45 | ||
| ... | @@ -54,6 +56,15 @@ public class UserOperationController { | ... | @@ -54,6 +56,15 @@ public class UserOperationController { |
| 54 | @Autowired | 56 | @Autowired |
| 55 | private RedisUtils redisUtils; | 57 | private RedisUtils redisUtils; |
| 56 | 58 | ||
| 59 | @Log("获取大屏绑定的小屏会员列表") | ||
| 60 | @GetMapping(value = "/findBindByPlatformAccount/{platformAccount}") | ||
| 61 | @AnonymousAccess | ||
| 62 | public ResultInfo findBindByPlatformAccount(@PathVariable("platformAccount") String platformAccount) { | ||
| 63 | log.info("resources :[{}]",platformAccount); | ||
| 64 | List<MemberDTO> result = this.userTvOperationService.findBindByPlatformAccount(platformAccount); | ||
| 65 | return ResultInfo.success(result); | ||
| 66 | } | ||
| 67 | |||
| 57 | @Log("带参二维码") | 68 | @Log("带参二维码") |
| 58 | @PostMapping(value = "/sendQrCodeMessage") | 69 | @PostMapping(value = "/sendQrCodeMessage") |
| 59 | @ApiOperation("带参二维码") | 70 | @ApiOperation("带参二维码") |
| ... | @@ -90,13 +101,14 @@ public class UserOperationController { | ... | @@ -90,13 +101,14 @@ public class UserOperationController { |
| 90 | @AnonymousAccess | 101 | @AnonymousAccess |
| 91 | public ResultInfo addCollection(@RequestBody String content) { | 102 | public ResultInfo addCollection(@RequestBody String content) { |
| 92 | log.info("resources :[{}]",content); | 103 | log.info("resources :[{}]",content); |
| 93 | boolean result = true; | 104 | boolean result = this.userTvOperationService.addCollection(content); |
| 94 | return ResultInfo.success(result); | 105 | return ResultInfo.success(result); |
| 95 | } | 106 | } |
| 96 | 107 | ||
| 97 | @Log("新增大屏账户同时创建会员信息") | 108 | @Log("新增大屏账户同时创建会员信息") |
| 98 | @PostMapping(value = "/createUserAndCreateMember") | 109 | @PostMapping(value = "/createUserAndCreateMember") |
| 99 | @ApiOperation("新增大屏账户同时创建会员信息") | 110 | @ApiOperation("新增大屏账户同时创建会员信息") |
| 111 | @AnonymousAccess | ||
| 100 | public ResultInfo createUserAndCreateMember(@Validated @RequestBody TempIptvUser resources) { | 112 | public ResultInfo createUserAndCreateMember(@Validated @RequestBody TempIptvUser resources) { |
| 101 | UserTv userTv = new UserTv(); | 113 | UserTv userTv = new UserTv(); |
| 102 | BeanUtils.copyProperties(resources,userTv); | 114 | BeanUtils.copyProperties(resources,userTv); |
| ... | @@ -127,6 +139,7 @@ public class UserOperationController { | ... | @@ -127,6 +139,7 @@ public class UserOperationController { |
| 127 | @Log("微信小程序登录") | 139 | @Log("微信小程序登录") |
| 128 | @PostMapping("/appletLogin") | 140 | @PostMapping("/appletLogin") |
| 129 | @ApiOperation("微信小程序登录") | 141 | @ApiOperation("微信小程序登录") |
| 142 | @AnonymousAccess | ||
| 130 | public ResultInfo appletLogin(@Validated @RequestBody WeiXinUserBean resources) { | 143 | public ResultInfo appletLogin(@Validated @RequestBody WeiXinUserBean resources) { |
| 131 | UserWeixinDTO result = this.userTvOperationService.appletLogin(resources); | 144 | UserWeixinDTO result = this.userTvOperationService.appletLogin(resources); |
| 132 | return ResultInfo.success(result); | 145 | return ResultInfo.success(result); |
| ... | @@ -240,9 +253,12 @@ public class UserOperationController { | ... | @@ -240,9 +253,12 @@ public class UserOperationController { |
| 240 | * @author Hongyan Wang | 253 | * @author Hongyan Wang |
| 241 | * @date 2021/8/24 4:54 下午 | 254 | * @date 2021/8/24 4:54 下午 |
| 242 | */ | 255 | */ |
| 256 | @Log("保存大屏侧信息") | ||
| 243 | @PostMapping(value = "/saveUserInfo") | 257 | @PostMapping(value = "/saveUserInfo") |
| 244 | @ApiOperation("保存大屏侧信息") | 258 | @ApiOperation("保存大屏侧信息") |
| 259 | @AnonymousAccess | ||
| 245 | public ResultInfo saveUserInfo(@RequestBody String data) { | 260 | public ResultInfo saveUserInfo(@RequestBody String data) { |
| 261 | log.info("resources :[{}]",data); | ||
| 246 | String s = this.userTvOperationService.saveUserInfo(data); | 262 | String s = this.userTvOperationService.saveUserInfo(data); |
| 247 | return ResultInfo.success(s); | 263 | return ResultInfo.success(s); |
| 248 | } | 264 | } | ... | ... |
| 1 | package com.topdraw.business.process.service; | 1 | package com.topdraw.business.process.service; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 3 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 4 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
| 4 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 5 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 5 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 6 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
| 6 | import com.topdraw.business.process.domian.weixin.BuyVipBean; | 7 | import com.topdraw.business.process.domian.weixin.BuyVipBean; |
| 7 | import com.topdraw.business.process.domian.weixin.SubscribeBean; | 8 | import com.topdraw.business.process.domian.weixin.SubscribeBean; |
| 8 | import com.topdraw.business.process.domian.weixin.WeiXinUserBean; | 9 | import com.topdraw.business.process.domian.weixin.WeiXinUserBean; |
| 9 | 10 | ||
| 11 | import java.util.List; | ||
| 12 | |||
| 10 | public interface UserOperationService { | 13 | public interface UserOperationService { |
| 11 | 14 | ||
| 12 | boolean createMemberByUserTv(UserTv resources); | 15 | boolean createMemberByUserTv(UserTv resources); |
| ... | @@ -30,4 +33,8 @@ public interface UserOperationService { | ... | @@ -30,4 +33,8 @@ public interface UserOperationService { |
| 30 | boolean deleteAllCollection(String content); | 33 | boolean deleteAllCollection(String content); |
| 31 | 34 | ||
| 32 | boolean deleteCollection(String content); | 35 | boolean deleteCollection(String content); |
| 36 | |||
| 37 | boolean addCollection(String content); | ||
| 38 | |||
| 39 | List<MemberDTO> findBindByPlatformAccount(String platformAccount); | ||
| 33 | } | 40 | } | ... | ... |
| 1 | package com.topdraw.business.process.service.impl; | 1 | package com.topdraw.business.process.service.impl; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.date.DateUtil; | ||
| 4 | import cn.hutool.core.util.ObjectUtil; | 5 | import cn.hutool.core.util.ObjectUtil; |
| 5 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
| 6 | import cn.hutool.http.HttpUtil; | 7 | import cn.hutool.http.HttpUtil; |
| ... | @@ -34,6 +35,7 @@ import com.topdraw.business.process.domian.weixin.SubscribeBean; | ... | @@ -34,6 +35,7 @@ import com.topdraw.business.process.domian.weixin.SubscribeBean; |
| 34 | import com.topdraw.business.process.domian.weixin.UserCollectionMq; | 35 | import com.topdraw.business.process.domian.weixin.UserCollectionMq; |
| 35 | import com.topdraw.business.process.domian.weixin.WeiXinUserBean; | 36 | import com.topdraw.business.process.domian.weixin.WeiXinUserBean; |
| 36 | import com.topdraw.business.process.service.UserOperationService; | 37 | import com.topdraw.business.process.service.UserOperationService; |
| 38 | import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper; | ||
| 37 | import com.topdraw.config.LocalConstants; | 39 | import com.topdraw.config.LocalConstants; |
| 38 | import com.topdraw.config.RedisKeyUtil; | 40 | import com.topdraw.config.RedisKeyUtil; |
| 39 | import com.topdraw.exception.BadRequestException; | 41 | import com.topdraw.exception.BadRequestException; |
| ... | @@ -97,6 +99,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -97,6 +99,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 97 | private UserCollectionDetailService userCollectionDetailService; | 99 | private UserCollectionDetailService userCollectionDetailService; |
| 98 | @Autowired | 100 | @Autowired |
| 99 | private UserCollectionDetailRepository userCollectionDetailRepository; | 101 | private UserCollectionDetailRepository userCollectionDetailRepository; |
| 102 | @Autowired | ||
| 103 | private CollectionMq2DetailMapper collectionMq2DetailMapper; | ||
| 100 | 104 | ||
| 101 | 105 | ||
| 102 | 106 | ||
| ... | @@ -853,7 +857,14 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -853,7 +857,14 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 853 | BeanUtils.copyProperties(resources,userTv); | 857 | BeanUtils.copyProperties(resources,userTv); |
| 854 | userTv.setPlatformAccount(platformAccount); | 858 | userTv.setPlatformAccount(platformAccount); |
| 855 | userTv.setMemberCode(member.getCode()); | 859 | userTv.setMemberCode(member.getCode()); |
| 856 | 860 | userTv.setNickname(platformAccount); | |
| 861 | userTv.setUsername(platformAccount); | ||
| 862 | userTv.setLoginDays(1); | ||
| 863 | userTv.setStatus(1); | ||
| 864 | userTv.setActiveTime(TimestampUtil.now()); | ||
| 865 | userTv.setContinueDays(1); | ||
| 866 | userTv.setCreateBy("system"); | ||
| 867 | userTv.setUpdateBy("system"); | ||
| 857 | this.userTvService.create(userTv); | 868 | this.userTvService.create(userTv); |
| 858 | 869 | ||
| 859 | } | 870 | } |
| ... | @@ -1077,6 +1088,70 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1077,6 +1088,70 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1077 | return true; | 1088 | return true; |
| 1078 | } | 1089 | } |
| 1079 | 1090 | ||
| 1091 | @Override | ||
| 1092 | public boolean addCollection(String content) { | ||
| 1093 | try { | ||
| 1094 | log.info("receive UserCollection add message, content {}", content); | ||
| 1095 | JSONObject jsonObject = JSONObject.parseObject(content); | ||
| 1096 | String platformAccount = jsonObject.getString("platformAccount"); | ||
| 1097 | String data = jsonObject.getString("data"); | ||
| 1098 | if (StringUtils.isBlank(data) || !data.startsWith("[")) { | ||
| 1099 | return false; | ||
| 1100 | } | ||
| 1101 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
| 1102 | |||
| 1103 | Long tvUserId = userTvDTO.getId(); | ||
| 1104 | List<UserCollectionMq> userCollectionMqList = JSONObject.parseArray(data, UserCollectionMq.class); | ||
| 1105 | if (userCollectionMqList == null || userCollectionMqList.isEmpty()) { | ||
| 1106 | return false; | ||
| 1107 | } | ||
| 1108 | Map<Long, List<UserCollectionMq>> collect = userCollectionMqList.stream().collect(Collectors.groupingBy(UserCollectionMq::getUserCollectionId)); | ||
| 1109 | for (Map.Entry<Long, List<UserCollectionMq>> entry : collect.entrySet()) { | ||
| 1110 | List<UserCollectionMq> value = entry.getValue(); | ||
| 1111 | UserCollectionMq userCollectionMq = value.get(0); | ||
| 1112 | if (StringUtils.isBlank(userCollectionMq.getName())) { | ||
| 1113 | userCollectionMq.setName("DEFAULT"); | ||
| 1114 | } | ||
| 1115 | UserCollection userCollection = this.userCollectionService | ||
| 1116 | .findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName()).orElseGet(UserCollection::new); | ||
| 1117 | userCollection.setAppId(userCollectionMq.getAppId()) | ||
| 1118 | .setUserId(tvUserId) | ||
| 1119 | .setName(userCollectionMq.getName()) | ||
| 1120 | .setType(userCollectionMq.getType()) | ||
| 1121 | .setCount(userCollection.getCount() == null ? value.size() : userCollection.getCount() + value.size()); | ||
| 1122 | UserCollection userCollectionSave = this.userCollectionService.save(userCollection); | ||
| 1123 | for (UserCollectionMq collectionMq : value) { | ||
| 1124 | UserCollectionDetail userCollectionDetail = collectionMq2DetailMapper.toEntity(collectionMq); | ||
| 1125 | Optional<UserCollectionDetail> userCollectionDetailOptional = userCollectionDetailRepository | ||
| 1126 | .findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(), userCollectionDetail.getDetailType(), userCollectionSave.getId()); | ||
| 1127 | //观影记录同一天只存一条记录 | ||
| 1128 | if (userCollectionDetailOptional.isPresent() && | ||
| 1129 | DateUtil.isSameDay(new Date(userCollectionDetailOptional.get().getCreateTime().getTime()), new Date())) { | ||
| 1130 | userCollectionDetail.setId(userCollectionDetailOptional.get().getId()); | ||
| 1131 | } else { | ||
| 1132 | userCollectionDetail.setId(null) | ||
| 1133 | .setUserCollectionId(userCollectionSave.getId()); | ||
| 1134 | } | ||
| 1135 | userCollectionDetailRepository.save(userCollectionDetail); | ||
| 1136 | } | ||
| 1137 | } | ||
| 1138 | } catch (Exception e) { | ||
| 1139 | log.error("CollectionAddConsumer || UserCollection add error || {}", e.toString(), e); | ||
| 1140 | } | ||
| 1141 | return true; | ||
| 1142 | } | ||
| 1143 | |||
| 1144 | @Override | ||
| 1145 | public List<MemberDTO> findBindByPlatformAccount(String platformAccount) { | ||
| 1146 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
| 1147 | if (Objects.nonNull(userTvDTO.getId())) { | ||
| 1148 | Long id = userTvDTO.getId(); | ||
| 1149 | |||
| 1150 | return this.memberService.findByUserIptvId(id); | ||
| 1151 | } | ||
| 1152 | return null; | ||
| 1153 | } | ||
| 1154 | |||
| 1080 | /** | 1155 | /** |
| 1081 | * 保存、修改会员加密信息 | 1156 | * 保存、修改会员加密信息 |
| 1082 | * @param resources | 1157 | * @param resources | ... | ... |
| 1 | package com.topdraw.business.process.service.mapper; | ||
| 2 | |||
| 3 | import com.topdraw.base.BaseMapper; | ||
| 4 | import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail; | ||
| 5 | import com.topdraw.business.process.domian.weixin.UserCollectionMq; | ||
| 6 | import org.mapstruct.Mapper; | ||
| 7 | import org.mapstruct.Mapping; | ||
| 8 | import org.mapstruct.Mappings; | ||
| 9 | import org.mapstruct.ReportingPolicy; | ||
| 10 | |||
| 11 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
| 12 | public interface CollectionMq2DetailMapper extends BaseMapper<UserCollectionMq, UserCollectionDetail> { | ||
| 13 | @Override | ||
| 14 | @Mappings({ | ||
| 15 | @Mapping(target = "detailImg", source = "images") | ||
| 16 | }) | ||
| 17 | UserCollectionDetail toEntity(UserCollectionMq dto); | ||
| 18 | } |
-
Please register or sign in to post a comment