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
bb3d6fbf
Commit
bb3d6fbf
authored
Dec 08, 2020
by
unset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增官网咨询和banner
parent
c570cc68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
152 additions
and
153 deletions
+152
-153
IntegralUserRecordBiz.java
...com/xxfc/platform/activity/biz/IntegralUserRecordBiz.java
+152
-153
No files found.
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/IntegralUserRecordBiz.java
View file @
bb3d6fbf
...
@@ -32,159 +32,158 @@ import java.util.List;
...
@@ -32,159 +32,158 @@ import java.util.List;
@Slf4j
@Slf4j
public
class
IntegralUserRecordBiz
extends
BaseBiz
<
IntegralUserRecordMapper
,
IntegralUserRecord
>
{
public
class
IntegralUserRecordBiz
extends
BaseBiz
<
IntegralUserRecordMapper
,
IntegralUserRecord
>
{
@Autowired
@Autowired
UserInfoBiz
userInfoBiz
;
UserInfoBiz
userInfoBiz
;
@Autowired
@Autowired
IntegralUserTotalBiz
integralUserTotalBiz
;
IntegralUserTotalBiz
integralUserTotalBiz
;
@Autowired
@Autowired
IntegralRuleBiz
integralRuleBiz
;
IntegralRuleBiz
integralRuleBiz
;
@Autowired
@Autowired
IntegralUserStatusBiz
integralUserStatusBiz
;
IntegralUserStatusBiz
integralUserStatusBiz
;
/**
/**
* 添加用户积分记录
* 添加用户积分记录
*
*
* @param integralUserRecord
* @param integralUserRecord
* @return
* @return
*/
*/
public
ObjectRestResponse
add
(
IntegralUserRecordDto
integralUserRecord
)
{
public
ObjectRestResponse
add
(
IntegralUserRecordDto
integralUserRecord
)
{
log
.
info
(
"添加积分记录的参数:integralUserRecord = {}"
,
integralUserRecord
);
log
.
info
(
"添加积分记录的参数:integralUserRecord = {}"
,
integralUserRecord
);
if
(
integralUserRecord
==
null
||
StringUtils
.
isBlank
(
integralUserRecord
.
getIntegralRuleCode
()))
{
if
(
integralUserRecord
==
null
||
StringUtils
.
isBlank
(
integralUserRecord
.
getIntegralRuleCode
()))
{
return
ObjectRestResponse
.
paramIsEmpty
();
return
ObjectRestResponse
.
paramIsEmpty
();
}
}
//如果参数没有积分,说明是消息队列过来的参数,需要查询规则表获取积分数
//如果参数没有积分,说明是消息队列过来的参数,需要查询规则表获取积分数
IntegralRuleDto
integralRule
=
new
IntegralRuleDto
();
IntegralRuleDto
integralRule
=
new
IntegralRuleDto
();
integralRule
.
setCode
(
integralUserRecord
.
getIntegralRuleCode
());
integralRule
.
setCode
(
integralUserRecord
.
getIntegralRuleCode
());
ObjectRestResponse
<
IntegralRule
>
ruleObjectRestResponse
=
integralRuleBiz
.
getOne
(
integralRule
);
ObjectRestResponse
<
IntegralRule
>
ruleObjectRestResponse
=
integralRuleBiz
.
getOne
(
integralRule
);
if
(
ruleObjectRestResponse
.
getData
()
==
null
)
{
if
(
ruleObjectRestResponse
.
getData
()
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
1202
,
"积分规则不存在"
);
return
ObjectRestResponse
.
createFailedResult
(
1202
,
"积分规则不存在"
);
}
}
IntegralRule
oldValue
=
ruleObjectRestResponse
.
getData
();
IntegralRule
oldValue
=
ruleObjectRestResponse
.
getData
();
if
(
integralUserRecord
.
getPoint
()
==
null
)
{
if
(
integralUserRecord
.
getPoint
()
==
null
)
{
Integer
point
=
0
;
Integer
point
=
0
;
if
(
oldValue
.
getPoint
()
==
0
)
{
//没有基础分需要计算分数
if
(
oldValue
.
getPoint
()
==
0
)
{
//没有基础分需要计算分数
Integer
amount
=
Integer
.
parseInt
(
new
BigDecimal
(
integralUserRecord
.
getAmount
()).
divide
(
new
BigDecimal
(
"100"
),
0
,
BigDecimal
.
ROUND_DOWN
).
toString
());
Integer
amount
=
new
BigDecimal
(
integralUserRecord
.
getAmount
()).
intValue
();
//Integer amount = Integer.parseInt(integralUserRecord.getAmount());
//Integer amount = Integer.parseInt(integralUserRecord.getAmount());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
oldValue
.
getOtherRule
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
oldValue
.
getOtherRule
());
log
.
info
(
"查询的其他规则json信息:jsonObject = {}"
,
jsonObject
);
log
.
info
(
"查询的其他规则json信息:jsonObject = {}"
,
jsonObject
);
if
(
jsonObject
==
null
)
{
if
(
jsonObject
==
null
)
{
point
=
ruleObjectRestResponse
.
getData
().
getPoint
();
point
=
oldValue
.
getPoint
();
}
else
{
}
else
{
point
=
jsonObject
.
getInteger
(
"rule"
)
==
null
?
0
*
amount
:
jsonObject
.
getInteger
(
"rule"
)
*
amount
;
point
=
jsonObject
.
getInteger
(
"rule"
)
==
null
?
0
*
amount
:
jsonObject
.
getInteger
(
"rule"
)
*
amount
;
}
}
}
else
{
}
else
{
point
=
ruleObjectRestResponse
.
getData
().
getPoint
();
point
=
ruleObjectRestResponse
.
getData
().
getPoint
();
}
}
log
.
info
(
"查询的其他规则积分数:point = {}"
,
point
);
log
.
info
(
"查询的其他规则积分数:point = {}"
,
point
);
//把规则表中的积分数设置到参数对象中,然后进行后续操作
//把规则表中的积分数设置到参数对象中,然后进行后续操作
integralUserRecord
.
setPoint
(
point
/
100
);
integralUserRecord
.
setPoint
(
point
);
}
}
if
(
integralUserRecord
.
getType
()
==
0
)
{
//获取积分 增加总积分表
if
(
integralUserRecord
.
getType
()
==
0
)
{
//获取积分 增加总积分表
IntegralUserTotalDto
integralUserTotalDto
=
new
IntegralUserTotalDto
();
IntegralUserTotalDto
integralUserTotalDto
=
new
IntegralUserTotalDto
();
integralUserTotalDto
.
setUserId
(
integralUserRecord
.
getUserId
());
integralUserTotalDto
.
setUserId
(
integralUserRecord
.
getUserId
());
integralUserTotalDto
.
setPoint
(
integralUserRecord
.
getPoint
());
integralUserTotalDto
.
setPoint
(
integralUserRecord
.
getPoint
());
integralUserTotalBiz
.
update
(
integralUserTotalDto
);
integralUserTotalBiz
.
update
(
integralUserTotalDto
);
}
else
if
(
integralUserRecord
.
getType
()
==
1
)
{
//扣减积分
}
else
if
(
integralUserRecord
.
getType
()
==
1
)
{
//扣减积分
ObjectRestResponse
<
IntegralUserTotal
>
objectRestResponse
=
integralUserTotalBiz
.
getByUser
();
ObjectRestResponse
<
IntegralUserTotal
>
objectRestResponse
=
integralUserTotalBiz
.
getByUser
();
if
(
objectRestResponse
.
getStatus
()
==
RestCode
.
SUCCESS
.
getStatus
()
&&
objectRestResponse
.
getData
()
!=
null
)
{
if
(
objectRestResponse
.
getStatus
()
==
RestCode
.
SUCCESS
.
getStatus
()
&&
objectRestResponse
.
getData
()
!=
null
)
{
IntegralUserTotal
integralUserTotal
=
objectRestResponse
.
getData
();
IntegralUserTotal
integralUserTotal
=
objectRestResponse
.
getData
();
IntegralUserTotalDto
integralUserTotalDto
=
new
IntegralUserTotalDto
();
IntegralUserTotalDto
integralUserTotalDto
=
new
IntegralUserTotalDto
();
integralUserTotalDto
.
setUserId
(
integralUserTotal
.
getUserId
());
integralUserTotalDto
.
setUserId
(
integralUserTotal
.
getUserId
());
integralUserTotalDto
.
setPoint
(-
integralUserRecord
.
getPoint
());
integralUserTotalDto
.
setPoint
(-
integralUserRecord
.
getPoint
());
integralUserTotalBiz
.
update
(
integralUserTotalDto
);
integralUserTotalBiz
.
update
(
integralUserTotalDto
);
}
else
{
}
else
{
return
ObjectRestResponse
.
createFailedResult
(
1008
,
"用户积分不足"
);
return
ObjectRestResponse
.
createFailedResult
(
1008
,
"用户积分不足"
);
}
}
}
}
insertSelective
(
integralUserRecord
.
getIntegralUserRecord
());
insertSelective
(
integralUserRecord
.
getIntegralUserRecord
());
if
(
oldValue
!=
null
)
{
if
(
oldValue
!=
null
)
{
getUserRecordStatus
(
integralUserRecord
,
oldValue
.
getPeriod
(),
oldValue
.
getNumber
());
getUserRecordStatus
(
integralUserRecord
,
oldValue
.
getPeriod
(),
oldValue
.
getNumber
());
}
}
return
ObjectRestResponse
.
succ
();
return
ObjectRestResponse
.
succ
();
}
}
/**
/**
* 删除一个用户记录
* 删除一个用户记录
*
*
* @param id
* @param id
* @return
* @return
*/
*/
public
ObjectRestResponse
deleteOne
(
Integer
id
)
{
public
ObjectRestResponse
deleteOne
(
Integer
id
)
{
log
.
info
(
"删除用户积分记录的参数:id = {}"
,
id
);
log
.
info
(
"删除用户积分记录的参数:id = {}"
,
id
);
if
(
id
==
null
||
id
<=
0
)
{
if
(
id
==
null
||
id
<=
0
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
return
ObjectRestResponse
.
paramIsEmpty
();
}
}
IntegralUserRecord
integralUserRecord
=
mapper
.
selectByPrimaryKey
(
id
);
IntegralUserRecord
integralUserRecord
=
mapper
.
selectByPrimaryKey
(
id
);
if
(
integralUserRecord
==
null
)
{
if
(
integralUserRecord
==
null
)
{
log
.
info
(
"删除的用户记录不存在,要删除的id ={}"
,
id
);
log
.
info
(
"删除的用户记录不存在,要删除的id ={}"
,
id
);
return
ObjectRestResponse
.
createDefaultFail
();
return
ObjectRestResponse
.
createDefaultFail
();
}
}
integralUserRecord
.
setIsdel
(
true
);
integralUserRecord
.
setIsdel
(
true
);
updateByIdRe
(
integralUserRecord
);
updateByIdRe
(
integralUserRecord
);
return
ObjectRestResponse
.
succ
();
return
ObjectRestResponse
.
succ
();
}
}
/**
/**
* 根据获取某个用户的列表
* 根据获取某个用户的列表
*
*
* @return
* @return
*/
*/
public
ObjectRestResponse
<
PageDataVO
>
getUserList
(
IntegralUserRecordDto
integralUserRecordDto
)
{
public
ObjectRestResponse
<
PageDataVO
>
getUserList
(
IntegralUserRecordDto
integralUserRecordDto
)
{
log
.
info
(
"获取用户积分记录的参数:integralUserRecordDto = {}"
,
integralUserRecordDto
.
toString
());
log
.
info
(
"获取用户积分记录的参数:integralUserRecordDto = {}"
,
integralUserRecordDto
.
toString
());
AppUserDTO
appUserDTO
=
userInfoBiz
.
getUserInfo
();
AppUserDTO
appUserDTO
=
userInfoBiz
.
getUserInfo
();
if
(
appUserDTO
==
null
)
{
if
(
appUserDTO
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
508
,
"token is null or invalid"
);
return
ObjectRestResponse
.
createFailedResult
(
508
,
"token is null or invalid"
);
}
}
integralUserRecordDto
.
setUserId
(
appUserDTO
.
getUserid
());
integralUserRecordDto
.
setUserId
(
appUserDTO
.
getUserid
());
Query
query
=
new
Query
(
integralUserRecordDto
);
Query
query
=
new
Query
(
integralUserRecordDto
);
PageDataVO
pageDataVO
=
PageDataVO
.
pageInfo
(
query
,
()
->
mapper
.
selectByUserId
(
appUserDTO
.
getUserid
()));
PageDataVO
pageDataVO
=
PageDataVO
.
pageInfo
(
query
,
()
->
mapper
.
selectByUserId
(
appUserDTO
.
getUserid
()));
return
ObjectRestResponse
.
succ
(
pageDataVO
);
return
ObjectRestResponse
.
succ
(
pageDataVO
);
}
}
public
ObjectRestResponse
<
List
<
IntegralUserRecord
>>
getByUserAndTime
(
IntegralUserRecordDto
integralUserRecordDto
)
{
public
ObjectRestResponse
<
List
<
IntegralUserRecord
>>
getByUserAndTime
(
IntegralUserRecordDto
integralUserRecordDto
)
{
log
.
info
(
"获取用户积分记录的参数:integralUserRecordDto = {}"
,
integralUserRecordDto
.
toString
());
log
.
info
(
"获取用户积分记录的参数:integralUserRecordDto = {}"
,
integralUserRecordDto
.
toString
());
if
(
integralUserRecordDto
==
null
)
{
if
(
integralUserRecordDto
==
null
)
{
return
ObjectRestResponse
.
paramIsEmpty
();
return
ObjectRestResponse
.
paramIsEmpty
();
}
}
AppUserDTO
appUserDTO
=
userInfoBiz
.
getUserInfo
();
AppUserDTO
appUserDTO
=
userInfoBiz
.
getUserInfo
();
if
(
appUserDTO
==
null
)
{
if
(
appUserDTO
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
508
,
"token is null or invalid"
);
return
ObjectRestResponse
.
createFailedResult
(
508
,
"token is null or invalid"
);
}
}
integralUserRecordDto
.
setUserId
(
appUserDTO
.
getUserid
());
integralUserRecordDto
.
setUserId
(
appUserDTO
.
getUserid
());
List
<
IntegralUserRecord
>
integralUserRecordList
=
mapper
.
selectByUserAndTime
(
integralUserRecordDto
);
List
<
IntegralUserRecord
>
integralUserRecordList
=
mapper
.
selectByUserAndTime
(
integralUserRecordDto
);
return
ObjectRestResponse
.
succ
(
integralUserRecordList
);
return
ObjectRestResponse
.
succ
(
integralUserRecordList
);
}
}
/**
/**
* //判断用户获取积分是否达标
* //判断用户获取积分是否达标
*
*
* @param integralUserRecordDto 积分记录实体
* @param integralUserRecordDto 积分记录实体
* @param period 周期
* @param period 周期
* number 周期内可获得积分的次数
* number 周期内可获得积分的次数
*/
*/
public
void
getUserRecordStatus
(
IntegralUserRecordDto
integralUserRecordDto
,
Integer
period
,
Integer
number
)
{
public
void
getUserRecordStatus
(
IntegralUserRecordDto
integralUserRecordDto
,
Integer
period
,
Integer
number
)
{
IntegralUserStatus
integralUserStatus
=
new
IntegralUserStatus
();
IntegralUserStatus
integralUserStatus
=
new
IntegralUserStatus
();
integralUserStatus
.
setUserId
(
integralUserRecordDto
.
getUserId
());
integralUserStatus
.
setUserId
(
integralUserRecordDto
.
getUserId
());
integralUserStatus
.
setIntegralRuleCode
(
integralUserRecordDto
.
getIntegralRuleCode
());
integralUserStatus
.
setIntegralRuleCode
(
integralUserRecordDto
.
getIntegralRuleCode
());
if
(
period
==
IntegralRulePeriod
.
DAY
.
getCode
())
{
//按天
if
(
period
==
IntegralRulePeriod
.
DAY
.
getCode
())
{
//按天
integralUserRecordDto
.
setStartTime
(
IntegralToolsUtils
.
getDayStart
());
integralUserRecordDto
.
setStartTime
(
IntegralToolsUtils
.
getDayStart
());
integralUserRecordDto
.
setEndTime
(
IntegralToolsUtils
.
getDayStart
()
+
24
*
60
*
60
*
1000
);
integralUserRecordDto
.
setEndTime
(
IntegralToolsUtils
.
getDayStart
()
+
24
*
60
*
60
*
1000
);
Integer
count
=
mapper
.
countByUserAndCode
(
integralUserRecordDto
);
Integer
count
=
mapper
.
countByUserAndCode
(
integralUserRecordDto
);
integralUserStatus
.
setIntegralStatus
(
count
==
number
);
integralUserStatus
.
setIntegralStatus
(
count
==
number
);
}
else
{
}
else
{
integralUserRecordDto
.
setStartTime
(
null
);
integralUserRecordDto
.
setStartTime
(
null
);
Integer
count
=
mapper
.
countByUserAndCode
(
integralUserRecordDto
);
Integer
count
=
mapper
.
countByUserAndCode
(
integralUserRecordDto
);
integralUserStatus
.
setIntegralStatus
(
true
);
integralUserStatus
.
setIntegralStatus
(
true
);
}
}
integralUserStatusBiz
.
save
(
integralUserStatus
);
integralUserStatusBiz
.
save
(
integralUserStatus
);
}
}
}
}
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