Commit fdd7f7f8 fdd7f7f82e49b2dbaaad7918d7e1de9907c9aa9c by xianghan

1.添加参加活动、首次消耗积分、完善用户信息任务

1 parent 9c602b84
...@@ -73,15 +73,18 @@ public class MemberServiceImpl implements MemberService { ...@@ -73,15 +73,18 @@ public class MemberServiceImpl implements MemberService {
73 @Transactional(readOnly = true) 73 @Transactional(readOnly = true)
74 public MemberSimpleDTO findSimpleById(Long id) { 74 public MemberSimpleDTO findSimpleById(Long id) {
75 Object memberSimpleRedis = this.redisUtils.get(RedisKeyConstants.cacheMemberSimpleById + "::" + id); 75 Object memberSimpleRedis = this.redisUtils.get(RedisKeyConstants.cacheMemberSimpleById + "::" + id);
76 log.info("从redis中获取会员信息, 结果集 dealTask# memberSimpleRedis ==>> {} ", memberSimpleRedis);
76 if (Objects.nonNull(memberSimpleRedis)) { 77 if (Objects.nonNull(memberSimpleRedis)) {
77 return JSONObject.parseObject(JSON.toJSONString(memberSimpleRedis), MemberSimpleDTO.class); 78 return JSONObject.parseObject(JSON.toJSONString(memberSimpleRedis), MemberSimpleDTO.class);
78 } 79 }
79 80
80 MemberSimple memberSimple = this.memberSimpleRepository.findSimpleById(id).orElseGet(MemberSimple::new); 81 MemberSimple memberSimple = this.memberSimpleRepository.findSimpleById(id).orElseGet(MemberSimple::new);
82 log.info("从数据库中获取会员信息, 结果集 dealTask# memberSimple ==>> {} ", memberSimple);
81 if (Objects.nonNull(memberSimple.getId())) { 83 if (Objects.nonNull(memberSimple.getId())) {
82 MemberSimpleDTO memberSimpleDTO = new MemberSimpleDTO(); 84 MemberSimpleDTO memberSimpleDTO = new MemberSimpleDTO();
83 BeanUtils.copyProperties(memberSimple, memberSimpleDTO); 85 BeanUtils.copyProperties(memberSimple, memberSimpleDTO);
84 this.redisUtils.set(RedisKeyConstants.cacheMemberSimpleById + "::" + id, memberSimpleDTO); 86 boolean result = this.redisUtils.set(RedisKeyConstants.cacheMemberSimpleById + "::" + id, memberSimpleDTO);
87 log.info("将结果存入redis中, dealTask# memberSimpleDTO ==>> {} || 存入结果 ==>> {}", memberSimpleDTO, result);
85 } 88 }
86 return this.memberSimpleMapper.toDto(memberSimple); 89 return this.memberSimpleMapper.toDto(memberSimple);
87 } 90 }
......
...@@ -3,8 +3,12 @@ package com.topdraw.business.module.task.attribute.repository; ...@@ -3,8 +3,12 @@ package com.topdraw.business.module.task.attribute.repository;
3 import com.topdraw.business.module.task.attribute.domain.TaskAttr; 3 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
4 import org.springframework.data.jpa.repository.JpaRepository; 4 import org.springframework.data.jpa.repository.JpaRepository;
5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 5 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 import org.springframework.data.jpa.repository.Query;
6 7
8 import java.util.List;
9 import java.util.Map;
7 import java.util.Optional; 10 import java.util.Optional;
11 import java.util.Set;
8 12
9 /** 13 /**
10 * @author XiangHan 14 * @author XiangHan
...@@ -13,4 +17,7 @@ import java.util.Optional; ...@@ -13,4 +17,7 @@ import java.util.Optional;
13 public interface TaskAttrRepository extends JpaRepository<TaskAttr, Long>, JpaSpecificationExecutor<TaskAttr> { 17 public interface TaskAttrRepository extends JpaRepository<TaskAttr, Long>, JpaSpecificationExecutor<TaskAttr> {
14 18
15 Optional<TaskAttr> findByTaskId(Long taskId); 19 Optional<TaskAttr> findByTaskId(Long taskId);
20
21 @Query(value = "SELECT * FROM `tr_task_attr` WHERE task_id IN(?1)", nativeQuery = true)
22 List<Map<String, Object>> findTasksByTaskIds(Set<Object> taskIds);
16 } 23 }
......
...@@ -3,6 +3,9 @@ package com.topdraw.business.module.task.attribute.service; ...@@ -3,6 +3,9 @@ package com.topdraw.business.module.task.attribute.service;
3 import com.topdraw.business.module.task.attribute.domain.TaskAttr; 3 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
4 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO; 4 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
5 5
6 import java.util.List;
7 import java.util.Set;
8
6 /** 9 /**
7 * @author XiangHan 10 * @author XiangHan
8 * @date 2022-01-13 11 * @date 2022-01-13
...@@ -39,4 +42,6 @@ public interface TaskAttrService { ...@@ -39,4 +42,6 @@ public interface TaskAttrService {
39 * @return 42 * @return
40 */ 43 */
41 TaskAttrDTO findByTaskId(Long taskId); 44 TaskAttrDTO findByTaskId(Long taskId);
45
46 List<TaskAttrDTO> findTasksByTaskIds(Set<Object> id);
42 } 47 }
......
1 package com.topdraw.business.module.task.attribute.service.impl; 1 package com.topdraw.business.module.task.attribute.service.impl;
2 2
3 import com.alibaba.fastjson.JSON;
3 import com.topdraw.business.module.task.attribute.domain.TaskAttr; 4 import com.topdraw.business.module.task.attribute.domain.TaskAttr;
4 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
5 import com.topdraw.business.module.task.attribute.repository.TaskAttrRepository; 6 import com.topdraw.business.module.task.attribute.repository.TaskAttrRepository;
...@@ -12,6 +13,12 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -12,6 +13,12 @@ import org.springframework.transaction.annotation.Propagation;
12 import org.springframework.transaction.annotation.Transactional; 13 import org.springframework.transaction.annotation.Transactional;
13 import org.springframework.dao.EmptyResultDataAccessException; 14 import org.springframework.dao.EmptyResultDataAccessException;
14 import org.springframework.util.Assert; 15 import org.springframework.util.Assert;
16 import org.springframework.util.CollectionUtils;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21 import java.util.Set;
15 22
16 /** 23 /**
17 * @author XiangHan 24 * @author XiangHan
...@@ -64,5 +71,20 @@ public class TaskAttrServiceImpl implements TaskAttrService { ...@@ -64,5 +71,20 @@ public class TaskAttrServiceImpl implements TaskAttrService {
64 return this.taskAttrMapper.toDto(taskAttr); 71 return this.taskAttrMapper.toDto(taskAttr);
65 } 72 }
66 73
74 @Override
75 public List<TaskAttrDTO> findTasksByTaskIds(Set<Object> taskIds) {
76 List<Map<String,Object>> maps = this.taskAttrRepository.findTasksByTaskIds(taskIds);
77 if (!CollectionUtils.isEmpty(maps)) {
78 List<TaskAttr> taskAttrs = new ArrayList<>();
79 for (Map<String, Object> map : maps) {
80 TaskAttr taskAttr = JSON.parseObject(JSON.toJSONString(map), TaskAttr.class);
81 taskAttrs.add(taskAttr);
82 }
83
84 return this.taskAttrMapper.toDto(taskAttrs);
85 }
86 return new ArrayList<>();
87 }
88
67 89
68 } 90 }
......
...@@ -15,6 +15,7 @@ import java.sql.Timestamp; ...@@ -15,6 +15,7 @@ import java.sql.Timestamp;
15 15
16 import java.io.Serializable; 16 import java.io.Serializable;
17 import java.time.LocalDateTime; 17 import java.time.LocalDateTime;
18 import java.util.List;
18 19
19 /** 20 /**
20 * @author XiangHan 21 * @author XiangHan
......
...@@ -61,7 +61,7 @@ public class TaskBuilder { ...@@ -61,7 +61,7 @@ public class TaskBuilder {
61 61
62 task_.setDeleteMark(Objects.isNull(task.getDeleteMark()) ? 0 : task.getDeleteMark()); 62 task_.setDeleteMark(Objects.isNull(task.getDeleteMark()) ? 0 : task.getDeleteMark());
63 63
64 task_.setAttr(StringUtils.isBlank(task.getAttr()) ? null : task.getAttr()); 64 // task_.setAttr(StringUtils.isBlank(task.getAttr()) ? null : task.getAttr());
65 return task_; 65 return task_;
66 } 66 }
67 67
......
...@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Query; ...@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Query;
8 import org.springframework.transaction.annotation.Transactional; 8 import org.springframework.transaction.annotation.Transactional;
9 9
10 import java.util.List; 10 import java.util.List;
11 import java.util.Map;
11 import java.util.Optional; 12 import java.util.Optional;
12 13
13 /** 14 /**
...@@ -25,9 +26,8 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat ...@@ -25,9 +26,8 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
25 26
26 Optional<Task> findByCode(String code); 27 Optional<Task> findByCode(String code);
27 28
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 @Query(value = "SELECT ta.* FROM tr_task ta LEFT JOIN tr_task_template tm ON ta.task_template_id = tm.id " +
29 " LEFT JOIN tr_task_attr attr ON attr.task_id = ta.id " +
30 " WHERE ta.`status` = 1 AND ta.valid_time <= now() and ta.expire_time >= now() AND ta.delete_mark = 0 AND " + 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 AND ta.`member_level` <= ?2 and ta.`member_vip` <= ?3", nativeQuery = true) 31 " tm.type = ?1 AND ta.`member_level` <= ?2 and ta.`member_vip` <= ?3", nativeQuery = true)
32 List<Task> findByEvent(Integer event, Integer level, Integer vip); 32 List<Map<String,Object>> findByEventAndLevelAndVip(Integer event, Integer level, Integer vip);
33 } 33 }
......
1 package com.topdraw.business.module.task.service.impl; 1 package com.topdraw.business.module.task.service.impl;
2 2
3 import com.alibaba.fastjson.JSON;
3 import com.alibaba.fastjson.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
5 import com.alibaba.fastjson.JSONObject;
6 import com.topdraw.business.module.task.attribute.service.TaskAttrService;
7 import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
4 import com.topdraw.business.module.task.domain.Task; 8 import com.topdraw.business.module.task.domain.Task;
5 import com.topdraw.business.module.task.repository.TaskRepository; 9 import com.topdraw.business.module.task.repository.TaskRepository;
6 import com.topdraw.business.module.task.service.TaskService; 10 import com.topdraw.business.module.task.service.TaskService;
...@@ -17,7 +21,9 @@ import org.springframework.util.CollectionUtils; ...@@ -17,7 +21,9 @@ import org.springframework.util.CollectionUtils;
17 21
18 import java.util.ArrayList; 22 import java.util.ArrayList;
19 import java.util.List; 23 import java.util.List;
24 import java.util.Map;
20 import java.util.Objects; 25 import java.util.Objects;
26 import java.util.stream.Collectors;
21 27
22 /** 28 /**
23 * @author XiangHan 29 * @author XiangHan
...@@ -29,6 +35,9 @@ import java.util.Objects; ...@@ -29,6 +35,9 @@ import java.util.Objects;
29 public class TaskServiceImpl implements TaskService { 35 public class TaskServiceImpl implements TaskService {
30 36
31 @Autowired 37 @Autowired
38 private TaskAttrService taskAttrService;
39
40 @Autowired
32 private TaskMapper taskMapper; 41 private TaskMapper taskMapper;
33 @Autowired 42 @Autowired
34 private TaskRepository taskRepository; 43 private TaskRepository taskRepository;
...@@ -80,11 +89,45 @@ public class TaskServiceImpl implements TaskService { ...@@ -80,11 +89,45 @@ public class TaskServiceImpl implements TaskService {
80 public List<Task> findByEventAndMemberLevelAndVip(Integer event, Integer level, Integer vip) { 89 public List<Task> findByEventAndMemberLevelAndVip(Integer event, Integer level, Integer vip) {
81 try { 90 try {
82 boolean b = this.redisUtils.hasKey(RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip + "::" + event + ":" + level + ":" + vip); 91 boolean b = this.redisUtils.hasKey(RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip + "::" + event + ":" + level + ":" + vip);
92
83 if (b) { 93 if (b) {
84 List<Object> tasksObjs = redisUtils.lGet(RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip + "::" + event + ":" + level + ":" + vip, 0, -1); 94 List<Object> tasksObjs = redisUtils.lGet(RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip + "::" + event + ":" + level + ":" + vip, 0, -1);
85 return JSONArray.parseArray(tasksObjs.get(0).toString(), Task.class); 95 return JSONArray.parseArray(tasksObjs.get(0).toString(), Task.class);
86 } 96 }
87 List<Task> tasks = this.taskRepository.findByEvent(event, level, vip); 97
98 List<Map<String, Object>> maps = this.taskRepository.findByEventAndLevelAndVip(event, level, vip);
99
100 List<Task> tasks = new ArrayList<>();
101 if (CollectionUtils.isEmpty(maps)) {
102 return tasks;
103 }
104
105 List<TaskAttrDTO> taskAttrDTOS = this.taskAttrService.findTasksByTaskIds(maps.stream().map(t -> t.get("id")).collect(Collectors.toSet()));
106
107 if (!CollectionUtils.isEmpty(taskAttrDTOS)) {
108
109 for (Map<String, Object> map : maps) {
110 Task task = JSONObject.parseObject(JSON.toJSONString(map), Task.class);
111
112 List<String> taskAttrs = taskAttrDTOS.stream().filter(taskAttrDTO -> taskAttrDTO.getTaskId().equals(task.getId())).
113 map(TaskAttrDTO::getAttrStr).collect(Collectors.toList());
114 log.info("任务属性值, dealTask# taskAttrs ==>> {}", taskAttrs);
115 if (!CollectionUtils.isEmpty(taskAttrs)) {
116 task.setAttr(String.join(",", taskAttrs));
117 }
118
119 tasks.add(task);
120 }
121
122 } else {
123
124 for (Map<String, Object> map : maps) {
125 Task task = JSONObject.parseObject(JSON.toJSONString(map), Task.class);
126 tasks.add(task);
127 }
128
129 }
130
88 if (!CollectionUtils.isEmpty(tasks)) { 131 if (!CollectionUtils.isEmpty(tasks)) {
89 this.redisUtils.lSet(RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip + "::" + event + ":" + level + ":" + vip, tasks, 45 * 60); 132 this.redisUtils.lSet(RedisKeyConstants.cacheTaskByEventAndMemberLevelAndVip + "::" + event + ":" + level + ":" + vip, tasks, 45 * 60);
90 } 133 }
......
...@@ -38,15 +38,8 @@ public class TaskOperationController { ...@@ -38,15 +38,8 @@ public class TaskOperationController {
38 @ApiOperation("事件处理") 38 @ApiOperation("事件处理")
39 @AnonymousAccess 39 @AnonymousAccess
40 public IResultInfo dealTask(@RequestBody @Validated TaskOperationQueryCriteria criteria) { 40 public IResultInfo dealTask(@RequestBody @Validated TaskOperationQueryCriteria criteria) {
41 log.info("事件处理,开始,参数 ==>> {}", criteria); 41 log.info("事件处理,参数 ==>> dealTask#==>>{}", criteria);
42 long l = System.currentTimeMillis(); 42 return this.taskOperationService.dealTask(criteria.getContent());
43
44 // 任务处理
45 ResultInfo resultInfo = this.taskOperationService.dealTask(criteria.getContent());
46 long l2 = System.currentTimeMillis();
47 log.info("事件处理,结束,总耗时 ==>> {}", (l2-l));
48
49 return resultInfo;
50 } 43 }
51 44
52 /** 45 /**
......
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray;
4 import com.alibaba.fastjson.JSONObject; 5 import com.alibaba.fastjson.JSONObject;
5 import com.topdraw.aspect.AsyncMqSend; 6 import com.topdraw.aspect.AsyncMqSend;
6 import com.topdraw.business.module.coupon.service.CouponService; 7 import com.topdraw.business.module.coupon.service.CouponService;
...@@ -122,7 +123,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -122,7 +123,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
122 */ 123 */
123 private void createTaskAttr(Task task) { 124 private void createTaskAttr(Task task) {
124 TaskAttr taskAttr = new TaskAttr(); 125 TaskAttr taskAttr = new TaskAttr();
125 taskAttr.setAttrStr(task.getAttr()); 126 // taskAttr.setAttrStr(task.getAttr());
126 taskAttr.setTaskId(task.getId()); 127 taskAttr.setTaskId(task.getId());
127 this.taskAttrService.create(taskAttr); 128 this.taskAttrService.create(taskAttr);
128 } 129 }
...@@ -148,14 +149,14 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -148,14 +149,14 @@ public class TaskOperationServiceImpl implements TaskOperationService {
148 * @param task 任务 149 * @param task 任务
149 */ 150 */
150 private void updateTaskAttr(Task task) { 151 private void updateTaskAttr(Task task) {
151 152 /* List<String> attr = task.getAttr();
152 TaskAttrDTO taskAttrDTO = this.taskAttrService.findByTaskId(task.getId()); 153 TaskAttrDTO taskAttrDTO = this.taskAttrService.findByTaskId(task.getId());
153 if (Objects.nonNull(taskAttrDTO.getId())) { 154 if (Objects.nonNull(taskAttrDTO.getId())) {
154 TaskAttr taskAttr = new TaskAttr(); 155 TaskAttr taskAttr = new TaskAttr();
155 BeanUtils.copyProperties(taskAttrDTO, taskAttr); 156 BeanUtils.copyProperties(taskAttrDTO, taskAttr);
156 taskAttr.setAttrStr(task.getAttr()); 157 taskAttr.setAttrStr();
157 this.taskAttrService.update(taskAttr); 158 this.taskAttrService.update(taskAttr);
158 } 159 }*/
159 } 160 }
160 161
161 @Override 162 @Override
...@@ -209,7 +210,6 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -209,7 +210,6 @@ public class TaskOperationServiceImpl implements TaskOperationService {
209 public ResultInfo dealTask(String content) { 210 public ResultInfo dealTask(String content) {
210 211
211 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); 212 DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
212 log.info("事件dataSyncMsg ==>> {}", dataSyncMsg);
213 213
214 if (StringUtils.isBlank(dataSyncMsg.getMsgData())) { 214 if (StringUtils.isBlank(dataSyncMsg.getMsgData())) {
215 log.error("参数错误,事件消息体为空"); 215 log.error("参数错误,事件消息体为空");
...@@ -231,7 +231,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -231,7 +231,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
231 231
232 String platformAccount = platformAccountObj.toString(); 232 String platformAccount = platformAccountObj.toString();
233 UserTvSimpleDTO userTvDTO = this.userTvService.findSimpleByPlatformAccount(platformAccount); 233 UserTvSimpleDTO userTvDTO = this.userTvService.findSimpleByPlatformAccount(platformAccount);
234 log.info("查询大屏信息 ==>> {}", userTvDTO); 234 log.info("查询大屏信息, dealTask# ==>> {}", userTvDTO);
235 235
236 if (Objects.nonNull(userTvDTO)) { 236 if (Objects.nonNull(userTvDTO)) {
237 237
...@@ -240,56 +240,53 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -240,56 +240,53 @@ public class TaskOperationServiceImpl implements TaskOperationService {
240 240
241 String priorityMemberCode = userTvDTO.getPriorityMemberCode(); 241 String priorityMemberCode = userTvDTO.getPriorityMemberCode();
242 if (StringUtils.isNotBlank(priorityMemberCode)) { 242 if (StringUtils.isNotBlank(priorityMemberCode)) {
243 // TODO 是否需要将code和id都进行缓存
244 memberDTO = this.memberService.findSimpleByCode(priorityMemberCode); 243 memberDTO = this.memberService.findSimpleByCode(priorityMemberCode);
245 log.info("查询绑定的小屏的主会员信息, member ==>> {}", memberDTO); 244 log.info("查询绑定的小屏的主会员信息, dealTask# member ==>> {}", memberDTO);
246 } else if (Objects.nonNull(userTvDTO.getMemberId())) { 245 } else if (Objects.nonNull(userTvDTO.getMemberId())) {
247 long l4 = System.currentTimeMillis();
248 memberDTO = this.memberService.findSimpleById(userTvDTO.getMemberId()); 246 memberDTO = this.memberService.findSimpleById(userTvDTO.getMemberId());
249 long l5 = System.currentTimeMillis(); 247 log.info("查询大屏自身的会员信息, dealTask# memberId ==>> {}", userTvDTO.getMemberId());
250 log.info("查询大屏自身的会员信息, memberId ==>> {} , 总耗时 ==>> {}", userTvDTO.getMemberId(), (l5-l4));
251 } 248 }
252 249
253 } else { 250 } else {
254 251
255 memberDTO = this.memberService.findSimpleById(userTvDTO.getMemberId()); 252 memberDTO = this.memberService.findSimpleById(userTvDTO.getMemberId());
256 log.info("查询大屏会员信息 ==>> {}", memberDTO); 253 log.info("查询大屏会员信息, dealTask# memberDTO ==>> {}", memberDTO);
257 } 254 }
258 255
259 } else { 256 } else {
260 log.error("大屏账号不存在,请检查数据, platformAccount ==>> {}", platformAccount); 257 log.error("大屏账号不存在,请检查数据, dealTask# platformAccount ==>> {}", platformAccount);
261 return ResultInfo.failure("大屏账号不存在,请检查数据"); 258 return ResultInfo.failure("大屏账号不存在,请检查数据");
262 } 259 }
263 260
264 log.info("获取大屏会员信息 ==>> platformAccount ==>> {} || 会员信息 ==>> {}", platformAccount, memberDTO);
265
266 } else { 261 } else {
267 // 小屏侧传递的参数是memberId 262 // 小屏侧传递的参数是memberId
268 memberDTO = this.memberService.findSimpleById(Long.valueOf(memberIdObj.toString())); 263 memberDTO = this.memberService.findSimpleById(Long.valueOf(memberIdObj.toString()));
269 } 264 }
270 265
266 log.info("获取会员信息, dealTask# memberDTO ==>> {}", memberDTO);
267
271 if (Objects.isNull(memberDTO.getId())) { 268 if (Objects.isNull(memberDTO.getId())) {
272 log.error("会员信息不存在 ==>> {}", memberDTO); 269 log.error("会员信息不存在 ==>> dealTask# memberDTO ==>> {}", memberDTO);
273 return ResultInfo.failure("会员信息不存在"); 270 return ResultInfo.failure("会员信息不存在");
274 } 271 }
275 272
276 // 检查黑名单状态 0:正常 1:黑名单 273 // 检查黑名单状态 0:正常 1:黑名单
277 Long blackStatus = memberDTO.getBlackStatus(); 274 Long blackStatus = memberDTO.getBlackStatus();
278 if (Objects.nonNull(blackStatus) && blackStatus.equals(LocalConstants.BLACK_STATUS)) { 275 if (Objects.nonNull(blackStatus) && blackStatus.equals(LocalConstants.BLACK_STATUS)) {
279 log.error("会员已被加入黑名单 ==>> {}", memberDTO); 276 log.error("会员已被加入黑名单, dealTask# ==>> {}", memberDTO);
280 return ResultInfo.forbidden("会员已被加入黑名单"); 277 return ResultInfo.forbidden("会员已被加入黑名单");
281 } 278 }
282 279
283 // 检索满足条件的任务 1.先检查redis中是否存在符合条件的任务 2.从redis中获取当前会员未完成的任务 280 // 检索满足条件的任务 1.先检查redis中是否存在符合条件的任务 2.从redis中获取当前会员未完成的任务
284 List<Task> tasks = this.findValidTasksAndRefreshTaskProcess(memberDTO, dataSyncMsg.getEvent(), msgData); 281 List<Task> tasks = this.findValidTasksAndRefreshTaskProcess(memberDTO, dataSyncMsg.getEvent(), msgData);
285 log.info("当前用户可执行的任务详情 ==>> {}", tasks); 282 log.info("当前用户可执行的任务详情, dealTask# tasks ==>> [{}]", tasks);
286 if (CollectionUtils.isEmpty(tasks)) { 283 if (CollectionUtils.isEmpty(tasks)) {
287 // 类型 1:登录;2:观影;3:参加活动;4:订购;5:优享会员;6:签到;7:完成设置;8:播放记录; 284 // 类型 1:登录;2:观影;3:参加活动;4:订购;5:优享会员;6:签到;7:完成设置;8:播放记录;
288 // 10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 285 // 10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他
286 log.warn("无可执行的任务");
289 return ResultInfo.failure("无可执行的任务"); 287 return ResultInfo.failure("无可执行的任务");
290 } 288 }
291 289
292 if (!CollectionUtils.isEmpty(tasks)) {
293 // 5.权益区分(积分、权益、成长值) 290 // 5.权益区分(积分、权益、成长值)
294 Map<RightType,Object> tempRightsMap = this.distinguishRight(memberDTO, tasks, msgData, dataSyncMsg); 291 Map<RightType,Object> tempRightsMap = this.distinguishRight(memberDTO, tasks, msgData, dataSyncMsg);
295 292
...@@ -299,7 +296,6 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -299,7 +296,6 @@ public class TaskOperationServiceImpl implements TaskOperationService {
299 if (integer > 0) { 296 if (integer > 0) {
300 return ResultInfo.success(integer); 297 return ResultInfo.success(integer);
301 } 298 }
302 }
303 299
304 return ResultInfo.failure("任务处理失败"); 300 return ResultInfo.failure("任务处理失败");
305 301
...@@ -354,10 +350,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -354,10 +350,8 @@ public class TaskOperationServiceImpl implements TaskOperationService {
354 private List<Task> findValidTasksAndRefreshTaskProcess(MemberSimpleDTO memberDTO, Integer event, JSONObject msgData) { 350 private List<Task> findValidTasksAndRefreshTaskProcess(MemberSimpleDTO memberDTO, Integer event, JSONObject msgData) {
355 351
356 // 任务是否存在 352 // 任务是否存在
357 long l = System.currentTimeMillis();
358 List<Task> tasks = this.taskService.findByEventAndMemberLevelAndVip(event, memberDTO.getLevel(), memberDTO.getVip()); 353 List<Task> tasks = this.taskService.findByEventAndMemberLevelAndVip(event, memberDTO.getLevel(), memberDTO.getVip());
359 long l1 = System.currentTimeMillis(); 354 log.info("查询任务列表, dealTask# tasks ==>> [{}]",tasks);
360 log.info("查询任务列表,任务详情 ==>> {}, 总耗时 ==>> {}",tasks, (l1-l));
361 if (Objects.isNull(tasks) || CollectionUtils.isEmpty(tasks)) { 355 if (Objects.isNull(tasks) || CollectionUtils.isEmpty(tasks)) {
362 return Collections.singletonList(null); 356 return Collections.singletonList(null);
363 } 357 }
...@@ -365,16 +359,35 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -365,16 +359,35 @@ public class TaskOperationServiceImpl implements TaskOperationService {
365 // 获取当前会员所有任务的完成进度 359 // 获取当前会员所有任务的完成进度
366 Map<Object, Object> todayFinishTask = 360 Map<Object, Object> todayFinishTask =
367 this.trTaskProgressService.countTodayFinishTaskByMemberId(memberDTO.getId(), LocalDateTimeUtil.todayStart()); 361 this.trTaskProgressService.countTodayFinishTaskByMemberId(memberDTO.getId(), LocalDateTimeUtil.todayStart());
362 log.info("查询今天所有任务的完成进度, dealTask# todayFinishTask ==>> {}", todayFinishTask);
363
368 Map<Object, Object> finishTaskCount = this.trTaskProgressService.countTotalFinishTaskByMemberId(memberDTO.getId()); 364 Map<Object, Object> finishTaskCount = this.trTaskProgressService.countTotalFinishTaskByMemberId(memberDTO.getId());
365 log.info("查询所有任务的完成次数, dealTask# finishTaskCount ==>> {}", finishTaskCount);
369 366
370 List<Task> tasksResult = new ArrayList<>(); 367 List<Task> tasksResult = new ArrayList<>();
371 // 检查当前会员针对这些任务的完成情况 368 // 检查当前会员针对这些任务的完成情况
372 for (Task task : tasks) { 369 for (Task task : tasks) {
373 /*// 校验用户分组 370 boolean result = false;
374 if (StringUtils.isNotBlank(task.getGroups()) && !task.getGroups().contains(memberDTO.getGroups())) { 371 // 校验用户分组
375 log.warn("此用户分组不满足任务要求,任务分组 ==>> {} || 会员分组 ==>> {}",task.getGroups(), memberDTO.getGroups()); 372 if (StringUtils.isNotBlank(task.getGroups()) && !task.getGroups().contains("0")) {
373 String groups = memberDTO.getGroups();
374 log.info("会员分组信息, dealTask# groups ==>> {}", groups);
375 if (StringUtils.isNotBlank(groups)) {
376 String[] split = groups.split(",");
377 if (split.length > 0) {
378 for (String s : split) {
379 if (task.getGroups().contains(s)){
380 result = true;
381 break;
382 }
383 }
384 }
385 }
386 if (!result) {
387 log.warn("此用户分组不满足任务要求,任务分组 ==>> {} || 会员分组 ==>> {}", task.getGroups(), memberDTO.getGroups());
376 continue; 388 continue;
377 }*/ 389 }
390 }
378 391
379 // 任务每日重置 0:不重置;1:重置 392 // 任务每日重置 0:不重置;1:重置
380 Integer taskDailyReset = task.getTaskDailyReset(); 393 Integer taskDailyReset = task.getTaskDailyReset();
...@@ -415,10 +428,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -415,10 +428,15 @@ public class TaskOperationServiceImpl implements TaskOperationService {
415 break; 428 break;
416 // 参加活动 429 // 参加活动
417 case TaskEventType.ACTIVITY: 430 case TaskEventType.ACTIVITY:
418 431 if (this.doActivityEvent(msgData, task, memberDTO)) {
432 tasksResult.add(task);
433 }
419 break; 434 break;
420 // 订购 435 // 订购
421 case TaskEventType.ORDER: 436 case TaskEventType.ORDER:
437 if (this.doOrderEvent(msgData, task, memberDTO)) {
438 tasksResult.add(task);
439 }
422 break; 440 break;
423 // 优享会员 441 // 优享会员
424 case TaskEventType.MEMBER_PRIORITY: 442 case TaskEventType.MEMBER_PRIORITY:
...@@ -429,7 +447,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -429,7 +447,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
429 tasksResult.add(task); 447 tasksResult.add(task);
430 } 448 }
431 break; 449 break;
432 // 完成设置 450 // 完善个人资料
433 case TaskEventType.COMPLETE_INFO: 451 case TaskEventType.COMPLETE_INFO:
434 if (this.doCompleteMemberInfoEvent(msgData, task, memberDTO)) { 452 if (this.doCompleteMemberInfoEvent(msgData, task, memberDTO)) {
435 tasksResult.add(task); 453 tasksResult.add(task);
...@@ -475,6 +493,18 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -475,6 +493,18 @@ public class TaskOperationServiceImpl implements TaskOperationService {
475 return tasksResult; 493 return tasksResult;
476 } 494 }
477 495
496 private boolean doOrderEvent(JSONObject msgData, Task task, MemberSimpleDTO memberDTO) {
497 Integer actionAmount = task.getActionAmount();
498 // 用户行为次数
499 // TODO 后续需要按照业务对用户行为数据进行修改
500 int completeCount = 1;
501 if (completeCount >= actionAmount) {
502 this.saveOrUpdateTaskProcess(null, memberDTO.getId(), task, completeCount, TASK_FINISH_STATUS);
503 return true;
504 }
505 return false;
506 }
507
478 private boolean doPointsExchangeGoodsEvent(JSONObject msgData, Task task, MemberSimpleDTO memberDTO) { 508 private boolean doPointsExchangeGoodsEvent(JSONObject msgData, Task task, MemberSimpleDTO memberDTO) {
479 Integer actionAmount = task.getActionAmount(); 509 Integer actionAmount = task.getActionAmount();
480 // 用户行为次数 510 // 用户行为次数
...@@ -529,6 +559,30 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -529,6 +559,30 @@ public class TaskOperationServiceImpl implements TaskOperationService {
529 return false; 559 return false;
530 } 560 }
531 561
562 private boolean doActivityEvent(JSONObject msgData, Task task, MemberSimpleDTO memberDTO) {
563 Integer actionAmount = task.getActionAmount();
564 String attrStr = task.getAttr();
565 if (StringUtils.isBlank(attrStr)) {
566 int joinCount = 1;//msgData.getInteger("joinCount");
567 if (joinCount >= actionAmount) {
568 this.saveOrUpdateTaskProcess(null, memberDTO.getId(), task, joinCount, TASK_FINISH_STATUS);
569 return true;
570 }
571 }
572
573 Integer marketingActivityId = msgData.getInteger("marketingActivityId");
574 if (new ArrayList<>(Arrays.asList(attrStr.split(","))).contains(Integer.toString(marketingActivityId))) {
575 int joinCount = 1;//msgData.getInteger("joinCount");
576 if (joinCount >= actionAmount) {
577 this.saveOrUpdateTaskProcess(null, memberDTO.getId(), task, joinCount, TASK_FINISH_STATUS);
578 return true;
579 }
580 }
581
582 log.warn("未找到对应的活动,参数 marketingActivityId ==>> {} || 任务属性 ==>> {}", marketingActivityId, attrStr);
583 return false;
584 }
585
532 private boolean doSignEvent(JSONObject msgData, Task task, MemberSimpleDTO memberDTO) { 586 private boolean doSignEvent(JSONObject msgData, Task task, MemberSimpleDTO memberDTO) {
533 Integer actionAmount = task.getActionAmount(); 587 Integer actionAmount = task.getActionAmount();
534 // // 用户行为次数 签到天数 588 // // 用户行为次数 签到天数
...@@ -554,6 +608,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -554,6 +608,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
554 608
555 private boolean doLoginEvent(JSONObject msgData, Task task, MemberSimpleDTO memberDTO) { 609 private boolean doLoginEvent(JSONObject msgData, Task task, MemberSimpleDTO memberDTO) {
556 Integer actionAmount = task.getActionAmount(); 610 Integer actionAmount = task.getActionAmount();
611
557 // 登录天数 612 // 登录天数
558 int continueLogin = msgData.getInteger("CONTINUE_LOGIN"); 613 int continueLogin = msgData.getInteger("CONTINUE_LOGIN");
559 if (continueLogin >= actionAmount) { 614 if (continueLogin >= actionAmount) {
......
...@@ -164,7 +164,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -164,7 +164,7 @@ public class UserOperationServiceImpl implements UserOperationService {
164 164
165 } 165 }
166 166
167 return null; 167 return userAppDTO;
168 } 168 }
169 169
170 @Override 170 @Override
......
...@@ -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>
......
...@@ -155,7 +155,7 @@ public class TaskOperationControllerTest extends BaseTest { ...@@ -155,7 +155,7 @@ public class TaskOperationControllerTest extends BaseTest {
155 task.setValidTime(TimestampUtil.now()); 155 task.setValidTime(TimestampUtil.now());
156 task.setPointsType(0); 156 task.setPointsType(0);
157 157
158 task.setAttr("{\"value\":\"[1,2]\"}"); 158 // task.setAttr("{\"value\":\"[1,2]\"}");
159 159
160 task.setTaskTemplateId(13L); 160 task.setTaskTemplateId(13L);
161 161
...@@ -169,7 +169,7 @@ public class TaskOperationControllerTest extends BaseTest { ...@@ -169,7 +169,7 @@ public class TaskOperationControllerTest extends BaseTest {
169 Task task = new Task(); 169 Task task = new Task();
170 BeanUtils.copyProperties(taskDTO, task); 170 BeanUtils.copyProperties(taskDTO, task);
171 task.setName("testTask4455"); 171 task.setName("testTask4455");
172 task.setAttr("{\"value\":\"[4,10]\"}"); 172 // task.setAttr("{\"value\":\"[4,10]\"}");
173 this.taskOperationController.updateTask(task); 173 this.taskOperationController.updateTask(task);
174 } 174 }
175 175
......