Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cust-api
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
李伟
cust-api
Commits
c422763f
Commit
c422763f
authored
Feb 12, 2025
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改了留言
parent
847fa5f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
7 deletions
+41
-7
MemLeaveMessage.java
...soft/business/memLeaveMessage/entity/MemLeaveMessage.java
+7
-0
MemLeaveMessageServiceImpl.java
...LeaveMessage/service/impl/MemLeaveMessageServiceImpl.java
+34
-7
No files found.
src/main/java/org/rcisoft/business/memLeaveMessage/entity/MemLeaveMessage.java
View file @
c422763f
...
...
@@ -88,5 +88,12 @@ public class MemLeaveMessage extends CyIdIncreNotDataEntity<MemLeaveMessage> {
*/
@TableField
(
exist
=
false
)
private
String
isPay
;
/**
* 会员wxOpenid
*/
@TableField
(
exist
=
false
)
private
String
wxOpenid
;
}
src/main/java/org/rcisoft/business/memLeaveMessage/service/impl/MemLeaveMessageServiceImpl.java
View file @
c422763f
...
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.rcisoft.business.memInfo.bean.MemberInfoRedisBean
;
import
org.rcisoft.business.memInfo.dao.MemInfoRepository
;
import
org.rcisoft.business.memInfo.entity.MemInfo
;
import
org.rcisoft.business.memLeaveMessage.bean.MemLeaveMessageRedisBean
;
import
org.rcisoft.business.memLeaveMessage.dao.MemLeaveMessageRepository
;
import
org.rcisoft.business.memLeaveMessage.entity.*
;
...
...
@@ -51,6 +53,8 @@ public class MemLeaveMessageServiceImpl extends ServiceImpl<MemLeaveMessageRepos
@Autowired
private
CyRedisServiceImpl
cyRedisServiceImpl
;
@Autowired
private
MemInfoRepository
memInfoRepository
;
/**
* 留言
* @param memLeaveMessage
...
...
@@ -61,16 +65,30 @@ public class MemLeaveMessageServiceImpl extends ServiceImpl<MemLeaveMessageRepos
public
CyPersistModel
leaveMessage
(
MemLeaveMessage
memLeaveMessage
)
{
String
userId
=
CyUserUtil
.
getAuthenBusinessId
();
//获取留言每天限制条数
List
<
DictData
>
articleConfig
=
dictionaryService
.
selectByTypes
(
"leave_message_config"
);
DictData
dictData
=
articleConfig
.
stream
().
filter
(
item
->
item
.
getDictLabel
().
equals
(
"leave_message_limit_count"
)).
findFirst
().
orElse
(
null
);
Integer
leaveMessageLimitCount
=
Integer
.
valueOf
(
dictData
.
getDictValue
());
//判断留言次数是否大于等于leaveMessageLimitCount
List
<
DictData
>
leaveMessageConfig
=
dictionaryService
.
selectByTypes
(
"leave_message_config"
);
DictData
dictData1
=
leaveMessageConfig
.
stream
().
filter
(
item
->
item
.
getDictLabel
().
equals
(
"leave_message_limit_count"
)).
findFirst
().
orElse
(
null
);
DictData
dictData2
=
leaveMessageConfig
.
stream
().
filter
(
item
->
item
.
getDictLabel
().
equals
(
"pay_leave_message_limit_count"
)).
findFirst
().
orElse
(
null
);
Integer
leaveMessageLimitCount
=
Integer
.
valueOf
(
dictData1
.
getDictValue
());
Integer
payLeaveMessageLimitCount
=
Integer
.
valueOf
(
dictData2
.
getDictValue
());
//判断redis中的留言次数是否大于等于leaveMessageLimitCount
Object
redisLeaveMessageCount
=
cyRedisServiceImpl
.
hget
(
MemLeaveMessageRedisBean
.
USER_LEAVE_MESSAGE
+
userId
,
String
.
valueOf
(
memLeaveMessage
.
getTargetId
()));
if
(
redisLeaveMessageCount
!=
null
&&
Integer
.
parseInt
(
redisLeaveMessageCount
.
toString
())
>=
leaveMessageLimitCount
){
//超出留言次数的条件:
//1:redis中的存储数量>=字典限制数量
//2:用户不用金币进行留言
//3:超出金币进行留言的限制数量
if
(
redisLeaveMessageCount
!=
null
&&
Integer
.
parseInt
(
redisLeaveMessageCount
.
toString
())
>=
leaveMessageLimitCount
&&
memLeaveMessage
.
getIsPay
().
equals
(
"0"
)){
//超出留言次数
throw
new
CyServiceException
(
"留言次数超出限制"
);
if
(
Integer
.
parseInt
(
redisLeaveMessageCount
.
toString
())
>=
payLeaveMessageLimitCount
){
//超出金币进行留言的数量限制
throw
new
CyServiceException
(
1002
,
"今日留言次数超出限制"
);
}
else
{
throw
new
CyServiceException
(
1001
,
"留言次数超出限制"
);
}
}
else
{
//未超出留言次数
if
(
Integer
.
parseInt
(
redisLeaveMessageCount
.
toString
())
>=
payLeaveMessageLimitCount
){
//超出金币进行留言的数量限制
throw
new
CyServiceException
(
1002
,
"今日留言次数超出限制"
);
}
//先插入到留言表
memLeaveMessage
.
setCreateBy
(
Integer
.
valueOf
(
userId
));
memLeaveMessage
.
setUpdateBy
(
Integer
.
valueOf
(
userId
));
...
...
@@ -113,6 +131,15 @@ public class MemLeaveMessageServiceImpl extends ServiceImpl<MemLeaveMessageRepos
cyRedisServiceImpl
.
hset
(
MemLeaveMessageRedisBean
.
USER_LEAVE_MESSAGE
+
userId
,
String
.
valueOf
(
memLeaveMessage
.
getTargetId
()),
1L
);
}
}
//金币支付进行留言
if
(
memLeaveMessage
.
getIsPay
().
equals
(
"1"
)){
//扣除该用户的金币数量
DictData
dictData3
=
leaveMessageConfig
.
stream
().
filter
(
item
->
item
.
getDictLabel
().
equals
(
"pay_count"
)).
findFirst
().
orElse
(
null
);
Integer
payCount
=
Integer
.
valueOf
(
dictData3
.
getDictValue
());
MemInfo
memInfo
=
memInfoRepository
.
selectByOpenId
(
memLeaveMessage
.
getWxOpenid
());
memInfo
.
setGoldCoinsCount
(
memInfo
.
getGoldCoinsCount
()
-
payCount
);
memInfoRepository
.
updateById
(
memInfo
);
}
return
new
CyPersistModel
(
line
);
}
}
...
...
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