1.优化sql
2.添加缓存
Showing
52 changed files
with
1156 additions
and
757 deletions
... | @@ -32,10 +32,8 @@ public class MemberProfileController { | ... | @@ -32,10 +32,8 @@ public class MemberProfileController { |
32 | @RequestMapping(value = "/update") | 32 | @RequestMapping(value = "/update") |
33 | @ApiOperation("修改会员属性") | 33 | @ApiOperation("修改会员属性") |
34 | @AnonymousAccess | 34 | @AnonymousAccess |
35 | @Deprecated | ||
36 | public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody MemberProfile resources) { | 35 | public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody MemberProfile resources) { |
37 | 36 | log.info("memberProfile ==>> update ==>> resources ===>> {}",resources); | |
38 | log.info("memberProfile ==>> update ==>> resources ===>> [{}]",resources); | ||
39 | MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources); | 37 | MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources); |
40 | return ResultInfo.success(memberProfileDTO); | 38 | return ResultInfo.success(memberProfileDTO); |
41 | } | 39 | } |
... | @@ -44,8 +42,7 @@ public class MemberProfileController { | ... | @@ -44,8 +42,7 @@ public class MemberProfileController { |
44 | @ApiOperation("修改会员属性并同步会员信息") | 42 | @ApiOperation("修改会员属性并同步会员信息") |
45 | @AnonymousAccess | 43 | @AnonymousAccess |
46 | public ResultInfo updateMemberProfileAndMember(@Validated @RequestBody MemberProfile resources) { | 44 | public ResultInfo updateMemberProfileAndMember(@Validated @RequestBody MemberProfile resources) { |
47 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); | 45 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> {}",resources); |
48 | |||
49 | MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources); | 46 | MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.updateMemberProfileAndMember(resources); |
50 | return ResultInfo.success(memberProfileDTO); | 47 | return ResultInfo.success(memberProfileDTO); |
51 | } | 48 | } |
... | @@ -55,9 +52,7 @@ public class MemberProfileController { | ... | @@ -55,9 +52,7 @@ public class MemberProfileController { |
55 | @AnonymousAccess | 52 | @AnonymousAccess |
56 | @Deprecated | 53 | @Deprecated |
57 | public ResultInfo create(@Validated(value = {CreateGroup.class}) @RequestBody MemberProfile resources) { | 54 | public ResultInfo create(@Validated(value = {CreateGroup.class}) @RequestBody MemberProfile resources) { |
58 | 55 | log.info("memberProfile ==>> update ==>> resources ===>> {}",resources); | |
59 | log.info("memberProfile ==>> update ==>> resources ===>> [{}]",resources); | ||
60 | |||
61 | MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.createMemberProfileAndSyncMember(resources); | 56 | MemberProfileDTO memberProfileDTO = this.memberProfileOperationService.createMemberProfileAndSyncMember(resources); |
62 | return ResultInfo.success(memberProfileDTO); | 57 | return ResultInfo.success(memberProfileDTO); |
63 | } | 58 | } | ... | ... |
... | @@ -175,27 +175,26 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -175,27 +175,26 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
175 | return memberProfileDTO; | 175 | return memberProfileDTO; |
176 | } | 176 | } |
177 | 177 | ||
178 | private void synchronizedMemberData(MemberProfile resources, MemberDTO memberDTO) { | 178 | private void synchronizedMemberData(MemberProfile memberProfile, MemberDTO memberDTO) { |
179 | 179 | ||
180 | log.info("updateMemberProfileAndMember ==>> resources ==>> [{}]",resources); | 180 | log.info("updateMemberProfileAndMember ==>> resources ==>> [{}]",memberProfile); |
181 | 181 | ||
182 | memberDTO.setId(resources.getMemberId()); | 182 | Member member = new Member(); |
183 | if(StringUtils.isNotBlank(resources.getRealname())) { | 183 | member.setId(memberDTO.getId()); |
184 | memberDTO.setNickname(resources.getRealname()); | 184 | member.setCode(memberDTO.getCode()); |
185 | if(StringUtils.isNotBlank(memberProfile.getRealname())) { | ||
186 | member.setNickname(memberProfile.getRealname()); | ||
185 | } | 187 | } |
186 | if(Objects.nonNull(resources.getGender()) && resources.getGender() != -1) { | 188 | if(Objects.nonNull(memberProfile.getGender()) && memberProfile.getGender() != -1) { |
187 | memberDTO.setGender(resources.getGender()); | 189 | member.setGender(memberProfile.getGender()); |
188 | } | 190 | } |
189 | if(StringUtils.isNotBlank(resources.getBirthday())) { | 191 | if(StringUtils.isNotBlank(memberProfile.getBirthday())) { |
190 | memberDTO.setBirthday(resources.getBirthday()); | 192 | member.setBirthday(memberProfile.getBirthday()); |
191 | } | 193 | } |
192 | if(StringUtils.isNotBlank(resources.getAvatarUrl())) { | 194 | if(StringUtils.isNotBlank(memberProfile.getAvatarUrl())) { |
193 | memberDTO.setAvatarUrl(resources.getAvatarUrl()); | 195 | member.setAvatarUrl(memberProfile.getAvatarUrl()); |
194 | } | 196 | } |
195 | 197 | ||
196 | Member member = new Member(); | 198 | this.memberService.doUpdateMemberAvatarUrlAndNicknameAndGender(member); |
197 | BeanUtils.copyProperties(memberDTO,member); | ||
198 | |||
199 | this.memberService.update(member); | ||
200 | } | 199 | } |
201 | } | 200 | } | ... | ... |
... | @@ -23,24 +23,48 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif | ... | @@ -23,24 +23,48 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif |
23 | 23 | ||
24 | Optional<Member> findByIdOrCode(Long id,String code); | 24 | Optional<Member> findByIdOrCode(Long id,String code); |
25 | 25 | ||
26 | |||
27 | @Modifying | 26 | @Modifying |
28 | @Query(value = "UPDATE `uc_member` SET `user_iptv_id` = ?2, `update_time` = ?3 , `bind_iptv_platform_type`= 0, " + | 27 | @Query(value = "UPDATE `uc_member` SET `user_iptv_id` = ?2, `update_time` = ?3 , `bind_iptv_platform_type`= 0, " + |
29 | "`bind_iptv_time`=?3 WHERE `id` = ?1", nativeQuery = true) | 28 | "`bind_iptv_time`=?3 WHERE `id` = ?1", nativeQuery = true) |
30 | void updateUserIptvIdById(Long id, Long userIptvId, LocalDateTime now); | 29 | void updateUserIptvIdById(Long id, Long userIptvId, LocalDateTime now); |
31 | 30 | ||
32 | @Modifying | 31 | @Modifying |
33 | @Query(value = "UPDATE `uc_member` SET `exp` = :#{#resources.exp}, `level` = :#{#resources.level} , `update_time`= now() " + | 32 | @Query(value = "UPDATE `uc_member` SET `exp` = :#{#resources.exp}, " + |
33 | "`level` = :#{#resources.level} , `update_time`= now() " + | ||
34 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) | 34 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) |
35 | void updateExpAndLevel(@Param("resources") Member member); | 35 | Integer updateExpAndLevel(@Param("resources") Member member); |
36 | 36 | ||
37 | @Modifying | 37 | @Modifying |
38 | @Query(value = "UPDATE `uc_member` SET `points` = :#{#resources.points}, `due_points` = :#{#resources.duePoints} , `update_time`= now() " + | 38 | @Query(value = "UPDATE `uc_member` SET `points` = :#{#resources.points}, " + |
39 | "`due_points` = :#{#resources.duePoints} , `update_time`= now() " + | ||
39 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) | 40 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) |
40 | void updatePointAndDuePoint(@Param("resources") Member resources); | 41 | Integer updatePointAndDuePoint(@Param("resources") Member resources); |
42 | |||
43 | @Modifying | ||
44 | @Query(value = "UPDATE `uc_member` SET `coupon_amount` = :#{#resources.couponAmount}, " + | ||
45 | "`due_coupon_amount` = :#{#resources.dueCouponAmount} , `update_time`= now() " + | ||
46 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) | ||
47 | Integer doUpdateMemberCoupon(@Param("resources") Member member); | ||
48 | |||
49 | @Query(value = "SELECT um.* FROM uc_member um LEFT JOIN uc_user_tv tv ON um.id = tv.member_id " + | ||
50 | " WHERE tv.platform_account = ?1 ", nativeQuery = true) | ||
51 | Optional<Member> findByPlatformAccount(String platformAccount); | ||
41 | 52 | ||
42 | @Modifying | 53 | @Modifying |
43 | @Query(value = "UPDATE `uc_member` SET `coupon_amount` = :#{#resources.couponAmount}, `due_coupon_amount` = :#{#resources.dueCouponAmount} , `update_time`= now() " + | 54 | @Query(value = "UPDATE `uc_member` SET `vip` = :#{#resources.vip}, " + |
55 | "`vip_expire_time` = :#{#resources.vipExpireTime} , `update_time`= now() " + | ||
44 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) | 56 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) |
45 | void doUpdateMemberCoupon(@Param("resources") Member member); | 57 | Integer updateMemberVipAndVipExpireTime(@Param("resources") Member member); |
58 | |||
59 | @Modifying | ||
60 | @Query(value = "UPDATE `uc_member` SET `user_iptv_id` = :#{#resources.userIptvId}, `update_time` = now() , " + | ||
61 | " `bind_iptv_platform_type`= :#{#resources.bindIptvPlatformType}, " + | ||
62 | " `bind_iptv_time`=:#{#resources.bindIptvTime} WHERE `id` = :#{#resources.id}", nativeQuery = true) | ||
63 | Integer updateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(@Param("resources") Member member); | ||
64 | |||
65 | @Modifying | ||
66 | @Query(value = "UPDATE `uc_member` SET `avatar_url` = :#{#resources.avatarUrl}, `update_time` = now() , " + | ||
67 | " `nickname`= :#{#resources.nickname}, " + | ||
68 | " `gender`=:#{#resources.gender} WHERE `id` = :#{#resources.id}", nativeQuery = true) | ||
69 | Integer updateMemberAvatarUrlAndNicknameAndGender(@Param("resources") Member resource); | ||
46 | } | 70 | } | ... | ... |
... | @@ -52,8 +52,8 @@ public class MemberController { | ... | @@ -52,8 +52,8 @@ public class MemberController { |
52 | @AnonymousAccess | 52 | @AnonymousAccess |
53 | @ApiOperation("手动修改vip") | 53 | @ApiOperation("手动修改vip") |
54 | public ResultInfo doUpdateVipByCode(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) { | 54 | public ResultInfo doUpdateVipByCode(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) { |
55 | log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources); | 55 | log.info("member ==>> doUpdateVipByCode ==>> param ==>> {}",resources); |
56 | this.memberOperationService.updateMemberVip(resources); | 56 | this.memberOperationService.doUpdateMemberVipAndVipExpireTime(resources); |
57 | return ResultInfo.success(); | 57 | return ResultInfo.success(); |
58 | } | 58 | } |
59 | 59 | ||
... | @@ -67,7 +67,6 @@ public class MemberController { | ... | @@ -67,7 +67,6 @@ public class MemberController { |
67 | if (StringUtils.isNotBlank(code)) { | 67 | if (StringUtils.isNotBlank(code)) { |
68 | MemberDTO memberDTO = this.memberOperationService.findByCode(code); | 68 | MemberDTO memberDTO = this.memberOperationService.findByCode(code); |
69 | resources.setId(memberDTO.getId()); | 69 | resources.setId(memberDTO.getId()); |
70 | // BeanUtils.copyProperties(resources, memberDTO); | ||
71 | } | 70 | } |
72 | 71 | ||
73 | MemberDTO memberDTO = this.memberOperationService.update(resources); | 72 | MemberDTO memberDTO = this.memberOperationService.update(resources); | ... | ... |
... | @@ -40,13 +40,6 @@ public interface MemberService { | ... | @@ -40,13 +40,6 @@ public interface MemberService { |
40 | MemberDTO create(Member resources); | 40 | MemberDTO create(Member resources); |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * 创建并返回会员 | ||
44 | * @param resources 会员 | ||
45 | * @return Member | ||
46 | */ | ||
47 | MemberDTO createAndReturnMember(Member resources); | ||
48 | |||
49 | /** | ||
50 | * 修改会员 | 43 | * 修改会员 |
51 | * @param resources | 44 | * @param resources |
52 | */ | 45 | */ |
... | @@ -91,4 +84,31 @@ public interface MemberService { | ... | @@ -91,4 +84,31 @@ public interface MemberService { |
91 | * @return | 84 | * @return |
92 | */ | 85 | */ |
93 | MemberDTO doUpdateMemberCoupon(Member member); | 86 | MemberDTO doUpdateMemberCoupon(Member member); |
87 | |||
88 | /** | ||
89 | * | ||
90 | * @param platformAccount | ||
91 | * @return | ||
92 | */ | ||
93 | MemberDTO findByPlatformAccount(String platformAccount); | ||
94 | |||
95 | /** | ||
96 | * | ||
97 | * @param member | ||
98 | * @return | ||
99 | */ | ||
100 | MemberDTO doUpdateMemberVipAndVipExpireTime(Member member); | ||
101 | |||
102 | /** | ||
103 | * | ||
104 | * @param member | ||
105 | * @return | ||
106 | */ | ||
107 | MemberDTO doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(Member member); | ||
108 | |||
109 | /** | ||
110 | * | ||
111 | * @param member | ||
112 | */ | ||
113 | MemberDTO doUpdateMemberAvatarUrlAndNicknameAndGender(Member member); | ||
94 | } | 114 | } | ... | ... |
... | @@ -9,17 +9,14 @@ import com.topdraw.business.module.member.repository.MemberRepository; | ... | @@ -9,17 +9,14 @@ 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.config.RedisKeyConstants; | ||
12 | import com.topdraw.exception.BadRequestException; | 13 | import com.topdraw.exception.BadRequestException; |
13 | import com.topdraw.exception.GlobeExceptionMsg; | 14 | import com.topdraw.exception.GlobeExceptionMsg; |
14 | import com.topdraw.utils.RedisUtils; | 15 | import com.topdraw.utils.RedisUtils; |
15 | import com.topdraw.utils.ValidationUtil; | ||
16 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
17 | import org.apache.commons.lang3.StringUtils; | 17 | import org.apache.commons.lang3.StringUtils; |
18 | import org.springframework.beans.BeanUtils; | 18 | import org.springframework.beans.BeanUtils; |
19 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
20 | import org.springframework.cache.annotation.CacheEvict; | ||
21 | import org.springframework.cache.annotation.CachePut; | ||
22 | import org.springframework.cache.annotation.Cacheable; | ||
23 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
24 | import org.springframework.transaction.annotation.Propagation; | 21 | import org.springframework.transaction.annotation.Propagation; |
25 | import org.springframework.transaction.annotation.Transactional; | 22 | import org.springframework.transaction.annotation.Transactional; |
... | @@ -45,7 +42,6 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -45,7 +42,6 @@ public class MemberServiceImpl implements MemberService { |
45 | @Autowired | 42 | @Autowired |
46 | private RedisUtils redisUtils; | 43 | private RedisUtils redisUtils; |
47 | 44 | ||
48 | |||
49 | @Override | 45 | @Override |
50 | public String findCodeById(Long id) { | 46 | public String findCodeById(Long id) { |
51 | MemberDTO memberDTO = this.findById(id); | 47 | MemberDTO memberDTO = this.findById(id); |
... | @@ -56,35 +52,18 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -56,35 +52,18 @@ public class MemberServiceImpl implements MemberService { |
56 | public MemberDTO findById(Long id) { | 52 | public MemberDTO findById(Long id) { |
57 | Member member = this.memberRepository.findById(id).orElseGet(Member::new); | 53 | Member member = this.memberRepository.findById(id).orElseGet(Member::new); |
58 | return this.memberMapper.toDto(member); | 54 | return this.memberMapper.toDto(member); |
59 | |||
60 | } | 55 | } |
61 | 56 | ||
62 | @Override | 57 | @Override |
63 | public MemberDTO findByCode(String code) { | 58 | public MemberDTO findByCode(String code) { |
64 | |||
65 | Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new); | 59 | Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new); |
66 | ValidationUtil.isNull(member.getId(),"Member","id",code); | ||
67 | |||
68 | return this.memberMapper.toDto(member); | 60 | return this.memberMapper.toDto(member); |
69 | |||
70 | } | ||
71 | |||
72 | private MemberDTO findByIdOrCode(Long id,String code) { | ||
73 | |||
74 | Member member = this.memberRepository.findByIdOrCode(id,code).orElseGet(Member::new); | ||
75 | ValidationUtil.isNull(member.getId(),"Member","param",code); | ||
76 | |||
77 | return this.memberMapper.toDto(member); | ||
78 | |||
79 | } | 61 | } |
80 | 62 | ||
81 | @Override | 63 | @Override |
82 | public List<MemberDTO> findByUserIptvId(Long id) { | 64 | public List<MemberDTO> findByUserIptvId(Long id) { |
83 | |||
84 | List<Member> memberList = this.memberRepository.findByUserIptvId(id); | 65 | List<Member> memberList = this.memberRepository.findByUserIptvId(id); |
85 | |||
86 | return this.memberMapper.toDto(memberList); | 66 | return this.memberMapper.toDto(memberList); |
87 | |||
88 | } | 67 | } |
89 | 68 | ||
90 | @Override | 69 | @Override |
... | @@ -94,11 +73,11 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -94,11 +73,11 @@ public class MemberServiceImpl implements MemberService { |
94 | throw new BadRequestException(GlobeExceptionMsg.MEMBER_ID_AND_CODE_ARE_NULL); | 73 | throw new BadRequestException(GlobeExceptionMsg.MEMBER_ID_AND_CODE_ARE_NULL); |
95 | 74 | ||
96 | if (StringUtils.isNotBlank(memberCode)) { | 75 | if (StringUtils.isNotBlank(memberCode)) { |
97 | MemberDTO memberDTO = this.findByCode(memberCode); | 76 | Member member = this.memberRepository.findFirstByCode(memberCode).orElseGet(Member::new); |
98 | return memberDTO; | 77 | return this.memberMapper.toDto(member); |
99 | } else if (Objects.nonNull(id)) { | 78 | } else if (Objects.nonNull(id)) { |
100 | MemberDTO memberDTO = this.findById(id); | 79 | Member member = this.memberRepository.findById(id).orElseGet(Member::new); |
101 | return memberDTO; | 80 | return this.memberMapper.toDto(member); |
102 | } | 81 | } |
103 | 82 | ||
104 | return null; | 83 | return null; |
... | @@ -106,102 +85,158 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -106,102 +85,158 @@ public class MemberServiceImpl implements MemberService { |
106 | 85 | ||
107 | @Override | 86 | @Override |
108 | public MemberDTO checkMember(Member member) { | 87 | public MemberDTO checkMember(Member member) { |
109 | |||
110 | String memberCode = member.getCode(); | 88 | String memberCode = member.getCode(); |
111 | Long memberId = member.getId(); | 89 | Long memberId = member.getId(); |
112 | |||
113 | return this.checkMember(memberId,memberCode); | 90 | return this.checkMember(memberId,memberCode); |
91 | } | ||
114 | 92 | ||
93 | @Override | ||
94 | @Transactional(rollbackFor = Exception.class) | ||
95 | public MemberDTO doUpdateMemberExpAndLevel(Member resource) { | ||
96 | |||
97 | Integer count = this.memberRepository.updateExpAndLevel(resource); | ||
98 | if (Objects.nonNull(count) && count > 0) { | ||
99 | Member member = this.memberRepository.findById(resource.getId()).orElseGet(Member::new); | ||
100 | return this.memberMapper.toDto(member); | ||
101 | } | ||
102 | |||
103 | return this.memberMapper.toDto(resource); | ||
115 | } | 104 | } |
116 | 105 | ||
117 | @Override | 106 | @Override |
118 | @Transactional(rollbackFor = Exception.class) | 107 | @Transactional(rollbackFor = Exception.class) |
119 | public MemberDTO doUpdateMemberExpAndLevel(Member resources) { | 108 | public MemberDTO doUpdateMemberCoupon(Member resource) { |
120 | this.redisUtils.doLock("member::code" + resources.getCode()); | 109 | log.info("修改会员优惠券 =>> {}", resource); |
121 | try { | 110 | try { |
122 | MemberDTO memberDTO = this.findById(resources.getId()); | 111 | this.redisUtils.doLock(RedisKeyConstants.updateCacheMemberById + resource.getId()); |
123 | if (Objects.nonNull(memberDTO)) { | 112 | |
124 | this.memberRepository.updateExpAndLevel(resources); | 113 | Integer count = this.memberRepository.doUpdateMemberCoupon(resource); |
114 | if (Objects.nonNull(count) && count > 0) { | ||
115 | Member member = this.memberRepository.findById(resource.getId()).orElseGet(Member::new); | ||
116 | return this.memberMapper.toDto(member); | ||
125 | } | 117 | } |
126 | return memberDTO; | 118 | |
127 | } catch (Exception e) { | 119 | } catch (Exception e) { |
128 | e.printStackTrace(); | 120 | log.info("修改会员优惠券,"+e.getMessage()); |
129 | throw e; | ||
130 | } finally { | 121 | } finally { |
131 | this.redisUtils.doUnLock("member::code" + resources.getCode()); | 122 | this.redisUtils.doUnLock(RedisKeyConstants.updateCacheMemberById + resource.getId()); |
132 | } | 123 | } |
124 | |||
125 | return this.memberMapper.toDto(resource); | ||
126 | } | ||
127 | |||
128 | @Override | ||
129 | public MemberDTO findByPlatformAccount(String platformAccount) { | ||
130 | log.info("从数据库中检索大屏账号对应的会员, platformAccount ==>> {}", platformAccount); | ||
131 | Member member = this.memberRepository.findByPlatformAccount(platformAccount).orElseGet(Member::new); | ||
132 | return this.memberMapper.toDto(member); | ||
133 | } | 133 | } |
134 | 134 | ||
135 | @Override | 135 | @Override |
136 | @Transactional(rollbackFor = Exception.class) | 136 | @Transactional(rollbackFor = Exception.class) |
137 | public MemberDTO doUpdateMemberCoupon(Member member) { | 137 | public MemberDTO doUpdateMemberVipAndVipExpireTime(Member resource) { |
138 | // MemberDTO memberDTO = this.update(member); | 138 | log.info("修改会员vip和vip过期时间 ==>> {}", resource); |
139 | this.redisUtils.doLock("member::code" + member.getCode()); | ||
140 | try { | 139 | try { |
141 | MemberDTO memberDTO = this.findById(member.getId()); | 140 | this.redisUtils.doLock(RedisKeyConstants.updateCacheMemberById + resource.getId()); |
142 | if (Objects.nonNull(memberDTO)) { | 141 | |
143 | this.memberRepository.doUpdateMemberCoupon(member); | 142 | Integer count = this.memberRepository.updateMemberVipAndVipExpireTime(resource); |
143 | if (Objects.nonNull(count) && count > 0) { | ||
144 | Member member = this.memberRepository.findById(resource.getId()).orElseGet(Member::new); | ||
145 | return this.memberMapper.toDto(member); | ||
144 | } | 146 | } |
145 | return memberDTO; | 147 | |
146 | } catch (Exception e) { | 148 | } catch (Exception e) { |
147 | e.printStackTrace(); | 149 | log.info("修改会员vip和vip过期时间,"+e.getMessage()); |
148 | throw e; | ||
149 | } finally { | 150 | } finally { |
150 | this.redisUtils.doUnLock("member::code" + member.getCode()); | 151 | this.redisUtils.doUnLock(RedisKeyConstants.updateCacheMemberById + resource.getId()); |
151 | } | 152 | } |
153 | |||
154 | return this.memberMapper.toDto(resource); | ||
152 | } | 155 | } |
153 | 156 | ||
154 | @Override | 157 | @Override |
155 | @Transactional(rollbackFor = Exception.class) | 158 | @Transactional(rollbackFor = Exception.class) |
156 | public MemberDTO create(Member resources) { | 159 | public MemberDTO doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(Member resource) { |
160 | log.info("修改会员绑定大屏信息 ==>> {}", resource); | ||
161 | try { | ||
162 | this.redisUtils.doLock(RedisKeyConstants.updateCacheMemberById + resource.getId()); | ||
157 | 163 | ||
158 | Member member = MemberBuilder.build(resources); | 164 | Integer count = this.memberRepository.updateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(resource); |
159 | Member _member = this.save(member); | 165 | if (Objects.nonNull(count) && count > 0) { |
166 | Member member = this.memberRepository.findById(resource.getId()).orElseGet(Member::new); | ||
167 | return this.memberMapper.toDto(member); | ||
168 | } | ||
160 | 169 | ||
161 | if (Objects.nonNull(_member.getId())) { | 170 | } catch (Exception e) { |
162 | MemberProfile memberProfile = MemberProfileBuilder.build(_member); | 171 | log.info("修改会员绑定大屏信息,"+e.getMessage()); |
163 | // 保存会员属性 | 172 | } finally { |
164 | this.memberProfileService.create(memberProfile); | 173 | this.redisUtils.doUnLock(RedisKeyConstants.updateCacheMemberById + resource.getId()); |
165 | } | 174 | } |
166 | 175 | ||
176 | return this.memberMapper.toDto(resource); | ||
177 | } | ||
178 | |||
179 | @Override | ||
180 | @Transactional(rollbackFor = Exception.class) | ||
181 | public MemberDTO doUpdateMemberAvatarUrlAndNicknameAndGender(Member resource) { | ||
182 | log.info("修改会员头像、昵称、性别 ==>> {}", resource); | ||
183 | try { | ||
184 | this.redisUtils.doLock(RedisKeyConstants.updateCacheMemberById + resource.getId()); | ||
185 | |||
186 | Integer count = this.memberRepository.updateMemberAvatarUrlAndNicknameAndGender(resource); | ||
187 | if (Objects.nonNull(count) && count > 0) { | ||
188 | Member member = this.memberRepository.findById(resource.getId()).orElseGet(Member::new); | ||
167 | return this.memberMapper.toDto(member); | 189 | return this.memberMapper.toDto(member); |
190 | } | ||
168 | 191 | ||
192 | } catch (Exception e) { | ||
193 | log.info("修改会员头像、昵称、性别异常,"+e.getMessage()); | ||
194 | } finally { | ||
195 | this.redisUtils.doUnLock(RedisKeyConstants.updateCacheMemberById + resource.getId()); | ||
169 | } | 196 | } |
170 | 197 | ||
198 | return this.memberMapper.toDto(resource); | ||
199 | } | ||
200 | |||
201 | |||
171 | @Override | 202 | @Override |
172 | @Transactional(rollbackFor = Exception.class) | 203 | @Transactional(rollbackFor = Exception.class) |
173 | public MemberDTO createAndReturnMember(Member resources) { | 204 | public MemberDTO create(Member resources) { |
174 | 205 | ||
175 | MemberDTO memberDTO = this.create(MemberBuilder.build(resources)); | 206 | Member member = MemberBuilder.build(resources); |
207 | Member _member = this.save(member); | ||
176 | 208 | ||
177 | return memberDTO; | 209 | if (Objects.nonNull(_member.getId())) { |
210 | MemberProfile memberProfile = MemberProfileBuilder.build(_member); | ||
211 | // 保存会员属性 | ||
212 | this.memberProfileService.create(memberProfile); | ||
213 | } | ||
214 | |||
215 | return this.memberMapper.toDto(member); | ||
178 | 216 | ||
179 | } | 217 | } |
180 | 218 | ||
181 | @Override | 219 | @Override |
182 | @Transactional(rollbackFor = Exception.class) | 220 | @Transactional(rollbackFor = Exception.class) |
183 | public MemberDTO update(Member resources) { | 221 | public MemberDTO update(Member resources) { |
184 | 222 | log.info("修改会员信息 ==>> {}", resources); | |
185 | log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources); | ||
186 | this.redisUtils.doLock("member::code" + resources.getCode()); | ||
187 | try { | 223 | try { |
188 | MemberDTO memberDTO = this.checkMember(resources); | 224 | this.redisUtils.doLock(RedisKeyConstants.updateCacheMemberById + resources.getId()); |
189 | 225 | ||
226 | MemberDTO memberDTO = this.checkMember(resources); | ||
190 | Member member = new Member(); | 227 | Member member = new Member(); |
191 | BeanUtils.copyProperties(memberDTO,member); | 228 | BeanUtils.copyProperties(memberDTO,member); |
192 | member.copy(resources); | 229 | member.copy(resources); |
193 | |||
194 | Member _member = this.save(member); | 230 | Member _member = this.save(member); |
195 | |||
196 | return this.memberMapper.toDto(_member); | 231 | return this.memberMapper.toDto(_member); |
197 | 232 | ||
198 | } catch (Exception e) { | 233 | } catch (Exception e) { |
199 | e.printStackTrace(); | 234 | log.info(e.getMessage()); |
200 | throw e; | ||
201 | } finally { | 235 | } finally { |
202 | this.redisUtils.doUnLock("member::code" + resources.getCode()); | 236 | this.redisUtils.doUnLock(RedisKeyConstants.updateCacheMemberById + resources.getId()); |
203 | } | 237 | } |
204 | 238 | ||
239 | return this.memberMapper.toDto(resources); | ||
205 | } | 240 | } |
206 | 241 | ||
207 | @Transactional(propagation = Propagation.REQUIRES_NEW) | 242 | @Transactional(propagation = Propagation.REQUIRES_NEW) |
... | @@ -212,26 +247,14 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -212,26 +247,14 @@ public class MemberServiceImpl implements MemberService { |
212 | @Override | 247 | @Override |
213 | @Transactional(rollbackFor = Exception.class) | 248 | @Transactional(rollbackFor = Exception.class) |
214 | public MemberDTO doUpdateMemberPoints(Member resources) { | 249 | public MemberDTO doUpdateMemberPoints(Member resources) { |
215 | try { | ||
216 | this.redisUtils.doLock("member::code" + resources.getCode()); | ||
217 | |||
218 | /*ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | ||
219 | member.copy(resources); | ||
220 | 250 | ||
221 | Member _member = this.save(member);*/ | 251 | Integer count = this.memberRepository.updatePointAndDuePoint(resources); |
222 | MemberDTO memberDTO = this.findById(resources.getId()); | 252 | if (Objects.nonNull(count) && count > 0) { |
223 | if (Objects.nonNull(memberDTO)) { | 253 | Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new); |
224 | this.memberRepository.updatePointAndDuePoint(resources); | 254 | return this.memberMapper.toDto(member); |
225 | } | 255 | } |
226 | 256 | ||
227 | return memberDTO; | 257 | return this.memberMapper.toDto(resources); |
228 | |||
229 | } catch (Exception e) { | ||
230 | e.printStackTrace(); | ||
231 | throw e; | ||
232 | } finally { | ||
233 | this.redisUtils.doUnLock("member::code" + resources.getCode()); | ||
234 | } | ||
235 | } | 258 | } |
236 | 259 | ||
237 | } | 260 | } | ... | ... |
... | @@ -47,7 +47,7 @@ public class Rights implements Serializable { | ... | @@ -47,7 +47,7 @@ public class Rights implements Serializable { |
47 | 47 | ||
48 | /** 权益的实体类型 1:积分;2成长值;3优惠券 */ | 48 | /** 权益的实体类型 1:积分;2成长值;3优惠券 */ |
49 | @Column(name = "entity_type", nullable = false) | 49 | @Column(name = "entity_type", nullable = false) |
50 | private String entityType; | 50 | private Integer entityType; |
51 | 51 | ||
52 | /** 实体id */ | 52 | /** 实体id */ |
53 | @Column(name = "entity_id", nullable = false) | 53 | @Column(name = "entity_id", nullable = false) | ... | ... |
... | @@ -28,7 +28,7 @@ public class RightsDTO implements Serializable { | ... | @@ -28,7 +28,7 @@ public class RightsDTO implements Serializable { |
28 | private Integer type; | 28 | private Integer type; |
29 | 29 | ||
30 | /** 权益的实体类型 1:积分;2成长值;3优惠券 */ | 30 | /** 权益的实体类型 1:积分;2成长值;3优惠券 */ |
31 | private String entityType; | 31 | private Integer entityType; |
32 | 32 | ||
33 | /** 实体id */ | 33 | /** 实体id */ |
34 | private Long entityId; | 34 | private Long entityId; | ... | ... |
... | @@ -16,5 +16,5 @@ public interface TrTaskProgressRepository extends JpaRepository<TrTaskProgress, | ... | @@ -16,5 +16,5 @@ public interface TrTaskProgressRepository extends JpaRepository<TrTaskProgress, |
16 | @Query(value = "select id, member_id, task_id , current_action_amount , \n" + | 16 | @Query(value = "select id, member_id, task_id , current_action_amount , \n" + |
17 | " target_action_amount , `status` , completion_time,create_time,update_time from uc_tr_task_progress where member_id = ?1 \n" + | 17 | " target_action_amount , `status` , completion_time,create_time,update_time from uc_tr_task_progress where member_id = ?1 \n" + |
18 | " and task_id = ?2 and Date(completion_time) = ?3 ",nativeQuery = true) | 18 | " and task_id = ?2 and Date(completion_time) = ?3 ",nativeQuery = true) |
19 | List<TrTaskProgress> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); | 19 | TrTaskProgress findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); |
20 | } | 20 | } | ... | ... |
... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.task.progress.service; | ... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.task.progress.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; | 3 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; |
4 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; | 4 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; |
5 | |||
6 | import java.time.LocalDateTime; | ||
5 | import java.util.List; | 7 | import java.util.List; |
6 | 8 | ||
7 | /** | 9 | /** |
... | @@ -21,13 +23,13 @@ public interface TrTaskProgressService { | ... | @@ -21,13 +23,13 @@ public interface TrTaskProgressService { |
21 | * | 23 | * |
22 | * @param resources | 24 | * @param resources |
23 | */ | 25 | */ |
24 | void create(TrTaskProgress resources); | 26 | TrTaskProgress create(TrTaskProgress resources, String date); |
25 | 27 | ||
26 | /** | 28 | /** |
27 | * | 29 | * |
28 | * @param resources | 30 | * @param resources |
29 | */ | 31 | */ |
30 | void update(TrTaskProgress resources); | 32 | TrTaskProgress update(TrTaskProgress resources, String date); |
31 | 33 | ||
32 | /** | 34 | /** |
33 | * | 35 | * |
... | @@ -42,5 +44,6 @@ public interface TrTaskProgressService { | ... | @@ -42,5 +44,6 @@ public interface TrTaskProgressService { |
42 | * @param time1 | 44 | * @param time1 |
43 | * @return | 45 | * @return |
44 | */ | 46 | */ |
45 | List<TrTaskProgressDTO> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); | 47 | TrTaskProgressDTO findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); |
48 | |||
46 | } | 49 | } | ... | ... |
1 | package com.topdraw.business.module.task.progress.service.impl; | 1 | package com.topdraw.business.module.task.progress.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; | 3 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; |
4 | import com.topdraw.config.RedisKeyConstants; | ||
4 | import com.topdraw.utils.ValidationUtil; | 5 | import com.topdraw.utils.ValidationUtil; |
5 | import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository; | 6 | import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository; |
6 | import com.topdraw.business.module.task.progress.service.TrTaskProgressService; | 7 | import com.topdraw.business.module.task.progress.service.TrTaskProgressService; |
7 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; | 8 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; |
8 | import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper; | 9 | import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper; |
10 | import lombok.extern.slf4j.Slf4j; | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
12 | import org.springframework.cache.annotation.CachePut; | ||
13 | import org.springframework.cache.annotation.Cacheable; | ||
10 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
11 | import org.springframework.transaction.annotation.Propagation; | 15 | import org.springframework.transaction.annotation.Propagation; |
12 | import org.springframework.transaction.annotation.Transactional; | 16 | import org.springframework.transaction.annotation.Transactional; |
13 | import org.springframework.dao.EmptyResultDataAccessException; | 17 | import org.springframework.dao.EmptyResultDataAccessException; |
14 | import org.springframework.util.Assert; | 18 | import org.springframework.util.Assert; |
15 | 19 | ||
20 | import java.time.LocalDateTime; | ||
16 | import java.util.List; | 21 | import java.util.List; |
17 | 22 | ||
18 | /** | 23 | /** |
... | @@ -21,6 +26,7 @@ import java.util.List; | ... | @@ -21,6 +26,7 @@ import java.util.List; |
21 | */ | 26 | */ |
22 | @Service | 27 | @Service |
23 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 28 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
29 | @Slf4j | ||
24 | public class TrTaskProgressServiceImpl implements TrTaskProgressService { | 30 | public class TrTaskProgressServiceImpl implements TrTaskProgressService { |
25 | 31 | ||
26 | @Autowired | 32 | @Autowired |
... | @@ -38,17 +44,21 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService { | ... | @@ -38,17 +44,21 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService { |
38 | 44 | ||
39 | @Override | 45 | @Override |
40 | @Transactional(rollbackFor = Exception.class) | 46 | @Transactional(rollbackFor = Exception.class) |
41 | public void create(TrTaskProgress resources) { | 47 | @Cacheable(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#resources.memberId+':'+#resources.taskId+':'+#date", unless = "#result == null ") |
42 | this.trTaskProgressRepository.save(resources); | 48 | public TrTaskProgress create(TrTaskProgress resources, String date) { |
49 | TrTaskProgress trTaskProgress = this.trTaskProgressRepository.save(resources); | ||
50 | return trTaskProgress; | ||
43 | } | 51 | } |
44 | 52 | ||
45 | @Override | 53 | @Override |
46 | @Transactional(rollbackFor = Exception.class) | 54 | @Transactional(rollbackFor = Exception.class) |
47 | public void update(TrTaskProgress resources) { | 55 | @Cacheable(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#resources.memberId+':'+#resources.taskId+':'+#date", unless = "#result == null ") |
48 | TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(resources.getId()).orElseGet(TrTaskProgress::new); | 56 | public TrTaskProgress update(TrTaskProgress resources, String date) { |
49 | ValidationUtil.isNull( TrTaskProgress.getId(),"TrTaskProgress","id",resources.getId()); | 57 | TrTaskProgress trTaskProgress = this.trTaskProgressRepository.findById(resources.getId()).orElseGet(TrTaskProgress::new); |
50 | TrTaskProgress.copy(resources); | 58 | ValidationUtil.isNull( trTaskProgress.getId(),"TrTaskProgress","id",resources.getId()); |
51 | this.trTaskProgressRepository.save(TrTaskProgress); | 59 | trTaskProgress.copy(resources); |
60 | TrTaskProgress save = this.trTaskProgressRepository.save(trTaskProgress); | ||
61 | return save; | ||
52 | } | 62 | } |
53 | 63 | ||
54 | @Override | 64 | @Override |
... | @@ -61,9 +71,12 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService { | ... | @@ -61,9 +71,12 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService { |
61 | } | 71 | } |
62 | 72 | ||
63 | @Override | 73 | @Override |
64 | public List<TrTaskProgressDTO> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1) { | 74 | @Cacheable(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#memberId+':'+#taskId+':'+#time1", unless = "#result == null") |
75 | public TrTaskProgressDTO findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1) { | ||
76 | log.info("从数据库查询当前会员今天是否完成了此任务, memberId ==>> {} || taskId ==>> {}", memberId, taskId); | ||
65 | return this.trTaskProgressMapper.toDto(this.trTaskProgressRepository.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1)); | 77 | return this.trTaskProgressMapper.toDto(this.trTaskProgressRepository.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1)); |
66 | } | 78 | } |
67 | 79 | ||
68 | 80 | ||
81 | |||
69 | } | 82 | } | ... | ... |
... | @@ -21,7 +21,13 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat | ... | @@ -21,7 +21,13 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat |
21 | @Modifying | 21 | @Modifying |
22 | @Transactional | 22 | @Transactional |
23 | @Query(value = "UPDATE `tr_task` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true) | 23 | @Query(value = "UPDATE `tr_task` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true) |
24 | void updateDeleteMark(Long id); | 24 | Integer updateDeleteMark(Long id); |
25 | 25 | ||
26 | Optional<Task> findByCode(String code); | 26 | Optional<Task> findByCode(String code); |
27 | |||
28 | @Query(value = "SELECT ta.*, attr.attr_str AS attr FROM tr_task ta LEFT JOIN tr_task_template tm ON ta.task_template_id = tm.id " + | ||
29 | " LEFT JOIN tr_task_attr attr ON attr.task_id = ta.id " + | ||
30 | " WHERE ta.`status` = 1 AND ta.valid_time <= now() and ta.expire_time >= now() AND ta.delete_mark = 0 AND " + | ||
31 | " tm.type = ?1 ", nativeQuery = true) | ||
32 | List<Task> findByEvent(Integer event); | ||
27 | } | 33 | } | ... | ... |
1 | package com.topdraw.business.module.task.service; | 1 | package com.topdraw.business.module.task.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.task.domain.Task; | 3 | import com.topdraw.business.module.task.domain.Task; |
4 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; | ||
4 | import com.topdraw.business.module.task.service.dto.TaskDTO; | 5 | import com.topdraw.business.module.task.service.dto.TaskDTO; |
6 | |||
7 | import java.time.LocalDateTime; | ||
5 | import java.util.List; | 8 | import java.util.List; |
6 | 9 | ||
7 | /** | 10 | /** |
... | @@ -47,11 +50,19 @@ public interface TaskService { | ... | @@ -47,11 +50,19 @@ public interface TaskService { |
47 | * | 50 | * |
48 | * @param task | 51 | * @param task |
49 | */ | 52 | */ |
50 | void delete(Task task); | 53 | Integer delete(Task task); |
51 | 54 | ||
52 | /** | 55 | /** |
53 | * | 56 | * |
54 | * @param id | 57 | * @param id |
55 | */ | 58 | */ |
56 | void delete(Long id); | 59 | Integer delete(Long id); |
60 | |||
61 | /** | ||
62 | * | ||
63 | * @param event | ||
64 | * @return | ||
65 | */ | ||
66 | List<Task> findByEvent(Integer event); | ||
67 | |||
57 | } | 68 | } | ... | ... |
member-service-impl/src/main/java/com/topdraw/business/module/task/service/impl/TaskServiceImpl.java
... | @@ -5,11 +5,15 @@ import com.topdraw.business.module.task.repository.TaskRepository; | ... | @@ -5,11 +5,15 @@ import com.topdraw.business.module.task.repository.TaskRepository; |
5 | import com.topdraw.business.module.task.service.TaskService; | 5 | import com.topdraw.business.module.task.service.TaskService; |
6 | import com.topdraw.business.module.task.service.dto.TaskDTO; | 6 | import com.topdraw.business.module.task.service.dto.TaskDTO; |
7 | import com.topdraw.business.module.task.service.mapper.TaskMapper; | 7 | import com.topdraw.business.module.task.service.mapper.TaskMapper; |
8 | import com.topdraw.config.RedisKeyConstants; | ||
9 | import lombok.extern.slf4j.Slf4j; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.cache.annotation.Cacheable; | ||
9 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
10 | import org.springframework.transaction.annotation.Propagation; | 13 | import org.springframework.transaction.annotation.Propagation; |
11 | import org.springframework.transaction.annotation.Transactional; | 14 | import org.springframework.transaction.annotation.Transactional; |
12 | 15 | ||
16 | import java.util.ArrayList; | ||
13 | import java.util.List; | 17 | import java.util.List; |
14 | import java.util.Objects; | 18 | import java.util.Objects; |
15 | 19 | ||
... | @@ -19,6 +23,7 @@ import java.util.Objects; | ... | @@ -19,6 +23,7 @@ import java.util.Objects; |
19 | */ | 23 | */ |
20 | @Service | 24 | @Service |
21 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 25 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
26 | @Slf4j | ||
22 | public class TaskServiceImpl implements TaskService { | 27 | public class TaskServiceImpl implements TaskService { |
23 | 28 | ||
24 | @Autowired | 29 | @Autowired |
... | @@ -56,14 +61,20 @@ public class TaskServiceImpl implements TaskService { | ... | @@ -56,14 +61,20 @@ public class TaskServiceImpl implements TaskService { |
56 | } | 61 | } |
57 | 62 | ||
58 | @Override | 63 | @Override |
59 | public void delete(Task task) { | 64 | public Integer delete(Task task) { |
60 | Long id = task.getId(); | 65 | Long id = task.getId(); |
61 | this.delete(id); | 66 | return this.delete(id); |
62 | } | 67 | } |
63 | 68 | ||
64 | @Override | 69 | @Override |
65 | public void delete(Long id) { | 70 | public Integer delete(Long id) { |
66 | this.taskRepository.updateDeleteMark(id); | 71 | return this.taskRepository.updateDeleteMark(id); |
67 | } | 72 | } |
68 | 73 | ||
74 | @Override | ||
75 | // @Cacheable(value = RedisKeyConstants.cacheTaskByTaskTemplateId, key = "#event" , unless = "#result.size() == 0") | ||
76 | public List<Task> findByEvent(Integer event) { | ||
77 | log.info("从数据库查询事件列表 ==>> {}", event); | ||
78 | return Objects.nonNull(event) ? this.taskRepository.findByEvent(event) : new ArrayList<>(); | ||
79 | } | ||
69 | } | 80 | } | ... | ... |
... | @@ -26,4 +26,6 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long | ... | @@ -26,4 +26,6 @@ public interface TaskTemplateRepository extends JpaRepository<TaskTemplate, Long |
26 | @Transactional | 26 | @Transactional |
27 | @Query(value = "UPDATE `tr_task_template` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true) | 27 | @Query(value = "UPDATE `tr_task_template` SET `delete_mark` = 1 , `update_time` = now() WHERE `id` = ?1", nativeQuery = true) |
28 | void updateDeleteMark(Long id); | 28 | void updateDeleteMark(Long id); |
29 | |||
30 | Long countByCodeAndType(String code, Integer type); | ||
29 | } | 31 | } | ... | ... |
... | @@ -61,4 +61,11 @@ public interface TaskTemplateService { | ... | @@ -61,4 +61,11 @@ public interface TaskTemplateService { |
61 | * @return | 61 | * @return |
62 | */ | 62 | */ |
63 | TaskTemplateDTO findByType(Integer event); | 63 | TaskTemplateDTO findByType(Integer event); |
64 | |||
65 | /** | ||
66 | * | ||
67 | * @param taskTemplate | ||
68 | * @return | ||
69 | */ | ||
70 | Long countByCodeAndType(TaskTemplate taskTemplate); | ||
64 | } | 71 | } | ... | ... |
... | @@ -83,4 +83,10 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { | ... | @@ -83,4 +83,10 @@ public class TaskTemplateServiceImpl implements TaskTemplateService { |
83 | return Objects.nonNull(event) ? this.taskTemplateMapper.toDto(this.taskTemplateRepository.findByType(event).orElseGet(TaskTemplate::new)) : new TaskTemplateDTO(); | 83 | return Objects.nonNull(event) ? this.taskTemplateMapper.toDto(this.taskTemplateRepository.findByType(event).orElseGet(TaskTemplate::new)) : new TaskTemplateDTO(); |
84 | } | 84 | } |
85 | 85 | ||
86 | @Override | ||
87 | public Long countByCodeAndType(TaskTemplate taskTemplate) { | ||
88 | Long count = this.taskTemplateRepository.countByCodeAndType(taskTemplate.getCode(), taskTemplate.getType()); | ||
89 | return count; | ||
90 | } | ||
91 | |||
86 | } | 92 | } | ... | ... |
... | @@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; | ... | @@ -5,6 +5,8 @@ import org.springframework.data.jpa.repository.JpaRepository; |
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
6 | import org.springframework.data.jpa.repository.Modifying; | 6 | import org.springframework.data.jpa.repository.Modifying; |
7 | import org.springframework.data.jpa.repository.Query; | 7 | import org.springframework.data.jpa.repository.Query; |
8 | import org.springframework.data.repository.query.Param; | ||
9 | import org.springframework.transaction.annotation.Transactional; | ||
8 | 10 | ||
9 | import java.time.LocalDateTime; | 11 | import java.time.LocalDateTime; |
10 | import java.util.Optional; | 12 | import java.util.Optional; |
... | @@ -24,4 +26,9 @@ public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecif | ... | @@ -24,4 +26,9 @@ public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecif |
24 | @Modifying | 26 | @Modifying |
25 | @Query(value = "UPDATE `uc_user_tv` SET `vis_user_id` = ?2, `update_time` = ?3 WHERE `id` = ?1", nativeQuery = true) | 27 | @Query(value = "UPDATE `uc_user_tv` SET `vis_user_id` = ?2, `update_time` = ?3 WHERE `id` = ?1", nativeQuery = true) |
26 | Integer updateUserTvVisUserId(Long id, Long visUserId, LocalDateTime now); | 28 | Integer updateUserTvVisUserId(Long id, Long visUserId, LocalDateTime now); |
29 | |||
30 | @Modifying | ||
31 | @Query(value = "UPDATE `uc_user_tv` SET `priority_member_code` = :#{#resources.priorityMemberCode}, `update_time` = now()" + | ||
32 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) | ||
33 | Integer updatePriorityMemberCode(@Param("resources") UserTv resources); | ||
27 | } | 34 | } | ... | ... |
... | @@ -69,7 +69,7 @@ public interface UserTvService { | ... | @@ -69,7 +69,7 @@ public interface UserTvService { |
69 | * @param memberCode | 69 | * @param memberCode |
70 | * @return | 70 | * @return |
71 | */ | 71 | */ |
72 | boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId,String memberCode); | 72 | boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId, String memberCode); |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * | 75 | * |
... | @@ -84,4 +84,11 @@ public interface UserTvService { | ... | @@ -84,4 +84,11 @@ public interface UserTvService { |
84 | * @return | 84 | * @return |
85 | */ | 85 | */ |
86 | UserTvDTO updateUserTvVisUserId(UserTv resources); | 86 | UserTvDTO updateUserTvVisUserId(UserTv resources); |
87 | |||
88 | /** | ||
89 | * | ||
90 | * @param resources | ||
91 | * @return | ||
92 | */ | ||
93 | UserTvDTO doUpdatePriorityMemberCode(UserTv resources); | ||
87 | } | 94 | } | ... | ... |
... | @@ -5,6 +5,7 @@ import com.topdraw.business.module.member.service.MemberService; | ... | @@ -5,6 +5,7 @@ import com.topdraw.business.module.member.service.MemberService; |
5 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 5 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
6 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 6 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
7 | import com.topdraw.business.process.service.impl.UserOperationServiceImpl; | 7 | import com.topdraw.business.process.service.impl.UserOperationServiceImpl; |
8 | import com.topdraw.config.RedisKeyConstants; | ||
8 | import com.topdraw.exception.EntityNotFoundException; | 9 | import com.topdraw.exception.EntityNotFoundException; |
9 | import com.topdraw.exception.GlobeExceptionMsg; | 10 | import com.topdraw.exception.GlobeExceptionMsg; |
10 | import com.topdraw.utils.ValidationUtil; | 11 | import com.topdraw.utils.ValidationUtil; |
... | @@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j; | ... | @@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j; |
16 | import org.apache.commons.lang3.StringUtils; | 17 | import org.apache.commons.lang3.StringUtils; |
17 | import org.springframework.aop.framework.AopContext; | 18 | import org.springframework.aop.framework.AopContext; |
18 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
20 | import org.springframework.cache.annotation.Cacheable; | ||
19 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
20 | import org.springframework.transaction.annotation.Propagation; | 22 | import org.springframework.transaction.annotation.Propagation; |
21 | import org.springframework.transaction.annotation.Transactional; | 23 | import org.springframework.transaction.annotation.Transactional; |
... | @@ -96,6 +98,16 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -96,6 +98,16 @@ public class UserTvServiceImpl implements UserTvService { |
96 | return null; | 98 | return null; |
97 | } | 99 | } |
98 | 100 | ||
101 | @Override | ||
102 | @Transactional(rollbackFor = Exception.class) | ||
103 | public UserTvDTO doUpdatePriorityMemberCode(UserTv resources) { | ||
104 | Integer count = this.userTvRepository.updatePriorityMemberCode(resources); | ||
105 | if (Objects.nonNull(count) && count > 0) { | ||
106 | UserTv userTv = this.userTvRepository.findById(resources.getId()).orElseGet(UserTv::new); | ||
107 | return this.userTvMapper.toDto(userTv); | ||
108 | } | ||
109 | return this.userTvMapper.toDto(resources); | ||
110 | } | ||
99 | 111 | ||
100 | 112 | ||
101 | private MemberDTO findMemberByMemberCode(String memberCode) { | 113 | private MemberDTO findMemberByMemberCode(String memberCode) { |
... | @@ -157,7 +169,9 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -157,7 +169,9 @@ public class UserTvServiceImpl implements UserTvService { |
157 | } | 169 | } |
158 | 170 | ||
159 | @Override | 171 | @Override |
172 | @Cacheable(cacheNames = RedisKeyConstants.cacheUserTvByPlatformAccount, key = "#platformAccount") | ||
160 | public UserTvDTO findByPlatformAccount(String platformAccount) { | 173 | public UserTvDTO findByPlatformAccount(String platformAccount) { |
174 | log.info("从数据库通过大屏账号检索大屏账号信息"); | ||
161 | Optional<UserTv> userTv = this.userTvRepository.findByPlatformAccount(platformAccount); | 175 | Optional<UserTv> userTv = this.userTvRepository.findByPlatformAccount(platformAccount); |
162 | if (userTv.isPresent()) { | 176 | if (userTv.isPresent()) { |
163 | ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId()); | 177 | ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId()); | ... | ... |
... | @@ -29,9 +29,7 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J | ... | @@ -29,9 +29,7 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J |
29 | Optional<UserWeixin> findFirstByMemberId(Long memberId); | 29 | Optional<UserWeixin> findFirstByMemberId(Long memberId); |
30 | 30 | ||
31 | @Modifying | 31 | @Modifying |
32 | @Transactional | 32 | @Query(value = "UPDATE `uc_user_weixin` SET update_time = now(), `status` = :#{#resources.status}" + |
33 | @Query(value = "update `uc_user_weixin` set update_time = :#{#resources.updateTime} " + | 33 | " WHERE `id` = :#{#resources.id}", nativeQuery = true) |
34 | "where appid = :#{#resources.appid} and openid = :#{#resources.openid}", nativeQuery = true) | 34 | Integer updateWeixinStatus(@Param("resources") UserWeixin resource); |
35 | void updateTime(@Param("resources") UserWeixin resources); | ||
36 | |||
37 | } | 35 | } | ... | ... |
... | @@ -31,12 +31,6 @@ public interface UserWeixinService { | ... | @@ -31,12 +31,6 @@ public interface UserWeixinService { |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * | 33 | * |
34 | * @param resources | ||
35 | */ | ||
36 | void updateTime(UserWeixin resources); | ||
37 | |||
38 | /** | ||
39 | * | ||
40 | * @param id | 34 | * @param id |
41 | */ | 35 | */ |
42 | void delete(Long id); | 36 | void delete(Long id); |
... | @@ -87,4 +81,11 @@ public interface UserWeixinService { | ... | @@ -87,4 +81,11 @@ public interface UserWeixinService { |
87 | * @return | 81 | * @return |
88 | */ | 82 | */ |
89 | UserWeixinDTO findFirstByMemberId(Long memberId); | 83 | UserWeixinDTO findFirstByMemberId(Long memberId); |
84 | |||
85 | /** | ||
86 | * | ||
87 | * @param userWeixin | ||
88 | * @return | ||
89 | */ | ||
90 | UserWeixinDTO doUpdateWeixinStatus(UserWeixin userWeixin); | ||
90 | } | 91 | } | ... | ... |
... | @@ -14,6 +14,8 @@ import org.springframework.transaction.annotation.Transactional; | ... | @@ -14,6 +14,8 @@ import org.springframework.transaction.annotation.Transactional; |
14 | import org.springframework.dao.EmptyResultDataAccessException; | 14 | import org.springframework.dao.EmptyResultDataAccessException; |
15 | import org.springframework.util.Assert; | 15 | import org.springframework.util.Assert; |
16 | 16 | ||
17 | import java.util.Objects; | ||
18 | |||
17 | /** | 19 | /** |
18 | * @author XiangHan | 20 | * @author XiangHan |
19 | * @date 2021-12-16 | 21 | * @date 2021-12-16 |
... | @@ -54,11 +56,6 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -54,11 +56,6 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
54 | } | 56 | } |
55 | 57 | ||
56 | @Override | 58 | @Override |
57 | public void updateTime(UserWeixin resources) { | ||
58 | this.userWeixinRepository.updateTime(resources); | ||
59 | } | ||
60 | |||
61 | @Override | ||
62 | @Transactional(rollbackFor = Exception.class) | 59 | @Transactional(rollbackFor = Exception.class) |
63 | public void delete(Long id) { | 60 | public void delete(Long id) { |
64 | Assert.notNull(id, "The given id must not be null!"); | 61 | Assert.notNull(id, "The given id must not be null!"); |
... | @@ -104,4 +101,15 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -104,4 +101,15 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
104 | return this.userWeixinMapper.toDto(userWeixin); | 101 | return this.userWeixinMapper.toDto(userWeixin); |
105 | } | 102 | } |
106 | 103 | ||
104 | @Override | ||
105 | @Transactional(rollbackFor = Exception.class) | ||
106 | public UserWeixinDTO doUpdateWeixinStatus(UserWeixin resource) { | ||
107 | Integer count = this.userWeixinRepository.updateWeixinStatus(resource); | ||
108 | if (Objects.nonNull(count) && count > 0) { | ||
109 | UserWeixin userWeixin = this.userWeixinRepository.findById(resource.getId()).orElseGet(UserWeixin::new); | ||
110 | return this.userWeixinMapper.toDto(userWeixin); | ||
111 | } | ||
112 | return this.userWeixinMapper.toDto(resource); | ||
113 | } | ||
114 | |||
107 | } | 115 | } | ... | ... |
... | @@ -5,6 +5,7 @@ import com.topdraw.business.process.service.ExpOperationService; | ... | @@ -5,6 +5,7 @@ import com.topdraw.business.process.service.ExpOperationService; |
5 | import com.topdraw.common.ResultInfo; | 5 | import com.topdraw.common.ResultInfo; |
6 | import io.swagger.annotations.Api; | 6 | import io.swagger.annotations.Api; |
7 | import io.swagger.annotations.ApiOperation; | 7 | import io.swagger.annotations.ApiOperation; |
8 | import lombok.extern.slf4j.Slf4j; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
9 | import org.springframework.validation.annotation.Validated; | 10 | import org.springframework.validation.annotation.Validated; |
10 | import org.springframework.web.bind.annotation.PostMapping; | 11 | import org.springframework.web.bind.annotation.PostMapping; |
... | @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; | ... | @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; |
14 | 15 | ||
15 | import java.util.Arrays; | 16 | import java.util.Arrays; |
16 | import java.util.List; | 17 | import java.util.List; |
18 | import java.util.Objects; | ||
17 | 19 | ||
18 | /** | 20 | /** |
19 | * @author XiangHan | 21 | * @author XiangHan |
... | @@ -22,14 +24,27 @@ import java.util.List; | ... | @@ -22,14 +24,27 @@ import java.util.List; |
22 | @Api(tags = "成长值管理") | 24 | @Api(tags = "成长值管理") |
23 | @RestController | 25 | @RestController |
24 | @RequestMapping("/uce/expOperation") | 26 | @RequestMapping("/uce/expOperation") |
27 | @Slf4j | ||
25 | public class ExpOperationController { | 28 | public class ExpOperationController { |
26 | 29 | ||
27 | @Autowired | 30 | @Autowired |
28 | private ExpOperationService expOperationService; | 31 | private ExpOperationService expOperationService; |
29 | 32 | ||
30 | @PostMapping(value = "/grantExpByManual") | 33 | @PostMapping(value = "/addExp") |
31 | @ApiOperation("手动发放成长值") | 34 | @ApiOperation("手动发放成长值") |
32 | public ResultInfo grantExpByManual(@Validated @RequestBody TempExp tempExp) { | 35 | public ResultInfo grantExpByManual(@Validated @RequestBody TempExp tempExp) { |
36 | log.info("手动发放成长值,参数 ==>> {}", tempExp); | ||
37 | Long memberId = tempExp.getMemberId(); | ||
38 | if (Objects.isNull(memberId)) { | ||
39 | log.error("发放成长值失败,参数错误,无会员id"); | ||
40 | return ResultInfo.failure("发放成长值失败,参数错误,无会员id"); | ||
41 | } | ||
42 | |||
43 | Long rewardExp = tempExp.getRewardExp(); | ||
44 | if (Objects.isNull(rewardExp) || rewardExp <= 0L) { | ||
45 | log.error("发放成长值失败,参数错误,成长值为空或者小于0 ==>> {}", rewardExp); | ||
46 | return ResultInfo.failure("发放成长值失败,参数错误,成长值为空或者小于0"); | ||
47 | } | ||
33 | List<TempExp> tempExpList = Arrays.asList(tempExp); | 48 | List<TempExp> tempExpList = Arrays.asList(tempExp); |
34 | this.expOperationService.grantExpByManual(tempExpList); | 49 | this.expOperationService.grantExpByManual(tempExpList); |
35 | return ResultInfo.success(); | 50 | return ResultInfo.success(); | ... | ... |
... | @@ -14,6 +14,7 @@ import com.topdraw.exception.BadRequestException; | ... | @@ -14,6 +14,7 @@ import com.topdraw.exception.BadRequestException; |
14 | import io.swagger.annotations.Api; | 14 | import io.swagger.annotations.Api; |
15 | import io.swagger.annotations.ApiOperation; | 15 | import io.swagger.annotations.ApiOperation; |
16 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
17 | import org.apache.commons.lang3.StringUtils; | ||
17 | import org.springframework.beans.BeanUtils; | 18 | import org.springframework.beans.BeanUtils; |
18 | import org.springframework.beans.factory.annotation.Autowired; | 19 | import org.springframework.beans.factory.annotation.Autowired; |
19 | import org.springframework.validation.annotation.Validated; | 20 | import org.springframework.validation.annotation.Validated; |
... | @@ -50,7 +51,7 @@ public class MemberOperationController { | ... | @@ -50,7 +51,7 @@ public class MemberOperationController { |
50 | if (Objects.nonNull(vipExpireTime)) { | 51 | if (Objects.nonNull(vipExpireTime)) { |
51 | member.setVipExpireTime(vipExpireTime); | 52 | member.setVipExpireTime(vipExpireTime); |
52 | } | 53 | } |
53 | this.memberOperationService.update(member); | 54 | this.memberOperationService.doUpdateMemberVipAndVipExpireTime(member); |
54 | return ResultInfo.success(); | 55 | return ResultInfo.success(); |
55 | } | 56 | } |
56 | 57 | ||
... | @@ -59,23 +60,28 @@ public class MemberOperationController { | ... | @@ -59,23 +60,28 @@ public class MemberOperationController { |
59 | @AnonymousAccess | 60 | @AnonymousAccess |
60 | public ResultInfo updateVipByMemberCode(@Validated(value = {UpdateGroup.class}) @RequestBody MemberOperationBean resources) { | 61 | public ResultInfo updateVipByMemberCode(@Validated(value = {UpdateGroup.class}) @RequestBody MemberOperationBean resources) { |
61 | log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources); | 62 | log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources); |
63 | String memberCode = resources.getMemberCode(); | ||
64 | if (StringUtils.isBlank(memberCode)) { | ||
65 | log.error("参数错误,memberCode 不存在"); | ||
66 | return ResultInfo.failure("参数错误,memberCode 不存在"); | ||
67 | } | ||
68 | |||
62 | Integer vip = resources.getVip(); | 69 | Integer vip = resources.getVip(); |
70 | if (Objects.isNull(vip) || vip < 0) { | ||
71 | log.error("参数错误,vip为空或者小于0 , vip ==>> {}", vip); | ||
72 | return ResultInfo.failure("参数错误,vip为空或者小于0"); | ||
73 | } | ||
63 | Timestamp vipExpireTime = resources.getVipExpireTime(); | 74 | Timestamp vipExpireTime = resources.getVipExpireTime(); |
64 | String memberCode = resources.getMemberCode(); | 75 | |
65 | MemberDTO memberDTO = this.memberOperationService.findByCode(memberCode); | ||
66 | 76 | ||
67 | Member member = new Member(); | 77 | Member member = new Member(); |
68 | BeanUtils.copyProperties(memberDTO, member); | 78 | member.setCode(memberCode); |
69 | if (Objects.nonNull(vip)) { | ||
70 | member.setVip(vip); | 79 | member.setVip(vip); |
71 | } | ||
72 | if (Objects.nonNull(vipExpireTime)) { | ||
73 | member.setVipExpireTime(vipExpireTime); | 80 | member.setVipExpireTime(vipExpireTime); |
74 | } | ||
75 | 81 | ||
82 | MemberDTO memberDTO = this.memberOperationService.doUpdateMemberVipAndVipExpireTime(member); | ||
76 | this.createVipHistory(memberDTO.getId(), memberDTO.getCode(), vip, vipExpireTime); | 83 | this.createVipHistory(memberDTO.getId(), memberDTO.getCode(), vip, vipExpireTime); |
77 | 84 | ||
78 | this.memberOperationService.updateMemberVip(member); | ||
79 | return ResultInfo.success(); | 85 | return ResultInfo.success(); |
80 | } | 86 | } |
81 | 87 | ||
... | @@ -93,6 +99,7 @@ public class MemberOperationController { | ... | @@ -93,6 +99,7 @@ public class MemberOperationController { |
93 | @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}") | 99 | @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}") |
94 | @ApiOperation("获取会员基本信息并且检查vip状态") | 100 | @ApiOperation("获取会员基本信息并且检查vip状态") |
95 | @AnonymousAccess | 101 | @AnonymousAccess |
102 | @Deprecated | ||
96 | public IResultInfo getMemberProfileAndCheckVip(@PathVariable(value = "appId") String appId, @PathVariable(value = "memberId") Long memberId) { | 103 | public IResultInfo getMemberProfileAndCheckVip(@PathVariable(value = "appId") String appId, @PathVariable(value = "memberId") Long memberId) { |
97 | MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId); | 104 | MemberProfileDTO memberProfileDTO = this.memberOperationService.getMemberProfileAndCheckVip(memberId, appId); |
98 | return ResultInfo.success(memberProfileDTO); | 105 | return ResultInfo.success(memberProfileDTO); | ... | ... |
... | @@ -49,6 +49,7 @@ public class PointsOperationController { | ... | @@ -49,6 +49,7 @@ public class PointsOperationController { |
49 | @GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}") | 49 | @GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}") |
50 | @ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用") | 50 | @ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用") |
51 | @AnonymousAccess | 51 | @AnonymousAccess |
52 | @Deprecated | ||
52 | public ResultInfo cleanInvalidPointsAndCalculateCurrentPoints(@PathVariable("id") Long id) { | 53 | public ResultInfo cleanInvalidPointsAndCalculateCurrentPoints(@PathVariable("id") Long id) { |
53 | Long aLong = this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(id); | 54 | Long aLong = this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(id); |
54 | return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong); | 55 | return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong); |
... | @@ -59,15 +60,22 @@ public class PointsOperationController { | ... | @@ -59,15 +60,22 @@ public class PointsOperationController { |
59 | @ApiOperation("手动发放积分") | 60 | @ApiOperation("手动发放积分") |
60 | @AnonymousAccess | 61 | @AnonymousAccess |
61 | public ResultInfo addPoints(@Validated @RequestBody TempPoints tempPoints) { | 62 | public ResultInfo addPoints(@Validated @RequestBody TempPoints tempPoints) { |
63 | log.info("手动发放积分,参数 ==>>{} ", tempPoints); | ||
62 | Long memberId = tempPoints.getMemberId(); | 64 | Long memberId = tempPoints.getMemberId(); |
65 | if (Objects.isNull(memberId)) { | ||
66 | log.error("积分发放失败,参数错误,会员id 不存在"); | ||
67 | return ResultInfo.failure("积分发放失败,参数错误"); | ||
68 | } | ||
63 | Long points = tempPoints.getPoints(); | 69 | Long points = tempPoints.getPoints(); |
64 | Assert.notNull(memberId,"memberId can't be null!"); | 70 | if (Objects.isNull(points) || points <= 0L) { |
65 | Assert.notNull(points,"points can't be null!"); | 71 | log.error("积分发放失败,参数错误,积分不存在或者积分小于0"); |
72 | return ResultInfo.failure("积分发放失败,参数错误"); | ||
73 | } | ||
66 | MemberDTO memberDTO = this.memberService.findById(memberId); | 74 | MemberDTO memberDTO = this.memberService.findById(memberId); |
67 | if (Objects.nonNull(memberDTO)) { | 75 | if (Objects.nonNull(memberDTO)) { |
68 | String code = memberDTO.getCode(); | 76 | String code = memberDTO.getCode(); |
69 | Assert.notNull(code,"code can't be null!"); | ||
70 | tempPoints.setMemberCode(code); | 77 | tempPoints.setMemberCode(code); |
78 | tempPoints.setMemberId(memberDTO.getId()); | ||
71 | this.pointsOperationService.grantPointsByManualByTempPoints(tempPoints); | 79 | this.pointsOperationService.grantPointsByManualByTempPoints(tempPoints); |
72 | } | 80 | } |
73 | return ResultInfo.success(); | 81 | return ResultInfo.success(); |
... | @@ -176,7 +184,6 @@ public class PointsOperationController { | ... | @@ -176,7 +184,6 @@ public class PointsOperationController { |
176 | return ResultInfo.success(Arrays.asList(b),description); | 184 | return ResultInfo.success(Arrays.asList(b),description); |
177 | } | 185 | } |
178 | 186 | ||
179 | // @Log("积分兑换商品") | ||
180 | @PostMapping(value = "/consumeItemPoints") | 187 | @PostMapping(value = "/consumeItemPoints") |
181 | @ApiOperation("积分兑换商品") | 188 | @ApiOperation("积分兑换商品") |
182 | @AnonymousAccess | 189 | @AnonymousAccess | ... | ... |
... | @@ -42,11 +42,11 @@ public class TaskOperationController { | ... | @@ -42,11 +42,11 @@ public class TaskOperationController { |
42 | long l = System.currentTimeMillis(); | 42 | long l = System.currentTimeMillis(); |
43 | 43 | ||
44 | // 任务处理 | 44 | // 任务处理 |
45 | this.taskOperationService.dealTask(criteria.getContent()); | 45 | ResultInfo resultInfo = this.taskOperationService.dealTask(criteria.getContent()); |
46 | long l2 = System.currentTimeMillis(); | 46 | long l2 = System.currentTimeMillis(); |
47 | log.info("事件处理,结束,总耗时 ==>> {}", (l2-l)); | 47 | log.info("事件处理,结束,总耗时 ==>> {}", (l2-l)); |
48 | 48 | ||
49 | return ResultInfo.success(); | 49 | return resultInfo; |
50 | } | 50 | } |
51 | 51 | ||
52 | /** | 52 | /** |
... | @@ -99,12 +99,17 @@ public class TaskOperationController { | ... | @@ -99,12 +99,17 @@ public class TaskOperationController { |
99 | @PostMapping(value = "/deleteTask") | 99 | @PostMapping(value = "/deleteTask") |
100 | @ApiOperation("删除任务") | 100 | @ApiOperation("删除任务") |
101 | @AnonymousAccess | 101 | @AnonymousAccess |
102 | public void deleteTask(@RequestBody @Validated Task task) { | 102 | public ResultInfo deleteTask(@RequestBody @Validated Task task) { |
103 | log.info("taskOperation ==>> deleteTask ==>> param ==>> {}", task); | 103 | log.info("taskOperation ==>> deleteTask ==>> param ==>> {}", task); |
104 | 104 | ||
105 | Long id = task.getId(); | 105 | Long id = task.getId(); |
106 | // 删除任务 | 106 | // 删除任务 |
107 | this.taskOperationService.deleteTask(id); | 107 | Integer integer = this.taskOperationService.deleteTask(id); |
108 | if (integer > 1) { | ||
109 | return ResultInfo.success("删除成功"); | ||
110 | } else { | ||
111 | return ResultInfo.failure("删除失败"); | ||
112 | } | ||
108 | } | 113 | } |
109 | 114 | ||
110 | /** | 115 | /** | ... | ... |
... | @@ -34,9 +34,8 @@ public class TaskTemplateOperationController { | ... | @@ -34,9 +34,8 @@ public class TaskTemplateOperationController { |
34 | log.info("taskTemplateOperation ==>> create ==>> param ==>> {}", taskTemplate); | 34 | log.info("taskTemplateOperation ==>> create ==>> param ==>> {}", taskTemplate); |
35 | String code = taskTemplate.getCode(); | 35 | String code = taskTemplate.getCode(); |
36 | Integer type = taskTemplate.getType(); | 36 | Integer type = taskTemplate.getType(); |
37 | TaskTemplateDTO taskTemplateDTO_ = this.taskTemplateOperationService.findByCode(code); | 37 | Long count = this.taskTemplateOperationService.countByCodeAndType(taskTemplate); |
38 | TaskTemplateDTO taskTemplateDTO_1 = this.taskTemplateOperationService.findByType(type); | 38 | if (count < 1) { |
39 | if (Objects.isNull(taskTemplateDTO_.getId()) && Objects.isNull(taskTemplateDTO_1.getId())) { | ||
40 | // 新增任务 | 39 | // 新增任务 |
41 | this.taskTemplateOperationService.create(taskTemplate); | 40 | this.taskTemplateOperationService.create(taskTemplate); |
42 | } | 41 | } | ... | ... |
... | @@ -38,6 +38,7 @@ import org.springframework.util.Assert; | ... | @@ -38,6 +38,7 @@ import org.springframework.util.Assert; |
38 | import org.springframework.validation.annotation.Validated; | 38 | import org.springframework.validation.annotation.Validated; |
39 | import org.springframework.web.bind.annotation.*; | 39 | import org.springframework.web.bind.annotation.*; |
40 | 40 | ||
41 | import javax.validation.constraints.NotNull; | ||
41 | import java.io.IOException; | 42 | import java.io.IOException; |
42 | import java.net.URLDecoder; | 43 | import java.net.URLDecoder; |
43 | import java.sql.Timestamp; | 44 | import java.sql.Timestamp; |
... | @@ -89,7 +90,8 @@ public class UserOperationController { | ... | @@ -89,7 +90,8 @@ public class UserOperationController { |
89 | MemberDTO memberDTO = this.memberService.findById(memberId); | 90 | MemberDTO memberDTO = this.memberService.findById(memberId); |
90 | 91 | ||
91 | Member member = new Member(); | 92 | Member member = new Member(); |
92 | BeanUtils.copyProperties(memberDTO, member); | 93 | member.setId(memberDTO.getId()); |
94 | member.setCode(memberDTO.getCode()); | ||
93 | if (Objects.nonNull(vip)) { | 95 | if (Objects.nonNull(vip)) { |
94 | member.setVip(vip); | 96 | member.setVip(vip); |
95 | } | 97 | } |
... | @@ -97,9 +99,9 @@ public class UserOperationController { | ... | @@ -97,9 +99,9 @@ public class UserOperationController { |
97 | member.setVipExpireTime(vipExpireTime); | 99 | member.setVipExpireTime(vipExpireTime); |
98 | } | 100 | } |
99 | 101 | ||
100 | this.createVipHistory(userId, vip, vipExpireTime); | 102 | this.memberOperationService.doUpdateMemberVipAndVipExpireTime(member); |
101 | 103 | ||
102 | this.memberOperationService.updateMemberVip(member); | 104 | this.createVipHistory(userId, vip, vipExpireTime); |
103 | 105 | ||
104 | return ResultInfo.success(); | 106 | return ResultInfo.success(); |
105 | } | 107 | } |
... | @@ -152,8 +154,12 @@ public class UserOperationController { | ... | @@ -152,8 +154,12 @@ public class UserOperationController { |
152 | SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(data.getContent(), SubscribeBean.class); | 154 | SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(data.getContent(), SubscribeBean.class); |
153 | // 解析参数 | 155 | // 解析参数 |
154 | this.parseSubscribe(subscribeBean); | 156 | this.parseSubscribe(subscribeBean); |
155 | this.userOperationService.subscribe(subscribeBean); | 157 | boolean subscribe = this.userOperationService.subscribe(subscribeBean); |
156 | return ResultInfo.success(); | 158 | if (subscribe) { |
159 | return ResultInfo.success("关注成功"); | ||
160 | } else { | ||
161 | return ResultInfo.failure("关注失败"); | ||
162 | } | ||
157 | } | 163 | } |
158 | 164 | ||
159 | /** | 165 | /** |
... | @@ -266,6 +272,16 @@ public class UserOperationController { | ... | @@ -266,6 +272,16 @@ public class UserOperationController { |
266 | public ResultInfo minaBind(@Validated(value = {BindGroup.class}) @RequestBody BindBean resources) { | 272 | public ResultInfo minaBind(@Validated(value = {BindGroup.class}) @RequestBody BindBean resources) { |
267 | log.info("UserOperationController ==> appletBind ==>> param ==> [{}]",resources); | 273 | log.info("UserOperationController ==> appletBind ==>> param ==> [{}]",resources); |
268 | 274 | ||
275 | Long memberId = resources.getMemberId(); | ||
276 | if (Objects.isNull(memberId)) { | ||
277 | return ResultInfo.failure("参数错误,memberId 不存在"); | ||
278 | } | ||
279 | |||
280 | String platformAccount = resources.getPlatformAccount(); | ||
281 | if (StringUtils.isBlank(platformAccount)) { | ||
282 | return ResultInfo.failure("参数错误,大屏账号不存在"); | ||
283 | } | ||
284 | |||
269 | boolean result = this.userOperationService.minaBind(resources); | 285 | boolean result = this.userOperationService.minaBind(resources); |
270 | return ResultInfo.success(result); | 286 | return ResultInfo.success(result); |
271 | } | 287 | } |
... | @@ -276,8 +292,17 @@ public class UserOperationController { | ... | @@ -276,8 +292,17 @@ public class UserOperationController { |
276 | public ResultInfo minaUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) { | 292 | public ResultInfo minaUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) { |
277 | log.info("UserOperationController ==> minaUnbind ==>> param ==> [{}]", weixinUnBindBean); | 293 | log.info("UserOperationController ==> minaUnbind ==>> param ==> [{}]", weixinUnBindBean); |
278 | 294 | ||
279 | this.userOperationService.minaUnbind(weixinUnBindBean); | 295 | Long memberId = weixinUnBindBean.getMemberId(); |
280 | return ResultInfo.success(); | 296 | if (Objects.isNull(memberId)) { |
297 | log.error("小屏解绑失败,参数错误,memberId不存在"); | ||
298 | return ResultInfo.failure("参数错误,会员id不存在"); | ||
299 | } | ||
300 | boolean b = this.userOperationService.minaUnbind(weixinUnBindBean); | ||
301 | if (b) { | ||
302 | return ResultInfo.success("解绑成功"); | ||
303 | } else { | ||
304 | return ResultInfo.failure("解绑失败"); | ||
305 | } | ||
281 | } | 306 | } |
282 | 307 | ||
283 | /** | 308 | /** |
... | @@ -293,12 +318,18 @@ public class UserOperationController { | ... | @@ -293,12 +318,18 @@ public class UserOperationController { |
293 | public ResultInfo memberPreprocess(@RequestBody String data) { | 318 | public ResultInfo memberPreprocess(@RequestBody String data) { |
294 | 319 | ||
295 | log.info("UserOperationController ==> saveUserInfo ==>> param ==>> [{}]",data); | 320 | log.info("UserOperationController ==> saveUserInfo ==>> param ==>> [{}]",data); |
296 | Assert.notNull(data, "用户数据不可为空"); | 321 | if (StringUtils.isBlank(data)) { |
322 | log.error("预存大小屏账号信息失败,无参数"); | ||
323 | return ResultInfo.failure("参数错误"); | ||
324 | } | ||
297 | 325 | ||
298 | JSONObject json = JSONObject.parseObject(data); | 326 | JSONObject json = JSONObject.parseObject(data); |
299 | 327 | ||
300 | String unionid = json.getString("unionid"); | 328 | String unionid = json.getString("unionid"); |
301 | Assert.state(StrUtil.isNotBlank(unionid), "unionid不可为空"); | 329 | if (StringUtils.isBlank(unionid)) { |
330 | log.error("预存大小屏账号信息失败,参数错误,unionid不存在"); | ||
331 | return ResultInfo.failure("参数错误,unionid不存在"); | ||
332 | } | ||
302 | 333 | ||
303 | 334 | ||
304 | List<Object> resultList = new ArrayList<>(); | 335 | List<Object> resultList = new ArrayList<>(); |
... | @@ -471,8 +502,10 @@ public class UserOperationController { | ... | @@ -471,8 +502,10 @@ public class UserOperationController { |
471 | throw new BadRequestException(GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL); | 502 | throw new BadRequestException(GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL); |
472 | } | 503 | } |
473 | 504 | ||
474 | this.userOperationService.tvUnbind(resources); | 505 | boolean b = this.userOperationService.tvUnbind(resources); |
475 | return ResultInfo.success(); | 506 | if (b) { |
507 | return ResultInfo.success("解绑成功"); | ||
508 | } else return ResultInfo.failure("解绑失败"); | ||
476 | } | 509 | } |
477 | 510 | ||
478 | @RequestMapping(value = "/changeMainAccount") | 511 | @RequestMapping(value = "/changeMainAccount") |
... | @@ -493,9 +526,9 @@ public class UserOperationController { | ... | @@ -493,9 +526,9 @@ public class UserOperationController { |
493 | UserTv userTv = new UserTv(); | 526 | UserTv userTv = new UserTv(); |
494 | userTv.setMemberCode(memberCode); | 527 | userTv.setMemberCode(memberCode); |
495 | userTv.setPlatformAccount(platformAccount); | 528 | userTv.setPlatformAccount(platformAccount); |
496 | this.userOperationService.changeMainAccount(userTv); | 529 | boolean b = this.userOperationService.changeMainAccount(userTv); |
497 | 530 | ||
498 | return ResultInfo.success(); | 531 | return ResultInfo.success(b); |
499 | } | 532 | } |
500 | 533 | ||
501 | @PostMapping(value = "/deleteAllCollection") | 534 | @PostMapping(value = "/deleteAllCollection") | ... | ... |
... | @@ -13,13 +13,6 @@ import java.util.List; | ... | @@ -13,13 +13,6 @@ import java.util.List; |
13 | public interface PointsOperationService { | 13 | public interface PointsOperationService { |
14 | 14 | ||
15 | /** | 15 | /** |
16 | * 手动发放积分 | ||
17 | * @param memberId 会员id | ||
18 | * @param tempPoints 积分详情 | ||
19 | */ | ||
20 | void grantPointsByManual(Long memberId , TempPoints tempPoints); | ||
21 | |||
22 | /** | ||
23 | * | 16 | * |
24 | * @param tempPoints | 17 | * @param tempPoints |
25 | */ | 18 | */ |
... | @@ -44,5 +37,6 @@ public interface PointsOperationService { | ... | @@ -44,5 +37,6 @@ public interface PointsOperationService { |
44 | * @param memberId | 37 | * @param memberId |
45 | * @return | 38 | * @return |
46 | */ | 39 | */ |
40 | @Deprecated | ||
47 | Long cleanInvalidPointsAndCalculateCurrentPoints(Long memberId); | 41 | Long cleanInvalidPointsAndCalculateCurrentPoints(Long memberId); |
48 | } | 42 | } | ... | ... |
1 | package com.topdraw.business.process.service; | 1 | package com.topdraw.business.process.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.rights.history.domain.RightsHistory; | 3 | import com.topdraw.business.module.rights.history.domain.RightsHistory; |
4 | import com.topdraw.business.process.domian.constant.RightType; | 4 | import com.topdraw.business.module.rights.constant.RightType; |
5 | 5 | ||
6 | import java.util.List; | 6 | import java.util.List; |
7 | import java.util.Map; | 7 | import java.util.Map; | ... | ... |
... | @@ -11,8 +11,18 @@ import com.topdraw.common.ResultInfo; | ... | @@ -11,8 +11,18 @@ import com.topdraw.common.ResultInfo; |
11 | */ | 11 | */ |
12 | public interface TaskOperationService { | 12 | public interface TaskOperationService { |
13 | 13 | ||
14 | /** | ||
15 | * | ||
16 | * @param id | ||
17 | * @return | ||
18 | */ | ||
14 | TaskDTO findById(Long id); | 19 | TaskDTO findById(Long id); |
15 | 20 | ||
21 | /** | ||
22 | * | ||
23 | * @param code | ||
24 | * @return | ||
25 | */ | ||
16 | TaskDTO findByCode(String code); | 26 | TaskDTO findByCode(String code); |
17 | 27 | ||
18 | /** | 28 | /** |
... | @@ -26,25 +36,25 @@ public interface TaskOperationService { | ... | @@ -26,25 +36,25 @@ public interface TaskOperationService { |
26 | * | 36 | * |
27 | * @param task | 37 | * @param task |
28 | */ | 38 | */ |
29 | void createTask(Task task); | 39 | TaskDTO createTask(Task task); |
30 | 40 | ||
31 | /** | 41 | /** |
32 | * | 42 | * |
33 | * @param task | 43 | * @param task |
34 | */ | 44 | */ |
35 | void updateTask(Task task); | 45 | TaskDTO updateTask(Task task); |
36 | 46 | ||
37 | /** | 47 | /** |
38 | * | 48 | * |
39 | * @param task | 49 | * @param task |
40 | */ | 50 | */ |
41 | void deleteTask(Task task); | 51 | Integer deleteTask(Task task); |
42 | 52 | ||
43 | /** | 53 | /** |
44 | * | 54 | * |
45 | * @param id | 55 | * @param id |
46 | */ | 56 | */ |
47 | void deleteTask(Long id); | 57 | Integer deleteTask(Long id); |
48 | 58 | ||
49 | /** | 59 | /** |
50 | * | 60 | * |
... | @@ -54,6 +64,4 @@ public interface TaskOperationService { | ... | @@ -54,6 +64,4 @@ public interface TaskOperationService { |
54 | */ | 64 | */ |
55 | boolean createPoint2ChongQing(String platformAccount, Long points); | 65 | boolean createPoint2ChongQing(String platformAccount, Long points); |
56 | 66 | ||
57 | |||
58 | |||
59 | } | 67 | } | ... | ... |
... | @@ -43,6 +43,13 @@ public interface TaskTemplateOperationService { | ... | @@ -43,6 +43,13 @@ public interface TaskTemplateOperationService { |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * | 45 | * |
46 | * @param taskTemplate | ||
47 | * @return | ||
48 | */ | ||
49 | Long countByCodeAndType(TaskTemplate taskTemplate); | ||
50 | |||
51 | /** | ||
52 | * | ||
46 | * @param id | 53 | * @param id |
47 | * @return | 54 | * @return |
48 | */ | 55 | */ | ... | ... |
... | @@ -52,13 +52,13 @@ public interface UserOperationService { | ... | @@ -52,13 +52,13 @@ public interface UserOperationService { |
52 | * 大屏解绑 | 52 | * 大屏解绑 |
53 | * @param userTv | 53 | * @param userTv |
54 | */ | 54 | */ |
55 | void tvUnbind(TvUnBindBean userTv); | 55 | boolean tvUnbind(TvUnBindBean userTv); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * 大屏切换主账户(会员) | 58 | * 大屏切换主账户(会员) |
59 | * @param userTv | 59 | * @param userTv |
60 | */ | 60 | */ |
61 | void changeMainAccount(UserTv userTv); | 61 | boolean changeMainAccount(UserTv userTv); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * 微信公众号关注 | 64 | * 微信公众号关注 |
... | @@ -114,20 +114,6 @@ public interface UserOperationService { | ... | @@ -114,20 +114,6 @@ public interface UserOperationService { |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * | 116 | * |
117 | * @param memberCode | ||
118 | * @param platformAccount | ||
119 | */ | ||
120 | void bind(String memberCode, String platformAccount); | ||
121 | |||
122 | /** | ||
123 | * | ||
124 | * @param memberDTO | ||
125 | * @param userTvDTO | ||
126 | */ | ||
127 | void bind(MemberDTO memberDTO, UserTvDTO userTvDTO); | ||
128 | |||
129 | /** | ||
130 | * | ||
131 | * @param memberDTO | 117 | * @param memberDTO |
132 | * @param platformAccount | 118 | * @param platformAccount |
133 | * @return | 119 | * @return |
... | @@ -152,7 +138,7 @@ public interface UserOperationService { | ... | @@ -152,7 +138,7 @@ public interface UserOperationService { |
152 | * 小屏解绑 | 138 | * 小屏解绑 |
153 | * @param weixinUnBindBean | 139 | * @param weixinUnBindBean |
154 | */ | 140 | */ |
155 | void minaUnbind(WeixinUnBindBean weixinUnBindBean); | 141 | boolean minaUnbind(WeixinUnBindBean weixinUnBindBean); |
156 | 142 | ||
157 | /** | 143 | /** |
158 | * | 144 | * | ... | ... |
... | @@ -12,6 +12,7 @@ import com.topdraw.business.process.service.CouponOperationService; | ... | @@ -12,6 +12,7 @@ import com.topdraw.business.process.service.CouponOperationService; |
12 | import com.topdraw.business.process.service.member.MemberOperationService; | 12 | import com.topdraw.business.process.service.member.MemberOperationService; |
13 | import com.topdraw.business.process.domian.TempCoupon; | 13 | import com.topdraw.business.process.domian.TempCoupon; |
14 | import com.topdraw.business.process.service.RightsOperationService; | 14 | import com.topdraw.business.process.service.RightsOperationService; |
15 | import com.topdraw.config.RedisKeyConstants; | ||
15 | import com.topdraw.util.TimestampUtil; | 16 | import com.topdraw.util.TimestampUtil; |
16 | import com.topdraw.utils.RedisUtils; | 17 | import com.topdraw.utils.RedisUtils; |
17 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
... | @@ -73,7 +74,6 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -73,7 +74,6 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
73 | } | 74 | } |
74 | } | 75 | } |
75 | 76 | ||
76 | |||
77 | /** | 77 | /** |
78 | * 优惠券领取历史记录表 | 78 | * 优惠券领取历史记录表 |
79 | * | 79 | * |
... | @@ -92,11 +92,10 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -92,11 +92,10 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
92 | * @param tempCoupon 账号id | 92 | * @param tempCoupon 账号id |
93 | */ | 93 | */ |
94 | private void refreshMemberCoupon(TempCoupon tempCoupon) { | 94 | private void refreshMemberCoupon(TempCoupon tempCoupon) { |
95 | // Long userId = tempCoupon.getUserId(); | ||
96 | Long memberId = tempCoupon.getMemberId(); | 95 | Long memberId = tempCoupon.getMemberId(); |
97 | Integer rightsAmount = tempCoupon.getRightsAmount(); | 96 | Integer rightsAmount = tempCoupon.getRightsAmount(); |
98 | try { | 97 | try { |
99 | 98 | this.redisUtils.doLock(RedisKeyConstants.updateCacheCouponByMemberId + memberId.toString()); | |
100 | // 1.历史总优惠券数量 | 99 | // 1.历史总优惠券数量 |
101 | Long historyCouponCount = this.getTotalHistoryCoupon(memberId); | 100 | Long historyCouponCount = this.getTotalHistoryCoupon(memberId); |
102 | // 1.当前总优惠券数量 | 101 | // 1.当前总优惠券数量 |
... | @@ -107,15 +106,12 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -107,15 +106,12 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
107 | Long expireSoonCouponCount = this.getTotalExpireSoonCoupon(memberId, EXPIRE_FACTOR_DAY); | 106 | Long expireSoonCouponCount = this.getTotalExpireSoonCoupon(memberId, EXPIRE_FACTOR_DAY); |
108 | // 4.当前优惠券数量 = 总优惠券-已过期的优惠券 | 107 | // 4.当前优惠券数量 = 总优惠券-已过期的优惠券 |
109 | Long currentCoupon = this.getCurrentCoupon(totalCouponCount, expireCouponCount); | 108 | Long currentCoupon = this.getCurrentCoupon(totalCouponCount, expireCouponCount); |
110 | |||
111 | this.redisUtils.doLock("right::member::id::" + memberId.toString()); | ||
112 | // 5.更新用户信息(优惠券数量、即将过期的优惠券数量) | 109 | // 5.更新用户信息(优惠券数量、即将过期的优惠券数量) |
113 | this.doUpdateMemberInfo(memberId,currentCoupon,expireSoonCouponCount); | 110 | this.doUpdateMemberInfo(memberId,currentCoupon,expireSoonCouponCount); |
114 | } catch (Exception e) { | 111 | } catch (Exception e) { |
115 | e.printStackTrace(); | 112 | log.error(e.getMessage()); |
116 | throw e; | ||
117 | } finally { | 113 | } finally { |
118 | this.redisUtils.doUnLock("right::member::id::" + memberId.toString()); | 114 | this.redisUtils.doUnLock(RedisKeyConstants.updateCacheCouponByMemberId + memberId.toString()); |
119 | } | 115 | } |
120 | } | 116 | } |
121 | 117 | ||
... | @@ -134,7 +130,6 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -134,7 +130,6 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
134 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); | 130 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); |
135 | 131 | ||
136 | Member member = new Member(); | 132 | Member member = new Member(); |
137 | // BeanUtils.copyProperties(memberDTO,member); | ||
138 | member.setId(memberDTO.getId()); | 133 | member.setId(memberDTO.getId()); |
139 | member.setCode(memberDTO.getCode()); | 134 | member.setCode(memberDTO.getCode()); |
140 | member.setCouponAmount(currentCoupon); | 135 | member.setCouponAmount(currentCoupon); | ... | ... |
... | @@ -11,6 +11,7 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; | ... | @@ -11,6 +11,7 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; |
11 | import com.topdraw.business.process.service.ExpOperationService; | 11 | import com.topdraw.business.process.service.ExpOperationService; |
12 | import com.topdraw.business.process.service.member.MemberOperationService; | 12 | import com.topdraw.business.process.service.member.MemberOperationService; |
13 | import com.topdraw.business.process.domian.TempExp; | 13 | import com.topdraw.business.process.domian.TempExp; |
14 | import com.topdraw.config.RedisKeyConstants; | ||
14 | import com.topdraw.util.IdWorker; | 15 | import com.topdraw.util.IdWorker; |
15 | import com.topdraw.util.TimestampUtil; | 16 | import com.topdraw.util.TimestampUtil; |
16 | import com.topdraw.utils.RedisUtils; | 17 | import com.topdraw.utils.RedisUtils; |
... | @@ -76,6 +77,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -76,6 +77,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
76 | */ | 77 | */ |
77 | private void refresh(TempExp tempExp) { | 78 | private void refresh(TempExp tempExp) { |
78 | try { | 79 | try { |
80 | this.redisUtils.doLock(RedisKeyConstants.updateCacheExpByMemberId + tempExp.getMemberId()); | ||
79 | 81 | ||
80 | // 原始经验值 | 82 | // 原始经验值 |
81 | long originExp = this.getExpByMemberId(tempExp); | 83 | long originExp = this.getExpByMemberId(tempExp); |
... | @@ -84,7 +86,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -84,7 +86,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
84 | long totalExp = this.calculateTotalExp(originExp, tempExp); | 86 | long totalExp = this.calculateTotalExp(originExp, tempExp); |
85 | log.info("----计算总经验值 ==>> {}", totalExp); | 87 | log.info("----计算总经验值 ==>> {}", totalExp); |
86 | 88 | ||
87 | this.redisUtils.doLock("right::member::id::" + tempExp.getMemberId()); | ||
88 | // 2.更新成长值与等级 | 89 | // 2.更新成长值与等级 |
89 | log.info("----更新会员经验值与对应等级 ==>> {}", totalExp); | 90 | log.info("----更新会员经验值与对应等级 ==>> {}", totalExp); |
90 | this.refreshMemberExpAndLevel(tempExp, totalExp); | 91 | this.refreshMemberExpAndLevel(tempExp, totalExp); |
... | @@ -93,10 +94,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -93,10 +94,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
93 | this.doInsertExpDetail(tempExp, originExp, totalExp); | 94 | this.doInsertExpDetail(tempExp, originExp, totalExp); |
94 | 95 | ||
95 | } catch (Exception e) { | 96 | } catch (Exception e) { |
96 | e.printStackTrace(); | 97 | log.error("成长值发放失败,"+e.getMessage()); |
97 | throw e; | ||
98 | } finally { | 98 | } finally { |
99 | this.redisUtils.doUnLock("right::member::id::" + tempExp.getMemberId()); | 99 | this.redisUtils.doUnLock(RedisKeyConstants.updateCacheExpByMemberId + tempExp.getMemberId()); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
... | @@ -148,7 +148,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -148,7 +148,6 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
148 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); | 148 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); |
149 | 149 | ||
150 | Member member = new Member(); | 150 | Member member = new Member(); |
151 | // BeanUtils.copyProperties(memberDTO, member); | ||
152 | member.setId(memberDTO.getId()); | 151 | member.setId(memberDTO.getId()); |
153 | member.setCode(memberDTO.getCode()); | 152 | member.setCode(memberDTO.getCode()); |
154 | member.setExp(totalExp); | 153 | member.setExp(totalExp); | ... | ... |
... | @@ -17,6 +17,8 @@ import com.topdraw.business.process.service.dto.CustomPointsResult; | ... | @@ -17,6 +17,8 @@ import com.topdraw.business.process.service.dto.CustomPointsResult; |
17 | import com.topdraw.business.process.service.member.MemberOperationService; | 17 | import com.topdraw.business.process.service.member.MemberOperationService; |
18 | import com.topdraw.business.process.service.PointsOperationService; | 18 | import com.topdraw.business.process.service.PointsOperationService; |
19 | import com.topdraw.business.process.domian.TempPoints; | 19 | import com.topdraw.business.process.domian.TempPoints; |
20 | import com.topdraw.config.RedisKeyConstants; | ||
21 | import com.topdraw.mq.producer.MessageProducer; | ||
20 | import com.topdraw.util.DateUtil; | 22 | import com.topdraw.util.DateUtil; |
21 | import com.topdraw.util.IdWorker; | 23 | import com.topdraw.util.IdWorker; |
22 | import com.topdraw.util.TimestampUtil; | 24 | import com.topdraw.util.TimestampUtil; |
... | @@ -83,26 +85,13 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -83,26 +85,13 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
83 | public void asyncPointsDetail(PointsDetail pointsDetail) {} | 85 | public void asyncPointsDetail(PointsDetail pointsDetail) {} |
84 | 86 | ||
85 | @Override | 87 | @Override |
86 | @Transactional(rollbackFor = Exception.class) | ||
87 | public void grantPointsByManual(Long memberId, TempPoints tempPoints){ | ||
88 | if (Objects.nonNull(tempPoints) && Objects.nonNull(tempPoints.getPoints())) { | ||
89 | MemberDTO memberDTo = this.memberService.findById(memberId); | ||
90 | String memberCode = memberDTo.getCode(); | ||
91 | tempPoints.setMemberCode(memberCode); | ||
92 | this.refresh(tempPoints); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | @Override | ||
97 | public void grantPointsByManualByTempPoints(TempPoints tempPoints) { | 88 | public void grantPointsByManualByTempPoints(TempPoints tempPoints) { |
98 | if (Objects.nonNull(tempPoints) && Objects.nonNull(tempPoints.getPoints())) { | ||
99 | Timestamp expireTime = tempPoints.getExpireTime(); | 89 | Timestamp expireTime = tempPoints.getExpireTime(); |
100 | if (Objects.isNull(expireTime)){ | 90 | if (Objects.isNull(expireTime)){ |
101 | tempPoints.setExpireTime(TimestampUtil.localDateTime2Timestamp(DateUtil.getLastDateTimeSecondYear())); | 91 | tempPoints.setExpireTime(TimestampUtil.localDateTime2Timestamp(DateUtil.getLastDateTimeSecondYear())); |
102 | } | 92 | } |
103 | this.refresh(tempPoints); | 93 | this.refresh(tempPoints); |
104 | } | 94 | } |
105 | } | ||
106 | 95 | ||
107 | /** | 96 | /** |
108 | * 积分消耗 | 97 | * 积分消耗 |
... | @@ -118,7 +107,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -118,7 +107,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
118 | Long memberId = tempPoints.getMemberId(); | 107 | Long memberId = tempPoints.getMemberId(); |
119 | 108 | ||
120 | try { | 109 | try { |
121 | this.redisUtils.doLock("member::id::" + memberId.toString()); | 110 | this.redisUtils.doLock(RedisKeyConstants.cacheMemberById + memberId.toString()); |
122 | //1.删除过期的积分 | 111 | //1.删除过期的积分 |
123 | this.cleanInvalidAvailablePointsByMemberId(memberId); | 112 | this.cleanInvalidAvailablePointsByMemberId(memberId); |
124 | log.info("删除过期的积分 ==>> cleanInvalidAvailablePointsByMemberId ==>> "); | 113 | log.info("删除过期的积分 ==>> cleanInvalidAvailablePointsByMemberId ==>> "); |
... | @@ -153,11 +142,10 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -153,11 +142,10 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
153 | customPointsResult.setPoint(currentPoints); | 142 | customPointsResult.setPoint(currentPoints); |
154 | } | 143 | } |
155 | 144 | ||
156 | }catch (Exception e) { | 145 | } catch (Exception e) { |
157 | e.printStackTrace(); | 146 | log.error("消耗积分失败,"+e.getMessage()); |
158 | throw e; | ||
159 | } finally { | 147 | } finally { |
160 | this.redisUtils.doUnLock("member::id::" + memberId.toString()); | 148 | this.redisUtils.doUnLock(RedisKeyConstants.cacheMemberById + memberId.toString()); |
161 | } | 149 | } |
162 | 150 | ||
163 | return customPointsResult; | 151 | return customPointsResult; |
... | @@ -445,7 +433,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -445,7 +433,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
445 | Long memberId = tempPoints.getMemberId(); | 433 | Long memberId = tempPoints.getMemberId(); |
446 | log.info("----------->> 会员id ===>>>>" + memberId); | 434 | log.info("----------->> 会员id ===>>>>" + memberId); |
447 | try { | 435 | try { |
448 | 436 | this.redisUtils.doLock(RedisKeyConstants.updateCachePointsByMemberId + memberId.toString()); | |
449 | // 1.可用总积分 | 437 | // 1.可用总积分 |
450 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); | 438 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); |
451 | log.info("----------->> 获取会员当前可用总积分 --->>>> {}", currentPoints); | 439 | log.info("----------->> 获取会员当前可用总积分 --->>>> {}", currentPoints); |
... | @@ -466,8 +454,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -466,8 +454,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
466 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); | 454 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); |
467 | log.info("----------->> 即将过期的积分 ------->>>>> {}", soonExpirePoints); | 455 | log.info("----------->> 即将过期的积分 ------->>>>> {}", soonExpirePoints); |
468 | 456 | ||
469 | this.redisUtils.doLock("right::member::id::" + memberId.toString()); | ||
470 | |||
471 | // 6.更新会员的总积分 | 457 | // 6.更新会员的总积分 |
472 | log.info("----------->> 更新会员的总积分 ------->>>>> 总积分--->>> {}", totalPoints); | 458 | log.info("----------->> 更新会员的总积分 ------->>>>> 总积分--->>> {}", totalPoints); |
473 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); | 459 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); |
... | @@ -476,7 +462,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -476,7 +462,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
476 | e.printStackTrace(); | 462 | e.printStackTrace(); |
477 | throw e; | 463 | throw e; |
478 | } finally { | 464 | } finally { |
479 | this.redisUtils.doUnLock("right::member::id::" + memberId.toString()); | 465 | this.redisUtils.doUnLock(RedisKeyConstants.updateCachePointsByMemberId + memberId.toString()); |
480 | } | 466 | } |
481 | } | 467 | } |
482 | 468 | ||
... | @@ -530,7 +516,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -530,7 +516,6 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
530 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); | 516 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); |
531 | 517 | ||
532 | Member member = new Member(); | 518 | Member member = new Member(); |
533 | // BeanUtils.copyProperties(memberDTO, member); | ||
534 | member.setId(memberDTO.getId()); | 519 | member.setId(memberDTO.getId()); |
535 | member.setCode(memberDTO.getCode()); | 520 | member.setCode(memberDTO.getCode()); |
536 | member.setPoints(Objects.nonNull(currentPoints) ? currentPoints:0); | 521 | member.setPoints(Objects.nonNull(currentPoints) ? currentPoints:0); |
... | @@ -541,7 +526,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -541,7 +526,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
541 | 526 | ||
542 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncMemberPoint(member); | 527 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncMemberPoint(member); |
543 | } catch (Exception e){ | 528 | } catch (Exception e){ |
544 | throw e; | 529 | log.error("同步会员积分异常,"+e.getMessage()); |
545 | } | 530 | } |
546 | } | 531 | } |
547 | 532 | ... | ... |
... | @@ -6,7 +6,8 @@ import com.topdraw.business.module.rights.history.domain.RightsHistory; | ... | @@ -6,7 +6,8 @@ import com.topdraw.business.module.rights.history.domain.RightsHistory; |
6 | import com.topdraw.business.module.rights.history.service.RightsHistoryService; | 6 | import com.topdraw.business.module.rights.history.service.RightsHistoryService; |
7 | import com.topdraw.business.module.rights.service.RightsService; | 7 | import com.topdraw.business.module.rights.service.RightsService; |
8 | import com.topdraw.business.module.rights.service.dto.RightsDTO; | 8 | import com.topdraw.business.module.rights.service.dto.RightsDTO; |
9 | import com.topdraw.business.process.domian.constant.RightType; | 9 | import com.topdraw.business.module.rights.constant.RightType; |
10 | import com.topdraw.business.module.rights.constant.RightTypeConstants; | ||
10 | import com.topdraw.business.process.service.CouponOperationService; | 11 | import com.topdraw.business.process.service.CouponOperationService; |
11 | import com.topdraw.business.process.service.ExpOperationService; | 12 | import com.topdraw.business.process.service.ExpOperationService; |
12 | import com.topdraw.business.process.service.PointsOperationService; | 13 | import com.topdraw.business.process.service.PointsOperationService; |
... | @@ -14,8 +15,6 @@ import com.topdraw.business.process.service.RightsOperationService; | ... | @@ -14,8 +15,6 @@ import com.topdraw.business.process.service.RightsOperationService; |
14 | import com.topdraw.business.process.domian.*; | 15 | import com.topdraw.business.process.domian.*; |
15 | import com.topdraw.util.TimestampUtil; | 16 | import com.topdraw.util.TimestampUtil; |
16 | import lombok.extern.slf4j.Slf4j; | 17 | import lombok.extern.slf4j.Slf4j; |
17 | import org.slf4j.Logger; | ||
18 | import org.slf4j.LoggerFactory; | ||
19 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
20 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | 19 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
21 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
... | @@ -24,7 +23,6 @@ import org.springframework.util.StringUtils; | ... | @@ -24,7 +23,6 @@ import org.springframework.util.StringUtils; |
24 | 23 | ||
25 | import java.sql.Timestamp; | 24 | import java.sql.Timestamp; |
26 | import java.util.*; | 25 | import java.util.*; |
27 | import java.util.concurrent.ThreadPoolExecutor; | ||
28 | 26 | ||
29 | /** | 27 | /** |
30 | * 权益处理 | 28 | * 权益处理 |
... | @@ -148,54 +146,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -148,54 +146,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
148 | * @param tempRightsMap | 146 | * @param tempRightsMap |
149 | */ | 147 | */ |
150 | private void refresh(Map<RightType, Object> tempRightsMap) { | 148 | private void refresh(Map<RightType, Object> tempRightsMap) { |
151 | /*FutureTask<Map<Long,Long>> futureTask1 = new FutureTask(()->{ | ||
152 | log.info(Thread.currentThread().getName() + "=========>> start"); | ||
153 | // 积分 | ||
154 | this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | ||
155 | log.info(Thread.currentThread().getName() + "=========>>grantPoint end"); | ||
156 | // 成长值 | ||
157 | // this.grantExp((List<TempExp>) tempRightsMap.get(RightType.EXP)); | ||
158 | // 优惠券 | ||
159 | // this.grantCoupon((List<TempCoupon>) tempRightsMap.get(RightType.COUPON)); | ||
160 | return null; | ||
161 | }); | ||
162 | FutureTask<Map<Long,Long>> futureTask2 = new FutureTask(()->{ | ||
163 | // 积分 | ||
164 | // this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | ||
165 | // 成长值 | ||
166 | this.grantExp((List<TempExp>) tempRightsMap.get(RightType.EXP)); | ||
167 | // 优惠券 | ||
168 | // this.grantCoupon((List<TempCoupon>) tempRightsMap.get(RightType.COUPON)); | ||
169 | return null; | ||
170 | }); | ||
171 | FutureTask<Map<Long,Long>> futureTask3 = new FutureTask(()->{ | ||
172 | // 积分 | ||
173 | // this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | ||
174 | // 成长值 | ||
175 | // this.grantExp((List<TempExp>) tempRightsMap.get(RightType.EXP)); | ||
176 | // 优惠券 | ||
177 | this.grantCoupon((List<TempCoupon>) tempRightsMap.get(RightType.COUPON)); | ||
178 | return null; | ||
179 | }); | ||
180 | this.threadPoolTaskExecutor.execute(futureTask1); | ||
181 | this.threadPoolTaskExecutor.execute(futureTask2); | ||
182 | this.threadPoolTaskExecutor.execute(futureTask3);*/ | ||
183 | /*this.threadPoolTaskExecutor.execute(() -> { | ||
184 | // 积分 | ||
185 | this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | ||
186 | // 成长值 | ||
187 | this.grantExp((List<TempExp>) tempRightsMap.get(RightType.EXP)); | ||
188 | // 优惠券 | ||
189 | this.grantCoupon((List<TempCoupon>) tempRightsMap.get(RightType.COUPON)); | ||
190 | });*/ | ||
191 | |||
192 | 149 | ||
193 | /*this.threadPoolTaskExecutor.execute(() -> { | ||
194 | log.info(Thread.currentThread().getName() + "=========>> start"); | ||
195 | // 积分 | ||
196 | this.grantPoint((List<TempPoints>) tempRightsMap.get(RightType.POINTS)); | ||
197 | log.info(Thread.currentThread().getName() + "=========>> end"); | ||
198 | });*/ | ||
199 | this.threadPoolTaskExecutor.execute(() -> { | 150 | this.threadPoolTaskExecutor.execute(() -> { |
200 | List<TempPoints> tempPointsList = (List<TempPoints>) tempRightsMap.get(RightType.POINTS); | 151 | List<TempPoints> tempPointsList = (List<TempPoints>) tempRightsMap.get(RightType.POINTS); |
201 | if (!CollectionUtils.isEmpty(tempPointsList)) { | 152 | if (!CollectionUtils.isEmpty(tempPointsList)) { |
... | @@ -252,7 +203,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -252,7 +203,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
252 | 203 | ||
253 | // 活动机会 | 204 | // 活动机会 |
254 | case ACTIVITYCHANCE: | 205 | case ACTIVITYCHANCE: |
255 | 206 | // TODO MOSS 增加活动机会接口 | |
256 | break; | 207 | break; |
257 | 208 | ||
258 | // 积分商品 | 209 | // 积分商品 |
... | @@ -298,7 +249,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -298,7 +249,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
298 | // 权益类型 | 249 | // 权益类型 |
299 | RightsDTO rightsDTO = this.getRights(rightId); | 250 | RightsDTO rightsDTO = this.getRights(rightId); |
300 | // 权益的实体类型 1:积分;2成长值;3优惠券 | 251 | // 权益的实体类型 1:积分;2成长值;3优惠券 |
301 | String type = rightsDTO.getEntityType(); | 252 | Integer type = rightsDTO.getEntityType(); |
302 | Long expireTime1 = rightsDTO.getExpireTime(); | 253 | Long expireTime1 = rightsDTO.getExpireTime(); |
303 | Timestamp expireTime = null; | 254 | Timestamp expireTime = null; |
304 | if (Objects.nonNull(expireTime1)){ | 255 | if (Objects.nonNull(expireTime1)){ |
... | @@ -307,7 +258,8 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -307,7 +258,8 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
307 | 258 | ||
308 | switch (type) { | 259 | switch (type) { |
309 | // 优惠券 | 260 | // 优惠券 |
310 | case "1": | 261 | case RightTypeConstants |
262 | .DISCOUNT_COUPON: | ||
311 | Long entityId = rightsDTO.getEntityId(); | 263 | Long entityId = rightsDTO.getEntityId(); |
312 | CouponDTO couponDTO = this.findCouponById(entityId); | 264 | CouponDTO couponDTO = this.findCouponById(entityId); |
313 | if (Objects.nonNull(couponDTO)) { | 265 | if (Objects.nonNull(couponDTO)) { |
... | @@ -319,16 +271,15 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -319,16 +271,15 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
319 | tempCoupon.setRightsSendStrategy(0); | 271 | tempCoupon.setRightsSendStrategy(0); |
320 | tempCoupon.setCode(couponDTO.getCode()); | 272 | tempCoupon.setCode(couponDTO.getCode()); |
321 | if (Objects.nonNull(expireTime)) | 273 | if (Objects.nonNull(expireTime)) |
322 | // tempCoupon.setExpireTime(TimestampUtil.long2LocalDateTime(expireTime)); | ||
323 | tempCoupon.setExpireTime(expireTime); | 274 | tempCoupon.setExpireTime(expireTime); |
324 | tempCouponList.add(tempCoupon); | 275 | tempCouponList.add(tempCoupon); |
325 | } | 276 | } |
326 | break; | 277 | break; |
327 | // 观影券 | 278 | // 观影券 |
328 | case "2": | 279 | case RightTypeConstants.VIEW_COUPON: |
329 | break; | 280 | break; |
330 | // 活动参与机会 | 281 | // 活动参与机会 |
331 | case "3": | 282 | case RightTypeConstants.JOIN_ACTIVITY: |
332 | break; | 283 | break; |
333 | 284 | ||
334 | default: | 285 | default: | ... | ... |
... | @@ -23,7 +23,7 @@ import com.topdraw.business.module.user.iptv.domain.UserTv; | ... | @@ -23,7 +23,7 @@ import com.topdraw.business.module.user.iptv.domain.UserTv; |
23 | import com.topdraw.business.module.user.iptv.service.UserTvService; | 23 | import com.topdraw.business.module.user.iptv.service.UserTvService; |
24 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 24 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
25 | import com.topdraw.business.process.domian.constant.TaskTemplateType; | 25 | import com.topdraw.business.process.domian.constant.TaskTemplateType; |
26 | import com.topdraw.business.process.domian.constant.RightType; | 26 | import com.topdraw.business.module.rights.constant.RightType; |
27 | import com.topdraw.business.process.service.PointsOperationService; | 27 | import com.topdraw.business.process.service.PointsOperationService; |
28 | import com.topdraw.business.process.service.RightsOperationService; | 28 | import com.topdraw.business.process.service.RightsOperationService; |
29 | import com.topdraw.business.process.service.TaskOperationService; | 29 | import com.topdraw.business.process.service.TaskOperationService; |
... | @@ -36,14 +36,21 @@ import com.topdraw.business.module.task.template.service.TaskTemplateService; | ... | @@ -36,14 +36,21 @@ import com.topdraw.business.module.task.template.service.TaskTemplateService; |
36 | import com.topdraw.business.process.domian.*; | 36 | import com.topdraw.business.process.domian.*; |
37 | import com.topdraw.business.process.service.UserOperationService; | 37 | import com.topdraw.business.process.service.UserOperationService; |
38 | import com.topdraw.common.ResultInfo; | 38 | import com.topdraw.common.ResultInfo; |
39 | import com.topdraw.exception.BadRequestException; | 39 | import com.topdraw.config.LocalConstants; |
40 | import com.topdraw.business.module.rights.constant.RightTypeConstants; | ||
41 | import com.topdraw.business.module.task.template.constant.TaskEventType; | ||
42 | import com.topdraw.config.RedisKeyConstants; | ||
40 | import com.topdraw.mq.module.mq.DataSyncMsg; | 43 | import com.topdraw.mq.module.mq.DataSyncMsg; |
41 | import com.topdraw.util.*; | 44 | import com.topdraw.util.*; |
45 | import com.topdraw.utils.RedisUtils; | ||
42 | import lombok.extern.slf4j.Slf4j; | 46 | import lombok.extern.slf4j.Slf4j; |
43 | import org.apache.commons.lang3.StringUtils; | 47 | import org.apache.commons.lang3.StringUtils; |
44 | import org.springframework.aop.framework.AopContext; | 48 | import org.springframework.aop.framework.AopContext; |
45 | import org.springframework.beans.BeanUtils; | 49 | import org.springframework.beans.BeanUtils; |
46 | import org.springframework.beans.factory.annotation.Autowired; | 50 | import org.springframework.beans.factory.annotation.Autowired; |
51 | import org.springframework.beans.factory.annotation.Value; | ||
52 | import org.springframework.cache.annotation.CacheEvict; | ||
53 | import org.springframework.cache.annotation.CachePut; | ||
47 | import org.springframework.data.redis.core.StringRedisTemplate; | 54 | import org.springframework.data.redis.core.StringRedisTemplate; |
48 | import org.springframework.data.redis.core.ValueOperations; | 55 | import org.springframework.data.redis.core.ValueOperations; |
49 | import org.springframework.stereotype.Service; | 56 | import org.springframework.stereotype.Service; |
... | @@ -89,6 +96,12 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -89,6 +96,12 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
89 | @Autowired | 96 | @Autowired |
90 | private RightsOperationService rightsOperationService; | 97 | private RightsOperationService rightsOperationService; |
91 | 98 | ||
99 | @Autowired | ||
100 | private RedisUtils redisUtils; | ||
101 | |||
102 | @Value("${uc.validPriorityMember}") | ||
103 | private int validPriorityMember; | ||
104 | |||
92 | private static final Integer TASK_FINISH_STATUS = 1; | 105 | private static final Integer TASK_FINISH_STATUS = 1; |
93 | private static final Integer TASK_UNFINISH_STATUS = 2; | 106 | private static final Integer TASK_UNFINISH_STATUS = 2; |
94 | private static final Integer POINTS_TYPE_RANDOM = 1; | 107 | private static final Integer POINTS_TYPE_RANDOM = 1; |
... | @@ -103,9 +116,11 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -103,9 +116,11 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
103 | public void asyncDeleteTask(Task task) {} | 116 | public void asyncDeleteTask(Task task) {} |
104 | 117 | ||
105 | @Override | 118 | @Override |
106 | public void createTask(Task task) { | 119 | /* @CachePut(cacheNames = RedisKeyConstants.cacheTaskByTaskTemplateId, key = "#task.taskTemplateId", |
120 | unless = "#result.id == null")*/ | ||
121 | public TaskDTO createTask(Task task) { | ||
107 | Long taskTemplateId = task.getTaskTemplateId(); | 122 | Long taskTemplateId = task.getTaskTemplateId(); |
108 | TaskTemplateDTO taskTemplateDTO = this.findByTemplateId(taskTemplateId); | 123 | TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findById(taskTemplateId); |
109 | 124 | ||
110 | task.setTaskTemplateCode(taskTemplateDTO.getCode()); | 125 | task.setTaskTemplateCode(taskTemplateDTO.getCode()); |
111 | Task task_ = TaskBuilder.build(task); | 126 | Task task_ = TaskBuilder.build(task); |
... | @@ -116,15 +131,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -116,15 +131,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
116 | } | 131 | } |
117 | 132 | ||
118 | ((TaskOperationServiceImpl) AopContext.currentProxy()).asyncCreateTask(task_); | 133 | ((TaskOperationServiceImpl) AopContext.currentProxy()).asyncCreateTask(task_); |
119 | } | ||
120 | 134 | ||
121 | /** | 135 | return taskDTO; |
122 | * | ||
123 | * @param taskTemplateId | ||
124 | * @return | ||
125 | */ | ||
126 | private TaskTemplateDTO findByTemplateId(Long taskTemplateId){ | ||
127 | return this.taskTemplateService.findById(taskTemplateId); | ||
128 | } | 136 | } |
129 | 137 | ||
130 | /** | 138 | /** |
... | @@ -139,9 +147,11 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -139,9 +147,11 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
139 | } | 147 | } |
140 | 148 | ||
141 | @Override | 149 | @Override |
142 | public void updateTask(Task task) { | 150 | /*@CachePut(cacheNames = RedisKeyConstants.cacheTaskByTaskTemplateId, key = "#task.taskTemplateId", |
151 | unless = "#result.id == null")*/ | ||
152 | public TaskDTO updateTask(Task task) { | ||
143 | Long taskTemplateId = task.getTaskTemplateId(); | 153 | Long taskTemplateId = task.getTaskTemplateId(); |
144 | TaskTemplateDTO taskTemplateDTO = this.findByTemplateId(taskTemplateId); | 154 | TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findById(taskTemplateId); |
145 | task.setTaskTemplateCode(taskTemplateDTO.getCode()); | 155 | task.setTaskTemplateCode(taskTemplateDTO.getCode()); |
146 | TaskDTO update = this.taskService.update(task); | 156 | TaskDTO update = this.taskService.update(task); |
147 | if (Objects.nonNull(update.getId())) { | 157 | if (Objects.nonNull(update.getId())) { |
... | @@ -149,6 +159,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -149,6 +159,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
149 | } | 159 | } |
150 | 160 | ||
151 | ((TaskOperationServiceImpl) AopContext.currentProxy()).asyncUpdateTask(task); | 161 | ((TaskOperationServiceImpl) AopContext.currentProxy()).asyncUpdateTask(task); |
162 | |||
163 | return update; | ||
152 | } | 164 | } |
153 | 165 | ||
154 | /** | 166 | /** |
... | @@ -167,26 +179,33 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -167,26 +179,33 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
167 | } | 179 | } |
168 | 180 | ||
169 | @Override | 181 | @Override |
170 | public void deleteTask(Task task) { | 182 | /*@CacheEvict(cacheNames = "", key = "")*/ |
183 | public Integer deleteTask(Task task) { | ||
171 | Long id = task.getId(); | 184 | Long id = task.getId(); |
172 | TaskDTO taskDTO = this.findById(id); | 185 | TaskDTO taskDTO = this.findById(id); |
173 | if (Objects.nonNull(taskDTO.getId())) { | 186 | if (Objects.nonNull(taskDTO.getId())) { |
174 | task.setId(taskDTO.getId()); | 187 | task.setId(taskDTO.getId()); |
175 | this.taskService.delete(task); | 188 | Integer delete = this.taskService.delete(task); |
176 | task.setCode(taskDTO.getCode()); | 189 | task.setCode(taskDTO.getCode()); |
177 | ((TaskOperationServiceImpl) AopContext.currentProxy()).asyncDeleteTask(task); | 190 | ((TaskOperationServiceImpl) AopContext.currentProxy()).asyncDeleteTask(task); |
191 | |||
192 | return delete; | ||
178 | } | 193 | } |
194 | |||
195 | return 0; | ||
179 | } | 196 | } |
180 | 197 | ||
181 | @Override | 198 | @Override |
182 | public void deleteTask(Long id) { | 199 | public Integer deleteTask(Long id) { |
183 | TaskDTO taskDTO = this.findById(id); | 200 | TaskDTO taskDTO = this.findById(id); |
184 | if (Objects.nonNull(taskDTO.getId())) { | 201 | if (Objects.nonNull(taskDTO.getId())) { |
185 | Task task = new Task(); | 202 | Task task = new Task(); |
186 | task.setId(taskDTO.getId()); | 203 | task.setId(taskDTO.getId()); |
187 | task.setCode(taskDTO.getCode()); | 204 | task.setCode(taskDTO.getCode()); |
188 | this.deleteTask(task); | 205 | return this.deleteTask(task); |
189 | } | 206 | } |
207 | |||
208 | return 0; | ||
190 | } | 209 | } |
191 | 210 | ||
192 | @Override | 211 | @Override |
... | @@ -211,50 +230,97 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -211,50 +230,97 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
211 | public ResultInfo dealTask(String content) { | 230 | public ResultInfo dealTask(String content) { |
212 | 231 | ||
213 | DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); | 232 | DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); |
214 | Integer event = dataSyncMsg.getEvent(); | 233 | log.info("事件dataSyncMsg ==>> {}", dataSyncMsg); |
215 | String msgData1 = dataSyncMsg.getMsgData(); | 234 | DataSyncMsg.MsgData msgData = JSON.parseObject(dataSyncMsg.getMsgData(), DataSyncMsg.MsgData.class); |
216 | DataSyncMsg.MsgData msgData = JSON.parseObject(msgData1, DataSyncMsg.MsgData.class); | 235 | log.info("事件消息体解析后msgData ==>> {}", msgData); |
236 | if (Objects.isNull(msgData)) { | ||
237 | log.error("参数错误,事件消息体为空"); | ||
238 | return ResultInfo.failure("参数错误,事件消息体为空"); | ||
239 | } | ||
217 | 240 | ||
218 | String memberCode = msgData.getMemberCode(); | 241 | // 小屏侧传递的参数是memberId |
219 | Long memberId = msgData.getMemberId(); | 242 | Long memberId = msgData.getMemberId(); |
243 | // 大屏侧传递的参数是platformAccount | ||
244 | String platformAccount = msgData.getPlatformAccount(); | ||
245 | |||
246 | // 参数校验 | ||
247 | if (Objects.isNull(memberId) && StringUtils.isBlank(platformAccount)) { | ||
248 | log.error("参数错误,memberId 和 platformAccount 都为null"); | ||
249 | return ResultInfo.failure("参数错误"); | ||
250 | } | ||
220 | 251 | ||
252 | // 获取会员信息,小屏会员信息通过memberId进行检索,大屏会员信息通过platformAccount进行检索 | ||
221 | long l = System.currentTimeMillis(); | 253 | long l = System.currentTimeMillis(); |
222 | if (StringUtils.isNotBlank(memberCode)) { | 254 | MemberDTO memberDTO = null; |
255 | if (Objects.nonNull(memberId)) { | ||
223 | 256 | ||
224 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | 257 | memberDTO = this.memberService.findById(memberId); |
225 | log.info("获取会员信息 ==>> {}", memberDTO); | 258 | log.info("获取小屏会员信息 ==>> memberId ==>> {} || 会员信息 ==>> {}",memberId, memberDTO); |
226 | 259 | ||
227 | // 检查当前会员的黑名单状态 | 260 | } else if (StringUtils.isNotBlank(platformAccount)) { |
228 | boolean b = this.validatedMemberBlackStatus(memberDTO); | 261 | |
229 | log.info("会员信息 ==>> {} || 会员id ==>> {} || 黑名单状态 ==>> {}", memberDTO, memberDTO.getId(), memberDTO.getBlackStatus()); | 262 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); |
230 | if (!b) { | 263 | if (Objects.nonNull(userTvDTO.getId())) { |
231 | return ResultInfo.forbidden("会员已被加入黑名单"); | 264 | // 开启积分自动同步至小屏主会员 |
265 | if (validPriorityMember == 0) { | ||
266 | |||
267 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); | ||
268 | |||
269 | if (StringUtils.isNotBlank(priorityMemberCode)) { | ||
270 | memberDTO = this.memberService.findByCode(priorityMemberCode); | ||
271 | log.info("查询绑定的小屏的主会员信息, member ==>> {}", memberDTO); | ||
272 | } else if (Objects.nonNull(userTvDTO.getMemberId())) { | ||
273 | memberDTO = this.memberService.findById(userTvDTO.getMemberId()); | ||
274 | log.info("查询大屏自身的会员信息, member ==>> {}", memberDTO); | ||
275 | } | ||
276 | |||
277 | } else { | ||
278 | |||
279 | memberDTO = this.memberService.findById(userTvDTO.getMemberId()); | ||
280 | |||
281 | } | ||
282 | |||
283 | } else { | ||
284 | log.error("大屏账号不存在,请检查数据, platformAccount ==>> {}", platformAccount); | ||
285 | return ResultInfo.failure("大屏账号不存在,请检查数据"); | ||
232 | } | 286 | } |
233 | 287 | ||
234 | memberId = memberDTO.getId(); | 288 | log.info("获取大屏会员信息 ==>> platformAccount ==>> {} || 会员信息 ==>> {}", platformAccount, memberDTO); |
289 | |||
290 | } | ||
291 | |||
292 | if (Objects.isNull(memberDTO.getId())) { | ||
293 | log.error("会员信息不存在 ==>> {}" + memberDTO); | ||
294 | return ResultInfo.failure("会员信息不存在"); | ||
235 | } | 295 | } |
236 | 296 | ||
237 | // 1.通过任务标识获取任务模板,通过模板参数获取具体的模板 | 297 | // 检查黑名单状态 0:正常 1:黑名单 |
238 | TaskTemplate taskTemplate = this.getTaskTemplate(event, dataSyncMsg); | 298 | Long blackStatus = memberDTO.getBlackStatus(); |
239 | log.info("获取任务模板 taskTemplate ==>> {} ", taskTemplate); | 299 | if (Objects.nonNull(blackStatus) && blackStatus.equals(LocalConstants.BLACK_STATUS)) { |
300 | log.error("会员已被加入黑名单 ==>> {}" + memberDTO); | ||
301 | return ResultInfo.forbidden("会员已被加入黑名单"); | ||
302 | } | ||
240 | 303 | ||
241 | // 2.通过任务模板获取对应的任务列表 | 304 | // 检索满足条件的任务 1.先检查redis中是否存在符合条件的任务 2.从redis中获取当前会员未完成的任务 |
242 | List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate, dataSyncMsg); | 305 | List<Task> tasks = this.findValidTasksAndRefreshTaskProcess(memberDTO, dataSyncMsg.getEvent(), msgData); |
243 | log.info("获取任务 taskList ==>> [{}] ", taskList); | 306 | log.info("查询出来的任务列表 tasks ==>> [{}] ", tasks); |
307 | if (CollectionUtils.isEmpty(tasks)) { | ||
308 | // 类型 1:登录;2:观影;3:参加活动;4:订购;5:优享会员;6:签到;7:完成设置;8:播放记录; | ||
309 | // 10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 | ||
310 | log.warn("无可执行的任务, 请检查配置,任务模板类型 eventType ==>> {} || 消息体 ==>> msgData {}", dataSyncMsg.getEvent(), msgData); | ||
311 | return ResultInfo.failure("无可执行的任务"); | ||
312 | } | ||
244 | 313 | ||
245 | // 4.判断当前用户是否满足任务完成条件 | 314 | if (!CollectionUtils.isEmpty(tasks)) { |
246 | boolean checkResult = this.checkTaskCompletion(memberId, taskList, event, msgData); | ||
247 | log.info("检查当前会员的任务完成情况 ==>> {} , true:未完成", checkResult); | ||
248 | if (checkResult) { | ||
249 | // 5.权益区分(积分、权益、成长值) | 315 | // 5.权益区分(积分、权益、成长值) |
250 | Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId, taskList, msgData, dataSyncMsg); | 316 | Map<RightType,Object> tempRightsMap = this.distinguishRight(memberDTO, tasks, msgData, dataSyncMsg); |
251 | log.info("获取当前任务对应的权益 tempRightsMap ==>> {} ", tempRightsMap); | 317 | log.info("获取当前任务对应的权益 tempRightsMap ==>> {} ", tempRightsMap); |
252 | 318 | ||
253 | // 6.风控检查 | 319 | // 6.风控检查 TODO |
254 | boolean result = this.checkRiskManagement(memberId, tempRightsMap); | 320 | // boolean result = this.checkRiskManagement(memberId, tempRightsMap); |
255 | log.info("针对各项权益检查当前会员是否达到风控值 ==>> {},true:已达到风控指标 ", result); | 321 | // log.info("针对各项权益检查当前会员是否达到风控值 ==>> {},true:已达到风控指标 ", result); |
256 | 322 | ||
257 | if (result) throw new BadRequestException("发放失败,已达风控上限"); | 323 | // if (result) throw new BadRequestException("发放失败,已达风控上限"); |
258 | 324 | ||
259 | long l1 = System.currentTimeMillis(); | 325 | long l1 = System.currentTimeMillis(); |
260 | log.info("各项检查总耗时 ==>> {}", (l1-l)); | 326 | log.info("各项检查总耗时 ==>> {}", (l1-l)); |
... | @@ -265,50 +331,229 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -265,50 +331,229 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
265 | this.grantRight(tempRightsMap); | 331 | this.grantRight(tempRightsMap); |
266 | long l3 = System.currentTimeMillis(); | 332 | long l3 = System.currentTimeMillis(); |
267 | log.info("下发结束,总耗时 ==>> {}", (l3-l2)); | 333 | log.info("下发结束,总耗时 ==>> {}", (l3-l2)); |
268 | |||
269 | } | 334 | } |
270 | return ResultInfo.success(); | 335 | return ResultInfo.success(); |
271 | 336 | ||
272 | } | 337 | } |
273 | 338 | ||
339 | private void saveOrUpdateTaskProcess(Long memberId, Task task, Integer currentActionAmount) { | ||
340 | TrTaskProgress trTaskProgress = new TrTaskProgress(); | ||
341 | trTaskProgress.setCurrentActionAmount(currentActionAmount); | ||
342 | trTaskProgress.setCompletionTime(TimestampUtil.now()); | ||
343 | trTaskProgress.setStatus(1); | ||
344 | trTaskProgress.setTaskId(task.getId()); | ||
345 | trTaskProgress.setMemberId(memberId); | ||
346 | trTaskProgress.setTargetActionAmount(task.getActionAmount()); | ||
274 | 347 | ||
348 | // 更新任务完成情况 | ||
349 | log.info("更新任务完成情况 ==>> {}", trTaskProgress); | ||
350 | this.doRefreshTrTaskProcess(trTaskProgress); | ||
351 | } | ||
275 | 352 | ||
276 | /** | 353 | /** |
277 | * 风控检查 | 354 | * 获取满足条件的任务列表 |
278 | * @param memberId | 355 | * @param memberDTO 会员 |
279 | * @param tempRightsMap | 356 | * @param msgData 事件消息体 |
357 | * @param event 任务模板类型 | ||
280 | * @return | 358 | * @return |
281 | */ | 359 | */ |
282 | private boolean checkRiskManagement(Long memberId , Map<RightType, Object> tempRightsMap) { | 360 | private List<Task> findValidTasksAndRefreshTaskProcess(MemberDTO memberDTO, Integer event, DataSyncMsg.MsgData msgData) { |
283 | // TODO 风控 | 361 | |
284 | return false; | 362 | // 任务是否存在 |
363 | List<Task> tasks = this.taskService.findByEvent(event); | ||
364 | if (Objects.isNull(tasks) || CollectionUtils.isEmpty(tasks)) { | ||
365 | return Collections.singletonList(null); | ||
366 | } | ||
367 | |||
368 | // 用户行为量 | ||
369 | String param = msgData.getParam(); | ||
370 | JSONObject paramJsonObject = null; | ||
371 | if (StringUtils.isNotBlank(param)) { | ||
372 | paramJsonObject = JSONObject.parseObject(param, JSONObject.class); | ||
373 | } | ||
374 | |||
375 | List<Task> tasksResult = new ArrayList<>(); | ||
376 | // 检查当前会员针对这些任务的完成情况 | ||
377 | for (Task task : tasks) { | ||
378 | |||
379 | /*// 校验用户分组 | ||
380 | if (StringUtils.isNotBlank(task.getGroups()) && !task.getGroups().contains(memberDTO.getGroups())) { | ||
381 | log.warn("此用户分组不满足任务要求,任务分组 ==>> {} || 会员分组 ==>> {}",task.getGroups(), memberDTO.getGroups()); | ||
382 | continue; | ||
383 | } | ||
384 | // 校验会员等级 | ||
385 | if (Objects.nonNull(task.getMemberLevel()) && task.getMemberLevel() < memberDTO.getLevel()) { | ||
386 | log.warn("此用户等级不满足任务要求,任务要求会员等级 ==>> {} || 会员等级 ==>> {}",task.getMemberLevel(), memberDTO.getLevel()); | ||
387 | continue; | ||
388 | } | ||
389 | // 校验会员vip | ||
390 | if (Objects.nonNull(task.getMemberVip()) && task.getMemberVip() < memberDTO.getVip()) { | ||
391 | log.warn("此用户vip不满足任务要求,任务要求会员vip ==>> {} || 会员vip ==>> {}",task.getMemberVip(), memberDTO.getVip()); | ||
392 | continue; | ||
393 | }*/ | ||
394 | |||
395 | TrTaskProgressDTO trTaskProgressDTO = | ||
396 | this.trTaskProgressService.findByMemberIdAndTaskIdAndCompletionTime(memberDTO.getId(), task.getId(), LocalDateTimeUtil.todayStart()); | ||
397 | log.info("当前任务完成的情况,trTaskProgressDTO ==>> {}", trTaskProgressDTO); | ||
398 | |||
399 | // 任务未完成 | ||
400 | if (Objects.isNull(trTaskProgressDTO) || !trTaskProgressDTO.getStatus().equals(TASK_FINISH_STATUS)) { | ||
401 | |||
402 | // 任务最低行为量 | ||
403 | int actionAmount = task.getActionAmount(); | ||
404 | // 任务属性 | ||
405 | String attr = task.getAttr(); | ||
406 | |||
407 | switch (event) { | ||
408 | // 开机、登录 | ||
409 | case TaskEventType.LOGIN: | ||
410 | if (Objects.nonNull(paramJsonObject)) { | ||
411 | // 登录天数 | ||
412 | int continueLogin = paramJsonObject.getInteger("CONTINUE_LOGIN"); | ||
413 | if (continueLogin >= actionAmount) { | ||
414 | tasksResult.add(task); | ||
415 | |||
416 | log.info("保存开机、登录任务进度"); | ||
417 | this.saveOrUpdateTaskProcess(memberDTO.getId(), task, continueLogin); | ||
285 | } | 418 | } |
419 | } | ||
420 | break; | ||
421 | // 观影 | ||
422 | case TaskEventType.VIEW: | ||
423 | if (Objects.nonNull(paramJsonObject)) { | ||
424 | // 观影总时长 | ||
425 | int playDuration_ = paramJsonObject.getInteger("PLAYDURATION"); | ||
426 | if (playDuration_ >= actionAmount) { | ||
427 | tasksResult.add(task); | ||
428 | |||
429 | log.info("保存观影任务进度"); | ||
430 | this.saveOrUpdateTaskProcess(memberDTO.getId(), task, playDuration_); | ||
431 | } | ||
432 | } | ||
433 | break; | ||
434 | // 参加活动 | ||
435 | case TaskEventType.ACTIVITY: | ||
436 | if (Objects.nonNull(paramJsonObject)) { | ||
437 | } | ||
438 | break; | ||
439 | // 订购 | ||
440 | case TaskEventType.ORDER: | ||
441 | if (Objects.nonNull(paramJsonObject)) { | ||
442 | } | ||
443 | break; | ||
444 | // 优享会员 | ||
445 | case TaskEventType.MEMBER_PRIORITY: | ||
446 | if (Objects.nonNull(paramJsonObject)) { | ||
447 | } | ||
448 | break; | ||
449 | // 签到 | ||
450 | case TaskEventType.SIGN: | ||
451 | if (Objects.nonNull(paramJsonObject)) { | ||
452 | // 签到天数 | ||
453 | int signDays = paramJsonObject.getInteger("SIGN"); | ||
454 | if (signDays >= actionAmount) { | ||
455 | tasksResult.add(task); | ||
456 | |||
457 | log.info("保存签到天数任务进度"); | ||
458 | this.saveOrUpdateTaskProcess(memberDTO.getId(), task, signDays); | ||
459 | } | ||
460 | } | ||
461 | break; | ||
462 | // 完成设置 | ||
463 | case TaskEventType.COMPLETE_INFO: | ||
464 | if (Objects.nonNull(paramJsonObject)) { | ||
465 | // 完成设置次数 | ||
466 | int completeCount = paramJsonObject.getInteger("COMPLETECOUNT"); | ||
467 | if (completeCount >= actionAmount) { | ||
468 | tasksResult.add(task); | ||
469 | |||
470 | log.info("保存完成用户信息设置任务进度"); | ||
471 | this.saveOrUpdateTaskProcess(memberDTO.getId(), task, completeCount); | ||
472 | } | ||
473 | } | ||
474 | break; | ||
475 | // 播放时长 | ||
476 | case TaskEventType.PLAY: | ||
477 | // 用户播放总时长 | ||
478 | if (Objects.nonNull(paramJsonObject)) { | ||
479 | int playDuration = paramJsonObject.getInteger("PLAYDURATION"); | ||
480 | if (playDuration >= actionAmount) { | ||
481 | tasksResult.add(task); | ||
482 | |||
483 | log.info("保存用户播放总时长任务进度"); | ||
484 | this.saveOrUpdateTaskProcess(memberDTO.getId(), task, playDuration); | ||
485 | } | ||
486 | } | ||
487 | break; | ||
488 | // 跨屏绑定 | ||
489 | case TaskEventType.BINDING: | ||
490 | // 跨屏绑定次数 | ||
491 | if (Objects.nonNull(paramJsonObject)) { | ||
492 | int bindCount = paramJsonObject.getInteger("BINDCOUNT"); | ||
493 | if (bindCount >= actionAmount) { | ||
494 | tasksResult.add(task); | ||
495 | |||
496 | log.info("保存跨屏绑定任务进度"); | ||
497 | this.saveOrUpdateTaskProcess(memberDTO.getId(), task, bindCount); | ||
498 | } | ||
499 | } | ||
500 | break; | ||
501 | // 积分转移 | ||
502 | case TaskEventType.POINTS_TRANS: | ||
503 | |||
504 | break; | ||
505 | // 积分兑换商品 | ||
506 | case TaskEventType.POINTS_EXCHANGE_GOODS: | ||
507 | // 完成设置次数 | ||
508 | if (Objects.nonNull(paramJsonObject)) { | ||
509 | int exchangeCount = paramJsonObject.getInteger("EXCHANGCOUNT"); | ||
510 | if (exchangeCount >= actionAmount) { | ||
511 | tasksResult.add(task); | ||
512 | |||
513 | log.info("保存积分兑换商品任务进度"); | ||
514 | this.saveOrUpdateTaskProcess(memberDTO.getId(), task, exchangeCount); | ||
515 | } | ||
516 | } | ||
517 | |||
518 | break; | ||
519 | // 系统操作 | ||
520 | case TaskEventType.SYSTEM_OPERATE: | ||
521 | break; | ||
522 | default: | ||
523 | log.warn("没有找到对应的任务,findValidTasks"); | ||
524 | break; | ||
525 | } | ||
526 | } | ||
527 | } | ||
528 | |||
529 | |||
530 | return tasksResult; | ||
531 | } | ||
532 | |||
286 | 533 | ||
287 | /** | 534 | /** |
288 | * 验证会员信息 | 535 | * 风控检查 |
289 | * @param memberDTO | 536 | * @param memberId |
537 | * @param tempRightsMap | ||
290 | * @return | 538 | * @return |
291 | */ | 539 | */ |
292 | private boolean validatedMemberBlackStatus(MemberDTO memberDTO) { | 540 | private boolean checkRiskManagement(Long memberId , Map<RightType, Object> tempRightsMap) { |
293 | Long blackStatus = memberDTO.getBlackStatus(); | 541 | // TODO 风控 |
294 | if (Objects.nonNull(blackStatus) && blackStatus == 1) { | ||
295 | log.error("validatedMember -->> 会员已被加入黑名单 【blackStatus】 -->> " + blackStatus); | ||
296 | return false; | 542 | return false; |
297 | } | 543 | } |
298 | return true; | ||
299 | } | ||
300 | 544 | ||
301 | /** | 545 | /** |
302 | * 任务完成情况 | 546 | * 任务完成情况 |
303 | * @param resources 任务完成情况 | 547 | * @param resources 任务完成情况 |
304 | */ | 548 | */ |
305 | private void doRefreshTrTaskProcess(TrTaskProgress resources) { | 549 | private void doRefreshTrTaskProcess(TrTaskProgress resources) { |
550 | String date = LocalDateTimeUtil.todayStart(); | ||
306 | Long id = resources.getId(); | 551 | Long id = resources.getId(); |
307 | if (Objects.nonNull(id)) { | 552 | if (Objects.nonNull(id)) { |
308 | resources.setUpdateTime(TimestampUtil.now()); | 553 | resources.setUpdateTime(TimestampUtil.now()); |
309 | this.trTaskProgressService.update(resources); | 554 | this.trTaskProgressService.update(resources, date); |
310 | } else { | 555 | } else { |
311 | this.trTaskProgressService.create(resources); | 556 | this.trTaskProgressService.create(resources, date); |
312 | } | 557 | } |
313 | } | 558 | } |
314 | 559 | ||
... | @@ -326,25 +571,27 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -326,25 +571,27 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
326 | * @param taskList 任务列表 | 571 | * @param taskList 任务列表 |
327 | * @return Map<RightType,Object> 权益分类 | 572 | * @return Map<RightType,Object> 权益分类 |
328 | */ | 573 | */ |
329 | private Map<RightType,Object> distinguishRight(Long memberId, List<Task> taskList, DataSyncMsg.MsgData msgData, DataSyncMsg dataSyncMsg) { | 574 | private Map<RightType,Object> distinguishRight(MemberDTO memberDTO, List<Task> taskList, DataSyncMsg.MsgData msgData, DataSyncMsg dataSyncMsg) { |
330 | 575 | ||
331 | Map<RightType,Object> map = new HashMap<>(); | 576 | Map<RightType,Object> map = new HashMap<>(); |
332 | 577 | ||
333 | // 区分权益类型(成长值(reward_exp)、积分(reward_points)、实体券),并发放权益 | 578 | // 区分权益类型(成长值(reward_exp)、积分(reward_points)、实体券),并发放权益 |
579 | List<TempPoints> tempPoints = new ArrayList<>(); | ||
580 | List<TempExp> tempExps = new ArrayList<>(); | ||
334 | for (Task task : taskList) { | 581 | for (Task task : taskList) { |
335 | 582 | ||
336 | // 积分 | 583 | // 积分 |
337 | List<TempPoints> tempPointsList = this.getTempPoints(memberId, msgData, task, dataSyncMsg); | 584 | this.getTempPoints(memberDTO, msgData, task, dataSyncMsg, tempPoints); |
338 | if (!CollectionUtils.isEmpty(tempPointsList)) | 585 | if (!CollectionUtils.isEmpty(tempPoints)) |
339 | map.put(RightType.POINTS,tempPointsList); | 586 | map.put(RightType.POINTS, tempPoints); |
340 | 587 | ||
341 | // 成长值 | 588 | // 成长值 |
342 | List<TempExp> tempExpList = this.getTempExp(memberId,msgData,task, dataSyncMsg); | 589 | this.getTempExp(memberDTO,msgData,task, dataSyncMsg, tempExps); |
343 | if (!CollectionUtils.isEmpty(tempExpList)) | 590 | if (!CollectionUtils.isEmpty(tempExps)) |
344 | map.put(RightType.EXP,tempExpList); | 591 | map.put(RightType.EXP, tempExps); |
345 | 592 | ||
346 | // 权益 | 593 | // 权益 |
347 | map = this.getTempRight(memberId, task, map); | 594 | this.getTempRight(memberDTO, task, map); |
348 | 595 | ||
349 | } | 596 | } |
350 | 597 | ||
... | @@ -368,7 +615,6 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -368,7 +615,6 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
368 | Long expireTime1 = rightsDTO.getExpireTime(); | 615 | Long expireTime1 = rightsDTO.getExpireTime(); |
369 | if (Objects.nonNull(expireTime1)) { | 616 | if (Objects.nonNull(expireTime1)) { |
370 | Timestamp expireTime = TimestampUtil.long2Timestamp(expireTime1); | 617 | Timestamp expireTime = TimestampUtil.long2Timestamp(expireTime1); |
371 | if (Objects.nonNull(expireTime)) | ||
372 | tempRights.setExpireTime(expireTime); | 618 | tempRights.setExpireTime(expireTime); |
373 | } | 619 | } |
374 | return tempRights; | 620 | return tempRights; |
... | @@ -395,17 +641,17 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -395,17 +641,17 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
395 | 641 | ||
396 | /** | 642 | /** |
397 | * 权益1 | 643 | * 权益1 |
398 | * @param task | 644 | * @param task 任务 |
645 | * @param memberDTO 会员 | ||
646 | * @param map 权益分类 | ||
399 | * @return | 647 | * @return |
400 | */ | 648 | */ |
401 | private Map<RightType,Object> getTempRight(Long memberId , Task task , Map<RightType,Object> map) { | 649 | private Map<RightType,Object> getTempRight(MemberDTO memberDTO, Task task, Map<RightType,Object> map) { |
402 | 650 | ||
403 | // 优惠券 | 651 | // 优惠券 |
404 | List<TempCoupon> tempCouponList = new ArrayList<>(); | 652 | List<TempCoupon> tempCouponList = new ArrayList<>(); |
405 | // 权益列表,用以保存权益记录 | 653 | // 权益列表,用以保存权益记录 |
406 | List<TempRights> rightsList = new ArrayList<>(); | 654 | List<TempRights> rightsList = new ArrayList<>(); |
407 | // 会员信息 | ||
408 | MemberDTO memberDTO = this.findMemberById(memberId); | ||
409 | 655 | ||
410 | // 权益1 | 656 | // 权益1 |
411 | Long rights1Id = task.getRightsId(); | 657 | Long rights1Id = task.getRightsId(); |
... | @@ -437,27 +683,9 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -437,27 +683,9 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
437 | // 权益分类 | 683 | // 权益分类 |
438 | this.getTempRightType(memberDTO,rights3Id,rights3Amount,rightsSendStrategy,tempCouponList,rightsList,map); | 684 | this.getTempRightType(memberDTO,rights3Id,rights3Amount,rightsSendStrategy,tempCouponList,rightsList,map); |
439 | } | 685 | } |
440 | // 优惠券 | ||
441 | /*if (!CollectionUtils.isEmpty(tempCouponList)) { | ||
442 | map.put(RightType.COUPON,tempCouponList); | ||
443 | }*/ | ||
444 | // 权益 | ||
445 | /*if (!CollectionUtils.isEmpty(rightsList)) { | ||
446 | map.put(RightType.RIGHTS,rightsList); | ||
447 | }*/ | ||
448 | return map; | 686 | return map; |
449 | } | 687 | } |
450 | 688 | ||
451 | |||
452 | /** | ||
453 | * 会员对象 | ||
454 | * @param memberId | ||
455 | * @return | ||
456 | */ | ||
457 | private MemberDTO findMemberById(Long memberId) { | ||
458 | return this.memberService.findById(memberId); | ||
459 | } | ||
460 | |||
461 | /** | 689 | /** |
462 | * 权益分类 | 690 | * 权益分类 |
463 | * @param memberDTO | 691 | * @param memberDTO |
... | @@ -486,10 +714,10 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -486,10 +714,10 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
486 | } | 714 | } |
487 | 715 | ||
488 | // 权益类型 | 716 | // 权益类型 |
489 | String type = rightsDTO.getEntityType(); | 717 | Integer type = rightsDTO.getEntityType(); |
490 | switch (type) { | 718 | switch (type) { |
491 | // 优惠券 | 719 | // 优惠券 |
492 | case "1": | 720 | case RightTypeConstants.DISCOUNT_COUPON: |
493 | Long entityId1 = rightsDTO.getEntityId(); | 721 | Long entityId1 = rightsDTO.getEntityId(); |
494 | if (Objects.nonNull(entityId1)) { | 722 | if (Objects.nonNull(entityId1)) { |
495 | CouponDTO couponDTO = this.findCouponById(entityId1); | 723 | CouponDTO couponDTO = this.findCouponById(entityId1); |
... | @@ -505,7 +733,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -505,7 +733,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
505 | } | 733 | } |
506 | break; | 734 | break; |
507 | // 观影券 | 735 | // 观影券 |
508 | case "2": | 736 | case RightTypeConstants.VIEW_COUPON: |
509 | Long entityId2 = rightsDTO.getEntityId(); | 737 | Long entityId2 = rightsDTO.getEntityId(); |
510 | if (Objects.nonNull(entityId2)) { | 738 | if (Objects.nonNull(entityId2)) { |
511 | CouponDTO couponDTO = this.findCouponById(entityId2); | 739 | CouponDTO couponDTO = this.findCouponById(entityId2); |
... | @@ -521,19 +749,19 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -521,19 +749,19 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
521 | } | 749 | } |
522 | break; | 750 | break; |
523 | // 活动参与机会 | 751 | // 活动参与机会 |
524 | case "3": | 752 | case RightTypeConstants.JOIN_ACTIVITY: |
525 | map.put(RightType.ACTIVITYCHANCE, tempRights); | 753 | map.put(RightType.ACTIVITYCHANCE, tempRights); |
526 | break; | 754 | break; |
527 | // 积分商品 | 755 | // 积分商品 |
528 | case "4": | 756 | case RightTypeConstants.POINTS_GOODS: |
529 | map.put(RightType.POINTGOODS, tempRights); | 757 | map.put(RightType.POINTGOODS, tempRights); |
530 | break; | 758 | break; |
531 | // IPTV产品包 | 759 | // IPTV产品包 |
532 | case "5": | 760 | case RightTypeConstants.IPTV_PRODUCT: |
533 | map.put(RightType.IPTVPRODUCT, tempRights); | 761 | map.put(RightType.IPTVPRODUCT, tempRights); |
534 | break; | 762 | break; |
535 | // IPTV观影权益 | 763 | // IPTV观影权益 |
536 | case "6": | 764 | case RightTypeConstants.IPTV_VIEW: |
537 | map.put(RightType.IPTVVIEW, tempRights); | 765 | map.put(RightType.IPTVVIEW, tempRights); |
538 | break; | 766 | break; |
539 | default: | 767 | default: |
... | @@ -567,15 +795,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -567,15 +795,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
567 | * @param task | 795 | * @param task |
568 | * @return | 796 | * @return |
569 | */ | 797 | */ |
570 | private List<TempExp> getTempExp(Long memberId, DataSyncMsg.MsgData msgData, Task task, DataSyncMsg dataSyncMsg) { | 798 | private void getTempExp(MemberDTO memberDTO, DataSyncMsg.MsgData msgData, Task task, DataSyncMsg dataSyncMsg, List<TempExp> tempExps) { |
799 | |||
571 | Long rewardExp = task.getRewardExp(); | 800 | Long rewardExp = task.getRewardExp(); |
572 | if (Objects.nonNull(rewardExp) && rewardExp > 0L) { | 801 | if (Objects.nonNull(rewardExp) && rewardExp > 0L) { |
573 | 802 | ||
574 | TempExp tempExp = new TempExp(); | 803 | TempExp tempExp = new TempExp(); |
575 | tempExp.setMemberId(memberId); | 804 | tempExp.setMemberId(memberDTO.getId()); |
576 | tempExp.setAppCode(msgData.getAppCode()); | 805 | tempExp.setAppCode(msgData.getAppCode()); |
577 | tempExp.setMemberId(memberId); | 806 | tempExp.setMemberCode(memberDTO.getCode()); |
578 | tempExp.setMemberCode(msgData.getMemberCode()); | ||
579 | tempExp.setItemId(msgData.getItemId()); | 807 | tempExp.setItemId(msgData.getItemId()); |
580 | tempExp.setAccountId(msgData.getAccountId()); | 808 | tempExp.setAccountId(msgData.getAccountId()); |
581 | tempExp.setRewardExp(task.getRewardExp()); | 809 | tempExp.setRewardExp(task.getRewardExp()); |
... | @@ -586,12 +814,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -586,12 +814,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
586 | tempExp.setActivityId(msgData.getOrderId()); | 814 | tempExp.setActivityId(msgData.getOrderId()); |
587 | Integer rightsSendStrategy = task.getRightsSendStrategy(); | 815 | Integer rightsSendStrategy = task.getRightsSendStrategy(); |
588 | tempExp.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy); | 816 | tempExp.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy); |
589 | return Arrays.asList(tempExp); | 817 | tempExps.add(tempExp); |
590 | |||
591 | } | 818 | } |
592 | |||
593 | return null; | ||
594 | |||
595 | } | 819 | } |
596 | 820 | ||
597 | /** | 821 | /** |
... | @@ -599,8 +823,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -599,8 +823,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
599 | * @param task | 823 | * @param task |
600 | * @return | 824 | * @return |
601 | */ | 825 | */ |
602 | private List<TempPoints> getTempPoints(Long memberId, DataSyncMsg.MsgData msgData, Task task, DataSyncMsg dataSyncMsg) { | 826 | private void getTempPoints(MemberDTO memberDTO, DataSyncMsg.MsgData msgData, Task task, |
603 | 827 | DataSyncMsg dataSyncMsg, List<TempPoints> tempPoints) { | |
604 | // 积分: 数值、过期时间、积分类型(定值、随机)、随机积分最大值 | 828 | // 积分: 数值、过期时间、积分类型(定值、随机)、随机积分最大值 |
605 | Long rewardPoints = task.getRewardPoints(); | 829 | Long rewardPoints = task.getRewardPoints(); |
606 | // 过期时间 | 830 | // 过期时间 |
... | @@ -610,32 +834,32 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -610,32 +834,32 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
610 | Integer pointsType = task.getPointsType(); | 834 | Integer pointsType = task.getPointsType(); |
611 | // 随机积分的最大值 | 835 | // 随机积分的最大值 |
612 | Integer rewardMaxPoints = task.getRewardMaxPoints(); | 836 | Integer rewardMaxPoints = task.getRewardMaxPoints(); |
613 | if (Objects.nonNull(rewardPoints)) { | 837 | if (Objects.nonNull(rewardPoints) && rewardPoints > 0) { |
614 | TempPoints tempPoints = new TempPoints(); | 838 | TempPoints tempPoint = new TempPoints(); |
615 | // 如果积分是随机的,则取随机值 | 839 | // 如果积分是随机的,则取随机值 |
616 | if (pointsType == POINTS_TYPE_RANDOM) { | 840 | if (pointsType.equals(POINTS_TYPE_RANDOM)) { |
617 | rewardPoints = RandomUtil.getRandomPoints(POINTS_MIN,rewardMaxPoints); | 841 | rewardPoints = RandomUtil.getRandomPoints(POINTS_MIN, rewardMaxPoints); |
618 | } | 842 | } |
619 | tempPoints.setRewardPointsExpireTime(rewardPointsExpireTime); | 843 | tempPoint.setRewardPointsExpireTime(rewardPointsExpireTime); |
620 | tempPoints.setMemberId(memberId); | 844 | tempPoint.setMemberId(memberDTO.getId()); |
621 | tempPoints.setMemberCode(msgData.getMemberCode()); | 845 | tempPoint.setMemberCode(memberDTO.getCode()); |
622 | tempPoints.setAppCode(msgData.getAppCode()); | 846 | tempPoint.setAppCode(msgData.getAppCode()); |
623 | tempPoints.setPoints(rewardPoints); | 847 | tempPoint.setPoints(rewardPoints); |
624 | tempPoints.setPointsType(pointsType); | 848 | tempPoint.setPointsType(pointsType); |
625 | tempPoints.setDeviceType(dataSyncMsg.getDeviceType()); | 849 | tempPoint.setDeviceType(dataSyncMsg.getDeviceType()); |
626 | tempPoints.setExpireTime(expireTime); | 850 | tempPoint.setExpireTime(expireTime); |
627 | tempPoints.setOrderId(msgData.getOrderId()); | 851 | tempPoint.setOrderId(msgData.getOrderId()); |
628 | tempPoints.setActivityId(msgData.getOrderId()); | 852 | tempPoint.setActivityId(msgData.getActivityId()); |
629 | tempPoints.setMediaId(msgData.getMediaId()); | 853 | tempPoint.setMediaId(msgData.getMediaId()); |
630 | tempPoints.setItemId(msgData.getItemId()); | 854 | tempPoint.setItemId(msgData.getItemId()); |
631 | tempPoints.setAccountId(msgData.getAccountId()); | 855 | tempPoint.setAccountId(msgData.getAccountId()); |
632 | tempPoints.setEvtType(dataSyncMsg.getEvent()); | 856 | tempPoint.setEvtType(dataSyncMsg.getEvent()); |
633 | Integer rightsSendStrategy = task.getRightsSendStrategy(); | 857 | Integer rightsSendStrategy = task.getRightsSendStrategy(); |
634 | tempPoints.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy); | 858 | tempPoint.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy); |
635 | return Arrays.asList(tempPoints); | 859 | |
860 | tempPoints.add(tempPoint); | ||
636 | } | 861 | } |
637 | 862 | ||
638 | return null; | ||
639 | } | 863 | } |
640 | 864 | ||
641 | /** | 865 | /** |
... | @@ -675,6 +899,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -675,6 +899,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
675 | 899 | ||
676 | // 验证会员分组 | 900 | // 验证会员分组 |
677 | boolean result1 = this.validatedMemberGroup(memberId,taskList); | 901 | boolean result1 = this.validatedMemberGroup(memberId,taskList); |
902 | log.info("验证会员分组结果,==>> {}, true:验证通过", result1); | ||
678 | if (!result1) | 903 | if (!result1) |
679 | return false; | 904 | return false; |
680 | 905 | ||
... | @@ -802,7 +1027,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -802,7 +1027,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
802 | Long taskId = task.getId(); | 1027 | Long taskId = task.getId(); |
803 | // 任务完成记录 | 1028 | // 任务完成记录 |
804 | List<TrTaskProgressDTO> trTaskProgressDTOS = | 1029 | List<TrTaskProgressDTO> trTaskProgressDTOS = |
805 | this.trTaskProgressService.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1); | 1030 | null;//this.trTaskProgressService.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1); |
806 | 1031 | ||
807 | Long id = null; | 1032 | Long id = null; |
808 | Integer currentActionAmount = null; | 1033 | Integer currentActionAmount = null; |
... | @@ -817,10 +1042,13 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -817,10 +1042,13 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
817 | case 8: | 1042 | case 8: |
818 | if (!CollectionUtils.isEmpty(trTaskProgressDTOS)) { | 1043 | if (!CollectionUtils.isEmpty(trTaskProgressDTOS)) { |
819 | TrTaskProgressDTO trTaskProgressDTO_0 = trTaskProgressDTOS.get(0); | 1044 | TrTaskProgressDTO trTaskProgressDTO_0 = trTaskProgressDTOS.get(0); |
1045 | id = trTaskProgressDTO_0.getId(); | ||
820 | Integer status_0 = trTaskProgressDTO_0.getStatus(); | 1046 | Integer status_0 = trTaskProgressDTO_0.getStatus(); |
821 | Integer currentActionAmount_0 = trTaskProgressDTO_0.getCurrentActionAmount(); | 1047 | Integer currentActionAmount_0 = trTaskProgressDTO_0.getCurrentActionAmount(); |
822 | Timestamp completionTime_0 = trTaskProgressDTO_0.getCompletionTime(); | 1048 | Timestamp completionTime_0 = trTaskProgressDTO_0.getCompletionTime(); |
1049 | log.info("当前任务完成情况,trTaskProgressDTO_0 ==>> {}", trTaskProgressDTO_0); | ||
823 | if (status_0 == 1 && currentActionAmount_0 != null && Objects.nonNull(completionTime_0)) { | 1050 | if (status_0 == 1 && currentActionAmount_0 != null && Objects.nonNull(completionTime_0)) { |
1051 | log.info("任务已完成,返回false"); | ||
824 | return false; | 1052 | return false; |
825 | } | 1053 | } |
826 | } | 1054 | } |
... | @@ -828,7 +1056,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -828,7 +1056,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
828 | JSONObject jsonObject = JSON.parseObject(param); | 1056 | JSONObject jsonObject = JSON.parseObject(param); |
829 | Integer value = Integer.valueOf(jsonObject.get("playDuration").toString()); | 1057 | Integer value = Integer.valueOf(jsonObject.get("playDuration").toString()); |
830 | if (value >= actionAmount) { | 1058 | if (value >= actionAmount) { |
831 | currentActionAmount = actionAmount; | 1059 | currentActionAmount = value; |
832 | completionTime = TimestampUtil.now(); | 1060 | completionTime = TimestampUtil.now(); |
833 | status = TASK_FINISH_STATUS; | 1061 | status = TASK_FINISH_STATUS; |
834 | } | 1062 | } |
... | @@ -931,20 +1159,26 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -931,20 +1159,26 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
931 | trTaskProgress.setTargetActionAmount(actionAmount); | 1159 | trTaskProgress.setTargetActionAmount(actionAmount); |
932 | 1160 | ||
933 | // 更新任务完成情况 | 1161 | // 更新任务完成情况 |
1162 | log.info("更新任务完成情况 ==>> {}", trTaskProgress); | ||
934 | this.doRefreshTrTaskProcess(trTaskProgress); | 1163 | this.doRefreshTrTaskProcess(trTaskProgress); |
935 | 1164 | if (status == TASK_FINISH_STATUS) { | |
1165 | log.info("任务已完成, trTaskProgress ==>> {}", trTaskProgress); | ||
936 | return true; | 1166 | return true; |
937 | } | 1167 | } |
938 | 1168 | ||
939 | return false; | 1169 | return false; |
940 | } | 1170 | } |
941 | 1171 | ||
1172 | return false; | ||
1173 | } | ||
1174 | |||
942 | /** | 1175 | /** |
943 | * 获取任务模板对应的任务列表 | 1176 | * 获取任务模板对应的任务列表 |
944 | * | 1177 | * |
945 | * @param taskTemplate 任务模板 | 1178 | * @param taskTemplate 任务模板 |
946 | * @return List<task> 任务列表 | 1179 | * @return List<task> 任务列表 |
947 | */ | 1180 | */ |
1181 | @Deprecated | ||
948 | private List<Task> loadListTaskByTaskTemplate(TaskTemplate taskTemplate, DataSyncMsg dataSyncMsg) { | 1182 | private List<Task> loadListTaskByTaskTemplate(TaskTemplate taskTemplate, DataSyncMsg dataSyncMsg) { |
949 | 1183 | ||
950 | if (Objects.nonNull(taskTemplate)) { | 1184 | if (Objects.nonNull(taskTemplate)) { |
... | @@ -972,7 +1206,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -972,7 +1206,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
972 | private List<Task> pickUpTask(List<Task> taskList,DataSyncMsg dataSyncMsg,Integer type) { | 1206 | private List<Task> pickUpTask(List<Task> taskList,DataSyncMsg dataSyncMsg,Integer type) { |
973 | 1207 | ||
974 | List<Task> taskList1 = new ArrayList<>(); | 1208 | List<Task> taskList1 = new ArrayList<>(); |
975 | String msgData1 = dataSyncMsg.getMsgData(); | 1209 | String msgData1 = null;//dataSyncMsg.getMsgData(); |
976 | DataSyncMsg.MsgData msgData = JSON.parseObject(msgData1, DataSyncMsg.MsgData.class); | 1210 | DataSyncMsg.MsgData msgData = JSON.parseObject(msgData1, DataSyncMsg.MsgData.class); |
977 | 1211 | ||
978 | if (Objects.nonNull(msgData.getParam())) { | 1212 | if (Objects.nonNull(msgData.getParam())) { |
... | @@ -1104,7 +1338,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -1104,7 +1338,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
1104 | * @return TaskTemplate 任务模板 | 1338 | * @return TaskTemplate 任务模板 |
1105 | */ | 1339 | */ |
1106 | private TaskTemplate getTaskTemplate(Integer event, DataSyncMsg dataSyncMsg) { | 1340 | private TaskTemplate getTaskTemplate(Integer event, DataSyncMsg dataSyncMsg) { |
1107 | String msgData1 = dataSyncMsg.getMsgData(); | 1341 | String msgData1 = null;//dataSyncMsg.getMsgData(); |
1108 | DataSyncMsg.MsgData msg = JSON.parseObject(msgData1, DataSyncMsg.MsgData.class); | 1342 | DataSyncMsg.MsgData msg = JSON.parseObject(msgData1, DataSyncMsg.MsgData.class); |
1109 | 1343 | ||
1110 | if (Objects.nonNull(msg.getParam())) { | 1344 | if (Objects.nonNull(msg.getParam())) { | ... | ... |
... | @@ -82,6 +82,11 @@ public class TaskTemplateOperationServiceImpl implements TaskTemplateOperationSe | ... | @@ -82,6 +82,11 @@ public class TaskTemplateOperationServiceImpl implements TaskTemplateOperationSe |
82 | } | 82 | } |
83 | 83 | ||
84 | @Override | 84 | @Override |
85 | public Long countByCodeAndType(TaskTemplate taskTemplate) { | ||
86 | return this.taskTemplateService.countByCodeAndType(taskTemplate); | ||
87 | } | ||
88 | |||
89 | @Override | ||
85 | public TaskTemplateDTO findById(Long id) { | 90 | public TaskTemplateDTO findById(Long id) { |
86 | return this.taskTemplateService.findById(id); | 91 | return this.taskTemplateService.findById(id); |
87 | } | 92 | } | ... | ... |
... | @@ -114,6 +114,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -114,6 +114,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
114 | @AsyncMqSend | 114 | @AsyncMqSend |
115 | public void asyncUserTv(UserTvDTO userTvDTO) {} | 115 | public void asyncUserTv(UserTvDTO userTvDTO) {} |
116 | @AsyncMqSend | 116 | @AsyncMqSend |
117 | public void asyncUserTvChangeMainAccount(UserTvDTO userTvDTO) {} | ||
118 | @AsyncMqSend | ||
117 | public void asyncAppletBind(MemberAndUserTvDTO memberAndUserTvDTO) {} | 119 | public void asyncAppletBind(MemberAndUserTvDTO memberAndUserTvDTO) {} |
118 | @AsyncMqSend | 120 | @AsyncMqSend |
119 | public void asyncUnbind(MemberAndUserTvDTO memberAndUserTvDTO) {} | 121 | public void asyncUnbind(MemberAndUserTvDTO memberAndUserTvDTO) {} |
... | @@ -427,66 +429,61 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -427,66 +429,61 @@ public class UserOperationServiceImpl implements UserOperationService { |
427 | String headImgUrl = resources.getHeadimgurl(); | 429 | String headImgUrl = resources.getHeadimgurl(); |
428 | 430 | ||
429 | // 小屏账户 | 431 | // 小屏账户 |
430 | UserWeixinDTO _userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); | 432 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionId, appId, openId); |
431 | 433 | ||
432 | MemberDTO memberDTO = null; | 434 | MemberDTO memberDTO = null; |
433 | if (Objects.isNull(_userWeixinDTO.getId()) || StringUtils.isBlank(_userWeixinDTO.getUnionid()) || | 435 | if (Objects.isNull(userWeixinDTO.getId()) || StringUtils.isBlank(userWeixinDTO.getUnionid()) || |
434 | Objects.isNull(_userWeixinDTO.getMemberId())) { | 436 | Objects.isNull(userWeixinDTO.getMemberId())) { |
435 | 437 | ||
436 | UserWeixin userWeixin = new UserWeixin(); | 438 | UserWeixin userWeixin = new UserWeixin(); |
437 | BeanUtils.copyProperties(resources, userWeixin); | 439 | BeanUtils.copyProperties(resources, userWeixin); |
438 | userWeixin.setStatus(SUBSCRIBE_STATUS); | 440 | userWeixin.setStatus(SUBSCRIBE_STATUS); |
439 | 441 | ||
440 | // 创建小屏账户同时创建会员 | 442 | // 创建小屏账户同时创建会员 |
441 | _userWeixinDTO = this.createWeixinUserAndMember(userWeixin, 1); | 443 | userWeixinDTO = this.createWeixinUserAndMember(userWeixin, 1); |
442 | 444 | Long memberId = userWeixinDTO.getMemberId(); | |
443 | Long memberId = _userWeixinDTO.getMemberId(); | ||
444 | memberDTO = this.memberService.findById(memberId); | 445 | memberDTO = this.memberService.findById(memberId); |
445 | memberDTO.setVip(SUBSCRIBE_STATUS); | ||
446 | 446 | ||
447 | } else { | 447 | } else { |
448 | 448 | ||
449 | // 修改微信账户关注状态 | 449 | // 修改微信账户关注状态 |
450 | _userWeixinDTO = this.doUpdateUserWeiXinStatus(_userWeixinDTO, SUBSCRIBE_STATUS); | 450 | UserWeixin userWeixin = new UserWeixin(); |
451 | 451 | userWeixin.setId(userWeixinDTO.getId()); | |
452 | userWeixin.setStatus(SUBSCRIBE_STATUS); | ||
453 | userWeixinDTO = this.userWeixinService.doUpdateWeixinStatus(userWeixin); | ||
452 | // 小屏会员 | 454 | // 小屏会员 |
453 | memberDTO = this.findMemberByAppIdAndOpenId(appId,openId); | 455 | memberDTO = this.memberService.findById(userWeixinDTO.getMemberId()); |
454 | 456 | ||
455 | if (memberDTO != null) { | ||
456 | |||
457 | if (StringUtils.isNotBlank(headImgUrl) && StringUtils.isNotBlank(nickname)) { | ||
458 | memberDTO.setAvatarUrl(headImgUrl); | ||
459 | memberDTO.setNickname(nickname); | ||
460 | } | 457 | } |
461 | 458 | ||
459 | Member member = new Member(); | ||
460 | member.setId(memberDTO.getId()); | ||
461 | if (Objects.nonNull(memberDTO.getId())) { | ||
462 | Integer vip = memberDTO.getVip(); | 462 | Integer vip = memberDTO.getVip(); |
463 | // 未购买付费会员 | 463 | // 未购买付费会员 |
464 | if (Objects.isNull(vip) || vip < 1) { | 464 | if (Objects.isNull(vip) || vip < 1) { |
465 | memberDTO.setVip(1); | 465 | member.setVip(1); |
466 | } | 466 | member.setVipExpireTime(null); |
467 | 467 | } else { | |
468 | member.setVip(vip); | ||
468 | } | 469 | } |
469 | } | 470 | } |
470 | |||
471 | // 修改会员信息 | 471 | // 修改会员信息 |
472 | MemberDTO _memberDTO1 = this.doUpdateMemberByMemberDTO(memberDTO); | 472 | memberDTO = this.memberService.doUpdateMemberVipAndVipExpireTime(member); |
473 | log.info("发送关注消息至大屏侧,发送的账号信息 ==>> {} || 会员信息 ==>> {}", _userWeixinDTO , _memberDTO1); | 473 | log.info("发送关注消息至大屏侧,发送的账号信息 ==>> {} || 会员信息 ==>> {}", userWeixinDTO , memberDTO); |
474 | // 同步至iptv | 474 | // 同步至iptv |
475 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncSubscribe(new MemberAndWeixinUserDTO(_memberDTO1, _userWeixinDTO)); | 475 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncSubscribe(new MemberAndWeixinUserDTO(memberDTO, userWeixinDTO)); |
476 | |||
477 | 476 | ||
478 | // 大屏信息 | 477 | // 大屏信息 |
479 | JSONObject iptvUserInfo = resources.getIptvUserInfo(); | 478 | JSONObject iptvUserInfo = resources.getIptvUserInfo(); |
480 | log.info("存储的大小屏账号信息 iptvUserInfo ==>> {}" , iptvUserInfo); | 479 | log.info("存储的大小屏账号信息 iptvUserInfo ==>> {}" , iptvUserInfo); |
481 | |||
482 | if (Objects.nonNull(iptvUserInfo)) { | 480 | if (Objects.nonNull(iptvUserInfo)) { |
483 | // 大屏账户 | 481 | // 大屏账户 |
484 | String platformAccount = iptvUserInfo.getString("platformAccount"); | 482 | String platformAccount = iptvUserInfo.getString("platformAccount"); |
485 | log.info("存储的大屏账号信息 platformAccount ==>> {}" , platformAccount); | 483 | log.info("存储的大屏账号信息 platformAccount ==>> {}" , platformAccount); |
486 | log.info("绑定开始"); | ||
487 | 484 | ||
488 | if (StringUtils.isBlank(platformAccount)) { | 485 | if (StringUtils.isBlank(platformAccount)) { |
489 | log.warn("绑定失败,platformAccount is null "); | 486 | log.error("关注后绑定失败,platformAccount is null "); |
490 | return false; | 487 | return false; |
491 | } | 488 | } |
492 | 489 | ||
... | @@ -563,20 +560,44 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -563,20 +560,44 @@ public class UserOperationServiceImpl implements UserOperationService { |
563 | String openId = resources.getOpenid(); | 560 | String openId = resources.getOpenid(); |
564 | 561 | ||
565 | // 修改关注状态 0:未关注 | 562 | // 修改关注状态 0:未关注 |
566 | UserWeixinDTO userWeixinDTO = this.doUpdateUserWeiXinStatus(appId, openId, UNSUBSCRIBE_STATUS); | 563 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId, openId); |
564 | |||
565 | if (Objects.isNull(userWeixinDTO.getId())) { | ||
566 | log.error("取关失败,通过appid ==>> {} 和 openId ==>> {} 无法查询到指定的微信账号", appId, openId); | ||
567 | return false; | ||
568 | } | ||
569 | |||
570 | if (Objects.isNull(userWeixinDTO.getMemberId())) { | ||
571 | log.error("取关失败,该微信账号无会员id ==>> {}", userWeixinDTO); | ||
572 | return false; | ||
573 | } | ||
574 | |||
575 | UserWeixin userWeixin = new UserWeixin(); | ||
576 | userWeixin.setId(userWeixinDTO.getId()); | ||
577 | userWeixin.setStatus(UNSUBSCRIBE_STATUS); | ||
578 | userWeixinDTO = this.userWeixinService.doUpdateWeixinStatus(userWeixin); | ||
567 | 579 | ||
568 | // 会员 | 580 | // 会员 |
569 | MemberDTO memberDTO = this.findMemberByUserWeixinDTO(userWeixinDTO); | 581 | MemberDTO memberDTO = this.memberService.findById(userWeixinDTO.getMemberId()); |
570 | 582 | ||
571 | memberDTO.setUserIptvId(null); | ||
572 | // 修改会员vip,如果没有购买会员则取消团粉 | 583 | // 修改会员vip,如果没有购买会员则取消团粉 |
573 | MemberDTO _memberDTO = this.doUpdateMemberVip(memberDTO, 0); | 584 | Integer vip = memberDTO.getVip(); |
574 | 585 | vip = (vip == null ? 0 : vip); | |
575 | // 同步至iptv | 586 | // 未购买付费会员 |
576 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnsubscribe(new MemberAndWeixinUserDTO(_memberDTO, userWeixinDTO)); | 587 | if (vip <= 1) { |
588 | Member member = new Member(); | ||
589 | member.setId(memberDTO.getId()); | ||
590 | member.setCode(memberDTO.getCode()); | ||
591 | member.setVipExpireTime(null); | ||
592 | member.setVip(0); | ||
593 | memberDTO = this.memberService.doUpdateMemberVipAndVipExpireTime(member); | ||
594 | } | ||
577 | 595 | ||
578 | // 关注记录 | 596 | // 关注记录 |
579 | this.saveWechatSubscribeRecord(_memberDTO, "",2); | 597 | this.saveWechatSubscribeRecord(memberDTO, "",2); |
598 | |||
599 | // 同步至iptv | ||
600 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnsubscribe(new MemberAndWeixinUserDTO(memberDTO, userWeixinDTO)); | ||
580 | 601 | ||
581 | return true; | 602 | return true; |
582 | } | 603 | } |
... | @@ -656,31 +677,35 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -656,31 +677,35 @@ public class UserOperationServiceImpl implements UserOperationService { |
656 | * @param resources | 677 | * @param resources |
657 | */ | 678 | */ |
658 | @Override | 679 | @Override |
659 | public void changeMainAccount(UserTv resources) { | 680 | public boolean changeMainAccount(UserTv resources) { |
660 | 681 | ||
661 | // 会员编码 | 682 | // 会员编码 |
662 | String memberCode = resources.getMemberCode(); | 683 | String memberCode = resources.getMemberCode(); |
663 | this.findMemberByCode(memberCode); | 684 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); |
685 | if (Objects.isNull(memberDTO.getId())) { | ||
686 | log.error("会员信息不存在, memberCode ==>> {}", memberCode); | ||
687 | return false; | ||
688 | } | ||
664 | 689 | ||
665 | String platformAccount = resources.getPlatformAccount(); | 690 | String platformAccount = resources.getPlatformAccount(); |
666 | 691 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | |
667 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); | ||
668 | |||
669 | if (Objects.nonNull(userTvDTO)) { | 692 | if (Objects.nonNull(userTvDTO)) { |
670 | if (StringUtils.isNotBlank(userTvDTO.getPriorityMemberCode()) && userTvDTO.getPriorityMemberCode().equalsIgnoreCase(memberCode)) | 693 | if (StringUtils.isNotBlank(userTvDTO.getPriorityMemberCode()) && userTvDTO.getPriorityMemberCode().equalsIgnoreCase(memberCode)) |
671 | throw new BadRequestException("会员已是主账户"); | 694 | throw new BadRequestException("会员已是主账户"); |
672 | |||
673 | } else { | 695 | } else { |
674 | |||
675 | throw new EntityNotFoundException(UserTvDTO.class , "platformAccount" , GlobeExceptionMsg.IPTV_IS_NULL); | 696 | throw new EntityNotFoundException(UserTvDTO.class , "platformAccount" , GlobeExceptionMsg.IPTV_IS_NULL); |
676 | |||
677 | } | 697 | } |
678 | 698 | ||
679 | // 设置主会员 | 699 | // 设置主会员 |
680 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberCode, "manual"); | 700 | // UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, memberCode, "manual"); |
681 | 701 | UserTv userTv = new UserTv(); | |
702 | userTv.setId(userTvDTO.getId()); | ||
703 | userTv.setPriorityMemberCode(memberCode); | ||
704 | userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv); | ||
682 | // 同步至iptv | 705 | // 同步至iptv |
683 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTv(_userTvDTO); | 706 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUserTvChangeMainAccount(userTvDTO); |
707 | |||
708 | return true; | ||
684 | } | 709 | } |
685 | 710 | ||
686 | /** | 711 | /** |
... | @@ -688,41 +713,47 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -688,41 +713,47 @@ public class UserOperationServiceImpl implements UserOperationService { |
688 | * @param resources | 713 | * @param resources |
689 | */ | 714 | */ |
690 | @Override | 715 | @Override |
691 | public void tvUnbind(TvUnBindBean resources) { | 716 | public boolean tvUnbind(TvUnBindBean resources) { |
692 | 717 | ||
693 | Boolean autoModel = resources.getAutoModel(); | 718 | // 希望绑定的会员code |
694 | String bindMemberCode = resources.getBindMemberCode(); | 719 | String bindMemberCode = resources.getBindMemberCode(); |
695 | String platformAccount = resources.getPlatformAccount(); | 720 | String platformAccount = resources.getPlatformAccount(); |
696 | String memberCode = resources.getMemberCode(); | 721 | String memberCode = resources.getMemberCode(); |
697 | 722 | ||
698 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); | 723 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); |
699 | log.info("大屏解绑,通过大屏账号查询大屏账号信息,结果 userTvDTO ==>> {}", userTvDTO); | 724 | log.info("大屏解绑,通过大屏账号查询大屏账号信息,结果 userTvDTO ==>> {}", userTvDTO); |
700 | if (Objects.isNull(userTvDTO.getId())) | 725 | if (Objects.isNull(userTvDTO.getId())) { |
701 | throw new EntityNotFoundException(UserTvDTO.class, "PlatformAccount", GlobeExceptionMsg.IPTV_IS_NULL); | 726 | log.error("大屏解绑失败,无对应的大屏账号信息, platformAccount ==>> {}", platformAccount); |
727 | return false; | ||
728 | } | ||
702 | 729 | ||
703 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | 730 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); |
704 | log.info("大屏解绑,通过会员code查询会员信息,结果memberDTO==>>{}", memberDTO); | 731 | log.info("大屏解绑,通过会员code查询会员信息,结果memberDTO==>>{}", memberDTO); |
705 | 732 | if (Objects.isNull(memberDTO.getId())) { | |
733 | log.error("大屏解绑失败,无对应的会员信息, memberCode ==>> {}", memberCode); | ||
734 | return false; | ||
735 | } | ||
706 | 736 | ||
707 | // 解绑(置空大屏信息) | 737 | // 解绑(置空大屏信息) |
708 | log.info("开始置空会员的user_iptv_id ==>> {}", memberDTO); | 738 | Member member = new Member(); |
709 | MemberDTO _memberDTO = this.minaUnbind_(memberDTO); | 739 | member.setId(memberDTO.getId()); |
710 | if (Objects.isNull(_memberDTO)) { | 740 | member.setCode(memberDTO.getCode()); |
711 | _memberDTO = memberDTO; | 741 | member.setBindIptvTime(null); |
712 | } | 742 | member.setUserIptvId(null); |
713 | log.info("会员信息置空大屏的结果,_memberDTO ==>> {}", _memberDTO); | 743 | member.setBindIptvPlatformType(null); |
744 | log.info("置空会员绑定的大屏信息, member ==>> {}", member); | ||
745 | memberDTO = this.memberService.doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(member); | ||
746 | log.info("会员信息置空大屏的结果,memberDTO ==>> {}", memberDTO); | ||
747 | memberDTO.setPlatformAccount(platformAccount); | ||
714 | 748 | ||
715 | // 置空主账号 | 749 | // 置空主账号 |
716 | log.info("开始置空大屏账号的主会员priorityMemberCode"); | 750 | userTvDTO = this.resetMainAccount(memberDTO, userTvDTO, bindMemberCode); |
717 | UserTvDTO _userTvDTO = this.resetMainAccount(memberCode, userTvDTO.getId(), autoModel, bindMemberCode); | 751 | userTvDTO.setMemberCode(memberCode); |
718 | if (Objects.isNull(_userTvDTO)){ | ||
719 | _userTvDTO = userTvDTO; | ||
720 | } | ||
721 | log.info("大屏账号置空主会员的结果,_userTvDTO ==>> {}", _userTvDTO); | ||
722 | 752 | ||
723 | // 同步至iptv | 753 | log.info("大屏账号置空主会员的结果,userTvDTO ==>> {}", userTvDTO); |
724 | log.info("开始同步解绑,参数 ==>> {} ",new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); | 754 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnbind(new MemberAndUserTvDTO(memberDTO, userTvDTO)); |
725 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnbind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); | 755 | |
756 | return true; | ||
726 | } | 757 | } |
727 | 758 | ||
728 | 759 | ||
... | @@ -919,57 +950,60 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -919,57 +950,60 @@ public class UserOperationServiceImpl implements UserOperationService { |
919 | @Override | 950 | @Override |
920 | public boolean minaBind(BindBean resources) { | 951 | public boolean minaBind(BindBean resources) { |
921 | 952 | ||
922 | Long _memberId = resources.getMemberId(); | 953 | Long memberId = resources.getMemberId(); |
923 | 954 | ||
924 | String platformAccount = resources.getPlatformAccount(); | 955 | String platformAccount = resources.getPlatformAccount(); |
925 | 956 | ||
926 | // 大屏账户 | 957 | // 大屏账户 |
927 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | 958 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); |
959 | log.info("查询大屏账号信息, userTvDTO ==>> {}", userTvDTO); | ||
928 | // 账户是否存在 | 960 | // 账户是否存在 |
929 | if (Objects.isNull(userTvDTO.getId())) { | 961 | if (Objects.isNull(userTvDTO.getId())) { |
930 | log.error("appletBind ==> platformAccount ==> [{}]",platformAccount); | 962 | log.error("大屏账号信息不存在,platformAccount ==> {}",platformAccount); |
931 | throw new EntityNotFoundException(UserTvDTO.class,"id",GlobeExceptionMsg.IPTV_IS_NULL); | 963 | return false; |
932 | } | 964 | } |
933 | 965 | ||
934 | resources.setPlatformUserId(userTvDTO.getId()); | ||
935 | |||
936 | UserWeixinDTO userWeixinDTO = null; | ||
937 | // 微信账户 | 966 | // 微信账户 |
938 | if (Objects.nonNull(_memberId)) { | 967 | if (Objects.nonNull(memberId)) { |
939 | userWeixinDTO = this.userWeixinService.findFirstByMemberId(_memberId); | 968 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByMemberId(memberId); |
940 | } | 969 | log.info("检查小屏账号是否存在, userWeixinDTO ==>> {}", userWeixinDTO); |
941 | // 账户是否存在 | 970 | // 账户是否存在 |
942 | if (Objects.isNull(userWeixinDTO.getId())) { | 971 | if (Objects.isNull(userWeixinDTO.getId())) { |
943 | log.error("appletBind ==> weixinId ==> [{}]",userWeixinDTO.getId()); | 972 | log.error("通过会员id无法找到对应的微信账号,memberId ==> {}", memberId); |
944 | throw new EntityNotFoundException(UserWeixinDTO.class, "id", userWeixinDTO.getId().toString()); | 973 | return false; |
945 | } | 974 | } |
946 | |||
947 | // 会员 | ||
948 | Long memberId = userWeixinDTO.getMemberId(); | ||
949 | if (Objects.isNull(memberId)) { | ||
950 | log.error("appletBind ==> memberId ==> [{}]",memberId); | ||
951 | throw new EntityNotFoundException(UserWeixinDTO.class, "memberId", memberId.toString()); | ||
952 | } | 975 | } |
953 | 976 | ||
954 | MemberDTO memberDTO = this.findMemberById(memberId); | 977 | MemberDTO memberDTO = this.memberService.findById(memberId); |
955 | 978 | log.info("检查会员是否存在, memberDTO ==>> {}", memberDTO); | |
979 | if (Objects.nonNull(memberDTO.getId())) { | ||
956 | Long userIptvId = memberDTO.getUserIptvId(); | 980 | Long userIptvId = memberDTO.getUserIptvId(); |
957 | if (Objects.nonNull(userIptvId)) | 981 | if (Objects.nonNull(userIptvId)) { |
982 | log.error("该会员已绑定,大屏id ==> {}", userIptvId); | ||
958 | throw new BadRequestException(GlobeExceptionMsg.ALREADY_BIND); | 983 | throw new BadRequestException(GlobeExceptionMsg.ALREADY_BIND); |
984 | } | ||
985 | } else { | ||
986 | log.error("会员信息不存在,请检查数据, memberId ==>> {}", memberId); | ||
987 | return false; | ||
988 | } | ||
959 | 989 | ||
960 | // 主账户会员 | ||
961 | String code = memberDTO.getCode(); | ||
962 | |||
963 | // 更新大屏信息,同步大屏信息时使用 | ||
964 | userTvDTO.setMemberCode(code); | ||
965 | // 主账户 | 990 | // 主账户 |
966 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); | 991 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); |
967 | 992 | ||
968 | if (StringUtils.isBlank(priorityMemberCode)) { | 993 | if (StringUtils.isBlank(priorityMemberCode)) { |
969 | // 设置主账号 | 994 | priorityMemberCode = memberDTO.getCode(); |
970 | userTvDTO.setPriorityMemberCode(code); | 995 | log.info("大屏账号为绑定主账号,开始设置主会员 priorityMemberCode ==>> {}", priorityMemberCode); |
996 | UserTv userTv = new UserTv(); | ||
997 | userTv.setId(userTvDTO.getId()); | ||
998 | userTv.setPriorityMemberCode(priorityMemberCode); | ||
999 | // 更新大屏账户 | ||
1000 | userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv); | ||
1001 | userTvDTO.setMemberCode(memberDTO.getCode()); | ||
971 | } | 1002 | } |
972 | 1003 | ||
1004 | Member member = new Member(); | ||
1005 | member.setId(memberDTO.getId()); | ||
1006 | member.setCode(memberDTO.getCode()); | ||
973 | String platform = userTvDTO.getPlatform(); | 1007 | String platform = userTvDTO.getPlatform(); |
974 | // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 | 1008 | // 绑定IPTV平台 0:未知;1:电信;2:移动;3:联通 |
975 | Integer bindIptvPlatformType = 0; | 1009 | Integer bindIptvPlatformType = 0; |
... | @@ -985,54 +1019,23 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -985,54 +1019,23 @@ public class UserOperationServiceImpl implements UserOperationService { |
985 | if (UserConstant.platform_dx.contains(platform)) { | 1019 | if (UserConstant.platform_dx.contains(platform)) { |
986 | bindIptvPlatformType = PLATFORM_LIST[1]; | 1020 | bindIptvPlatformType = PLATFORM_LIST[1]; |
987 | } | 1021 | } |
988 | memberDTO.setUserIptvId(userTvDTO.getId()); | 1022 | member.setUserIptvId(userTvDTO.getId()); |
989 | memberDTO.setBindIptvTime(TimestampUtil.now()); | 1023 | member.setBindIptvTime(TimestampUtil.now()); |
990 | memberDTO.setBindIptvPlatformType(bindIptvPlatformType); | 1024 | member.setBindIptvPlatformType(bindIptvPlatformType); |
991 | memberDTO.setPlatformAccount(platformAccount); | 1025 | log.info("修改小屏会员对应的绑定关系,member ==>> {}", member); |
992 | |||
993 | // 更新大屏账户 | ||
994 | UserTvDTO _userTvDTO = this.doUpdateUserTv(userTvDTO); | ||
995 | // 修改会员信息 | 1026 | // 修改会员信息 |
996 | MemberDTO _memberDTO = this.doUpdateMemberByMemberDTO(memberDTO); | 1027 | memberDTO = this.memberService.doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(member); |
997 | 1028 | ||
1029 | memberDTO.setPlatformAccount(platformAccount); | ||
998 | // 同步至iptv | 1030 | // 同步至iptv |
999 | ((UserOperationServiceImpl)AopContext.currentProxy()) | 1031 | ((UserOperationServiceImpl)AopContext.currentProxy()) |
1000 | .asyncAppletBind(new MemberAndUserTvDTO(_memberDTO, _userTvDTO)); | 1032 | .asyncAppletBind(new MemberAndUserTvDTO(memberDTO, userTvDTO)); |
1001 | 1033 | ||
1002 | return true; | 1034 | return true; |
1003 | } | 1035 | } |
1004 | 1036 | ||
1005 | /** | 1037 | /** |
1006 | * | 1038 | * |
1007 | * @param memberCode | ||
1008 | * @param platformAccount | ||
1009 | */ | ||
1010 | @Override | ||
1011 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
1012 | public void bind(String memberCode, String platformAccount) { | ||
1013 | MemberDTO memberDTO = this.memberService.findByCode(memberCode); | ||
1014 | this.bind(memberDTO,platformAccount); | ||
1015 | } | ||
1016 | |||
1017 | /** | ||
1018 | * | ||
1019 | * @param memberDTO | ||
1020 | * @param userTvDTO | ||
1021 | */ | ||
1022 | @Override | ||
1023 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | ||
1024 | public void bind(MemberDTO memberDTO, UserTvDTO userTvDTO) { | ||
1025 | String platformAccount = userTvDTO.getPlatformAccount(); | ||
1026 | |||
1027 | if (StringUtils.isBlank(platformAccount)) { | ||
1028 | return; | ||
1029 | } | ||
1030 | // 绑定 | ||
1031 | this.bind(memberDTO,platformAccount); | ||
1032 | } | ||
1033 | |||
1034 | /** | ||
1035 | * | ||
1036 | * @param memberDTO | 1039 | * @param memberDTO |
1037 | * @param platformAccount | 1040 | * @param platformAccount |
1038 | * @return | 1041 | * @return |
... | @@ -1119,8 +1122,11 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1119,8 +1122,11 @@ public class UserOperationServiceImpl implements UserOperationService { |
1119 | memberDTO.setVip(vip1); | 1122 | memberDTO.setVip(vip1); |
1120 | 1123 | ||
1121 | Member member = new Member(); | 1124 | Member member = new Member(); |
1122 | BeanUtils.copyProperties(memberDTO, member); | 1125 | member.setId(memberDTO.getId()); |
1123 | this.memberService.update(member); | 1126 | member.setCode(memberDTO.getCode()); |
1127 | member.setVipExpireTime(null); | ||
1128 | // this.memberService.update(member); | ||
1129 | this.memberService.doUpdateMemberVipAndVipExpireTime(member); | ||
1124 | 1130 | ||
1125 | return memberDTO; | 1131 | return memberDTO; |
1126 | } | 1132 | } |
... | @@ -1153,13 +1159,11 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1153,13 +1159,11 @@ public class UserOperationServiceImpl implements UserOperationService { |
1153 | 1159 | ||
1154 | if (Objects.nonNull(userWeixinDTO.getId())) { | 1160 | if (Objects.nonNull(userWeixinDTO.getId())) { |
1155 | 1161 | ||
1156 | userWeixinDTO.setStatus(status); | ||
1157 | |||
1158 | UserWeixin userWeixin = new UserWeixin(); | 1162 | UserWeixin userWeixin = new UserWeixin(); |
1159 | BeanUtils.copyProperties(userWeixinDTO,userWeixin); | 1163 | userWeixin.setId(userWeixinDTO.getId()); |
1160 | 1164 | userWeixin.setStatus(status); | |
1161 | this.userWeixinService.update(userWeixin); | 1165 | userWeixinDTO = this.userWeixinService.doUpdateWeixinStatus(userWeixin); |
1162 | 1166 | return userWeixinDTO; | |
1163 | } | 1167 | } |
1164 | 1168 | ||
1165 | return userWeixinDTO; | 1169 | return userWeixinDTO; |
... | @@ -1245,16 +1249,13 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1245,16 +1249,13 @@ public class UserOperationServiceImpl implements UserOperationService { |
1245 | 1249 | ||
1246 | /** | 1250 | /** |
1247 | * 重置主账号 | 1251 | * 重置主账号 |
1248 | * @param memberCode 会员code | 1252 | * @param memberDTO 会员code |
1249 | * @param id 大屏id | 1253 | * @param userTvDTO 大屏id |
1250 | * @param autoModel true:自动设置主账号 false: 手动设置 | 1254 | * @param bindMemberCode true:自动设置主账号 false: 手动设置 |
1251 | */ | 1255 | */ |
1252 | private UserTvDTO resetMainAccount(String memberCode, Long id, Boolean autoModel, String bindMemberCode) { | 1256 | private UserTvDTO resetMainAccount(MemberDTO memberDTO, UserTvDTO userTvDTO, String bindMemberCode) { |
1253 | 1257 | ||
1254 | UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode); | ||
1255 | log.info("大屏解绑,重置大屏账号的主会员,查看当前会员是否是主账号 ==>>memberCode ==>> {} || 大屏账号 ==>> userTvDTO ==>> {}", userTvDTO); | 1258 | log.info("大屏解绑,重置大屏账号的主会员,查看当前会员是否是主账号 ==>>memberCode ==>> {} || 大屏账号 ==>> userTvDTO ==>> {}", userTvDTO); |
1256 | if (Objects.nonNull(userTvDTO.getId())) { | ||
1257 | log.info("主账号存在"); | ||
1258 | if (StringUtils.isBlank(bindMemberCode)) { | 1259 | if (StringUtils.isBlank(bindMemberCode)) { |
1259 | // 有其他绑定的小程序会员,排除自己 | 1260 | // 有其他绑定的小程序会员,排除自己 |
1260 | /*List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id); | 1261 | /*List<MemberDTO> memberDTOList = this.memberService.findByUserIptvId(id); |
... | @@ -1298,56 +1299,28 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1298,56 +1299,28 @@ public class UserOperationServiceImpl implements UserOperationService { |
1298 | 1299 | ||
1299 | }*/ | 1300 | }*/ |
1300 | 1301 | ||
1301 | log.info("无其他绑定的小屏会员信息 "); | ||
1302 | // 绑定新的主账号 | 1302 | // 绑定新的主账号 |
1303 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, null, "manual"); | 1303 | // UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, null, "manual"); |
1304 | UserTv userTv = new UserTv(); | ||
1305 | userTv.setId(userTvDTO.getId()); | ||
1306 | userTv.setPlatform(userTvDTO.getPlatformAccount()); | ||
1307 | userTv.setPriorityMemberCode(null); | ||
1308 | UserTvDTO _userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv); | ||
1304 | log.info("绑定新的主账号 ==>> _userTvDTO ==>> {}", _userTvDTO); | 1309 | log.info("绑定新的主账号 ==>> _userTvDTO ==>> {}", _userTvDTO); |
1305 | return _userTvDTO; | 1310 | return _userTvDTO; |
1306 | 1311 | ||
1307 | } else { | 1312 | } else { |
1308 | 1313 | ||
1309 | this.memberService.findByCode(bindMemberCode); | 1314 | UserTv userTv = new UserTv(); |
1310 | 1315 | userTv.setId(userTvDTO.getId()); | |
1316 | userTv.setPlatform(userTvDTO.getPlatformAccount()); | ||
1317 | userTv.setPriorityMemberCode(bindMemberCode); | ||
1311 | // 绑定新的主账号 | 1318 | // 绑定新的主账号 |
1312 | UserTvDTO _userTvDTO = this.bondPriorityMember(userTvDTO, bindMemberCode, "manual"); | 1319 | UserTvDTO _userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv); |
1313 | 1320 | ||
1314 | return _userTvDTO; | 1321 | return _userTvDTO; |
1315 | 1322 | ||
1316 | } | 1323 | } |
1317 | |||
1318 | } | ||
1319 | |||
1320 | return userTvDTO; | ||
1321 | |||
1322 | } | ||
1323 | |||
1324 | /** | ||
1325 | * 解绑(置空大屏信息) | ||
1326 | * @param memberDTOS | ||
1327 | */ | ||
1328 | private MemberDTO minaUnbind_(MemberDTO memberDTOS) { | ||
1329 | |||
1330 | // 若无关系,不做处理 | ||
1331 | if (Objects.nonNull(memberDTOS) && Objects.isNull(memberDTOS.getUserIptvId())) | ||
1332 | return null; | ||
1333 | |||
1334 | Member member = new Member(); | ||
1335 | memberDTOS.setBindIptvTime(null); | ||
1336 | memberDTOS.setUserIptvId(null); | ||
1337 | memberDTOS.setBindIptvPlatformType(null); | ||
1338 | BeanUtils.copyProperties(memberDTOS, member); | ||
1339 | log.info("大屏绑定,置空绑定的大屏信息, member ==>> {}", member); | ||
1340 | MemberDTO memberDTO = this.memberService.update(member); | ||
1341 | return memberDTO; | ||
1342 | } | ||
1343 | |||
1344 | /** | ||
1345 | * | ||
1346 | * @param memberCode 会员编码 | ||
1347 | * @return | ||
1348 | */ | ||
1349 | private MemberDTO findMemberByCode(String memberCode) { | ||
1350 | return memberService.findByCode(memberCode); | ||
1351 | } | 1324 | } |
1352 | 1325 | ||
1353 | /** | 1326 | /** |
... | @@ -1380,17 +1353,6 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1380,17 +1353,6 @@ public class UserOperationServiceImpl implements UserOperationService { |
1380 | } | 1353 | } |
1381 | 1354 | ||
1382 | /** | 1355 | /** |
1383 | * 更新大屏 | ||
1384 | * @param userTvDTO | ||
1385 | */ | ||
1386 | private UserTvDTO doUpdateUserTv(UserTvDTO userTvDTO) { | ||
1387 | UserTv userTv = new UserTv(); | ||
1388 | BeanUtils.copyProperties(userTvDTO,userTv); | ||
1389 | userTv.setUpdateTime(TimestampUtil.now()); | ||
1390 | return this.userTvService.update(userTv); | ||
1391 | } | ||
1392 | |||
1393 | /** | ||
1394 | * 同一用户有多个微信APP的情况下展示同一个账户信息 | 1356 | * 同一用户有多个微信APP的情况下展示同一个账户信息 |
1395 | * 原则:那个先创建就用那个id | 1357 | * 原则:那个先创建就用那个id |
1396 | * @param userWeixinDTO | 1358 | * @param userWeixinDTO |
... | @@ -1440,17 +1402,6 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1440,17 +1402,6 @@ public class UserOperationServiceImpl implements UserOperationService { |
1440 | 1402 | ||
1441 | /** | 1403 | /** |
1442 | * 获取小屏账户 | 1404 | * 获取小屏账户 |
1443 | * @param unionId | ||
1444 | * @param appId | ||
1445 | * @param openId | ||
1446 | * @return | ||
1447 | */ | ||
1448 | private UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId(String unionId, String appId, String openId) { | ||
1449 | return this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId,openId); | ||
1450 | } | ||
1451 | |||
1452 | /** | ||
1453 | * 获取小屏账户 | ||
1454 | * @param appId | 1405 | * @param appId |
1455 | * @param openId | 1406 | * @param openId |
1456 | * @return | 1407 | * @return |
... | @@ -1524,21 +1475,86 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1524,21 +1475,86 @@ public class UserOperationServiceImpl implements UserOperationService { |
1524 | } | 1475 | } |
1525 | 1476 | ||
1526 | @Override | 1477 | @Override |
1527 | public void minaUnbind(WeixinUnBindBean weixinUnBindBean) { | 1478 | public boolean minaUnbind(WeixinUnBindBean weixinUnBindBean) { |
1528 | 1479 | ||
1529 | Long memberId = weixinUnBindBean.getMemberId(); | 1480 | Long memberId = weixinUnBindBean.getMemberId(); |
1530 | MemberDTO memberDTO = this.memberService.findById(memberId); | 1481 | MemberDTO memberDTO = this.memberService.findById(memberId); |
1482 | if (Objects.isNull(memberDTO.getId())) { | ||
1483 | log.error("小屏解绑失败,会员信息不存在 memberId ==>> {}", memberId); | ||
1484 | return false; | ||
1485 | } | ||
1531 | 1486 | ||
1532 | Assert.notNull(memberDTO.getUserIptvId(), GlobeExceptionMsg.IPTV_IS_NULL); | 1487 | if (Objects.isNull(memberDTO.getUserIptvId())) { |
1488 | log.error("小屏解绑失败,未查询到大屏的大屏信息, memberId ==>> {}", memberId); | ||
1489 | return false; | ||
1490 | } | ||
1533 | 1491 | ||
1534 | UserTvDTO userTvDTO = this.userTvService.findById(memberDTO.getUserIptvId()); | 1492 | UserTvDTO userTvDTO = this.userTvService.findById(memberDTO.getUserIptvId()); |
1493 | if (Objects.isNull(userTvDTO.getId())) { | ||
1494 | log.info("小屏解绑失败,绑定的大屏账号不存在 userIptvId ==>> {}", memberDTO.getUserIptvId()); | ||
1495 | return false; | ||
1496 | } | ||
1497 | |||
1498 | boolean b = this.tvUnbindAndSetNewPriorityMemberCode(memberDTO, userTvDTO); | ||
1499 | return b; | ||
1500 | } | ||
1501 | |||
1502 | private boolean tvUnbindAndSetNewPriorityMemberCode(MemberDTO memberDTO, UserTvDTO userTvDTO) { | ||
1503 | |||
1504 | // 解绑(置空大屏信息) | ||
1505 | Member member = new Member(); | ||
1506 | member.setId(memberDTO.getId()); | ||
1507 | member.setCode(memberDTO.getCode()); | ||
1508 | member.setBindIptvTime(null); | ||
1509 | member.setUserIptvId(null); | ||
1510 | member.setBindIptvPlatformType(null); | ||
1511 | log.info("置空会员绑定的大屏信息, member ==>> {}", member); | ||
1512 | memberDTO = this.memberService.doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(member); | ||
1513 | log.info("会员信息置空大屏的结果,memberDTO ==>> {}", memberDTO); | ||
1514 | memberDTO.setPlatformAccount(userTvDTO.getPlatformAccount()); | ||
1515 | |||
1516 | // 有其他绑定的小程序会员,排除自己 | ||
1517 | List<MemberDTO> memberDTOS = this.memberService.findByUserIptvId(userTvDTO.getId()); | ||
1518 | log.info("后台指定一个默认主会员,通过大屏id查询到的绑定的小屏会员memberDTOList ==>> {}", memberDTOS); | ||
1519 | if (!CollectionUtils.isEmpty(memberDTOS)) { | ||
1520 | String oldMemberCode = memberDTO.getCode(); | ||
1521 | List<MemberDTO> collect = | ||
1522 | memberDTOS.stream().filter(memberDTO_ -> | ||
1523 | !memberDTO_.getCode().equalsIgnoreCase(oldMemberCode)).collect(Collectors.toList()); | ||
1524 | log.info("过滤掉当前会员 ==>> {}", collect); | ||
1525 | |||
1526 | if (!CollectionUtils.isEmpty(collect)) { | ||
1535 | 1527 | ||
1536 | TvUnBindBean tvUnBindBean = new TvUnBindBean(); | 1528 | // 按绑定时间倒排 |
1537 | tvUnBindBean.setMemberId(memberId); | 1529 | collect.sort(new Comparator<MemberDTO>() { |
1538 | tvUnBindBean.setAutoModel(weixinUnBindBean.getAutoModel()); | 1530 | @Override |
1539 | String platformAccount = userTvDTO.getPlatformAccount(); | 1531 | public int compare(MemberDTO memberDTO, MemberDTO t1) { |
1540 | tvUnBindBean.setPlatformAccount(platformAccount); | 1532 | return t1.getBindIptvTime().compareTo(memberDTO.getBindIptvTime()); |
1541 | this.tvUnbind(tvUnBindBean); | 1533 | } |
1534 | }); | ||
1535 | // 绑定新的主账号 | ||
1536 | UserTv userTv = new UserTv(); | ||
1537 | userTv.setId(userTvDTO.getId()); | ||
1538 | userTv.setPlatform(userTvDTO.getPlatformAccount()); | ||
1539 | userTv.setPriorityMemberCode(collect.get(0).getCode()); | ||
1540 | userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv); | ||
1541 | log.info("大屏账号绑定新的主账号 ==>> userTvDTO ==>> {}", userTvDTO); | ||
1542 | } | ||
1543 | |||
1544 | } else { | ||
1545 | log.info("无其他绑定的小屏会员信息 "); | ||
1546 | // 绑定新的主账号 | ||
1547 | UserTv userTv = new UserTv(); | ||
1548 | userTv.setId(userTvDTO.getId()); | ||
1549 | userTv.setPlatform(userTvDTO.getPlatformAccount()); | ||
1550 | userTv.setPriorityMemberCode(null); | ||
1551 | userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv); | ||
1552 | log.info("大屏账号置空主会员的结果,userTvDTO ==>> {}", userTvDTO); | ||
1553 | } | ||
1554 | |||
1555 | log.info("同步绑定信息至大屏侧, 参数 ==>> {}", new MemberAndUserTvDTO(memberDTO, userTvDTO)); | ||
1556 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncUnbind(new MemberAndUserTvDTO(memberDTO, userTvDTO)); | ||
1557 | return true; | ||
1542 | } | 1558 | } |
1543 | 1559 | ||
1544 | @Override | 1560 | @Override | ... | ... |
... | @@ -3,58 +3,53 @@ package com.topdraw.business.process.service.impl.member; | ... | @@ -3,58 +3,53 @@ package com.topdraw.business.process.service.impl.member; |
3 | import cn.hutool.core.util.ObjectUtil; | 3 | import cn.hutool.core.util.ObjectUtil; |
4 | import com.topdraw.aspect.AsyncMqSend; | 4 | import com.topdraw.aspect.AsyncMqSend; |
5 | import com.topdraw.business.module.member.domain.Member; | 5 | import com.topdraw.business.module.member.domain.Member; |
6 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | ||
7 | import com.topdraw.business.module.member.profile.service.MemberProfileService; | 6 | import com.topdraw.business.module.member.profile.service.MemberProfileService; |
8 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 7 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
9 | import com.topdraw.business.module.member.service.MemberService; | 8 | import com.topdraw.business.module.member.service.MemberService; |
10 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 9 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
11 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; | 10 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; |
12 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; | 11 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; |
13 | import com.topdraw.business.module.task.domain.Task; | ||
14 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 12 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
15 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; | 13 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; |
16 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 14 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
17 | import com.topdraw.business.process.domian.weixin.BuyVipBean; | 15 | import com.topdraw.business.process.domian.weixin.BuyVipBean; |
18 | import com.topdraw.business.process.service.member.MemberOperationService; | 16 | import com.topdraw.business.process.service.member.MemberOperationService; |
19 | import com.topdraw.business.process.service.member.MemberProfileOperationService; | 17 | import com.topdraw.config.RedisKeyConstants; |
20 | import com.topdraw.exception.EntityNotFoundException; | 18 | import com.topdraw.exception.EntityNotFoundException; |
21 | import com.topdraw.util.TimestampUtil; | 19 | import com.topdraw.util.TimestampUtil; |
20 | import lombok.extern.slf4j.Slf4j; | ||
22 | import org.springframework.aop.framework.AopContext; | 21 | import org.springframework.aop.framework.AopContext; |
23 | import org.springframework.beans.BeanUtils; | 22 | import org.springframework.beans.BeanUtils; |
24 | import org.springframework.beans.factory.annotation.Autowired; | 23 | import org.springframework.beans.factory.annotation.Autowired; |
25 | import org.springframework.cache.annotation.CacheConfig; | 24 | import org.springframework.cache.annotation.CacheConfig; |
26 | import org.springframework.cache.annotation.CacheEvict; | ||
27 | import org.springframework.cache.annotation.CachePut; | 25 | import org.springframework.cache.annotation.CachePut; |
28 | import org.springframework.cache.annotation.Cacheable; | ||
29 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
30 | import org.springframework.stereotype.Service; | 26 | import org.springframework.stereotype.Service; |
31 | import org.springframework.util.Assert; | 27 | import org.springframework.util.Assert; |
32 | 28 | ||
33 | import java.sql.Timestamp; | 29 | import java.sql.Timestamp; |
34 | import java.time.LocalDateTime; | 30 | import java.time.LocalDateTime; |
35 | import java.time.ZoneOffset; | ||
36 | import java.util.Objects; | 31 | import java.util.Objects; |
37 | 32 | ||
38 | @Service | 33 | @Service |
39 | //@CacheConfig(cacheNames = "member") | 34 | @Slf4j |
35 | @CacheConfig(cacheNames = RedisKeyConstants.cacheMemberById) | ||
40 | public class MemberOperationServiceImpl implements MemberOperationService { | 36 | public class MemberOperationServiceImpl implements MemberOperationService { |
41 | 37 | ||
38 | |||
42 | @Autowired | 39 | @Autowired |
43 | private MemberService memberService; | 40 | private MemberService memberService; |
44 | @Autowired | 41 | @Autowired |
42 | private UserWeixinService userWeixinService; | ||
43 | @Autowired | ||
45 | private MemberProfileService memberProfileService; | 44 | private MemberProfileService memberProfileService; |
46 | @Autowired | 45 | @Autowired |
47 | private MemberVipHistoryService memberVipHistoryService; | 46 | private MemberVipHistoryService memberVipHistoryService; |
48 | @Autowired | 47 | |
49 | private UserWeixinService userWeixinService; | ||
50 | @Autowired | ||
51 | private ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
52 | 48 | ||
53 | 49 | ||
54 | @AsyncMqSend | 50 | @AsyncMqSend |
55 | public void asyncUpdateMemberVip(MemberDTO me) {} | 51 | public void asyncUpdateMemberVip(MemberDTO memberDTO) {} |
56 | 52 | ||
57 | // @CachePut(key = "#resources.memberId") | ||
58 | @Override | 53 | @Override |
59 | public MemberDTO buyVipByUserId(BuyVipBean resources) { | 54 | public MemberDTO buyVipByUserId(BuyVipBean resources) { |
60 | // 小程序账户id | 55 | // 小程序账户id |
... | @@ -96,12 +91,12 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -96,12 +91,12 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
96 | 91 | ||
97 | } | 92 | } |
98 | 93 | ||
99 | memberDTO.setVip(vip1); | ||
100 | memberDTO.setVipExpireTime(vipExpireTime); | ||
101 | 94 | ||
102 | Member member = new Member(); | 95 | Member member = new Member(); |
103 | BeanUtils.copyProperties(memberDTO,member); | 96 | member.setVip(vip1); |
104 | this.update(member); | 97 | member.setVipExpireTime(vipExpireTime); |
98 | |||
99 | this.doUpdateMemberVipAndVipExpireTime(member); | ||
105 | 100 | ||
106 | MemberVipHistory memberVipHistory = new MemberVipHistory(); | 101 | MemberVipHistory memberVipHistory = new MemberVipHistory(); |
107 | memberVipHistory.setMemberId(memberId).setVip(vip1).setBeforeVip(vip); | 102 | memberVipHistory.setMemberId(memberId).setVip(vip1).setBeforeVip(vip); |
... | @@ -148,7 +143,6 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -148,7 +143,6 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
148 | return this.update(resources); | 143 | return this.update(resources); |
149 | } | 144 | } |
150 | 145 | ||
151 | // @CachePut(key = "#resources.id") | ||
152 | @Override | 146 | @Override |
153 | public MemberDTO doInsertMember(Member resources) { | 147 | public MemberDTO doInsertMember(Member resources) { |
154 | return this.memberService.create(resources); | 148 | return this.memberService.create(resources); |
... | @@ -160,34 +154,39 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -160,34 +154,39 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
160 | return Objects.nonNull(memberId) ? memberDTO : null; | 154 | return Objects.nonNull(memberId) ? memberDTO : null; |
161 | } | 155 | } |
162 | 156 | ||
163 | // @CachePut(key = "#resources.id") | ||
164 | @Override | 157 | @Override |
165 | public MemberDTO doUpdateMemberExpAndLevel(Member resources) { | 158 | public MemberDTO doUpdateMemberExpAndLevel(Member resources) { |
166 | return this.memberService.doUpdateMemberExpAndLevel(resources); | 159 | return this.memberService.doUpdateMemberExpAndLevel(resources); |
167 | } | 160 | } |
168 | 161 | ||
169 | // @CachePut(key = "#resources.id") | 162 | |
170 | @Override | 163 | @Override |
171 | public MemberDTO doUpdateMemberPoints(Member resources) { | 164 | public MemberDTO doUpdateMemberPoints(Member resources) { |
172 | return this.memberService.doUpdateMemberPoints(resources); | 165 | return this.memberService.doUpdateMemberPoints(resources); |
173 | } | 166 | } |
174 | 167 | ||
175 | // @CachePut(key = "#resources.id") | 168 | |
176 | @Override | 169 | @Override |
170 | @CachePut(cacheNames = RedisKeyConstants.cacheMemberById, key = "#member.id") | ||
177 | public MemberDTO doUpdateMemberCoupon(Member member) { | 171 | public MemberDTO doUpdateMemberCoupon(Member member) { |
178 | return this.memberService.doUpdateMemberCoupon(member); | 172 | return this.memberService.doUpdateMemberCoupon(member); |
179 | } | 173 | } |
180 | 174 | ||
181 | @Override | 175 | @Override |
182 | public MemberDTO updateMemberVip(Member member) { | 176 | // @CachePut(cacheNames = RedisKeyConstants.cacheMemberById, key = "#member.id") |
177 | public MemberDTO doUpdateMemberVipAndVipExpireTime(Member member) { | ||
183 | MemberDTO memberDTO1 = this.memberService.findByCode(member.getCode()); | 178 | MemberDTO memberDTO1 = this.memberService.findByCode(member.getCode()); |
179 | |||
184 | Member member1 = new Member(); | 180 | Member member1 = new Member(); |
185 | BeanUtils.copyProperties(memberDTO1, member1); | 181 | member1.setId(memberDTO1.getId()); |
182 | member1.setCode(memberDTO1.getCode()); | ||
186 | member1.setVip(member.getVip()); | 183 | member1.setVip(member.getVip()); |
187 | member1.setVipExpireTime(member.getVipExpireTime()); | 184 | member1.setVipExpireTime(member.getVipExpireTime()); |
188 | MemberDTO memberDTO = this.update(member1); | 185 | MemberDTO memberDTO_ = this.memberService.doUpdateMemberVipAndVipExpireTime(member1); |
189 | ((MemberOperationServiceImpl) AopContext.currentProxy()).asyncUpdateMemberVip(memberDTO); | 186 | |
190 | return memberDTO; | 187 | ((MemberOperationServiceImpl) AopContext.currentProxy()).asyncUpdateMemberVip(memberDTO_); |
188 | |||
189 | return memberDTO_; | ||
191 | } | 190 | } |
192 | 191 | ||
193 | @Override | 192 | @Override |
... | @@ -225,11 +224,12 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -225,11 +224,12 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
225 | MemberDTO memberDTO1 = this.checkVipStatus(memberDTO,vipExpireTime,appid); | 224 | MemberDTO memberDTO1 = this.checkVipStatus(memberDTO,vipExpireTime,appid); |
226 | 225 | ||
227 | // 更新会员信息 | 226 | // 更新会员信息 |
228 | this.threadPoolTaskExecutor.execute(()->{ | ||
229 | Member member = new Member(); | 227 | Member member = new Member(); |
230 | BeanUtils.copyProperties(memberDTO1,member); | 228 | member.setId(memberDTO1.getId()); |
231 | this.update(member); | 229 | member.setCode(memberDTO1.getCode()); |
232 | }); | 230 | member.setVip(memberDTO1.getVip()); |
231 | member.setVipExpireTime(memberDTO1.getVipExpireTime()); | ||
232 | this.doUpdateMemberVipAndVipExpireTime(member); | ||
233 | 233 | ||
234 | vip = memberDTO1.getVip(); | 234 | vip = memberDTO1.getVip(); |
235 | Timestamp vipExpireTime1 = memberDTO1.getVipExpireTime(); | 235 | Timestamp vipExpireTime1 = memberDTO1.getVipExpireTime(); | ... | ... |
... | @@ -111,12 +111,15 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation | ... | @@ -111,12 +111,15 @@ public class MemberProfileOperationServiceImpl implements MemberProfileOperation |
111 | } | 111 | } |
112 | 112 | ||
113 | private void syncMember(MemberProfileDTO memberProfileDTO, MemberDTO memberDTO) { | 113 | private void syncMember(MemberProfileDTO memberProfileDTO, MemberDTO memberDTO) { |
114 | memberDTO.setAvatarUrl(memberProfileDTO.getAvatarUrl()); | ||
115 | memberDTO.setNickname(memberProfileDTO.getRealname()); | ||
116 | memberDTO.setGender(memberProfileDTO.getGender()); | ||
117 | Member member = new Member(); | 114 | Member member = new Member(); |
118 | BeanUtils.copyProperties(memberDTO, member); | 115 | |
119 | this.memberService.update(member); | 116 | member.setId(memberDTO.getId()); |
117 | member.setCode(memberDTO.getCode()); | ||
118 | member.setAvatarUrl(memberProfileDTO.getAvatarUrl()); | ||
119 | member.setNickname(memberProfileDTO.getRealname()); | ||
120 | member.setGender(memberProfileDTO.getGender()); | ||
121 | // this.memberService.update(member); | ||
122 | this.memberService.doUpdateMemberAvatarUrlAndNicknameAndGender(member); | ||
120 | } | 123 | } |
121 | 124 | ||
122 | 125 | ... | ... |
... | @@ -90,5 +90,5 @@ public interface MemberOperationService { | ... | @@ -90,5 +90,5 @@ public interface MemberOperationService { |
90 | * | 90 | * |
91 | * @param member | 91 | * @param member |
92 | */ | 92 | */ |
93 | MemberDTO updateMemberVip(Member member); | 93 | MemberDTO doUpdateMemberVipAndVipExpireTime(Member member); |
94 | } | 94 | } | ... | ... |
... | @@ -28,4 +28,10 @@ public class LocalConstants { | ... | @@ -28,4 +28,10 @@ public class LocalConstants { |
28 | 28 | ||
29 | // 事件类型 3:参加活动 | 29 | // 事件类型 3:参加活动 |
30 | public static final Integer EVT_TYPE_ACTIVITY = 3; | 30 | public static final Integer EVT_TYPE_ACTIVITY = 3; |
31 | |||
32 | |||
33 | |||
34 | |||
35 | // 会员黑名单状态 | ||
36 | public static final Long BLACK_STATUS = 1L; | ||
31 | } | 37 | } | ... | ... |
1 | package com.topdraw.config; | ||
2 | |||
3 | import cn.hutool.core.util.ObjectUtil; | ||
4 | import org.springframework.beans.factory.annotation.Value; | ||
5 | import org.springframework.stereotype.Component; | ||
6 | |||
7 | @Component | ||
8 | public class ServiceEnvConfig { | ||
9 | |||
10 | // uc两侧部署,需配置位于哪一侧 mobile小屏侧 vis大屏侧 | ||
11 | public static String UC_SERVICE_TYPE; | ||
12 | |||
13 | @Value("${uc.service.type:mobile}") | ||
14 | public void setUcServiceType(String ucServiceType) { | ||
15 | UC_SERVICE_TYPE = ucServiceType; | ||
16 | } | ||
17 | |||
18 | public static boolean isMobile() { | ||
19 | return ObjectUtil.equals(UC_SERVICE_TYPE, LocalConstants.ENV_MOBILE); | ||
20 | } | ||
21 | |||
22 | public static boolean isVis() { | ||
23 | return ObjectUtil.equals(UC_SERVICE_TYPE, LocalConstants.ENV_VIS); | ||
24 | } | ||
25 | |||
26 | } |
... | @@ -23,10 +23,9 @@ public class DataSyncMsg implements Serializable { | ... | @@ -23,10 +23,9 @@ public class DataSyncMsg implements Serializable { |
23 | // 具体事件 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 | 23 | // 具体事件 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 |
24 | private Integer event; | 24 | private Integer event; |
25 | //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 25 | //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) |
26 | @NotNull | ||
27 | private Integer deviceType; | 26 | private Integer deviceType; |
28 | // 发送时间 | 27 | // 发送时间 |
29 | private LocalDateTime time; | 28 | private String time; |
30 | // 消息体 | 29 | // 消息体 |
31 | private String msgData; | 30 | private String msgData; |
32 | 31 | ||
... | @@ -37,20 +36,32 @@ public class DataSyncMsg implements Serializable { | ... | @@ -37,20 +36,32 @@ public class DataSyncMsg implements Serializable { |
37 | @AllArgsConstructor | 36 | @AllArgsConstructor |
38 | @NoArgsConstructor | 37 | @NoArgsConstructor |
39 | public static class MsgData { | 38 | public static class MsgData { |
40 | private String remarks; //备注 | 39 | /**备注*/ |
41 | @NotNull | 40 | private String remarks; |
42 | private Long memberId; // 会员id | 41 | // 会员id |
43 | private Long userId; // 账户id | 42 | private Long memberId; |
44 | @NotNull | 43 | // 账户id |
45 | private String appCode; //用户对应的应用code | 44 | private Long userId; |
45 | //用户对应的应用code | ||
46 | private String appCode; | ||
47 | // 会员code | ||
46 | private String memberCode; | 48 | private String memberCode; |
47 | private Long accountId; // 账号id | 49 | // 账号id |
50 | private Long accountId; | ||
51 | // 订单Id | ||
48 | private Long orderId; | 52 | private Long orderId; |
53 | // 活动id | ||
49 | private Long activityId; | 54 | private Long activityId; |
55 | // 节目id | ||
50 | private Long mediaId; | 56 | private Long mediaId; |
57 | // 产品id | ||
51 | private Long itemId; | 58 | private Long itemId; |
59 | // 模板参数 | ||
52 | private String param; | 60 | private String param; |
61 | // 描述 | ||
53 | private String description; | 62 | private String description; |
63 | // 大屏账号 | ||
64 | private String platformAccount; | ||
54 | } | 65 | } |
55 | 66 | ||
56 | } | 67 | } | ... | ... |
1 | package com.topdraw.mq.producer; | 1 | package com.topdraw.mq.producer; |
2 | 2 | ||
3 | import com.topdraw.business.process.service.impl.PointsOperationServiceImpl; | ||
3 | import lombok.extern.slf4j.Slf4j; | 4 | import lombok.extern.slf4j.Slf4j; |
4 | import org.springframework.amqp.core.AmqpTemplate; | 5 | import org.springframework.amqp.core.AmqpTemplate; |
6 | import org.springframework.aop.framework.AopContext; | ||
5 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
6 | import org.springframework.beans.factory.annotation.Value; | 8 | import org.springframework.beans.factory.annotation.Value; |
7 | import org.springframework.stereotype.Component; | 9 | import org.springframework.stereotype.Component; |
... | @@ -57,4 +59,5 @@ public class MessageProducer { | ... | @@ -57,4 +59,5 @@ public class MessageProducer { |
57 | amqpTemplate.convertAndSend(exchange, queue, msg); | 59 | amqpTemplate.convertAndSend(exchange, queue, msg); |
58 | log.info("send sendMessage msg || exchange: {} || queue: {} || msg:{} ", exchange, queue, msg); | 60 | log.info("send sendMessage msg || exchange: {} || queue: {} || msg:{} ", exchange, queue, msg); |
59 | } | 61 | } |
62 | |||
60 | } | 63 | } | ... | ... |
... | @@ -143,3 +143,7 @@ weixin: | ... | @@ -143,3 +143,7 @@ weixin: |
143 | 143 | ||
144 | api: | 144 | api: |
145 | uc-service: http://127.0.0.1:8446 | 145 | uc-service: http://127.0.0.1:8446 |
146 | |||
147 | uc: | ||
148 | # 主会员是否启用,如果启用任务获得的积分将添加至小屏会员上 | ||
149 | validPriorityMember: 0 | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -179,6 +179,13 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -179,6 +179,13 @@ public class TaskOperationControllerTest extends BaseTest { |
179 | this.taskOperationController.deleteTask(task); | 179 | this.taskOperationController.deleteTask(task); |
180 | } | 180 | } |
181 | 181 | ||
182 | @Test | ||
183 | public void dealTask() { | ||
184 | String content = "{\"deviceType\":1,\"event\":8,\"evt\":\"PLAY\",\"msgData\":\"{\\\"description\\\":\\\"{\\\\\\\"playDuration\\\\\\\":1,\\\\\\\"time\\\\\\\":\\\\\\\"2022-05-03 23:10:09\\\\\\\",\\\\\\\"mediaId\\\\\\\":432,\\\\\\\"mediaCode\\\\\\\":\\\\\\\"media_123\\\\\\\",\\\\\\\"mediaName\\\\\\\":\\\\\\\"白宫陷落\\\\\\\"}\\\",\\\"mediaId\\\":432,\\\"platformAccount\\\":\\\"6002110106@ITVP\\\",\\\"param\\\":\\\"{\\\\\\\"playDuration\\\\\\\":1}\\\"}\",\"time\":\"2022-06-17T13:07:16.433\"}\n"; | ||
185 | TaskOperationQueryCriteria task = new TaskOperationQueryCriteria(); | ||
186 | task.setContent(content); | ||
187 | this.taskOperationController.dealTask(task); | ||
188 | } | ||
182 | 189 | ||
183 | 190 | ||
184 | } | 191 | } | ... | ... |
-
Please register or sign in to post a comment