Commit b6c3d642 b6c3d642388b181f86deb6e7c19b9f7a519b3b8c by xianghan

1.优化

1 parent fd9a05fd
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.JSONArray; 4 import com.alibaba.fastjson.JSONArray;
4 import com.alibaba.fastjson.JSONObject; 5 import com.alibaba.fastjson.JSONObject;
6 import com.google.gson.JsonObject;
5 import com.topdraw.business.module.coupon.service.CouponService; 7 import com.topdraw.business.module.coupon.service.CouponService;
6 import com.topdraw.business.module.coupon.service.dto.CouponDTO; 8 import com.topdraw.business.module.coupon.service.dto.CouponDTO;
7 import com.topdraw.business.module.member.group.service.MemberGroupService; 9 import com.topdraw.business.module.member.group.service.MemberGroupService;
...@@ -111,14 +113,14 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -111,14 +113,14 @@ public class TaskOperationServiceImpl implements TaskOperationService {
111 } 113 }
112 114
113 // 1.通过任务标识获取任务模板,通过模板参数获取具体的模板 115 // 1.通过任务标识获取任务模板,通过模板参数获取具体的模板
114 TaskTemplate taskTemplate = this.getTaskTemplate(event,dataSyncMsg); 116 TaskTemplate taskTemplate = this.getTaskTemplate(event, dataSyncMsg);
115 // 2.通过任务模板获取对应的任务列表 117 // 2.通过任务模板获取对应的任务列表
116 List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate,dataSyncMsg); 118 List<Task> taskList = this.loadListTaskByTaskTemplate(taskTemplate, dataSyncMsg);
117 // 4.判断当前用户是否满足任务完成条件 119 // 4.判断当前用户是否满足任务完成条件
118 boolean checkResult = this.checkTaskCompletion(memberId,taskList); 120 boolean checkResult = this.checkTaskCompletion(memberId, taskList, event, msgData);
119 if (checkResult) { 121 if (checkResult) {
120 // 5.权益区分(积分、权益、成长值) 122 // 5.权益区分(积分、权益、成长值)
121 Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId,taskList,msgData); 123 Map<RightType,Object> tempRightsMap = this.distinguishRight(memberId, taskList, msgData);
122 124
123 // 6.风控检查 125 // 6.风控检查
124 boolean result = this.checkRiskManagement(memberId,tempRightsMap); 126 boolean result = this.checkRiskManagement(memberId,tempRightsMap);
...@@ -532,7 +534,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -532,7 +534,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
532 * @return boolean true:success false:fail 534 * @return boolean true:success false:fail
533 */ 535 */
534 //<taskId,boolean> 536 //<taskId,boolean>
535 private boolean checkTaskCompletion(Long memberId , List<Task> taskList) { 537 private boolean checkTaskCompletion(Long memberId , List<Task> taskList, Integer event, DataSyncMsg.MsgData msgData) {
536 if (!CollectionUtils.isEmpty(taskList)) { 538 if (!CollectionUtils.isEmpty(taskList)) {
537 // 会员信息 539 // 会员信息
538 MemberDTO memberDTO = this.memberService.findById(memberId); 540 MemberDTO memberDTO = this.memberService.findById(memberId);
...@@ -557,7 +559,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -557,7 +559,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
557 return false; 559 return false;
558 560
559 // 获取当前任务的完成情况 561 // 获取当前任务的完成情况
560 boolean result = this.checkAndRefreshTaskCompletion(memberId,taskList); 562 boolean result = this.checkAndRefreshTaskCompletion(memberId,taskList,event,msgData);
561 563
562 return result; 564 return result;
563 565
...@@ -673,7 +675,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -673,7 +675,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
673 * @param taskStream 675 * @param taskStream
674 * @return boolean false:失败 true:成功 676 * @return boolean false:失败 true:成功
675 */ 677 */
676 private boolean checkAndRefreshTaskCompletion(Long memberId , List<Task> taskStream) { 678 private boolean checkAndRefreshTaskCompletion(Long memberId , List<Task> taskStream, Integer event, DataSyncMsg.MsgData msgData) {
677 String time1 = LocalDateTimeUtil.todayStart(); 679 String time1 = LocalDateTimeUtil.todayStart();
678 for (Task task : taskStream) { 680 for (Task task : taskStream) {
679 681
...@@ -690,6 +692,30 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -690,6 +692,30 @@ public class TaskOperationServiceImpl implements TaskOperationService {
690 // 行为量(完成此任务需要多少次相同行为的触发) 692 // 行为量(完成此任务需要多少次相同行为的触发)
691 Integer actionAmount = task.getActionAmount(); 693 Integer actionAmount = task.getActionAmount();
692 694
695 switch (event) {
696 // 播放记录
697 case 8:
698 if (!CollectionUtils.isEmpty(trTaskProgressDTOS)) {
699 TrTaskProgressDTO trTaskProgressDTO_0 = trTaskProgressDTOS.get(0);
700 Integer status_0 = trTaskProgressDTO_0.getStatus();
701 Integer currentActionAmount_0 = trTaskProgressDTO_0.getCurrentActionAmount();
702 Timestamp completionTime_0 = trTaskProgressDTO_0.getCompletionTime();
703 if (status_0 == 1 && currentActionAmount_0 != null && Objects.nonNull(completionTime_0)) {
704 return false;
705 }
706 }
707 String param = msgData.getParam();
708 JSONObject jsonObject = JSON.parseObject(param);
709 Integer value = Integer.valueOf(jsonObject.get("playDuration").toString());
710 if (value >= actionAmount) {
711 currentActionAmount = actionAmount;
712 completionTime = TimestampUtil.now();
713 status = TASK_FINISH_STATUS;
714 }
715
716 break;
717
718 default:
693 // 行为量 1 719 // 行为量 1
694 if (actionAmount == 1) { 720 if (actionAmount == 1) {
695 721
...@@ -769,6 +795,12 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -769,6 +795,12 @@ public class TaskOperationServiceImpl implements TaskOperationService {
769 795
770 } 796 }
771 797
798 break;
799
800 }
801
802
803
772 TrTaskProgress trTaskProgress = new TrTaskProgress(); 804 TrTaskProgress trTaskProgress = new TrTaskProgress();
773 trTaskProgress.setId(id); 805 trTaskProgress.setId(id);
774 trTaskProgress.setCurrentActionAmount(currentActionAmount); 806 trTaskProgress.setCurrentActionAmount(currentActionAmount);
......