Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张云鹏
/
uc-engine
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
b6c3d642
...
b6c3d642388b181f86deb6e7c19b9f7a519b3b8c
authored
2022-04-14 20:55:40 +0800
by
xianghan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.优化
1 parent
fd9a05fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
73 deletions
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/TaskOperationServiceImpl.java
member-service-impl/src/main/java/com/topdraw/business/process/service/impl/TaskOperationServiceImpl.java
View file @
b6c3d64
package
com
.
topdraw
.
business
.
process
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.JsonObject
;
import
com.topdraw.business.module.coupon.service.CouponService
;
import
com.topdraw.business.module.coupon.service.dto.CouponDTO
;
import
com.topdraw.business.module.member.group.service.MemberGroupService
;
...
...
@@ -111,14 +113,14 @@ public class TaskOperationServiceImpl implements TaskOperationService {
}
// 1.通过任务标识获取任务模板,通过模板参数获取具体的模板
TaskTemplate
taskTemplate
=
this
.
getTaskTemplate
(
event
,
dataSyncMsg
);
TaskTemplate
taskTemplate
=
this
.
getTaskTemplate
(
event
,
dataSyncMsg
);
// 2.通过任务模板获取对应的任务列表
List
<
Task
>
taskList
=
this
.
loadListTaskByTaskTemplate
(
taskTemplate
,
dataSyncMsg
);
List
<
Task
>
taskList
=
this
.
loadListTaskByTaskTemplate
(
taskTemplate
,
dataSyncMsg
);
// 4.判断当前用户是否满足任务完成条件
boolean
checkResult
=
this
.
checkTaskCompletion
(
memberId
,
taskList
);
boolean
checkResult
=
this
.
checkTaskCompletion
(
memberId
,
taskList
,
event
,
msgData
);
if
(
checkResult
)
{
// 5.权益区分(积分、权益、成长值)
Map
<
RightType
,
Object
>
tempRightsMap
=
this
.
distinguishRight
(
memberId
,
taskList
,
msgData
);
Map
<
RightType
,
Object
>
tempRightsMap
=
this
.
distinguishRight
(
memberId
,
taskList
,
msgData
);
// 6.风控检查
boolean
result
=
this
.
checkRiskManagement
(
memberId
,
tempRightsMap
);
...
...
@@ -532,7 +534,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
* @return boolean true:success false:fail
*/
//<taskId,boolean>
private
boolean
checkTaskCompletion
(
Long
memberId
,
List
<
Task
>
taskList
)
{
private
boolean
checkTaskCompletion
(
Long
memberId
,
List
<
Task
>
taskList
,
Integer
event
,
DataSyncMsg
.
MsgData
msgData
)
{
if
(!
CollectionUtils
.
isEmpty
(
taskList
))
{
// 会员信息
MemberDTO
memberDTO
=
this
.
memberService
.
findById
(
memberId
);
...
...
@@ -557,7 +559,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
return
false
;
// 获取当前任务的完成情况
boolean
result
=
this
.
checkAndRefreshTaskCompletion
(
memberId
,
taskList
);
boolean
result
=
this
.
checkAndRefreshTaskCompletion
(
memberId
,
taskList
,
event
,
msgData
);
return
result
;
...
...
@@ -673,7 +675,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
* @param taskStream
* @return boolean false:失败 true:成功
*/
private
boolean
checkAndRefreshTaskCompletion
(
Long
memberId
,
List
<
Task
>
taskStream
)
{
private
boolean
checkAndRefreshTaskCompletion
(
Long
memberId
,
List
<
Task
>
taskStream
,
Integer
event
,
DataSyncMsg
.
MsgData
msgData
)
{
String
time1
=
LocalDateTimeUtil
.
todayStart
();
for
(
Task
task
:
taskStream
)
{
...
...
@@ -690,85 +692,115 @@ public class TaskOperationServiceImpl implements TaskOperationService {
// 行为量(完成此任务需要多少次相同行为的触发)
Integer
actionAmount
=
task
.
getActionAmount
();
// 行为量 1
if
(
actionAmount
==
1
)
{
switch
(
event
)
{
// 播放记录
case
8
:
if
(!
CollectionUtils
.
isEmpty
(
trTaskProgressDTOS
))
{
TrTaskProgressDTO
trTaskProgressDTO_0
=
trTaskProgressDTOS
.
get
(
0
);
Integer
status_0
=
trTaskProgressDTO_0
.
getStatus
();
Integer
currentActionAmount_0
=
trTaskProgressDTO_0
.
getCurrentActionAmount
();
Timestamp
completionTime_0
=
trTaskProgressDTO_0
.
getCompletionTime
();
if
(
status_0
==
1
&&
currentActionAmount_0
!=
null
&&
Objects
.
nonNull
(
completionTime_0
))
{
return
false
;
}
}
String
param
=
msgData
.
getParam
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
param
);
Integer
value
=
Integer
.
valueOf
(
jsonObject
.
get
(
"playDuration"
).
toString
());
if
(
value
>=
actionAmount
)
{
currentActionAmount
=
actionAmount
;
completionTime
=
TimestampUtil
.
now
();
status
=
TASK_FINISH_STATUS
;
}
if
(
CollectionUtils
.
isEmpty
(
trTaskProgressDTOS
))
{
currentActionAmount
=
1
;
completionTime
=
TimestampUtil
.
now
();
status
=
TASK_FINISH_STATUS
;
}
break
;
if
(!
CollectionUtils
.
isEmpty
(
trTaskProgressDTOS
))
{
// 此任务做过,但未完成
TrTaskProgressDTO
trTaskProgressDTO
=
trTaskProgressDTOS
.
get
(
0
);
Long
id_
=
trTaskProgressDTO
.
getId
();
Integer
status_
=
trTaskProgressDTO
.
getStatus
();
Integer
currentActionAmount_
=
trTaskProgressDTO
.
getCurrentActionAmount
();
Timestamp
completionTime1
=
trTaskProgressDTO
.
getCompletionTime
();
// 任务已做,不成功
if
(
Objects
.
nonNull
(
status_
)
&&
status_
==
1
&&
Objects
.
nonNull
(
currentActionAmount_
)
&&
currentActionAmount_
==
1
&&
Objects
.
nonNull
(
completionTime1
)
&&
completionTime1
.
toLocalDateTime
().
toLocalDate
().
compareTo
(
LocalDate
.
now
())
==
0
)
{
// 任务重复类型
Integer
taskDailyReset
=
task
.
getTaskDailyReset
();
if
(
taskDailyReset
==
-
1
)
{
return
true
;
}
else
if
(
currentActionAmount_
<
taskDailyReset
){
return
true
;
}
default
:
// 行为量 1
if
(
actionAmount
==
1
)
{
if
(
CollectionUtils
.
isEmpty
(
trTaskProgressDTOS
))
{
currentActionAmount
=
1
;
completionTime
=
TimestampUtil
.
now
();
status
=
TASK_FINISH_STATUS
;
}
return
false
;
if
(!
CollectionUtils
.
isEmpty
(
trTaskProgressDTOS
))
{
// 此任务做过,但未完成
TrTaskProgressDTO
trTaskProgressDTO
=
trTaskProgressDTOS
.
get
(
0
);
Long
id_
=
trTaskProgressDTO
.
getId
();
Integer
status_
=
trTaskProgressDTO
.
getStatus
();
Integer
currentActionAmount_
=
trTaskProgressDTO
.
getCurrentActionAmount
();
Timestamp
completionTime1
=
trTaskProgressDTO
.
getCompletionTime
();
// 任务已做,不成功
if
(
Objects
.
nonNull
(
status_
)
&&
status_
==
1
&&
Objects
.
nonNull
(
currentActionAmount_
)
&&
currentActionAmount_
==
1
&&
Objects
.
nonNull
(
completionTime1
)
&&
completionTime1
.
toLocalDateTime
().
toLocalDate
().
compareTo
(
LocalDate
.
now
())
==
0
)
{
// 任务重复类型
Integer
taskDailyReset
=
task
.
getTaskDailyReset
();
if
(
taskDailyReset
==
-
1
)
{
return
true
;
}
else
if
(
currentActionAmount_
<
taskDailyReset
){
return
true
;
}
return
false
;
// 未做,成功
}
else
{
id
=
id_
;
currentActionAmount
=
1
;
completionTime
=
TimestampUtil
.
now
();
status
=
TASK_FINISH_STATUS
;
}
// 未做,成功
}
else
{
id
=
id_
;
currentActionAmount
=
1
;
completionTime
=
TimestampUtil
.
now
();
status
=
TASK_FINISH_STATUS
;
}
}
}
}
// 行为量非1
if
(
actionAmount
!=
1
)
{
if
(!
CollectionUtils
.
isEmpty
(
trTaskProgressDTOS
))
{
// 此任务做过,但未完成
TrTaskProgressDTO
trTaskProgressDTO
=
trTaskProgressDTOS
.
get
(
0
);
Long
id_
=
trTaskProgressDTO
.
getId
();
// 状态 0:未完成;1:已完成
Integer
status_
=
trTaskProgressDTO
.
getStatus
();
Timestamp
completionTime_
=
trTaskProgressDTO
.
getCompletionTime
();
Integer
currentActionAmount_
=
trTaskProgressDTO
.
getCurrentActionAmount
();
// 行为量达到,完成
if
(
status_
!=
1
&&
Objects
.
isNull
(
completionTime_
)
&&
actionAmount
==
currentActionAmount_
+
1
)
{
id
=
id_
;
currentActionAmount
=
actionAmount
;
completionTime
=
TimestampUtil
.
now
();
status
=
TASK_FINISH_STATUS
;
}
else
{
// 行为量未达到,未完成
id
=
id_
;
currentActionAmount
=
currentActionAmount_
+
1
;
}
// 行为量非1
if
(
actionAmount
!=
1
)
{
if
(!
CollectionUtils
.
isEmpty
(
trTaskProgressDTOS
))
{
// 此任务做过,但未完成
TrTaskProgressDTO
trTaskProgressDTO
=
trTaskProgressDTOS
.
get
(
0
);
Long
id_
=
trTaskProgressDTO
.
getId
();
// 状态 0:未完成;1:已完成
Integer
status_
=
trTaskProgressDTO
.
getStatus
();
Timestamp
completionTime_
=
trTaskProgressDTO
.
getCompletionTime
();
Integer
currentActionAmount_
=
trTaskProgressDTO
.
getCurrentActionAmount
();
// 行为量达到,完成
if
(
status_
!=
1
&&
Objects
.
isNull
(
completionTime_
)
&&
actionAmount
==
currentActionAmount_
+
1
)
{
id
=
id_
;
currentActionAmount
=
actionAmount
;
completionTime
=
TimestampUtil
.
now
();
status
=
TASK_FINISH_STATUS
;
}
else
{
// 行为量未达到,未完成
id
=
id_
;
currentActionAmount
=
currentActionAmount_
+
1
;
}
}
}
// 未达到行为量,未完成
if
(
CollectionUtils
.
isEmpty
(
trTaskProgressDTOS
))
{
currentActionAmount
=
1
;
status
=
TASK_UNFINISH_STATUS
;
}
// 未达到行为量,未完成
if
(
CollectionUtils
.
isEmpty
(
trTaskProgressDTOS
))
{
currentActionAmount
=
1
;
status
=
TASK_UNFINISH_STATUS
;
}
}
break
;
}
TrTaskProgress
trTaskProgress
=
new
TrTaskProgress
();
trTaskProgress
.
setId
(
id
);
trTaskProgress
.
setCurrentActionAmount
(
currentActionAmount
);
...
...
Please
register
or
sign in
to post a comment