Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
03fee680
Commit
03fee680
authored
Dec 19, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://113.105.137.151:22280/youjj/cloud-platform
into dev
parents
4d0f80a0
1ccd7073
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
74 deletions
+79
-74
ActivityPopularizeBiz.java
...com/xxfc/platform/activity/biz/ActivityPopularizeBiz.java
+79
-74
No files found.
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/ActivityPopularizeBiz.java
View file @
03fee680
...
...
@@ -86,83 +86,86 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper, Act
}});
log
.
info
(
"活动邀请注册:activityPopularize = {}"
,
activityPopularize
.
toString
());
if
(
activityPopularize
!=
null
)
{
String
lockKey
=
String
.
format
(
"%s%d:%s:%d"
,
registerQueueDTO
.
getInParamDTO
().
getActivityCode
(),
registerQueueDTO
.
getAppUserId
(),
registerQueueDTO
.
getInParamDTO
().
getUsername
(),
activityPopularize
.
getId
());
RLock
rLock
=
redissonLock
.
getRLock
(
lockKey
);
try
{
boolean
isSuccess
=
rLock
.
tryLock
(
5
,
5
,
TimeUnit
.
SECONDS
);
if
(
isSuccess
)
{
List
<
ActivityPopularizeItem
>
activityPopularizeItems
=
activityPopularizeItemBiz
.
selectByPopularizeId
(
activityPopularize
.
getId
());
ActivityPopularizeItem
activityPopularizeItem
=
activityPopularizeItems
.
get
(
activityPopularizeItems
.
size
()
-
1
);
Date
now
=
DateUtil
.
date
();
Date
start
=
DateUtil
.
date
(
activityPopularize
.
getStartTime
());
Date
end
=
DateUtil
.
date
(
activityPopularize
.
getEndTime
());
//判断是否活动超时
if
(
now
.
before
(
start
)
||
now
.
after
(
end
))
{
log
.
error
(
"不在活动范围内 入参Json:"
+
JSONUtil
.
toJsonStr
(
registerQueueDTO
));
return
;
}
String
lockKey
=
String
.
format
(
"%s%d%d"
,
registerQueueDTO
.
getInParamDTO
().
getActivityCode
(),
appUserDTO
.
getInviterAccount
(),
activityPopularize
.
getId
());
RLock
rLock
=
redissonLock
.
getRLock
(
lockKey
);
try
{
boolean
isSuccess
=
rLock
.
tryLock
(
5
,
5
,
TimeUnit
.
SECONDS
);
if
(
isSuccess
)
{
log
.
info
(
"1, {}"
,
System
.
currentTimeMillis
());
Thread
.
sleep
(
1000
);
log
.
info
(
"2, {}"
,
System
.
currentTimeMillis
());
List
<
ActivityPopularizeItem
>
activityPopularizeItems
=
activityPopularizeItemBiz
.
selectByPopularizeId
(
activityPopularize
.
getId
());
ActivityPopularizeItem
activityPopularizeItem
=
activityPopularizeItems
.
get
(
activityPopularizeItems
.
size
()
-
1
);
Date
now
=
DateUtil
.
date
();
Date
start
=
DateUtil
.
date
(
activityPopularize
.
getStartTime
());
Date
end
=
DateUtil
.
date
(
activityPopularize
.
getEndTime
());
//判断是否活动超时
if
(
now
.
before
(
start
)
||
now
.
after
(
end
))
{
log
.
error
(
"不在活动范围内 入参Json:"
+
JSONUtil
.
toJsonStr
(
registerQueueDTO
));
return
;
}
Integer
majorUserId
=
Integer
.
valueOf
(
appUserDTO
.
getInviterAccount
());
ActivityPopularizeRelation
activityPopularizeRelation
=
new
ActivityPopularizeRelation
()
{{
setMajorUserId
(
majorUserId
);
setPopularizeId
(
activityPopularize
.
getId
());
}};
//新增第几个邀请人和邀请金额字段
Integer
num
=
relationBiz
.
getByUserIdAndPopularizeId
(
activityPopularizeRelation
);
double
amount
=
0
;
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
activityPopularizeItem
.
getDetail
());
if
(
jsonObject
!=
null
&&
StringUtils
.
isNotBlank
(
jsonObject
.
getString
(
"detail"
)))
{
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
jsonObject
.
getString
(
"detail"
));
if
(
jsonArray
!=
null
)
{
JSONObject
jsonObject1
=
jsonArray
.
getJSONObject
(
num
-
1
);
if
(
jsonObject1
!=
null
)
{
double
amountString
=
jsonObject1
.
getDouble
(
"amount"
);
amount
=
amount
+
amountString
;
Integer
majorUserId
=
Integer
.
valueOf
(
appUserDTO
.
getInviterAccount
());
ActivityPopularizeRelation
activityPopularizeRelation
=
new
ActivityPopularizeRelation
()
{{
setMajorUserId
(
majorUserId
);
setPopularizeId
(
activityPopularize
.
getId
());
}};
//新增第几个邀请人和邀请金额字段
Integer
num
=
relationBiz
.
getByUserIdAndPopularizeId
(
activityPopularizeRelation
);
double
amount
=
0
;
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
activityPopularizeItem
.
getDetail
());
if
(
jsonObject
!=
null
&&
StringUtils
.
isNotBlank
(
jsonObject
.
getString
(
"detail"
)))
{
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
jsonObject
.
getString
(
"detail"
));
if
(
jsonArray
!=
null
)
{
JSONObject
jsonObject1
=
jsonArray
.
getJSONObject
(
num
-
1
);
if
(
jsonObject1
!=
null
)
{
double
amountString
=
jsonObject1
.
getDouble
(
"amount"
);
amount
=
amount
+
amountString
;
}
}
}
double
a
=
amount
;
//添加活动关系
relationBiz
.
insertSelective
(
new
ActivityPopularizeRelation
()
{{
setPopularizeId
(
activityPopularize
.
getId
());
setMajorUserId
(
majorUserId
);
setMinorUserId
(
appUserDTO
.
getUserid
());
setNum
(
num
);
setAmount
(
new
BigDecimal
(
a
));
}});
ApLogDTO
apLogDTO
=
popularizeLogBiz
.
selectOneApLogDTO
(
new
ActivityPopularizeLog
()
{{
setUserId
(
majorUserId
);
setItemId
(
activityPopularizeItem
.
getId
());
}});
//生成任务项
if
(
null
==
apLogDTO
)
{
popularizeLogBiz
.
insertSelectiveRe
(
new
ActivityPopularizeLog
()
{{
setItemId
(
activityPopularizeItem
.
getId
());
setUserId
(
majorUserId
);
setStatus
(
SYS_FALSE
);
setPopularizeId
(
activityPopularize
.
getId
());
}});
}
}
}
double
a
=
amount
;
//添加活动关系
relationBiz
.
insertSelective
(
new
ActivityPopularizeRelation
()
{{
setPopularizeId
(
activityPopularize
.
getId
());
setMajorUserId
(
majorUserId
);
setMinorUserId
(
appUserDTO
.
getUserid
());
setNum
(
num
);
setAmount
(
new
BigDecimal
(
a
));
}});
ApLogDTO
apLogDTO
=
popularizeLogBiz
.
selectOneApLogDTO
(
new
ActivityPopularizeLog
()
{{
setUserId
(
majorUserId
);
setItemId
(
activityPopularizeItem
.
getId
());
}});
//生成任务项
if
(
null
==
apLogDTO
)
{
popularizeLogBiz
.
insertSelectiveRe
(
new
ActivityPopularizeLog
()
{{
setItemId
(
activityPopularizeItem
.
getId
());
setUserId
(
majorUserId
);
setStatus
(
SYS_FALSE
);
setPopularizeId
(
activityPopularize
.
getId
());
}});
}
//查出majorUser参与活动信息
ActivityPopularizeUser
activityPopularizeUser
=
popularizeUserBiz
.
selectOne
(
new
ActivityPopularizeUser
()
{{
setUserId
(
majorUserId
);
setPopularizeId
(
activityPopularize
.
getId
());
}});
double
currentProgress
=
activityPopularizeUser
.
getCurrentProgress
().
doubleValue
();
log
.
info
(
"用户原活动进度:currentProgress = {}"
,
currentProgress
);
currentProgress
+=
Double
.
parseDouble
(
a
+
""
);
BigDecimal
bigDecimal
=
new
BigDecimal
(
currentProgress
);
log
.
info
(
"用户现活动进度:newCurrentProgress = {}"
,
currentProgress
);
//修改当前进度
activityPopularizeUser
.
setCurrentProgress
(
bigDecimal
);
popularizeUserBiz
.
updateSelectiveById
(
activityPopularizeUser
);
//任务没有完成 加锁
//查出majorUser参与活动信息
ActivityPopularizeUser
activityPopularizeUser
=
popularizeUserBiz
.
selectOne
(
new
ActivityPopularizeUser
()
{{
setUserId
(
majorUserId
);
setPopularizeId
(
activityPopularize
.
getId
());
}});
double
currentProgress
=
activityPopularizeUser
.
getCurrentProgress
().
doubleValue
();
log
.
info
(
"用户原活动进度:currentProgress = {}"
,
currentProgress
);
currentProgress
+=
Double
.
parseDouble
(
a
+
""
);
BigDecimal
bigDecimal
=
new
BigDecimal
(
currentProgress
);
log
.
info
(
"用户现活动进度:newCurrentProgress = {}"
,
currentProgress
);
//修改当前进度
activityPopularizeUser
.
setCurrentProgress
(
bigDecimal
);
popularizeUserBiz
.
updateSelectiveById
(
activityPopularizeUser
);
//任务没有完成 加锁
if
(!
SYS_TRUE
.
equals
(
activityPopularizeUser
.
getStatus
()))
{
// AwardDTO awardDTO = JSONUtil.toBean(activityPopularize.getValue(), AwardDTO.class);
...
...
@@ -196,6 +199,8 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper, Act
}
}
catch
(
InterruptedException
e
)
{
log
.
error
(
"tryLock fail, key = [{}]"
,
lockKey
);
}
finally
{
log
.
info
(
"执行结束, {}"
,
System
.
currentTimeMillis
());
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment