1.优化部分任务处理接口,修改接收任务事件模型
2.为任务处理添加缓存
Showing
46 changed files
with
744 additions
and
260 deletions
member-service-impl/src/main/java/com/topdraw/business/module/member/domain/MemberSimple.java
0 → 100644
1 | package com.topdraw.business.module.member.domain; | ||
2 | |||
3 | import cn.hutool.core.bean.BeanUtil; | ||
4 | import cn.hutool.core.bean.copier.CopyOptions; | ||
5 | import com.topdraw.business.module.common.validated.UpdateGroup; | ||
6 | import lombok.Data; | ||
7 | import lombok.experimental.Accessors; | ||
8 | import org.springframework.data.annotation.CreatedDate; | ||
9 | import org.springframework.data.annotation.LastModifiedDate; | ||
10 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
11 | |||
12 | import javax.persistence.*; | ||
13 | import javax.validation.constraints.NotNull; | ||
14 | import java.io.Serializable; | ||
15 | import java.sql.Timestamp; | ||
16 | |||
17 | /** | ||
18 | * @author XiangHan | ||
19 | * @date 2021-10-22 | ||
20 | */ | ||
21 | @Entity | ||
22 | @Data | ||
23 | @EntityListeners(AuditingEntityListener.class) | ||
24 | @Accessors(chain = true) | ||
25 | @Table(name="uc_member") | ||
26 | public class MemberSimple implements Serializable { | ||
27 | |||
28 | /** 主键 */ | ||
29 | @Id | ||
30 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
31 | @Column(name = "id") | ||
32 | @NotNull(message = "id can't be null!!",groups = {UpdateGroup.class}) | ||
33 | private Long id; | ||
34 | |||
35 | /** 标识 */ | ||
36 | @Column(name = "code") | ||
37 | private String code; | ||
38 | |||
39 | /** 状态 0:不可用;1:可用 */ | ||
40 | @Column(name = "`status`") | ||
41 | private Integer status; | ||
42 | |||
43 | /** 分组信息 */ | ||
44 | @Column(name = "`groups`") | ||
45 | private String groups; | ||
46 | |||
47 | /** 是否会员 0:非会员;1:会员 */ | ||
48 | @Column(name = "vip") | ||
49 | private Integer vip; | ||
50 | |||
51 | /** 会员等级(对应level表的level字段,非id) */ | ||
52 | @Column(name = "`level`") | ||
53 | private Integer level; | ||
54 | |||
55 | /** iptv账号id */ | ||
56 | @Column(name = "user_iptv_id") | ||
57 | private Long userIptvId; | ||
58 | |||
59 | /** 是否在黑名单 1:是;0否 */ | ||
60 | @Column(name = "black_status") | ||
61 | private Long blackStatus; | ||
62 | |||
63 | public void copy(MemberSimple source){ | ||
64 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false)); | ||
65 | } | ||
66 | } |
1 | package com.topdraw.business.module.member.level.service.impl; | 1 | package com.topdraw.business.module.member.level.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.module.member.level.domain.MemberLevel; | 3 | import com.topdraw.business.module.member.level.domain.MemberLevel; |
4 | import com.topdraw.config.RedisKeyConstants; | ||
4 | import com.topdraw.utils.ValidationUtil; | 5 | import com.topdraw.utils.ValidationUtil; |
5 | import com.topdraw.business.module.member.level.repository.MemberLevelRepository; | 6 | import com.topdraw.business.module.member.level.repository.MemberLevelRepository; |
6 | import com.topdraw.business.module.member.level.service.MemberLevelService; | 7 | import com.topdraw.business.module.member.level.service.MemberLevelService; |
7 | import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; | 8 | import com.topdraw.business.module.member.level.service.dto.MemberLevelDTO; |
8 | import com.topdraw.business.module.member.level.service.mapper.MemberLevelMapper; | 9 | import com.topdraw.business.module.member.level.service.mapper.MemberLevelMapper; |
9 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.cache.annotation.Cacheable; | ||
10 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
11 | import org.springframework.transaction.annotation.Propagation; | 13 | import org.springframework.transaction.annotation.Propagation; |
12 | import org.springframework.transaction.annotation.Transactional; | 14 | import org.springframework.transaction.annotation.Transactional; |
... | @@ -42,8 +44,9 @@ public class MemberLevelServiceImpl implements MemberLevelService { | ... | @@ -42,8 +44,9 @@ public class MemberLevelServiceImpl implements MemberLevelService { |
42 | } | 44 | } |
43 | 45 | ||
44 | @Override | 46 | @Override |
47 | @Cacheable(cacheNames = RedisKeyConstants.cacheMemberLevelByLevel, key = "#level", unless = "#result.size() == 0") | ||
45 | public List<MemberLevelDTO> findLevelAndStatus(Integer level, Integer status) { | 48 | public List<MemberLevelDTO> findLevelAndStatus(Integer level, Integer status) { |
46 | return this.memberLevelMapper.toDto(this.memberLevelRepository.findByLevelAndStatus(level,status)); | 49 | return this.memberLevelMapper.toDto(this.memberLevelRepository.findByLevelAndStatus(level, status)); |
47 | } | 50 | } |
48 | 51 | ||
49 | } | 52 | } | ... | ... |
1 | package com.topdraw.business.module.member.repository; | 1 | package com.topdraw.business.module.member.repository; |
2 | 2 | ||
3 | import com.topdraw.business.module.member.domain.Member; | 3 | import com.topdraw.business.module.member.domain.Member; |
4 | import com.topdraw.business.module.member.domain.MemberSimple; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | 5 | import org.springframework.data.jpa.repository.JpaRepository; |
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
6 | import org.springframework.data.jpa.repository.Modifying; | 7 | import org.springframework.data.jpa.repository.Modifying; | ... | ... |
1 | package com.topdraw.business.module.member.repository; | ||
2 | |||
3 | import com.topdraw.business.module.member.domain.MemberSimple; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | ||
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
6 | import org.springframework.data.jpa.repository.Query; | ||
7 | |||
8 | import java.util.Optional; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-10-22 | ||
13 | */ | ||
14 | public interface MemberSimpleRepository extends JpaRepository<MemberSimple, Long>, JpaSpecificationExecutor<MemberSimple> { | ||
15 | |||
16 | @Query(value = "SELECT `id`, `code`, `status`, `groups`, `vip`, `level`,`user_iptv_id`, `black_status` FROM `uc_member` WHERE `id` = ?1", nativeQuery = true) | ||
17 | Optional<MemberSimple> findSimpleById(Long id); | ||
18 | |||
19 | @Query(value = "SELECT `id`, `code`, `status`, `groups`, `vip`, `level`,`user_iptv_id`, `black_status` FROM `uc_member` WHERE `code` = ?1", nativeQuery = true) | ||
20 | Optional<MemberSimple> findSimpleByCode(String code); | ||
21 | } |
... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.member.service; | ... | @@ -2,6 +2,8 @@ package com.topdraw.business.module.member.service; |
2 | 2 | ||
3 | import com.topdraw.business.module.member.domain.Member; | 3 | import com.topdraw.business.module.member.domain.Member; |
4 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 4 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
5 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; | ||
6 | import org.springframework.transaction.annotation.Transactional; | ||
5 | 7 | ||
6 | import java.util.List; | 8 | import java.util.List; |
7 | 9 | ||
... | @@ -26,6 +28,13 @@ public interface MemberService { | ... | @@ -26,6 +28,13 @@ public interface MemberService { |
26 | MemberDTO findById(Long id); | 28 | MemberDTO findById(Long id); |
27 | 29 | ||
28 | /** | 30 | /** |
31 | * | ||
32 | * @param id | ||
33 | * @return | ||
34 | */ | ||
35 | MemberSimpleDTO findSimpleById(Long id); | ||
36 | |||
37 | /** | ||
29 | * 通过code查询会员 | 38 | * 通过code查询会员 |
30 | * @param code 会员编码 | 39 | * @param code 会员编码 |
31 | * @return MemberDTO | 40 | * @return MemberDTO |
... | @@ -33,6 +42,13 @@ public interface MemberService { | ... | @@ -33,6 +42,13 @@ public interface MemberService { |
33 | MemberDTO findByCode(String code); | 42 | MemberDTO findByCode(String code); |
34 | 43 | ||
35 | /** | 44 | /** |
45 | * | ||
46 | * @param code | ||
47 | * @return | ||
48 | */ | ||
49 | MemberSimpleDTO findSimpleByCode(String code); | ||
50 | |||
51 | /** | ||
36 | * 保存 | 52 | * 保存 |
37 | * @param resources | 53 | * @param resources |
38 | * @return Long id | 54 | * @return Long id | ... | ... |
1 | package com.topdraw.business.module.member.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | |||
5 | import java.io.Serializable; | ||
6 | import java.sql.Timestamp; | ||
7 | |||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Data | ||
14 | public class MemberSimpleDTO implements Serializable { | ||
15 | |||
16 | /** 主键 */ | ||
17 | private Long id; | ||
18 | |||
19 | /** 标识 */ | ||
20 | private String code; | ||
21 | |||
22 | /** 昵称 */ | ||
23 | private String nickname; | ||
24 | |||
25 | /** 状态 0:不可用;1:可用 */ | ||
26 | private Integer status; | ||
27 | |||
28 | /** 分组信息 */ | ||
29 | private String groups; | ||
30 | |||
31 | /** 是否会员 0:非会员;1:会员 */ | ||
32 | private Integer vip; | ||
33 | |||
34 | /** 会员等级(对应level表的level字段,非id) */ | ||
35 | private Integer level; | ||
36 | |||
37 | /** iptv账号id */ | ||
38 | private Long userIptvId; | ||
39 | |||
40 | /** 是否在黑名单 1:是;0否 */ | ||
41 | private Long blackStatus; | ||
42 | |||
43 | } |
This diff is collapsed.
Click to expand it.
1 | package com.topdraw.business.module.member.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.module.member.domain.MemberSimple; | ||
5 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; | ||
6 | import org.mapstruct.Mapper; | ||
7 | import org.mapstruct.ReportingPolicy; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-10-22 | ||
12 | */ | ||
13 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
14 | public interface MemberSimpleMapper extends BaseMapper<MemberSimpleDTO, MemberSimple> { | ||
15 | |||
16 | } |
... | @@ -101,5 +101,5 @@ public interface PointsAvailableService { | ... | @@ -101,5 +101,5 @@ public interface PointsAvailableService { |
101 | * | 101 | * |
102 | * @param pointsAvailable | 102 | * @param pointsAvailable |
103 | */ | 103 | */ |
104 | PointsAvailableDTO create4Custom(PointsAvailable pointsAvailable); | 104 | void create4Custom(PointsAvailable pointsAvailable); |
105 | } | 105 | } | ... | ... |
... | @@ -160,17 +160,8 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { | ... | @@ -160,17 +160,8 @@ public class PointsAvailableServiceImpl implements PointsAvailableService { |
160 | } | 160 | } |
161 | 161 | ||
162 | @Override | 162 | @Override |
163 | public PointsAvailableDTO create4Custom(PointsAvailable resources) { | 163 | public void create4Custom(PointsAvailable resources) { |
164 | this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | 164 | this.pointsAvailableRepository.save(resources); |
165 | try { | ||
166 | PointsAvailable pointsAvailable = this.pointsAvailableRepository.save(resources); | ||
167 | return this.pointsAvailableMapper.toDto(pointsAvailable); | ||
168 | } catch (Exception e) { | ||
169 | e.printStackTrace(); | ||
170 | throw e; | ||
171 | } finally { | ||
172 | this.redisUtils.doUnLock("PointsAvailable::create::id"+resources.getMemberId().toString()); | ||
173 | } | ||
174 | } | 165 | } |
175 | 166 | ||
176 | } | 167 | } | ... | ... |
... | @@ -27,6 +27,9 @@ import java.io.Serializable; | ... | @@ -27,6 +27,9 @@ import java.io.Serializable; |
27 | @NoArgsConstructor | 27 | @NoArgsConstructor |
28 | public class TrTaskProgress implements Serializable { | 28 | public class TrTaskProgress implements Serializable { |
29 | 29 | ||
30 | @Transient | ||
31 | private String memberCode; | ||
32 | |||
30 | @Id | 33 | @Id |
31 | @GeneratedValue(strategy = GenerationType.IDENTITY) | 34 | @GeneratedValue(strategy = GenerationType.IDENTITY) |
32 | @Column(name = "id") | 35 | @Column(name = "id") | ... | ... |
... | @@ -5,7 +5,10 @@ import org.springframework.data.jpa.repository.JpaRepository; | ... | @@ -5,7 +5,10 @@ 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.Query; | 6 | import org.springframework.data.jpa.repository.Query; |
7 | 7 | ||
8 | import java.util.HashMap; | ||
8 | import java.util.List; | 9 | import java.util.List; |
10 | import java.util.Map; | ||
11 | import java.util.Optional; | ||
9 | 12 | ||
10 | /** | 13 | /** |
11 | * @author XiangHan | 14 | * @author XiangHan |
... | @@ -13,8 +16,17 @@ import java.util.List; | ... | @@ -13,8 +16,17 @@ import java.util.List; |
13 | */ | 16 | */ |
14 | public interface TrTaskProgressRepository extends JpaRepository<TrTaskProgress, Long>, JpaSpecificationExecutor<TrTaskProgress> { | 17 | public interface TrTaskProgressRepository extends JpaRepository<TrTaskProgress, Long>, JpaSpecificationExecutor<TrTaskProgress> { |
15 | 18 | ||
16 | @Query(value = "select id, member_id, task_id , current_action_amount , \n" + | 19 | @Query(value = "select id, member_id, task_id, current_action_amount," + |
17 | " target_action_amount , `status` , completion_time,create_time,update_time from uc_tr_task_progress where member_id = ?1 \n" + | 20 | " target_action_amount, `status`, completion_time, create_time, update_time from uc_tr_task_progress where member_id = ?1 " + |
18 | " and task_id = ?2 and Date(completion_time) = ?3 ",nativeQuery = true) | 21 | " and task_id = ?2 and Date(completion_time) = ?3 ",nativeQuery = true) |
19 | TrTaskProgress findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); | 22 | Optional<TrTaskProgress> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); |
23 | |||
24 | |||
25 | Integer countByMemberIdAndTaskId(Long memberId, Long taskId); | ||
26 | |||
27 | @Query(value = "select `task_id` AS taskId, count(*) AS finishCount from uc_tr_task_progress where member_id = ?1 and `status` = 1 GROUP BY `task_id` ", nativeQuery = true) | ||
28 | List<Map<String, Object>> countFinishTaskGroupByMemberId(Long memberId); | ||
29 | |||
30 | @Query(value = "select `task_id` AS taskId, count(*) AS finishCount from uc_tr_task_progress where member_id = ?1 and Date(completion_time) = ?2 and `status` = 1 GROUP BY `task_id`", nativeQuery = true) | ||
31 | List<Map<String, Object>> countFinishTaskGroupByMemberIdAndToday(Long memberId, String todayStart); | ||
20 | } | 32 | } | ... | ... |
... | @@ -4,7 +4,9 @@ import com.topdraw.business.module.task.progress.domain.TrTaskProgress; | ... | @@ -4,7 +4,9 @@ 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 | 5 | ||
6 | import java.time.LocalDateTime; | 6 | import java.time.LocalDateTime; |
7 | import java.util.HashMap; | ||
7 | import java.util.List; | 8 | import java.util.List; |
9 | import java.util.Map; | ||
8 | 10 | ||
9 | /** | 11 | /** |
10 | * @author XiangHan | 12 | * @author XiangHan |
... | @@ -44,6 +46,28 @@ public interface TrTaskProgressService { | ... | @@ -44,6 +46,28 @@ public interface TrTaskProgressService { |
44 | * @param time1 | 46 | * @param time1 |
45 | * @return | 47 | * @return |
46 | */ | 48 | */ |
47 | TrTaskProgressDTO findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); | 49 | TrTaskProgress findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1); |
48 | 50 | ||
51 | /** | ||
52 | * | ||
53 | * @param memberId | ||
54 | * @param taskId | ||
55 | * @return | ||
56 | */ | ||
57 | Integer countByMemberIdAndTaskId(Long memberId, Long taskId); | ||
58 | |||
59 | /** | ||
60 | * | ||
61 | * @param id | ||
62 | * @return | ||
63 | */ | ||
64 | Map<Object, Object> countTotalFinishTaskByMemberId(Long id); | ||
65 | |||
66 | /** | ||
67 | * | ||
68 | * @param id | ||
69 | * @param todayStart | ||
70 | * @return | ||
71 | */ | ||
72 | Map<Object, Object> countTodayFinishTaskByMemberId(Long id, String todayStart); | ||
49 | } | 73 | } | ... | ... |
1 | package com.topdraw.business.module.task.progress.service.impl; | 1 | package com.topdraw.business.module.task.progress.service.impl; |
2 | 2 | ||
3 | import cn.hutool.core.map.MapUtil; | ||
3 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; | 4 | import com.topdraw.business.module.task.progress.domain.TrTaskProgress; |
4 | import com.topdraw.config.RedisKeyConstants; | 5 | import com.topdraw.config.RedisKeyConstants; |
6 | import com.topdraw.utils.RedisUtils; | ||
5 | import com.topdraw.utils.ValidationUtil; | 7 | import com.topdraw.utils.ValidationUtil; |
6 | import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository; | 8 | import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository; |
7 | import com.topdraw.business.module.task.progress.service.TrTaskProgressService; | 9 | import com.topdraw.business.module.task.progress.service.TrTaskProgressService; |
... | @@ -16,9 +18,13 @@ import org.springframework.transaction.annotation.Propagation; | ... | @@ -16,9 +18,13 @@ import org.springframework.transaction.annotation.Propagation; |
16 | import org.springframework.transaction.annotation.Transactional; | 18 | import org.springframework.transaction.annotation.Transactional; |
17 | import org.springframework.dao.EmptyResultDataAccessException; | 19 | import org.springframework.dao.EmptyResultDataAccessException; |
18 | import org.springframework.util.Assert; | 20 | import org.springframework.util.Assert; |
21 | import org.springframework.util.CollectionUtils; | ||
19 | 22 | ||
23 | import java.time.LocalDate; | ||
20 | import java.time.LocalDateTime; | 24 | import java.time.LocalDateTime; |
21 | import java.util.List; | 25 | import java.util.*; |
26 | import java.util.stream.Collectors; | ||
27 | import java.util.stream.Stream; | ||
22 | 28 | ||
23 | /** | 29 | /** |
24 | * @author XiangHan | 30 | * @author XiangHan |
... | @@ -31,34 +37,30 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService { | ... | @@ -31,34 +37,30 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService { |
31 | 37 | ||
32 | @Autowired | 38 | @Autowired |
33 | private TrTaskProgressRepository trTaskProgressRepository; | 39 | private TrTaskProgressRepository trTaskProgressRepository; |
34 | |||
35 | @Autowired | 40 | @Autowired |
36 | private TrTaskProgressMapper trTaskProgressMapper; | 41 | private TrTaskProgressMapper trTaskProgressMapper; |
37 | 42 | ||
43 | @Autowired | ||
44 | private RedisUtils redisUtils; | ||
45 | |||
38 | @Override | 46 | @Override |
39 | public TrTaskProgressDTO findById(Long id) { | 47 | public TrTaskProgressDTO findById(Long id) { |
40 | TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(id).orElseGet(TrTaskProgress::new); | 48 | TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(id).orElseGet(TrTaskProgress::new); |
41 | ValidationUtil.isNull(TrTaskProgress.getId(),"TrTaskProgress","id",id); | ||
42 | return this.trTaskProgressMapper.toDto(TrTaskProgress); | 49 | return this.trTaskProgressMapper.toDto(TrTaskProgress); |
43 | } | 50 | } |
44 | 51 | ||
45 | @Override | 52 | @Override |
46 | @Transactional(rollbackFor = Exception.class) | 53 | @Transactional(rollbackFor = Exception.class) |
47 | @Cacheable(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#resources.memberId+':'+#resources.taskId+':'+#date", unless = "#result == null ") | 54 | // @CachePut(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#resources.memberId+':'+#resources.taskId+':'+#date", unless = "#result == null ") |
48 | public TrTaskProgress create(TrTaskProgress resources, String date) { | 55 | public TrTaskProgress create(TrTaskProgress resources, String date) { |
49 | TrTaskProgress trTaskProgress = this.trTaskProgressRepository.save(resources); | 56 | return this.trTaskProgressRepository.save(resources); |
50 | return trTaskProgress; | ||
51 | } | 57 | } |
52 | 58 | ||
53 | @Override | 59 | @Override |
54 | @Transactional(rollbackFor = Exception.class) | 60 | @Transactional(rollbackFor = Exception.class) |
55 | @Cacheable(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#resources.memberId+':'+#resources.taskId+':'+#date", unless = "#result == null ") | 61 | // @CachePut(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#resources.memberId+':'+#resources.taskId+':'+#date", unless = "#result == null ") |
56 | public TrTaskProgress update(TrTaskProgress resources, String date) { | 62 | public TrTaskProgress update(TrTaskProgress resources, String date) { |
57 | TrTaskProgress trTaskProgress = this.trTaskProgressRepository.findById(resources.getId()).orElseGet(TrTaskProgress::new); | 63 | return this.trTaskProgressRepository.save(resources); |
58 | ValidationUtil.isNull( trTaskProgress.getId(),"TrTaskProgress","id",resources.getId()); | ||
59 | trTaskProgress.copy(resources); | ||
60 | TrTaskProgress save = this.trTaskProgressRepository.save(trTaskProgress); | ||
61 | return save; | ||
62 | } | 64 | } |
63 | 65 | ||
64 | @Override | 66 | @Override |
... | @@ -71,12 +73,68 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService { | ... | @@ -71,12 +73,68 @@ public class TrTaskProgressServiceImpl implements TrTaskProgressService { |
71 | } | 73 | } |
72 | 74 | ||
73 | @Override | 75 | @Override |
74 | @Cacheable(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#memberId+':'+#taskId+':'+#time1", unless = "#result == null") | 76 | // @Cacheable(cacheNames = RedisKeyConstants.cacheTaskProcessByMemberId, key = "#memberId+':'+#taskId+':'+#time1", unless = "#result.id == null") |
75 | public TrTaskProgressDTO findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1) { | 77 | public TrTaskProgress findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1) { |
76 | log.info("从数据库查询当前会员今天是否完成了此任务, memberId ==>> {} || taskId ==>> {}", memberId, taskId); | 78 | log.info("从数据库查询当前会员今天是否完成了此任务, memberId ==>> {} || taskId ==>> {}", memberId, taskId); |
77 | return this.trTaskProgressMapper.toDto(this.trTaskProgressRepository.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1)); | 79 | return this.trTaskProgressRepository.findByMemberIdAndTaskIdAndCompletionTime(memberId, taskId, time1).orElseGet(TrTaskProgress::new); |
80 | } | ||
81 | |||
82 | @Override | ||
83 | public Integer countByMemberIdAndTaskId(Long memberId, Long taskId) { | ||
84 | return this.trTaskProgressRepository.countByMemberIdAndTaskId(memberId, taskId); | ||
78 | } | 85 | } |
79 | 86 | ||
87 | @Override | ||
88 | public Map<Object, Object> countTotalFinishTaskByMemberId(Long memberId) { | ||
89 | Map<Object, Object> hmget = this.redisUtils.hmget(RedisKeyConstants.cacheTotalFinishTaskCount + "::" + memberId); | ||
90 | if (Objects.isNull(hmget)) { | ||
91 | List<Map<String, Object>> maps = this.trTaskProgressRepository.countFinishTaskGroupByMemberId(memberId); | ||
92 | if (!CollectionUtils.isEmpty(maps)) { | ||
93 | Map<Object, Object> finishTasks = new HashMap<>(); | ||
94 | for (Map<String, Object> map : maps) { | ||
95 | Object taskId = map.get("taskId"); | ||
96 | if (Objects.isNull(taskId)) { | ||
97 | continue; | ||
98 | } | ||
99 | finishTasks.put(Long.valueOf(taskId.toString()), Integer.valueOf(map.get("finishCount").toString())); | ||
100 | |||
101 | // 总记录一直存储 | ||
102 | this.redisUtils.hmset(RedisKeyConstants.cacheTotalFinishTaskCount + "::" + memberId, finishTasks); | ||
103 | } | ||
104 | return finishTasks; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | return hmget; | ||
109 | } | ||
110 | |||
111 | @Override | ||
112 | public Map<Object, Object> countTodayFinishTaskByMemberId(Long memberId, String todayStart) { | ||
113 | |||
114 | Map<Object, Object> hmget = this.redisUtils.hmget(RedisKeyConstants.cacheTodayFinishTaskCount + "::" + memberId + ":" + todayStart); | ||
115 | if (Objects.isNull(hmget)) { | ||
116 | |||
117 | List<Map<String, Object>> maps = this.trTaskProgressRepository.countFinishTaskGroupByMemberIdAndToday(memberId, todayStart); | ||
118 | if (!CollectionUtils.isEmpty(maps)){ | ||
119 | Map<Object, Object> finishTasks = new HashMap<>(); | ||
120 | for (Map<String, Object> map : maps) { | ||
121 | Object taskId = map.get("taskId"); | ||
122 | if (Objects.isNull(taskId)) { | ||
123 | continue; | ||
124 | } | ||
125 | |||
126 | finishTasks.put(Long.valueOf(taskId.toString()), Integer.valueOf(map.get("finishCount").toString())); | ||
127 | |||
128 | // 单天的记录只存储一天 | ||
129 | this.redisUtils.hmset(RedisKeyConstants.cacheTodayFinishTaskCount + "::" + memberId + ":" + LocalDate.now(), finishTasks, 24*60*60); | ||
130 | } | ||
131 | return finishTasks; | ||
132 | |||
133 | } | ||
134 | |||
135 | } | ||
136 | return hmget; | ||
137 | } | ||
80 | 138 | ||
81 | 139 | ||
82 | } | 140 | } | ... | ... |
... | @@ -28,6 +28,6 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat | ... | @@ -28,6 +28,6 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat |
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 " + | 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 " + | 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 " + | 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) | 31 | " tm.type = ?1 AND ta.`member_level` <= ?2 and ta.`member_vip` <= ?3", nativeQuery = true) |
32 | List<Task> findByEvent(Integer event); | 32 | List<Task> findByEvent(Integer event, Integer level, Integer vip); |
33 | } | 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.member.service.dto.MemberSimpleDTO; | ||
3 | import com.topdraw.business.module.task.domain.Task; | 4 | import com.topdraw.business.module.task.domain.Task; |
4 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; | 5 | import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; |
5 | import com.topdraw.business.module.task.service.dto.TaskDTO; | 6 | import com.topdraw.business.module.task.service.dto.TaskDTO; |
... | @@ -63,6 +64,6 @@ public interface TaskService { | ... | @@ -63,6 +64,6 @@ public interface TaskService { |
63 | * @param event | 64 | * @param event |
64 | * @return | 65 | * @return |
65 | */ | 66 | */ |
66 | List<Task> findByEvent(Integer event); | 67 | List<Task> findByEventAndMemberLevelAndVip(Integer event, Integer level, Integer vip); |
67 | 68 | ||
68 | } | 69 | } | ... | ... |
member-service-impl/src/main/java/com/topdraw/business/module/task/service/impl/TaskServiceImpl.java
1 | package com.topdraw.business.module.task.service.impl; | 1 | package com.topdraw.business.module.task.service.impl; |
2 | 2 | ||
3 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; | ||
3 | import com.topdraw.business.module.task.domain.Task; | 4 | import com.topdraw.business.module.task.domain.Task; |
4 | import com.topdraw.business.module.task.repository.TaskRepository; | 5 | import com.topdraw.business.module.task.repository.TaskRepository; |
5 | import com.topdraw.business.module.task.service.TaskService; | 6 | import com.topdraw.business.module.task.service.TaskService; |
6 | import com.topdraw.business.module.task.service.dto.TaskDTO; | 7 | import com.topdraw.business.module.task.service.dto.TaskDTO; |
7 | import com.topdraw.business.module.task.service.mapper.TaskMapper; | 8 | import com.topdraw.business.module.task.service.mapper.TaskMapper; |
8 | import com.topdraw.config.RedisKeyConstants; | 9 | import com.topdraw.config.RedisKeyConstants; |
10 | import com.topdraw.utils.RedisUtils; | ||
9 | import lombok.extern.slf4j.Slf4j; | 11 | import lombok.extern.slf4j.Slf4j; |
10 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
11 | import org.springframework.cache.annotation.Cacheable; | 13 | import org.springframework.cache.annotation.Cacheable; |
12 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
13 | import org.springframework.transaction.annotation.Propagation; | 15 | import org.springframework.transaction.annotation.Propagation; |
14 | import org.springframework.transaction.annotation.Transactional; | 16 | import org.springframework.transaction.annotation.Transactional; |
17 | import org.springframework.util.CollectionUtils; | ||
15 | 18 | ||
16 | import java.util.ArrayList; | 19 | import java.util.ArrayList; |
17 | import java.util.List; | 20 | import java.util.List; |
... | @@ -30,6 +33,8 @@ public class TaskServiceImpl implements TaskService { | ... | @@ -30,6 +33,8 @@ public class TaskServiceImpl implements TaskService { |
30 | private TaskMapper taskMapper; | 33 | private TaskMapper taskMapper; |
31 | @Autowired | 34 | @Autowired |
32 | private TaskRepository taskRepository; | 35 | private TaskRepository taskRepository; |
36 | @Autowired | ||
37 | private RedisUtils redisUtils; | ||
33 | 38 | ||
34 | @Override | 39 | @Override |
35 | public TaskDTO findById(Long id) { | 40 | public TaskDTO findById(Long id) { |
... | @@ -72,9 +77,10 @@ public class TaskServiceImpl implements TaskService { | ... | @@ -72,9 +77,10 @@ public class TaskServiceImpl implements TaskService { |
72 | } | 77 | } |
73 | 78 | ||
74 | @Override | 79 | @Override |
75 | @Cacheable(value = RedisKeyConstants.cacheTaskByEvent, key = "#event" , unless = "#result.size() == 0") | 80 | @Cacheable(cacheNames = RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip, key = "#event+':'+#level+':'+#vip", |
76 | public List<Task> findByEvent(Integer event) { | 81 | unless = "#result.size() == 0") |
77 | log.info("从数据库查询事件列表 ==>> {}", event); | 82 | public List<Task> findByEventAndMemberLevelAndVip(Integer event, Integer level, Integer vip) { |
78 | return Objects.nonNull(event) ? this.taskRepository.findByEvent(event) : new ArrayList<>(); | 83 | List<Task> tasks = this.taskRepository.findByEvent(event, level, vip); |
84 | return Objects.nonNull(event) ? tasks : new ArrayList<>(); | ||
79 | } | 85 | } |
80 | } | 86 | } | ... | ... |
member-service-impl/src/main/java/com/topdraw/business/module/user/iptv/domain/UserTvSimple.java
0 → 100644
1 | package com.topdraw.business.module.user.iptv.domain; | ||
2 | |||
3 | import cn.hutool.core.bean.BeanUtil; | ||
4 | import cn.hutool.core.bean.copier.CopyOptions; | ||
5 | import com.topdraw.business.module.common.domain.AsyncMqModule; | ||
6 | import com.topdraw.business.module.common.validated.CreateGroup; | ||
7 | import com.topdraw.business.module.common.validated.UpdateGroup; | ||
8 | import lombok.Data; | ||
9 | import lombok.experimental.Accessors; | ||
10 | import org.springframework.data.annotation.CreatedDate; | ||
11 | import org.springframework.data.annotation.LastModifiedDate; | ||
12 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
13 | |||
14 | import javax.persistence.*; | ||
15 | import javax.validation.constraints.NotNull; | ||
16 | import java.io.Serializable; | ||
17 | import java.sql.Timestamp; | ||
18 | |||
19 | /** | ||
20 | * @author XiangHan | ||
21 | * @date 2021-12-16 | ||
22 | */ | ||
23 | @Entity | ||
24 | @Data | ||
25 | @EntityListeners(AuditingEntityListener.class) | ||
26 | @Accessors(chain = true) | ||
27 | @Table(name="uc_user_tv") | ||
28 | public class UserTvSimple extends AsyncMqModule implements Serializable { | ||
29 | |||
30 | /** ID */ | ||
31 | @Id | ||
32 | @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
33 | @Column(name = "id") | ||
34 | private Long id; | ||
35 | |||
36 | /** 会员id */ | ||
37 | @Column(name = "member_id") | ||
38 | private Long memberId; | ||
39 | |||
40 | /** 原vis_user_id */ | ||
41 | @Column(name = "vis_user_id") | ||
42 | private Long visUserId; | ||
43 | |||
44 | /** 绑定的小屏账户会员编码 */ | ||
45 | @Column(name = "priority_member_code") | ||
46 | private String priorityMemberCode; | ||
47 | |||
48 | public void copy(UserTvSimple source){ | ||
49 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false)); | ||
50 | } | ||
51 | } |
1 | package com.topdraw.business.module.user.iptv.repository; | 1 | package com.topdraw.business.module.user.iptv.repository; |
2 | 2 | ||
3 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 3 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
4 | import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO; | ||
4 | import org.springframework.data.jpa.repository.JpaRepository; | 5 | import org.springframework.data.jpa.repository.JpaRepository; |
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
6 | import org.springframework.data.jpa.repository.Modifying; | 7 | import org.springframework.data.jpa.repository.Modifying; | ... | ... |
1 | package com.topdraw.business.module.user.iptv.repository; | ||
2 | |||
3 | import com.topdraw.business.module.user.iptv.domain.UserTvSimple; | ||
4 | import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO; | ||
5 | import org.springframework.data.jpa.repository.JpaRepository; | ||
6 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
7 | import org.springframework.data.jpa.repository.Query; | ||
8 | |||
9 | /** | ||
10 | * @author XiangHan | ||
11 | * @date 2021-12-16 | ||
12 | */ | ||
13 | public interface UserTvSimpleRepository extends JpaRepository<UserTvSimple, Long>, JpaSpecificationExecutor<UserTvSimple> { | ||
14 | |||
15 | @Query(value = "SELECT `id`, `vis_user_id` , `member_id` , " + | ||
16 | " `priority_member_code` FROM `uc_user_tv` WHERE `platform_account` = ?1", nativeQuery = true) | ||
17 | UserTvSimple findSimpleByPlatformAccount(String platformAccount); | ||
18 | } |
... | @@ -3,6 +3,7 @@ package com.topdraw.business.module.user.iptv.service; | ... | @@ -3,6 +3,7 @@ package com.topdraw.business.module.user.iptv.service; |
3 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 3 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
4 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 4 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
5 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 5 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
6 | import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO; | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * @author XiangHan | 9 | * @author XiangHan |
... | @@ -51,6 +52,13 @@ public interface UserTvService { | ... | @@ -51,6 +52,13 @@ public interface UserTvService { |
51 | 52 | ||
52 | /** | 53 | /** |
53 | * | 54 | * |
55 | * @param platformAccount | ||
56 | * @return | ||
57 | */ | ||
58 | UserTvSimpleDTO findSimpleByPlatformAccount(String platformAccount); | ||
59 | |||
60 | /** | ||
61 | * | ||
54 | * @param memberCode | 62 | * @param memberCode |
55 | * @return | 63 | * @return |
56 | */ | 64 | */ | ... | ... |
1 | package com.topdraw.business.module.user.iptv.service.dto; | ||
2 | |||
3 | import lombok.Data; | ||
4 | |||
5 | import java.io.Serializable; | ||
6 | |||
7 | |||
8 | /** | ||
9 | * @author XiangHan | ||
10 | * @date 2021-12-16 | ||
11 | */ | ||
12 | @Data | ||
13 | public class UserTvSimpleDTO implements Serializable { | ||
14 | |||
15 | private Long visUserId; | ||
16 | /** 绑定的小屏账户会员编码 */ | ||
17 | private String priorityMemberCode; | ||
18 | /** 会员id */ | ||
19 | private Long memberId; | ||
20 | |||
21 | private String platformAccount; | ||
22 | } | ||
23 | |||
24 |
1 | package com.topdraw.business.module.user.iptv.service.impl; | 1 | package com.topdraw.business.module.user.iptv.service.impl; |
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | ||
3 | import com.topdraw.aspect.AsyncMqSend; | 4 | import com.topdraw.aspect.AsyncMqSend; |
4 | import com.topdraw.business.module.member.service.MemberService; | 5 | import com.topdraw.business.module.member.service.MemberService; |
5 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 6 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
6 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 7 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
7 | import com.topdraw.business.process.service.impl.UserOperationServiceImpl; | 8 | import com.topdraw.business.module.user.iptv.domain.UserTvSimple; |
9 | import com.topdraw.business.module.user.iptv.repository.UserTvSimpleRepository; | ||
10 | import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO; | ||
11 | import com.topdraw.business.module.user.iptv.service.mapper.UserTvSimpleMapper; | ||
8 | import com.topdraw.config.RedisKeyConstants; | 12 | import com.topdraw.config.RedisKeyConstants; |
9 | import com.topdraw.exception.EntityNotFoundException; | 13 | import com.topdraw.exception.EntityNotFoundException; |
10 | import com.topdraw.exception.GlobeExceptionMsg; | 14 | import com.topdraw.exception.GlobeExceptionMsg; |
15 | import com.topdraw.utils.RedisUtils; | ||
11 | import com.topdraw.utils.ValidationUtil; | 16 | import com.topdraw.utils.ValidationUtil; |
12 | import com.topdraw.business.module.user.iptv.repository.UserTvRepository; | 17 | import com.topdraw.business.module.user.iptv.repository.UserTvRepository; |
13 | import com.topdraw.business.module.user.iptv.service.UserTvService; | 18 | import com.topdraw.business.module.user.iptv.service.UserTvService; |
... | @@ -16,6 +21,7 @@ import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper; | ... | @@ -16,6 +21,7 @@ import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper; |
16 | import lombok.extern.slf4j.Slf4j; | 21 | import lombok.extern.slf4j.Slf4j; |
17 | import org.apache.commons.lang3.StringUtils; | 22 | import org.apache.commons.lang3.StringUtils; |
18 | import org.springframework.aop.framework.AopContext; | 23 | import org.springframework.aop.framework.AopContext; |
24 | import org.springframework.beans.BeanUtils; | ||
19 | import org.springframework.beans.factory.annotation.Autowired; | 25 | import org.springframework.beans.factory.annotation.Autowired; |
20 | import org.springframework.cache.annotation.Cacheable; | 26 | import org.springframework.cache.annotation.Cacheable; |
21 | import org.springframework.stereotype.Service; | 27 | import org.springframework.stereotype.Service; |
... | @@ -25,6 +31,8 @@ import org.springframework.dao.EmptyResultDataAccessException; | ... | @@ -25,6 +31,8 @@ import org.springframework.dao.EmptyResultDataAccessException; |
25 | import org.springframework.util.Assert; | 31 | import org.springframework.util.Assert; |
26 | 32 | ||
27 | import java.time.LocalDateTime; | 33 | import java.time.LocalDateTime; |
34 | import java.util.HashMap; | ||
35 | import java.util.Map; | ||
28 | import java.util.Objects; | 36 | import java.util.Objects; |
29 | import java.util.Optional; | 37 | import java.util.Optional; |
30 | 38 | ||
... | @@ -41,9 +49,16 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -41,9 +49,16 @@ public class UserTvServiceImpl implements UserTvService { |
41 | @Autowired | 49 | @Autowired |
42 | private UserTvMapper userTvMapper; | 50 | private UserTvMapper userTvMapper; |
43 | @Autowired | 51 | @Autowired |
52 | private UserTvSimpleMapper userTvSimpleMapper; | ||
53 | @Autowired | ||
44 | private MemberService memberService; | 54 | private MemberService memberService; |
45 | @Autowired | 55 | @Autowired |
46 | private UserTvRepository userTvRepository; | 56 | private UserTvRepository userTvRepository; |
57 | @Autowired | ||
58 | private UserTvSimpleRepository userTvSimpleRepository; | ||
59 | |||
60 | @Autowired | ||
61 | private RedisUtils redisUtils; | ||
47 | 62 | ||
48 | @AsyncMqSend | 63 | @AsyncMqSend |
49 | public void asyncUpdateUserTvVisUserId(UserTvDTO userTvDTO) {} | 64 | public void asyncUpdateUserTvVisUserId(UserTvDTO userTvDTO) {} |
... | @@ -57,6 +72,7 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -57,6 +72,7 @@ public class UserTvServiceImpl implements UserTvService { |
57 | * @return | 72 | * @return |
58 | */ | 73 | */ |
59 | @Override | 74 | @Override |
75 | @Transactional(readOnly = true) | ||
60 | public MemberDTO findMemberByPlatformAccount(String platformAccount){ | 76 | public MemberDTO findMemberByPlatformAccount(String platformAccount){ |
61 | // 大屏账户 | 77 | // 大屏账户 |
62 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); | 78 | UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount); |
... | @@ -119,6 +135,7 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -119,6 +135,7 @@ public class UserTvServiceImpl implements UserTvService { |
119 | } | 135 | } |
120 | 136 | ||
121 | @Override | 137 | @Override |
138 | @Transactional(readOnly = true) | ||
122 | public UserTvDTO findById(Long id) { | 139 | public UserTvDTO findById(Long id) { |
123 | UserTv UserTv = this.userTvRepository.findById(id).orElseGet(UserTv::new); | 140 | UserTv UserTv = this.userTvRepository.findById(id).orElseGet(UserTv::new); |
124 | ValidationUtil.isNull(UserTv.getId(),"UserTv","id",id); | 141 | ValidationUtil.isNull(UserTv.getId(),"UserTv","id",id); |
... | @@ -169,18 +186,39 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -169,18 +186,39 @@ public class UserTvServiceImpl implements UserTvService { |
169 | } | 186 | } |
170 | 187 | ||
171 | @Override | 188 | @Override |
172 | @Cacheable(cacheNames = RedisKeyConstants.cacheUserTvByPlatformAccount, key = "#platformAccount") | 189 | @Cacheable(cacheNames = RedisKeyConstants.cacheUserTvByPlatformAccount, key = "#platformAccount", unless = "#result.id == null") |
190 | @Transactional(readOnly = true) | ||
173 | public UserTvDTO findByPlatformAccount(String platformAccount) { | 191 | public UserTvDTO findByPlatformAccount(String platformAccount) { |
174 | log.info("从数据库通过大屏账号检索大屏账号信息"); | 192 | UserTv userTv = this.userTvRepository.findByPlatformAccount(platformAccount).orElseGet(UserTv::new); |
175 | Optional<UserTv> userTv = this.userTvRepository.findByPlatformAccount(platformAccount); | 193 | return this.userTvMapper.toDto(userTv); |
176 | if (userTv.isPresent()) { | 194 | } |
177 | ValidationUtil.isNull( userTv.get().getId(),"UserTv","id",userTv.get().getId()); | 195 | |
178 | return this.userTvMapper.toDto(userTv.get()); | 196 | @Override |
197 | // @Cacheable(cacheNames = RedisKeyConstants.cacheUserTvByPlatformAccount, key = "#platformAccount") | ||
198 | public UserTvSimpleDTO findSimpleByPlatformAccount(String platformAccount) { | ||
199 | |||
200 | Object userTvSimpleObj = this.redisUtils.get(RedisKeyConstants.cacheVisUserByPlatformAccount + "::" + platformAccount); | ||
201 | if (Objects.nonNull(userTvSimpleObj)) { | ||
202 | Map<String, Object> map = (Map<String, Object>)userTvSimpleObj; | ||
203 | UserTvSimpleDTO userTvSimpleDTO = new UserTvSimpleDTO(); | ||
204 | userTvSimpleDTO.setPlatformAccount(map.get("platformAccount").toString()); | ||
205 | userTvSimpleDTO.setMemberId(Long.valueOf(map.get("memberId").toString())); | ||
206 | userTvSimpleDTO.setPriorityMemberCode(map.get("priorityMemberCode") == null ? "" : map.get("priorityMemberCode").toString()); | ||
207 | return userTvSimpleDTO; | ||
179 | } | 208 | } |
209 | |||
210 | UserTvSimple userTvSimple = this.userTvSimpleRepository.findSimpleByPlatformAccount(platformAccount); | ||
211 | if (Objects.nonNull(userTvSimple)) { | ||
212 | HashMap hashMap = JSONObject.parseObject(userTvSimple.toString(), HashMap.class); | ||
213 | this.redisUtils.set(RedisKeyConstants.cacheVisUserByPlatformAccount + "::" + platformAccount, hashMap); | ||
214 | return this.userTvSimpleMapper.toDto(userTvSimple); | ||
215 | } | ||
216 | |||
180 | return null; | 217 | return null; |
181 | } | 218 | } |
182 | 219 | ||
183 | @Override | 220 | @Override |
221 | @Transactional(readOnly = true) | ||
184 | public UserTvDTO findByPriorityMemberCode(String memberCode) { | 222 | public UserTvDTO findByPriorityMemberCode(String memberCode) { |
185 | Optional<UserTv> userTv = this.userTvRepository.findByPriorityMemberCode(memberCode); | 223 | Optional<UserTv> userTv = this.userTvRepository.findByPriorityMemberCode(memberCode); |
186 | if (userTv.isPresent()) { | 224 | if (userTv.isPresent()) { |
... | @@ -191,6 +229,7 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -191,6 +229,7 @@ public class UserTvServiceImpl implements UserTvService { |
191 | } | 229 | } |
192 | 230 | ||
193 | @Override | 231 | @Override |
232 | @Transactional(readOnly = true) | ||
194 | public UserTvDTO findByMemberId(Long memberId) { | 233 | public UserTvDTO findByMemberId(Long memberId) { |
195 | Optional<UserTv> userTv = this.userTvRepository.findByMemberId(memberId); | 234 | Optional<UserTv> userTv = this.userTvRepository.findByMemberId(memberId); |
196 | if (userTv.isPresent()) { | 235 | if (userTv.isPresent()) { |
... | @@ -201,6 +240,7 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -201,6 +240,7 @@ public class UserTvServiceImpl implements UserTvService { |
201 | } | 240 | } |
202 | 241 | ||
203 | @Override | 242 | @Override |
243 | @Transactional(readOnly = true) | ||
204 | public boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId, String memberCode) { | 244 | public boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId, String memberCode) { |
205 | // 检查会员是否存在 | 245 | // 检查会员是否存在 |
206 | this.checkMember(memberId, memberCode); | 246 | this.checkMember(memberId, memberCode); | ... | ... |
1 | package com.topdraw.business.module.user.iptv.service.mapper; | ||
2 | |||
3 | import com.topdraw.base.BaseMapper; | ||
4 | import com.topdraw.business.module.user.iptv.domain.UserTv; | ||
5 | import com.topdraw.business.module.user.iptv.domain.UserTvSimple; | ||
6 | import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO; | ||
7 | import org.mapstruct.Mapper; | ||
8 | import org.mapstruct.ReportingPolicy; | ||
9 | |||
10 | /** | ||
11 | * @author XiangHan | ||
12 | * @date 2021-12-16 | ||
13 | */ | ||
14 | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
15 | public interface UserTvSimpleMapper extends BaseMapper<UserTvSimpleDTO, UserTvSimple> { | ||
16 | |||
17 | } |
... | @@ -35,6 +35,9 @@ public class TempRights { | ... | @@ -35,6 +35,9 @@ public class TempRights { |
35 | @Transient | 35 | @Transient |
36 | protected String memberCode; | 36 | protected String memberCode; |
37 | 37 | ||
38 | @Transient | ||
39 | protected Integer memberLevel; | ||
40 | |||
38 | /** 账号id */ | 41 | /** 账号id */ |
39 | @Transient | 42 | @Transient |
40 | protected Long userId; | 43 | protected Long userId; | ... | ... |
... | @@ -51,7 +51,7 @@ public class TaskOperationController { | ... | @@ -51,7 +51,7 @@ public class TaskOperationController { |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * 新增任务 | 53 | * 新增任务 |
54 | * | 54 | *uc_tr_task_progress |
55 | * @param task 消息 | 55 | * @param task 消息 |
56 | */ | 56 | */ |
57 | @PostMapping(value = "/createTask") | 57 | @PostMapping(value = "/createTask") | ... | ... |
... | @@ -473,8 +473,12 @@ public class UserOperationController { | ... | @@ -473,8 +473,12 @@ public class UserOperationController { |
473 | @ApiOperation("保存大屏账户同时创建会员信息") | 473 | @ApiOperation("保存大屏账户同时创建会员信息") |
474 | @AnonymousAccess | 474 | @AnonymousAccess |
475 | public ResultInfo createTvUserAndMember(@Validated(value = {CreateGroup.class}) @RequestBody UserTv resources) { | 475 | public ResultInfo createTvUserAndMember(@Validated(value = {CreateGroup.class}) @RequestBody UserTv resources) { |
476 | log.info("UserOperationController ==> createUserAndCreateMember ==>> param ==> [{}]",resources); | 476 | log.info("UserOperationController ==> createTvUserAndMember ==>> param ==> [{}]",resources); |
477 | 477 | String platformAccount = resources.getPlatformAccount(); | |
478 | if (StringUtils.isBlank(platformAccount)) { | ||
479 | log.error("保存大屏账户同时创建会员信息异常,参数错误,大屏账号不存在"); | ||
480 | return ResultInfo.failure("参数错误,大屏账号不存在"); | ||
481 | } | ||
478 | UserTvDTO result = this.userOperationService.createTvUserAndMember(resources); | 482 | UserTvDTO result = this.userOperationService.createTvUserAndMember(resources); |
479 | return ResultInfo.success(result); | 483 | return ResultInfo.success(result); |
480 | } | 484 | } | ... | ... |
member-service-impl/src/main/java/com/topdraw/business/process/service/AsyncTaskService.java
0 → 100644
1 | package com.topdraw.business.process.service; | ||
2 | |||
3 | import lombok.extern.slf4j.Slf4j; | ||
4 | import org.springframework.stereotype.Service; | ||
5 | |||
6 | /** | ||
7 | * @author : | ||
8 | * @description: | ||
9 | * @function : | ||
10 | * @date :Created in 2022/6/22 14:05 | ||
11 | * @version: : | ||
12 | * @modified By: | ||
13 | * @since : modified in 2022/6/22 14:05 | ||
14 | */ | ||
15 | @Service | ||
16 | @Slf4j | ||
17 | public class AsyncTaskService { | ||
18 | |||
19 | |||
20 | |||
21 | } |
... | @@ -23,5 +23,5 @@ public interface RightsOperationService { | ... | @@ -23,5 +23,5 @@ public interface RightsOperationService { |
23 | * 任务完成自动发放权益 | 23 | * 任务完成自动发放权益 |
24 | * @param tempRightsMap | 24 | * @param tempRightsMap |
25 | */ | 25 | */ |
26 | void grantRights(Map<RightType, Object> tempRightsMap); | 26 | Integer grantRights(Map<RightType, Object> tempRightsMap); |
27 | } | 27 | } | ... | ... |
... | @@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j; | ... | @@ -19,6 +19,7 @@ import lombok.extern.slf4j.Slf4j; |
19 | import org.springframework.aop.framework.AopContext; | 19 | import org.springframework.aop.framework.AopContext; |
20 | import org.springframework.beans.BeanUtils; | 20 | import org.springframework.beans.BeanUtils; |
21 | import org.springframework.beans.factory.annotation.Autowired; | 21 | import org.springframework.beans.factory.annotation.Autowired; |
22 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
22 | import org.springframework.stereotype.Service; | 23 | import org.springframework.stereotype.Service; |
23 | 24 | ||
24 | import java.time.LocalDate; | 25 | import java.time.LocalDate; |
... | @@ -43,6 +44,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -43,6 +44,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
43 | MemberService memberService; | 44 | MemberService memberService; |
44 | 45 | ||
45 | @Autowired | 46 | @Autowired |
47 | private ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
48 | |||
49 | @Autowired | ||
46 | private RedisUtils redisUtils; | 50 | private RedisUtils redisUtils; |
47 | 51 | ||
48 | // 过期阀值(默认一个月) | 52 | // 过期阀值(默认一个月) |
... | @@ -137,7 +141,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -137,7 +141,9 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
137 | member.setUpdateTime(TimestampUtil.now()); | 141 | member.setUpdateTime(TimestampUtil.now()); |
138 | this.memberOperationService.doUpdateMemberCoupon(member); | 142 | this.memberOperationService.doUpdateMemberCoupon(member); |
139 | 143 | ||
140 | ((CouponOperationServiceImpl) AopContext.currentProxy()).asyncMemberCoupon(member); | 144 | /*this.threadPoolTaskExecutor.submit(() -> { |
145 | ((CouponOperationServiceImpl) AopContext.currentProxy()).asyncMemberCoupon(member); | ||
146 | });*/ | ||
141 | } | 147 | } |
142 | 148 | ||
143 | private MemberDTO findMemberByMemberId(Long memberId) { | 149 | private MemberDTO findMemberByMemberId(Long memberId) { | ... | ... |
... | @@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j; | ... | @@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j; |
20 | import org.springframework.aop.framework.AopContext; | 20 | import org.springframework.aop.framework.AopContext; |
21 | import org.springframework.beans.BeanUtils; | 21 | import org.springframework.beans.BeanUtils; |
22 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
23 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
23 | import org.springframework.stereotype.Service; | 24 | import org.springframework.stereotype.Service; |
24 | import org.springframework.util.CollectionUtils; | 25 | import org.springframework.util.CollectionUtils; |
25 | 26 | ||
... | @@ -43,6 +44,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -43,6 +44,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
43 | MemberService memberService; | 44 | MemberService memberService; |
44 | 45 | ||
45 | @Autowired | 46 | @Autowired |
47 | private ThreadPoolTaskExecutor threadPoolTaskExecutor; | ||
48 | |||
49 | @Autowired | ||
46 | private RedisUtils redisUtils; | 50 | private RedisUtils redisUtils; |
47 | 51 | ||
48 | @AsyncMqSend | 52 | @AsyncMqSend |
... | @@ -80,21 +84,27 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -80,21 +84,27 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
80 | this.redisUtils.doLock(RedisKeyConstants.updateCacheExpByMemberId + tempExp.getMemberId()); | 84 | this.redisUtils.doLock(RedisKeyConstants.updateCacheExpByMemberId + tempExp.getMemberId()); |
81 | 85 | ||
82 | // 原始经验值 | 86 | // 原始经验值 |
87 | long l = System.currentTimeMillis(); | ||
83 | long originExp = this.getExpByMemberId(tempExp); | 88 | long originExp = this.getExpByMemberId(tempExp); |
84 | log.info("----获取会员当前原始经验值 ==>> {}", originExp); | 89 | long l1 = System.currentTimeMillis(); |
90 | log.info("----获取会员当前原始经验值 ==>> {}, 总耗时 -->> {}", originExp, (l1-l)); | ||
85 | // 总经验值 | 91 | // 总经验值 |
92 | // TODO | ||
86 | long totalExp = this.calculateTotalExp(originExp, tempExp); | 93 | long totalExp = this.calculateTotalExp(originExp, tempExp); |
87 | log.info("----计算总经验值 ==>> {}", totalExp); | 94 | log.info("----计算总经验值 ==>> {}", totalExp); |
88 | 95 | ||
89 | // 2.更新成长值与等级 | 96 | // 2.更新成长值与等级 |
90 | log.info("----更新会员经验值与对应等级 ==>> {}", totalExp); | 97 | long l2 = System.currentTimeMillis(); |
91 | this.refreshMemberExpAndLevel(tempExp, totalExp); | 98 | this.refreshMemberExpAndLevel(tempExp, totalExp); |
99 | long l3 = System.currentTimeMillis(); | ||
100 | log.info("----更新会员经验值与对应等级 ==>> {}, 总耗时 ==>> {}", totalExp, (l3-l2)); | ||
92 | 101 | ||
93 | log.info("----保存经验值历史 "); | 102 | long l4 = System.currentTimeMillis(); |
94 | this.doInsertExpDetail(tempExp, originExp, totalExp); | 103 | this.doInsertExpDetail(tempExp, originExp, totalExp); |
95 | 104 | long l5 = System.currentTimeMillis(); | |
105 | log.info("----保存经验值历史 -->> 总耗时 -->> {}", (l5-l4)); | ||
96 | } catch (Exception e) { | 106 | } catch (Exception e) { |
97 | log.error("成长值发放失败,"+e.getMessage()); | 107 | log.error("成长值发放失败,{}",e.getMessage()); |
98 | } finally { | 108 | } finally { |
99 | this.redisUtils.doUnLock(RedisKeyConstants.updateCacheExpByMemberId + tempExp.getMemberId()); | 109 | this.redisUtils.doUnLock(RedisKeyConstants.updateCacheExpByMemberId + tempExp.getMemberId()); |
100 | } | 110 | } |
... | @@ -112,8 +122,8 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -112,8 +122,8 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
112 | */ | 122 | */ |
113 | private long getExpByMemberId(TempExp tempExp) { | 123 | private long getExpByMemberId(TempExp tempExp) { |
114 | Long memberId = tempExp.getMemberId(); | 124 | Long memberId = tempExp.getMemberId(); |
115 | MemberDTO memberDTO = this.memberOperationService.findById(memberId); | 125 | MemberDTO memberDTO = this.memberService.findById(memberId); |
116 | if (Objects.nonNull(memberDTO)) { | 126 | if (Objects.nonNull(memberDTO.getId())) { |
117 | Long exp = memberDTO.getExp(); | 127 | Long exp = memberDTO.getExp(); |
118 | return Objects.isNull(exp) ? 0L : exp; | 128 | return Objects.isNull(exp) ? 0L : exp; |
119 | } | 129 | } |
... | @@ -127,13 +137,13 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -127,13 +137,13 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
127 | */ | 137 | */ |
128 | private void refreshMemberExpAndLevel(TempExp tempExp,long totalExp) { | 138 | private void refreshMemberExpAndLevel(TempExp tempExp,long totalExp) { |
129 | 139 | ||
140 | Integer memberLevel = tempExp.getMemberLevel(); | ||
130 | Long memberId = tempExp.getMemberId(); | 141 | Long memberId = tempExp.getMemberId(); |
131 | // 1.获取当前成长值 | ||
132 | MemberDTO memberDTO = this.getMemberInfoByMemberId(memberId); | ||
133 | // 2.获取下一级需要的成长值 | 142 | // 2.获取下一级需要的成长值 |
134 | MemberLevelDTO memberLevelDTO = this.getNextLevelExp(memberDTO.getLevel() + 1, 1); | 143 | // TODO 需要缓存 |
144 | MemberLevelDTO memberLevelDTO = this.getNextLevelExp(memberLevel + 1, 1); | ||
135 | // 4.成长值比较,判断是否升级 | 145 | // 4.成长值比较,判断是否升级 |
136 | Integer level = this.compareExp(totalExp, memberLevelDTO,memberDTO); | 146 | Integer level = this.compareExp(totalExp, memberLevelDTO, memberLevel); |
137 | // 5.更新用户信息 | 147 | // 5.更新用户信息 |
138 | this.updateMemberInfo(level, totalExp, memberId); | 148 | this.updateMemberInfo(level, totalExp, memberId); |
139 | } | 149 | } |
... | @@ -154,8 +164,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -154,8 +164,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
154 | member.setLevel(level); | 164 | member.setLevel(level); |
155 | member.setUpdateTime(TimestampUtil.now()); | 165 | member.setUpdateTime(TimestampUtil.now()); |
156 | this.memberOperationService.doUpdateMemberExpAndLevel(member); | 166 | this.memberOperationService.doUpdateMemberExpAndLevel(member); |
157 | 167 | /*this.threadPoolTaskExecutor.submit(() -> { | |
158 | ((ExpOperationServiceImpl) AopContext.currentProxy()).asyncMemberExpAndLevel(member); | 168 | ((ExpOperationServiceImpl) AopContext.currentProxy()).asyncMemberExpAndLevel(member); |
169 | });*/ | ||
159 | } | 170 | } |
160 | 171 | ||
161 | private MemberDTO findMemberByMemberId(Long memberId) { | 172 | private MemberDTO findMemberByMemberId(Long memberId) { |
... | @@ -163,7 +174,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -163,7 +174,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
163 | return memberDTO; | 174 | return memberDTO; |
164 | } | 175 | } |
165 | 176 | ||
166 | private Integer compareExp(long newExp, MemberLevelDTO memberLevelDTO,MemberDTO memberDTO) { | 177 | private Integer compareExp(long newExp, MemberLevelDTO memberLevelDTO, Integer oldMemberLevel) { |
167 | if (Objects.nonNull(memberLevelDTO)) { | 178 | if (Objects.nonNull(memberLevelDTO)) { |
168 | Long nextLevelExp = memberLevelDTO.getExpValue(); | 179 | Long nextLevelExp = memberLevelDTO.getExpValue(); |
169 | if (Objects.nonNull(nextLevelExp) && nextLevelExp > 0) | 180 | if (Objects.nonNull(nextLevelExp) && nextLevelExp > 0) |
... | @@ -171,11 +182,11 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -171,11 +182,11 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
171 | return memberLevelDTO.getLevel(); | 182 | return memberLevelDTO.getLevel(); |
172 | } | 183 | } |
173 | } | 184 | } |
174 | return memberDTO.getLevel(); | 185 | return oldMemberLevel; |
175 | } | 186 | } |
176 | 187 | ||
177 | private MemberLevelDTO getNextLevelExp(Integer i,Integer status) { | 188 | private MemberLevelDTO getNextLevelExp(Integer i,Integer status) { |
178 | List<MemberLevelDTO> memberLevelDTOList = this.memberLevelService.findLevelAndStatus(i,status); | 189 | List<MemberLevelDTO> memberLevelDTOList = this.memberLevelService.findLevelAndStatus(i, status); |
179 | if (!CollectionUtils.isEmpty(memberLevelDTOList)) { | 190 | if (!CollectionUtils.isEmpty(memberLevelDTOList)) { |
180 | return memberLevelDTOList.get(0); | 191 | return memberLevelDTOList.get(0); |
181 | } | 192 | } |
... | @@ -217,8 +228,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -217,8 +228,9 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
217 | } | 228 | } |
218 | this.expDetailService.create(expDetail); | 229 | this.expDetailService.create(expDetail); |
219 | 230 | ||
220 | 231 | /*this.threadPoolTaskExecutor.submit(() -> { | |
221 | ((ExpOperationServiceImpl) AopContext.currentProxy()).asyncExpDetail(expDetail); | 232 | ((ExpOperationServiceImpl) AopContext.currentProxy()).asyncExpDetail(expDetail); |
233 | });*/ | ||
222 | } | 234 | } |
223 | 235 | ||
224 | } | 236 | } | ... | ... |
... | @@ -52,22 +52,19 @@ import java.util.stream.Collectors; | ... | @@ -52,22 +52,19 @@ import java.util.stream.Collectors; |
52 | public class PointsOperationServiceImpl implements PointsOperationService { | 52 | public class PointsOperationServiceImpl implements PointsOperationService { |
53 | 53 | ||
54 | @Autowired | 54 | @Autowired |
55 | private PointsService pointsService; | ||
56 | @Autowired | ||
57 | private PointsDetailService pointsDetailService; | 55 | private PointsDetailService pointsDetailService; |
58 | @Autowired | 56 | @Autowired |
59 | private PointsAvailableService pointsAvailableService; | 57 | private PointsAvailableService pointsAvailableService; |
60 | @Autowired | 58 | @Autowired |
61 | private PointsDetailHistoryService pointsDetailHistoryService; | ||
62 | @Autowired | ||
63 | private MemberOperationService memberOperationService; | 59 | private MemberOperationService memberOperationService; |
64 | @Autowired | 60 | @Autowired |
65 | private MemberService memberService; | 61 | private MemberService memberService; |
66 | 62 | ||
67 | @Autowired | 63 | @Autowired |
68 | private RedisUtils redisUtils; | 64 | private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
65 | |||
69 | @Autowired | 66 | @Autowired |
70 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | 67 | private RedisUtils redisUtils; |
71 | 68 | ||
72 | // 过期阈值 30天 | 69 | // 过期阈值 30天 |
73 | private static final Integer EXPIRE_FACTOR = 30; | 70 | private static final Integer EXPIRE_FACTOR = 30; |
... | @@ -200,6 +197,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -200,6 +197,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
200 | long currentPoints) { | 197 | long currentPoints) { |
201 | // 兑换的积分 | 198 | // 兑换的积分 |
202 | Long points = tempPoints.getPoints(); | 199 | Long points = tempPoints.getPoints(); |
200 | String memberCode = tempPoints.getMemberCode(); | ||
203 | 201 | ||
204 | List<PointsAvailableDTO> pointsAvailableDTOS = customAvailablePointsMap.get(DELETE_AVAILABLE_POINTS); | 202 | List<PointsAvailableDTO> pointsAvailableDTOS = customAvailablePointsMap.get(DELETE_AVAILABLE_POINTS); |
205 | 203 | ||
... | @@ -211,9 +209,9 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -211,9 +209,9 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
211 | BeanUtils.copyProperties(pointsAvailableDTO, _tempPoints); | 209 | BeanUtils.copyProperties(pointsAvailableDTO, _tempPoints); |
212 | BeanUtils.copyProperties(tempPoints, _tempPoints); | 210 | BeanUtils.copyProperties(tempPoints, _tempPoints); |
213 | _tempPoints.setPoints(-(Math.abs(points))); | 211 | _tempPoints.setPoints(-(Math.abs(points))); |
214 | Long totalPoints = this.calculateTotalPoints(_tempPoints, currentPoints); | 212 | Long totalPoints = currentPoints + tempPoints.getPoints(); |
215 | 213 | ||
216 | this.doInsertTrPointsDetail(memberId, _tempPoints, currentPoints, totalPoints); | 214 | this.doInsertTrPointsDetail(memberId, memberCode, _tempPoints, currentPoints, totalPoints); |
217 | } | 215 | } |
218 | } | 216 | } |
219 | 217 | ||
... | @@ -429,39 +427,47 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -429,39 +427,47 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
429 | * | 427 | * |
430 | * @param tempPoints 积分 | 428 | * @param tempPoints 积分 |
431 | */ | 429 | */ |
432 | |||
433 | private void refresh(TempPoints tempPoints) { | 430 | private void refresh(TempPoints tempPoints) { |
434 | Long memberId = tempPoints.getMemberId(); | 431 | Long memberId = tempPoints.getMemberId(); |
432 | String memberCode = tempPoints.getMemberCode(); | ||
435 | log.info("----------->> 会员id ===>>>>" + memberId); | 433 | log.info("----------->> 会员id ===>>>>" + memberId); |
436 | try { | 434 | try { |
437 | this.redisUtils.doLock(RedisKeyConstants.updateCachePointsByMemberId + memberId.toString()); | 435 | this.redisUtils.doLock(RedisKeyConstants.updateCachePointsByMemberId + memberId.toString()); |
438 | // 1.可用总积分 | 436 | // 1.可用总积分 |
437 | long l = System.currentTimeMillis(); | ||
439 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); | 438 | Long currentPoints = this.findAvailablePointsByMemberId(memberId); |
440 | log.info("----------->> 获取会员当前可用总积分 --->>>> {}", currentPoints); | 439 | long l1 = System.currentTimeMillis(); |
440 | // log.info("查询大屏信息,总耗时 ==>> {}", (l1-l)); | ||
441 | log.info("----------->> 获取会员当前可用总积分 --->>>> {}, 总耗时 ==>> {}", currentPoints, (l1-l)); | ||
441 | 442 | ||
442 | // 2.计算总积分 | 443 | // 2.计算总积分 |
443 | Long totalPoints = this.calculateTotalPoints(tempPoints, currentPoints); | 444 | Long totalPoints = currentPoints + tempPoints.getPoints(); |
444 | log.info("----------->> 总积分(可用总积分+获得的积分) --->>> {}", totalPoints); | 445 | log.info("----------->> 总积分(可用总积分+获得的积分) --->>> {}", totalPoints); |
445 | 446 | ||
446 | // 3.添加积分明细 | 447 | // 3.添加积分明细 |
447 | this.doInsertTrPointsDetail(memberId, tempPoints, currentPoints, totalPoints); | 448 | long l2 = System.currentTimeMillis(); |
448 | log.info("----------->> 添加积分明细 --->>> "); | 449 | this.doInsertTrPointsDetail(memberId, memberCode, tempPoints, currentPoints, totalPoints); |
450 | long l3 = System.currentTimeMillis(); | ||
451 | log.info("----------->> 添加积分明细 --->>> 总耗时 ==>> {}", (l3-l2)); | ||
449 | 452 | ||
450 | // 4.添加可用积分 | 453 | // 4.添加可用积分 |
454 | long l4 = System.currentTimeMillis(); | ||
451 | this.doInsertTrPointsAvailable(tempPoints); | 455 | this.doInsertTrPointsAvailable(tempPoints); |
452 | log.info("----------->> 添加可用积分 -->>> "); | 456 | long l5 = System.currentTimeMillis(); |
457 | log.info("----------->> 添加可用积分 -->>> 总耗时 ==>> {}", (l5-l4)); | ||
453 | 458 | ||
454 | // 5.即将过期的积分 | 459 | // 5.即将过期的积分 |
460 | // TODO 查询的时候再更新过期积分 | ||
455 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); | 461 | long soonExpirePoints = this.getSoonExpirePoints(memberId, tempPoints); |
456 | log.info("----------->> 即将过期的积分 ------->>>>> {}", soonExpirePoints); | 462 | log.info("----------->> 即将过期的积分 ------->>>>> {}", soonExpirePoints); |
457 | 463 | ||
458 | // 6.更新会员的总积分 | 464 | // 6.更新会员的总积分 |
459 | log.info("----------->> 更新会员的总积分 ------->>>>> 总积分--->>> {}", totalPoints); | 465 | long l6 = System.currentTimeMillis(); |
460 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); | 466 | this.freshMemberCurrentPoints(memberId, totalPoints, soonExpirePoints); |
461 | 467 | long l7 = System.currentTimeMillis(); | |
468 | log.info("----------->> 更新会员的总积分 ------->>>>> 总积分--->>> {} -->>总耗时 ==>> {}", totalPoints, (l7-l6)); | ||
462 | } catch (Exception e) { | 469 | } catch (Exception e) { |
463 | e.printStackTrace(); | 470 | log.error(" ==>> {}", e.getMessage()); |
464 | throw e; | ||
465 | } finally { | 471 | } finally { |
466 | this.redisUtils.doUnLock(RedisKeyConstants.updateCachePointsByMemberId + memberId.toString()); | 472 | this.redisUtils.doUnLock(RedisKeyConstants.updateCachePointsByMemberId + memberId.toString()); |
467 | } | 473 | } |
... | @@ -477,7 +483,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -477,7 +483,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
477 | // 获取的积分 | 483 | // 获取的积分 |
478 | Long rewardPoints = tempPoints.getPoints(); | 484 | Long rewardPoints = tempPoints.getPoints(); |
479 | // 总积分 | 485 | // 总积分 |
480 | Long totalPoints = currentPoints + rewardPoints; | 486 | Long totalPoints = currentPoints + tempPoints.getPoints(); |
481 | return totalPoints; | 487 | return totalPoints; |
482 | } | 488 | } |
483 | 489 | ||
... | @@ -514,7 +520,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -514,7 +520,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
514 | */ | 520 | */ |
515 | private void freshMemberCurrentPoints(Long memberId, Long currentPoints, long duePoints) { | 521 | private void freshMemberCurrentPoints(Long memberId, Long currentPoints, long duePoints) { |
516 | 522 | ||
517 | MemberDTO memberDTO = this.findMemberByMemberId(memberId); | 523 | MemberDTO memberDTO = this.memberService.findById(memberId); |
518 | 524 | ||
519 | Member member = new Member(); | 525 | Member member = new Member(); |
520 | member.setId(memberDTO.getId()); | 526 | member.setId(memberDTO.getId()); |
... | @@ -525,17 +531,14 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -525,17 +531,14 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
525 | try { | 531 | try { |
526 | this.memberOperationService.doUpdateMemberPoints(member); | 532 | this.memberOperationService.doUpdateMemberPoints(member); |
527 | 533 | ||
528 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncMemberPoint(member); | 534 | /*this.threadPoolTaskExecutor.submit(() -> { |
535 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncMemberPoint(member); | ||
536 | });*/ | ||
529 | } catch (Exception e){ | 537 | } catch (Exception e){ |
530 | log.error("同步会员积分异常,"+e.getMessage()); | 538 | log.error("同步会员积分异常,"+e.getMessage()); |
531 | } | 539 | } |
532 | } | 540 | } |
533 | 541 | ||
534 | private MemberDTO findMemberByMemberId(Long memberId) { | ||
535 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
536 | return memberDTO; | ||
537 | } | ||
538 | |||
539 | /** | 542 | /** |
540 | * 更新可用积分表 | 543 | * 更新可用积分表 |
541 | * @param tempPoints | 544 | * @param tempPoints |
... | @@ -554,8 +557,9 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -554,8 +557,9 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
554 | } | 557 | } |
555 | 558 | ||
556 | this.pointsAvailableService.create4Custom(pointsAvailable); | 559 | this.pointsAvailableService.create4Custom(pointsAvailable); |
557 | 560 | /*this.threadPoolTaskExecutor.submit(() -> { | |
558 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncPointsAvailable(pointsAvailable); | 561 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncPointsAvailable(pointsAvailable); |
562 | });*/ | ||
559 | } | 563 | } |
560 | 564 | ||
561 | /** | 565 | /** |
... | @@ -564,15 +568,13 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -564,15 +568,13 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
564 | * @param tempPoints 积分 | 568 | * @param tempPoints 积分 |
565 | * @return Integer 总积分 | 569 | * @return Integer 总积分 |
566 | */ | 570 | */ |
567 | private void doInsertTrPointsDetail(Long memberId, TempPoints tempPoints, Long currentPoints, Long totalPoints){ | 571 | private void doInsertTrPointsDetail(Long memberId, String memberCode, TempPoints tempPoints, Long currentPoints, Long totalPoints){ |
568 | |||
569 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
570 | 572 | ||
571 | PointsDetail pointsDetail = new PointsDetail(); | 573 | PointsDetail pointsDetail = new PointsDetail(); |
572 | BeanUtils.copyProperties(tempPoints, pointsDetail); | 574 | BeanUtils.copyProperties(tempPoints, pointsDetail); |
573 | pointsDetail.setId(null); | 575 | pointsDetail.setId(null); |
574 | pointsDetail.setMemberId(memberId); | 576 | pointsDetail.setMemberId(memberId); |
575 | pointsDetail.setMemberCode(memberDTO.getCode()); | 577 | pointsDetail.setMemberCode(memberCode); |
576 | pointsDetail.setCode(String.valueOf(IdWorker.generator())); | 578 | pointsDetail.setCode(String.valueOf(IdWorker.generator())); |
577 | pointsDetail.setPoints(tempPoints.getPoints()); | 579 | pointsDetail.setPoints(tempPoints.getPoints()); |
578 | pointsDetail.setOriginalPoints(currentPoints); | 580 | pointsDetail.setOriginalPoints(currentPoints); |
... | @@ -587,7 +589,9 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -587,7 +589,9 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
587 | // 保存积分流水 | 589 | // 保存积分流水 |
588 | this.pointsDetailService.create4Custom(pointsDetail); | 590 | this.pointsDetailService.create4Custom(pointsDetail); |
589 | 591 | ||
590 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncPointsDetail(pointsDetail); | 592 | /*this.threadPoolTaskExecutor.submit(() -> { |
593 | ((PointsOperationServiceImpl) AopContext.currentProxy()).asyncPointsDetail(pointsDetail); | ||
594 | });*/ | ||
591 | } | 595 | } |
592 | 596 | ||
593 | } | 597 | } | ... | ... |
... | @@ -21,8 +21,12 @@ import org.springframework.stereotype.Service; | ... | @@ -21,8 +21,12 @@ import org.springframework.stereotype.Service; |
21 | import org.springframework.util.CollectionUtils; | 21 | import org.springframework.util.CollectionUtils; |
22 | import org.springframework.util.StringUtils; | 22 | import org.springframework.util.StringUtils; |
23 | 23 | ||
24 | import javax.annotation.Resource; | ||
24 | import java.sql.Timestamp; | 25 | import java.sql.Timestamp; |
25 | import java.util.*; | 26 | import java.util.*; |
27 | import java.util.concurrent.ExecutionException; | ||
28 | import java.util.concurrent.Future; | ||
29 | import java.util.concurrent.ThreadPoolExecutor; | ||
26 | 30 | ||
27 | /** | 31 | /** |
28 | * 权益处理 | 32 | * 权益处理 |
... | @@ -71,20 +75,23 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -71,20 +75,23 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
71 | * @param tempRightsMap 权益类型 | 75 | * @param tempRightsMap 权益类型 |
72 | */ | 76 | */ |
73 | @Override | 77 | @Override |
74 | public void grantRights(Map<RightType, Object> tempRightsMap) { | 78 | public Integer grantRights(Map<RightType, Object> tempRightsMap) { |
75 | 79 | ||
76 | this.threadPoolTaskExecutor.execute(()-> { | 80 | this.threadPoolTaskExecutor.execute(()-> { |
77 | // 2.创建权益历史对象 | 81 | // 2.创建权益历史对象 |
78 | List<RightsHistory> rightsList = this.getRightHistory(tempRightsMap); | 82 | List<RightsHistory> rightsList = this.getRightHistory(tempRightsMap); |
79 | if (!CollectionUtils.isEmpty(rightsList)) { | 83 | if (!CollectionUtils.isEmpty(rightsList)) { |
80 | log.info("异步保存权益领取历史开始 ==>> [{}]", rightsList); | 84 | // log.info("异步保存权益领取历史开始 ==>> [{}]", rightsList); |
85 | long l = System.currentTimeMillis(); | ||
81 | // 3.保存权益历史 | 86 | // 3.保存权益历史 |
82 | this.doInsertTrRightHistory(rightsList); | 87 | this.doInsertTrRightHistory(rightsList); |
88 | long l1 = System.currentTimeMillis(); | ||
89 | log.info("保存权益历史,总耗时 ==>> {}", l1-l); | ||
83 | } | 90 | } |
84 | }); | 91 | }); |
85 | 92 | ||
86 | // 1.权益下发 | 93 | // 1.权益下发 |
87 | this.refresh(tempRightsMap); | 94 | return this.refresh(tempRightsMap); |
88 | } | 95 | } |
89 | 96 | ||
90 | /** | 97 | /** |
... | @@ -141,28 +148,29 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -141,28 +148,29 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
141 | this.couponOperationService.grantCouponThroughTempCoupon(tempCouponList); | 148 | this.couponOperationService.grantCouponThroughTempCoupon(tempCouponList); |
142 | } | 149 | } |
143 | 150 | ||
151 | |||
144 | /** | 152 | /** |
145 | * 权益发放 | 153 | * 权益发放 |
146 | * @param tempRightsMap | 154 | * @param tempRightsMap |
147 | */ | 155 | */ |
148 | private void refresh(Map<RightType, Object> tempRightsMap) { | 156 | private Integer refresh(Map<RightType, Object> tempRightsMap) { |
149 | 157 | ||
150 | this.threadPoolTaskExecutor.execute(() -> { | 158 | // Future<?> submit = this.threadPoolTaskExecutor.submit(() -> { |
151 | List<TempPoints> tempPointsList = (List<TempPoints>) tempRightsMap.get(RightType.POINTS); | 159 | List<TempPoints> tempPointsList = (List<TempPoints>) tempRightsMap.get(RightType.POINTS); |
152 | if (!CollectionUtils.isEmpty(tempPointsList)) { | 160 | if (!CollectionUtils.isEmpty(tempPointsList)) { |
153 | log.info("发放积分开始 ==>> [{}]", tempPointsList); | 161 | // log.info("发放积分开始 ==>> [{}]", tempPointsList); |
154 | long l = System.currentTimeMillis(); | 162 | long l = System.currentTimeMillis(); |
155 | // 积分 | 163 | // 积分 |
156 | this.grantPoint(tempPointsList); | 164 | this.grantPoint(tempPointsList); |
157 | long l2 = System.currentTimeMillis(); | 165 | long l2 = System.currentTimeMillis(); |
158 | log.info("发放积分结束,总耗时 ==>> {}", (l2 - l)); | 166 | log.info("发放积分结束,总耗时 ==>> {}", (l2 - l)); |
159 | } | 167 | } |
160 | }); | 168 | // }); |
161 | 169 | ||
162 | this.threadPoolTaskExecutor.execute(()-> { | 170 | this.threadPoolTaskExecutor.submit(() -> { |
163 | List<TempExp> tempExpList = (List<TempExp>) tempRightsMap.get(RightType.EXP); | 171 | List<TempExp> tempExpList = (List<TempExp>) tempRightsMap.get(RightType.EXP); |
164 | if (!CollectionUtils.isEmpty(tempExpList)) { | 172 | if (!CollectionUtils.isEmpty(tempExpList)) { |
165 | log.info("发放成长值开始 ==>> [{}]", tempExpList); | 173 | // log.info("发放成长值开始 ==>> [{}]", tempExpList); |
166 | long l = System.currentTimeMillis(); | 174 | long l = System.currentTimeMillis(); |
167 | // 成长值 | 175 | // 成长值 |
168 | this.grantExp(tempExpList); | 176 | this.grantExp(tempExpList); |
... | @@ -171,25 +179,30 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -171,25 +179,30 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
171 | } | 179 | } |
172 | }); | 180 | }); |
173 | 181 | ||
174 | this.threadPoolTaskExecutor.execute(()-> { | 182 | // this.threadPoolTaskExecutor.submit(() -> { |
175 | List<TempCoupon> tempCouponList = (List<TempCoupon>) tempRightsMap.get(RightType.COUPON); | 183 | /*List<TempCoupon> tempCouponList = (List<TempCoupon>) tempRightsMap.get(RightType.COUPON); |
176 | if (!CollectionUtils.isEmpty(tempCouponList)) { | 184 | if (!CollectionUtils.isEmpty(tempCouponList)) { |
177 | log.info("发放优惠券开始 ==>> [{}]", tempCouponList); | 185 | // log.info("发放优惠券开始 ==>> [{}]", tempCouponList); |
178 | long l = System.currentTimeMillis(); | 186 | long l = System.currentTimeMillis(); |
179 | // 优惠券 | 187 | // 优惠券 |
180 | this.grantCoupon(tempCouponList); | 188 | this.grantCoupon(tempCouponList); |
181 | long l2 = System.currentTimeMillis(); | 189 | long l2 = System.currentTimeMillis(); |
182 | log.info("发放优惠券结束,总耗时 ==>> {}", (l2 - l)); | 190 | log.info("发放优惠券结束,总耗时 ==>> {}", (l2 - l)); |
183 | } | 191 | }*/ |
184 | }); | 192 | // }); |
185 | 193 | ||
186 | // 其他权益 | 194 | // 其他权益 |
187 | this.threadPoolTaskExecutor.execute(()-> { | 195 | // Future<?> submit = this.threadPoolTaskExecutor.submit(() -> { |
188 | log.info("发放其他权益开始 ==>> [{}]", tempRightsMap); | 196 | // log.info("发放其他权益开始 ==>> [{}]", tempRightsMap); |
197 | long l = System.currentTimeMillis(); | ||
189 | this.grantOtherRight(tempRightsMap); | 198 | this.grantOtherRight(tempRightsMap); |
190 | log.info("发放其他权益结束 ==>> [{}]", tempRightsMap); | 199 | long l2 = System.currentTimeMillis(); |
191 | }); | 200 | log.info("发放其他权益结束 ==>> 总耗时 ==>> {}", l-l2); |
201 | // }); | ||
202 | |||
203 | |||
192 | 204 | ||
205 | return tempRightsMap.keySet().size(); | ||
193 | } | 206 | } |
194 | 207 | ||
195 | private void grantOtherRight(Map<RightType, Object> tempRightsMap) { | 208 | private void grantOtherRight(Map<RightType, Object> tempRightsMap) { | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -10,11 +10,13 @@ import com.topdraw.business.module.member.domain.Member; | ... | @@ -10,11 +10,13 @@ import com.topdraw.business.module.member.domain.Member; |
10 | import com.topdraw.business.module.member.domain.MemberBuilder; | 10 | import com.topdraw.business.module.member.domain.MemberBuilder; |
11 | import com.topdraw.business.module.member.service.MemberService; | 11 | import com.topdraw.business.module.member.service.MemberService; |
12 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 12 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
13 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; | ||
13 | import com.topdraw.business.module.user.iptv.domain.UserConstant; | 14 | import com.topdraw.business.module.user.iptv.domain.UserConstant; |
14 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 15 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
15 | import com.topdraw.business.module.user.iptv.domain.UserTvBuilder; | 16 | import com.topdraw.business.module.user.iptv.domain.UserTvBuilder; |
16 | import com.topdraw.business.module.user.iptv.service.UserTvService; | 17 | import com.topdraw.business.module.user.iptv.service.UserTvService; |
17 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 18 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
19 | import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO; | ||
18 | import com.topdraw.business.module.user.weixin.collection.domain.UserCollection; | 20 | import com.topdraw.business.module.user.weixin.collection.domain.UserCollection; |
19 | import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail; | 21 | import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail; |
20 | import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionDetailRepository; | 22 | import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionDetailRepository; |
... | @@ -34,6 +36,7 @@ import com.topdraw.business.process.service.dto.MemberAndUserTvDTO; | ... | @@ -34,6 +36,7 @@ import com.topdraw.business.process.service.dto.MemberAndUserTvDTO; |
34 | import com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO; | 36 | import com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO; |
35 | import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper; | 37 | import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper; |
36 | import com.topdraw.config.LocalConstants; | 38 | import com.topdraw.config.LocalConstants; |
39 | import com.topdraw.config.RedisKeyConstants; | ||
37 | import com.topdraw.config.RedisKeyUtil; | 40 | import com.topdraw.config.RedisKeyUtil; |
38 | import com.topdraw.exception.BadRequestException; | 41 | import com.topdraw.exception.BadRequestException; |
39 | import com.topdraw.exception.EntityNotFoundException; | 42 | import com.topdraw.exception.EntityNotFoundException; |
... | @@ -49,6 +52,7 @@ import org.springframework.aop.framework.AopContext; | ... | @@ -49,6 +52,7 @@ import org.springframework.aop.framework.AopContext; |
49 | import org.springframework.beans.BeanUtils; | 52 | import org.springframework.beans.BeanUtils; |
50 | import org.springframework.beans.factory.annotation.Autowired; | 53 | import org.springframework.beans.factory.annotation.Autowired; |
51 | import org.springframework.beans.factory.annotation.Value; | 54 | import org.springframework.beans.factory.annotation.Value; |
55 | import org.springframework.cache.annotation.CachePut; | ||
52 | import org.springframework.data.domain.PageRequest; | 56 | import org.springframework.data.domain.PageRequest; |
53 | import org.springframework.data.domain.Sort; | 57 | import org.springframework.data.domain.Sort; |
54 | import org.springframework.stereotype.Service; | 58 | import org.springframework.stereotype.Service; |
... | @@ -119,8 +123,9 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -119,8 +123,9 @@ public class UserOperationServiceImpl implements UserOperationService { |
119 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | 123 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); |
120 | 124 | ||
121 | // 无账号 | 125 | // 无账号 |
122 | if (Objects.isNull(userTvDTO)) { | 126 | if (Objects.isNull(userTvDTO.getId())) { |
123 | 127 | ||
128 | // 会员昵称默认采用大屏账号,昵称通过base64加密与小屏保持一致 | ||
124 | String platformAccountEncode = Base64Utils.encodeToString(platformAccount.getBytes()); | 129 | String platformAccountEncode = Base64Utils.encodeToString(platformAccount.getBytes()); |
125 | 130 | ||
126 | // x_member | 131 | // x_member |
... | @@ -133,14 +138,15 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -133,14 +138,15 @@ public class UserOperationServiceImpl implements UserOperationService { |
133 | 138 | ||
134 | UserTv userTv = UserTvBuilder.build(memberDTO.getId(), memberDTO.getCode(), resources); | 139 | UserTv userTv = UserTvBuilder.build(memberDTO.getId(), memberDTO.getCode(), resources); |
135 | // 创建大屏账户 | 140 | // 创建大屏账户 |
136 | UserTvDTO tvUserDTO = this.createTvUser(userTv, memberDTO.getId(), memberDTO.getCode()); | 141 | UserTvDTO _tvUserDTO = this.createTvUser(userTv, memberDTO.getId(), memberDTO.getCode()); |
137 | 142 | ||
138 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(memberDTO, tvUserDTO)); | 143 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(memberDTO, _tvUserDTO)); |
139 | 144 | ||
140 | return tvUserDTO; | 145 | return _tvUserDTO; |
141 | 146 | ||
142 | } | 147 | } |
143 | 148 | ||
149 | log.error("保存大屏账号信息异常,无法创建大屏账号对应的会员,platoformAccount ==> {}", platformAccount); | ||
144 | throw new EntityNotFoundException(MemberDTO.class, "code", GlobeExceptionMsg.MEMBER_ID_IS_NULL); | 150 | throw new EntityNotFoundException(MemberDTO.class, "code", GlobeExceptionMsg.MEMBER_ID_IS_NULL); |
145 | 151 | ||
146 | // 有账号 | 152 | // 有账号 |
... | @@ -165,10 +171,10 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -165,10 +171,10 @@ public class UserOperationServiceImpl implements UserOperationService { |
165 | UserTv userTv = new UserTv(); | 171 | UserTv userTv = new UserTv(); |
166 | BeanUtils.copyProperties(userTvDTO, userTv); | 172 | BeanUtils.copyProperties(userTvDTO, userTv); |
167 | 173 | ||
168 | UserTvDTO userTvDTO1 = this.updateUserTvUnsyncIptv(userTv); | 174 | UserTvDTO _userTvDTO = this.userTvService.update(userTv); |
169 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(memberDTO, userTvDTO1)); | 175 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMemberAndUserTv4Iptv(new MemberAndUserTvDTO(memberDTO, _userTvDTO)); |
170 | 176 | ||
171 | return userTvDTO1; | 177 | return _userTvDTO; |
172 | } | 178 | } |
173 | 179 | ||
174 | } | 180 | } |
... | @@ -1065,6 +1071,13 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1065,6 +1071,13 @@ public class UserOperationServiceImpl implements UserOperationService { |
1065 | // 同步至iptv | 1071 | // 同步至iptv |
1066 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMinaBind(new MemberAndUserTvDTO(memberDTO, userTvDTO)); | 1072 | ((UserOperationServiceImpl)AopContext.currentProxy()).asyncMinaBind(new MemberAndUserTvDTO(memberDTO, userTvDTO)); |
1067 | 1073 | ||
1074 | // 修改缓存中MemberSimple的大屏主账号信息,因为执行任务之前会去检查主会员d | ||
1075 | UserTvSimpleDTO userTvSimpleDTO = this.userTvService.findSimpleByPlatformAccount(platformAccount); | ||
1076 | if (Objects.nonNull(userTvDTO)) { | ||
1077 | userTvSimpleDTO.setPriorityMemberCode(memberDTO.getCode()); | ||
1078 | HashMap hashMap = JSONObject.parseObject(userTvSimpleDTO.toString(), HashMap.class); | ||
1079 | this.redisUtils.set(RedisKeyConstants.cacheVisUserByPlatformAccount + "::" + platformAccount, hashMap); | ||
1080 | } | ||
1068 | return userTvDTO; | 1081 | return userTvDTO; |
1069 | } | 1082 | } |
1070 | 1083 | ||
... | @@ -1088,15 +1101,6 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1088,15 +1101,6 @@ public class UserOperationServiceImpl implements UserOperationService { |
1088 | } | 1101 | } |
1089 | 1102 | ||
1090 | /** | 1103 | /** |
1091 | * | ||
1092 | * @param userTv 大屏账号 | ||
1093 | * @return UserTvDTO | ||
1094 | */ | ||
1095 | private UserTvDTO updateUserTvUnsyncIptv(UserTv userTv){ | ||
1096 | return this.userTvService.update(userTv); | ||
1097 | } | ||
1098 | |||
1099 | /** | ||
1100 | * 重置主账号 | 1104 | * 重置主账号 |
1101 | * @param memberDTO 会员code | 1105 | * @param memberDTO 会员code |
1102 | * @param userTvDTO 大屏id | 1106 | * @param userTvDTO 大屏id |
... | @@ -1242,8 +1246,14 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1242,8 +1246,14 @@ public class UserOperationServiceImpl implements UserOperationService { |
1242 | * @param member 会员信息 | 1246 | * @param member 会员信息 |
1243 | * @return MemberDTO | 1247 | * @return MemberDTO |
1244 | */ | 1248 | */ |
1245 | private MemberDTO createMember(Member member){ | 1249 | public MemberDTO createMember(Member member){ |
1246 | return this.memberService.create(member); | 1250 | MemberDTO memberDTO = this.memberService.create(member); |
1251 | if (Objects.nonNull(memberDTO.getId())) { | ||
1252 | MemberSimpleDTO memberSimpleDTO = new MemberSimpleDTO(); | ||
1253 | BeanUtils.copyProperties(memberDTO, memberSimpleDTO); | ||
1254 | this.redisUtils.set(RedisKeyConstants.cacheMemberSimpleById+"::"+memberDTO.getId(), memberSimpleDTO); | ||
1255 | } | ||
1256 | return memberDTO; | ||
1247 | } | 1257 | } |
1248 | 1258 | ||
1249 | /** | 1259 | /** | ... | ... |
... | @@ -10,19 +10,49 @@ package com.topdraw.config; | ... | @@ -10,19 +10,49 @@ package com.topdraw.config; |
10 | * @since : modified in 2022/6/18 13:25 | 10 | * @since : modified in 2022/6/18 13:25 |
11 | */ | 11 | */ |
12 | public interface RedisKeyConstants { | 12 | public interface RedisKeyConstants { |
13 | 13 | // 全量会员信息 | |
14 | String cacheMemberById = "uce::member::id"; | 14 | String cacheMemberById = "uce::member::id"; |
15 | // 任务处理时会员信息 | ||
16 | String cacheMemberSimpleById = "uce::memberSimple::id"; | ||
17 | // 会员全量信息 | ||
15 | String cacheMemberByCode = "uce::member::code"; | 18 | String cacheMemberByCode = "uce::member::code"; |
16 | String updateCacheMemberById = "uce::updateMember::id"; | ||
17 | 19 | ||
20 | // 修改会员积分时的分布式锁 | ||
18 | String updateCachePointsByMemberId = "uce::updatePoints::memberId"; | 21 | String updateCachePointsByMemberId = "uce::updatePoints::memberId"; |
22 | // 修改会员成长值时的分布式锁 | ||
19 | String updateCacheExpByMemberId = "uce::updateExp::memberId"; | 23 | String updateCacheExpByMemberId = "uce::updateExp::memberId"; |
24 | // 修改会员优惠券时的分布式锁 | ||
20 | String updateCacheCouponByMemberId = "uce::updateCoupon::memberId"; | 25 | String updateCacheCouponByMemberId = "uce::updateCoupon::memberId"; |
21 | 26 | ||
27 | // 全量大屏信息 | ||
22 | String cacheUserTvByPlatformAccount = "uce::userTv::platformAccount"; | 28 | String cacheUserTvByPlatformAccount = "uce::userTv::platformAccount"; |
29 | String cacheVisUserByPlatformAccount = "uus::visUser::platformAccount"; | ||
30 | // 会员已完成的任务进度 | ||
23 | String cacheTaskProcessByMemberId = "uce::taskProcess::memberId"; | 31 | String cacheTaskProcessByMemberId = "uce::taskProcess::memberId"; |
24 | String cacheTaskByTaskTemplateId = "uce::task::taskTemplateId"; | 32 | // 任务模板类型对应的全量任务 |
25 | String cacheTaskByEvent = "uce::task::event"; | 33 | String cacheTaskByEvent = "uce::task::event"; |
34 | // 全量优惠券信息 | ||
26 | String cacheCouponById = "uce::coupon::id"; | 35 | String cacheCouponById = "uce::coupon::id"; |
36 | |||
37 | // 权益全量信息 | ||
27 | String cacheRightById = "uce::right::id"; | 38 | String cacheRightById = "uce::right::id"; |
39 | |||
40 | // 会员可以做的任务 | ||
41 | String cacheTaskByEventAndMemberLevelAndVip = "uce::task::eventAndMemberLevelAndVip"; | ||
42 | |||
43 | // 全量会员等级 | ||
44 | String cacheMemberLevelByLevel = "uce::memberLevel::level"; | ||
45 | |||
46 | // 今天处理完成任务数量 | ||
47 | String cacheTodayFinishTaskCount = "uce::todayCount::memberId"; | ||
48 | // 历史完成的任务数量 | ||
49 | String cacheTotalFinishTaskCount = "uce::totalCount::memberId"; | ||
50 | |||
51 | |||
52 | |||
53 | String CACHE_PLATFROMACCOUNT_PLAYDURATION = "uce::eventPlay::playduration"; | ||
54 | |||
55 | |||
56 | String CACHE_TODAY_FINISH_COUNT = "todayFinishCount"; | ||
57 | String CACHE_TOTAL_FINISH_COUNT = "totalFinishCount"; | ||
28 | } | 58 | } | ... | ... |
member-service-impl/src/main/java/com/topdraw/config/TheadPoolTaskExecutorConfiguration.java
0 → 100644
1 | package com.topdraw.config; | ||
2 | |||
3 | import org.springframework.beans.factory.annotation.Value; | ||
4 | import org.springframework.context.annotation.Bean; | ||
5 | import org.springframework.context.annotation.Configuration; | ||
6 | import org.springframework.context.annotation.Primary; | ||
7 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
8 | |||
9 | import java.util.concurrent.ArrayBlockingQueue; | ||
10 | import java.util.concurrent.Executor; | ||
11 | import java.util.concurrent.ThreadPoolExecutor; | ||
12 | import java.util.concurrent.TimeUnit; | ||
13 | |||
14 | /** | ||
15 | * @author : | ||
16 | * @description: | ||
17 | * @function : | ||
18 | * @date :Created in 2022/6/22 11:06 | ||
19 | * @version: : | ||
20 | * @modified By: | ||
21 | * @since : modified in 2022/6/22 11:06 | ||
22 | */ | ||
23 | @Configuration | ||
24 | public class TheadPoolTaskExecutorConfiguration { | ||
25 | |||
26 | @Value("${task.pool.core-pool-size}") | ||
27 | private Integer corePoolSize; | ||
28 | @Value("${task.pool.core-pool-size}") | ||
29 | private Integer maxPoolSize; | ||
30 | @Value("${task.pool.keep-alive-seconds}") | ||
31 | private Integer keepAliveSeconds; | ||
32 | @Value("${task.pool.queue-capacity}") | ||
33 | private Integer queueCapacity; | ||
34 | |||
35 | @Bean | ||
36 | @Primary | ||
37 | public ThreadPoolTaskExecutor getThreadPoolTaskExecutor() { | ||
38 | ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor(); | ||
39 | threadPoolTaskExecutor.setCorePoolSize(corePoolSize); | ||
40 | threadPoolTaskExecutor.setMaxPoolSize(maxPoolSize); | ||
41 | threadPoolTaskExecutor.setKeepAliveSeconds(keepAliveSeconds); | ||
42 | threadPoolTaskExecutor.setQueueCapacity(queueCapacity); | ||
43 | threadPoolTaskExecutor.setWaitForTasksToCompleteOnShutdown(true); | ||
44 | threadPoolTaskExecutor.initialize(); | ||
45 | return threadPoolTaskExecutor; | ||
46 | } | ||
47 | |||
48 | |||
49 | /*@Bean | ||
50 | public ThreadPoolExecutor getThreadPoolTaskExecutor() { | ||
51 | ArrayBlockingQueue arrayBlockingQueue = new ArrayBlockingQueue(queueCapacity); | ||
52 | ThreadPoolExecutor threadPoolTaskExecutor = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveSeconds, TimeUnit.SECONDS, arrayBlockingQueue); | ||
53 | return threadPoolTaskExecutor; | ||
54 | }*/ | ||
55 | |||
56 | } |
1 | package com.topdraw.config; | ||
2 | |||
3 | |||
4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
5 | import com.fasterxml.jackson.annotation.PropertyAccessor; | ||
6 | import com.fasterxml.jackson.databind.ObjectMapper; | ||
7 | import lombok.extern.slf4j.Slf4j; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.cache.annotation.CachingConfigurerSupport; | ||
10 | import org.springframework.context.annotation.Bean; | ||
11 | import org.springframework.context.annotation.Configuration; | ||
12 | import org.springframework.context.annotation.Primary; | ||
13 | import org.springframework.data.redis.cache.RedisCacheConfiguration; | ||
14 | import org.springframework.data.redis.cache.RedisCacheManager; | ||
15 | import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
16 | import org.springframework.data.redis.core.RedisTemplate; | ||
17 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | ||
18 | |||
19 | import java.time.Duration; | ||
20 | import java.util.HashSet; | ||
21 | import java.util.Set; | ||
22 | import java.util.concurrent.ConcurrentHashMap; | ||
23 | |||
24 | /** | ||
25 | * @author : | ||
26 | * @description: | ||
27 | * @function : | ||
28 | * @date :Created in 2022/6/19 16:30 | ||
29 | * @version: : | ||
30 | * @modified By: | ||
31 | * @since : modified in 2022/6/19 16:30 | ||
32 | */ | ||
33 | @Slf4j | ||
34 | @Configuration | ||
35 | public class UceRedisConfig { | ||
36 | |||
37 | @Autowired | ||
38 | private RedisConfig redisConfig; | ||
39 | @Autowired | ||
40 | private RedisConnectionFactory redisConnectionFactory; | ||
41 | |||
42 | @Bean(value = "uceRedisTemplate") | ||
43 | public RedisTemplate<Object, Object> uceRedisTemplate() { | ||
44 | return redisConfig.redisTemplate(redisConnectionFactory); | ||
45 | } | ||
46 | /** | ||
47 | * 自定义缓存管理器 | ||
48 | */ | ||
49 | @Bean(value = "uceCacheManagemer") | ||
50 | @Primary | ||
51 | public RedisCacheManager cacheManager(RedisConnectionFactory factory) { | ||
52 | RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); | ||
53 | Set<String> cacheNames = new HashSet<>(); | ||
54 | // cacheNames.add("car"); | ||
55 | // cacheNames.add(RedisKeyConstants.cacheTaskByEvent); | ||
56 | cacheNames.add(RedisKeyConstants.cacheTaskProcessByMemberId); | ||
57 | ConcurrentHashMap<String, RedisCacheConfiguration> configMap = new ConcurrentHashMap<>(); | ||
58 | // configMap.put("car", config.entryTtl(Duration.ofMinutes(6L))); | ||
59 | configMap.put(RedisKeyConstants.cacheTaskProcessByMemberId, config.entryTtl(Duration.ofDays(1))); | ||
60 | // configMap.put(RedisKeyConstants.cacheTaskByEvent, config); | ||
61 | |||
62 | //需要先初始化缓存名称,再初始化其它的配置。 | ||
63 | RedisCacheManager cacheManager = RedisCacheManager.builder(factory). | ||
64 | initialCacheNames(cacheNames).withInitialCacheConfigurations(configMap).build(); | ||
65 | return cacheManager; | ||
66 | } | ||
67 | } |
... | @@ -6,7 +6,6 @@ import lombok.NoArgsConstructor; | ... | @@ -6,7 +6,6 @@ import lombok.NoArgsConstructor; |
6 | 6 | ||
7 | import javax.validation.constraints.NotNull; | 7 | import javax.validation.constraints.NotNull; |
8 | import java.io.Serializable; | 8 | import java.io.Serializable; |
9 | import java.sql.Timestamp; | ||
10 | import java.time.LocalDateTime; | 9 | import java.time.LocalDateTime; |
11 | 10 | ||
12 | /** | 11 | /** |
... | @@ -25,43 +24,8 @@ public class DataSyncMsg implements Serializable { | ... | @@ -25,43 +24,8 @@ public class DataSyncMsg implements Serializable { |
25 | //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 24 | //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) |
26 | private Integer deviceType; | 25 | private Integer deviceType; |
27 | // 发送时间 | 26 | // 发送时间 |
28 | private String time; | 27 | private LocalDateTime time; |
29 | // 消息体 | 28 | // 消息体 |
30 | private String msgData; | 29 | private String msgData; |
31 | 30 | ||
32 | /** | ||
33 | * 消息体 | ||
34 | */ | ||
35 | @Data | ||
36 | @AllArgsConstructor | ||
37 | @NoArgsConstructor | ||
38 | public static class MsgData { | ||
39 | /**备注*/ | ||
40 | private String remarks; | ||
41 | // 会员id | ||
42 | private Long memberId; | ||
43 | // 账户id | ||
44 | private Long userId; | ||
45 | //用户对应的应用code | ||
46 | private String appCode; | ||
47 | // 会员code | ||
48 | private String memberCode; | ||
49 | // 账号id | ||
50 | private Long accountId; | ||
51 | // 订单Id | ||
52 | private Long orderId; | ||
53 | // 活动id | ||
54 | private Long activityId; | ||
55 | // 节目id | ||
56 | private Long mediaId; | ||
57 | // 产品id | ||
58 | private Long itemId; | ||
59 | // 模板参数 | ||
60 | private String param; | ||
61 | // 描述 | ||
62 | private String description; | ||
63 | // 大屏账号 | ||
64 | private String platformAccount; | ||
65 | } | ||
66 | |||
67 | } | 31 | } | ... | ... |
... | @@ -5,7 +5,7 @@ spring: | ... | @@ -5,7 +5,7 @@ spring: |
5 | url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_admin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | 5 | url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_admin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false |
6 | username: root | 6 | username: root |
7 | password: root | 7 | password: root |
8 | # url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs-small-sichuan?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false | 8 | # url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs_admin_chongshu?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false |
9 | # username: root | 9 | # username: root |
10 | # password: Tjlh@2021 | 10 | # password: Tjlh@2021 |
11 | 11 | ||
... | @@ -20,7 +20,7 @@ spring: | ... | @@ -20,7 +20,7 @@ spring: |
20 | # 最大连接数 | 20 | # 最大连接数 |
21 | max-active: 15 | 21 | max-active: 15 |
22 | # 获取连接超时时间 | 22 | # 获取连接超时时间 |
23 | max-wait: 5000 | 23 | max-wait: 5000000 |
24 | # 连接有效性检测时间 | 24 | # 连接有效性检测时间 |
25 | time-between-eviction-runs-millis: 90000 | 25 | time-between-eviction-runs-millis: 90000 |
26 | # 最大空闲时间 | 26 | # 最大空闲时间 | ... | ... |
... | @@ -25,13 +25,13 @@ spring: | ... | @@ -25,13 +25,13 @@ spring: |
25 | task: | 25 | task: |
26 | pool: | 26 | pool: |
27 | # 核心线程池大小 | 27 | # 核心线程池大小 |
28 | core-pool-size: 10 | 28 | core-pool-size: 16 |
29 | # 最大线程数 | 29 | # 最大线程数 |
30 | max-pool-size: 30 | 30 | max-pool-size: 35 |
31 | # 活跃时间 | 31 | # 活跃时间 |
32 | keep-alive-seconds: 60 | 32 | keep-alive-seconds: 10 |
33 | # 队列容量 | 33 | # 队列容量 |
34 | queue-capacity: 50 | 34 | queue-capacity: 300 |
35 | 35 | ||
36 | #登录图形验证码有效时间/分钟 | 36 | #登录图形验证码有效时间/分钟 |
37 | loginCode: | 37 | loginCode: | ... | ... |
... | @@ -64,7 +64,7 @@ | ... | @@ -64,7 +64,7 @@ |
64 | 64 | ||
65 | 65 | ||
66 | <!--监控sql日志输出 --> | 66 | <!--监控sql日志输出 --> |
67 | <logger name="jdbc.sqlonly" level="INFO" additivity="false"> | 67 | <logger name="jdbc.sqlonly" level="OFF" additivity="false"> |
68 | <appender-ref ref="console" /> | 68 | <appender-ref ref="console" /> |
69 | <appender-ref ref="info" /> | 69 | <appender-ref ref="info" /> |
70 | </logger> | 70 | </logger> | ... | ... |
... | @@ -96,11 +96,12 @@ public class TaskOperationControllerTest extends BaseTest { | ... | @@ -96,11 +96,12 @@ public class TaskOperationControllerTest extends BaseTest { |
96 | public void play() { | 96 | public void play() { |
97 | try { | 97 | try { |
98 | String s = "{\"evt\":\"PLAY\",\"event\":8,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + | 98 | String s = "{\"evt\":\"PLAY\",\"event\":8,\"time\":\"2022-05-03 23:10:09\",\"deviceType\":1," + |
99 | "\"msgData\":{\"memberCode\":\"1537253277861699584\",\"param\":\"{\\\"playDuration\\\":60}\"}}"; | 99 | "\"msgData\":{\"platformAccount\":\"1537253277861699584\",\"param\":\"{\\\"playDuration\\\":60}\"}}"; |
100 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); | 100 | TaskOperationQueryCriteria pointsQueryCriteria = new TaskOperationQueryCriteria(); |
101 | pointsQueryCriteria.setContent(s); | 101 | pointsQueryCriteria.setContent(s); |
102 | String s1 = JSON.toJSONString(pointsQueryCriteria); | 102 | String s1 = JSON.toJSONString(pointsQueryCriteria); |
103 | this.taskOperationController.dealTask(pointsQueryCriteria); | 103 | System.out.println(s1); |
104 | // this.taskOperationController.dealTask(pointsQueryCriteria); | ||
104 | } catch (Exception e) { | 105 | } catch (Exception e) { |
105 | e.printStackTrace(); | 106 | e.printStackTrace(); |
106 | } | 107 | } | ... | ... |
... | @@ -2,6 +2,8 @@ package com.topdraw.test.business.process.service; | ... | @@ -2,6 +2,8 @@ package com.topdraw.test.business.process.service; |
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.topdraw.business.module.member.domain.Member; | 4 | import com.topdraw.business.module.member.domain.Member; |
5 | import com.topdraw.business.module.member.service.MemberService; | ||
6 | import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; | ||
5 | import com.topdraw.business.process.service.member.MemberOperationService; | 7 | import com.topdraw.business.process.service.member.MemberOperationService; |
6 | import com.topdraw.BaseTest; | 8 | import com.topdraw.BaseTest; |
7 | import com.topdraw.util.IdWorker; | 9 | import com.topdraw.util.IdWorker; |
... | @@ -16,6 +18,15 @@ public class MemberOperationServiceTest extends BaseTest { | ... | @@ -16,6 +18,15 @@ public class MemberOperationServiceTest extends BaseTest { |
16 | @Autowired | 18 | @Autowired |
17 | MemberOperationService memberOperationService; | 19 | MemberOperationService memberOperationService; |
18 | 20 | ||
21 | @Autowired | ||
22 | MemberService memberService; | ||
23 | |||
24 | @Test | ||
25 | public void findMemberSimpleTest(){ | ||
26 | MemberSimpleDTO memberSimpleDTO = this.memberService.findSimpleById(20718L); | ||
27 | System.out.println(memberSimpleDTO); | ||
28 | } | ||
29 | |||
19 | @Test | 30 | @Test |
20 | public void findById() { | 31 | public void findById() { |
21 | Long memberId = 2L; | 32 | Long memberId = 2L; | ... | ... |
... | @@ -19,11 +19,7 @@ public class TaskOperationServiceTest extends BaseTest { | ... | @@ -19,11 +19,7 @@ public class TaskOperationServiceTest extends BaseTest { |
19 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); | 19 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); |
20 | // dataSyncMsg.setEntityType(EntityType.MEMBER); | 20 | // dataSyncMsg.setEntityType(EntityType.MEMBER); |
21 | dataSyncMsg.setEvt(EventType.LOGIN.name()); | 21 | dataSyncMsg.setEvt(EventType.LOGIN.name()); |
22 | DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData(); | ||
23 | msgData.setRemarks("remark"); | ||
24 | msgData.setMemberId(memberId); | ||
25 | 22 | ||
26 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); | ||
27 | // dataSyncMsg.setMsgData(msgData); | 23 | // dataSyncMsg.setMsgData(msgData); |
28 | 24 | ||
29 | String s = JSON.toJSONString(dataSyncMsg); | 25 | String s = JSON.toJSONString(dataSyncMsg); | ... | ... |
... | @@ -22,10 +22,10 @@ public class MqTest extends BaseTest { | ... | @@ -22,10 +22,10 @@ public class MqTest extends BaseTest { |
22 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); | 22 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); |
23 | // dataSyncMsg.setEventType(EventType.LOGIN.name()); | 23 | // dataSyncMsg.setEventType(EventType.LOGIN.name()); |
24 | dataSyncMsg.setEvt(EventType.LOGIN.name()); | 24 | dataSyncMsg.setEvt(EventType.LOGIN.name()); |
25 | DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData(); | 25 | /* DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData(); |
26 | msgData.setRemarks("remark"); | 26 | msgData.setRemarks("remark"); |
27 | msgData.setMemberId(1L); | 27 | msgData.setMemberId(1L); |
28 | msgData.setAppCode("WEI_XIN_GOLD_PANDA"); | 28 | msgData.setAppCode("WEI_XIN_GOLD_PANDA");*/ |
29 | // dataSyncMsg.setMsgData(msgData); | 29 | // dataSyncMsg.setMsgData(msgData); |
30 | String s = JSON.toJSONString(dataSyncMsg); | 30 | String s = JSON.toJSONString(dataSyncMsg); |
31 | amqpTemplate.convertAndSend( "uc.route.key.direct.event.aaa", s); | 31 | amqpTemplate.convertAndSend( "uc.route.key.direct.event.aaa", s); | ... | ... |
-
Please register or sign in to post a comment