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
568848fb
Commit
568848fb
authored
Feb 21, 2025
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了查看用户详情每日数量限制
parent
902a8f0e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
265 additions
and
2 deletions
+265
-2
AppMemInfoController.java
...isoft/app/appMemInfo/controller/AppMemInfoController.java
+30
-0
MemberInfoRedisBean.java
...rg/rcisoft/business/memInfo/bean/MemberInfoRedisBean.java
+7
-1
MemInfoRepository.java
...a/org/rcisoft/business/memInfo/dao/MemInfoRepository.java
+15
-0
MemUserTaskDTO.java
...a/org/rcisoft/business/memInfo/entity/MemUserTaskDTO.java
+49
-0
MemInfoService.java
.../org/rcisoft/business/memInfo/service/MemInfoService.java
+10
-0
MemInfoServiceImpl.java
...oft/business/memInfo/service/impl/MemInfoServiceImpl.java
+133
-1
MemInfoMapper.xml
...esources/mapper/business/memInfo/mapper/MemInfoMapper.xml
+21
-0
No files found.
src/main/java/org/rcisoft/app/appMemInfo/controller/AppMemInfoController.java
View file @
568848fb
...
...
@@ -358,4 +358,34 @@ public class AppMemInfoController extends CyPaginationController<MemInfo> {
}
return
getGridModelResponse
();
}
/**
* 我的-要微信
*/
@PreAuthorize
(
"@cyPerm.hasPerm('app:mem:exchangeWeChat')"
)
@CyOpeLogAnno
(
title
=
"system-互换微信-互换微信"
,
businessType
=
CyLogTypeEnum
.
INSERT
)
@Operation
(
summary
=
"互换微信"
,
description
=
"互换微信"
)
@PostMapping
(
value
=
"/memInfo/weChatTask"
)
public
CyResult
weChatTask
(
@RequestBody
MemUserTaskDTO
memUserTaskDTO
)
{
CyPersistModel
data
=
memInfoServiceImpl
.
weChatTask
(
memUserTaskDTO
);
return
CyResultGenUtil
.
builder
(
data
,
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
memUserTaskDTO
);
}
/**
* 我的-查询要微信记录
*/
@PreAuthorize
(
"@cyPerm.hasPerm('app:mem:exchangeWeChat')"
)
@CyOpeLogAnno
(
title
=
"system-查询互换微信记录-查询互换微信记录"
,
businessType
=
CyLogTypeEnum
.
INSERT
)
@Operation
(
summary
=
"查询互换微信记录"
,
description
=
"查询互换微信记录"
)
@GetMapping
(
value
=
"/memInfo/queryWeChatTaskRecord"
)
public
CyResult
queryWeChatTaskRecord
(
MemUserTaskDTO
memUserTaskDTO
)
{
MemUserTaskDTO
memUserTask
=
memInfoServiceImpl
.
queryWeChatTaskRecord
(
memUserTaskDTO
);
return
CyResultGenUtil
.
builder
(
new
CyPersistModel
(
1
),
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
memUserTask
);
}
}
src/main/java/org/rcisoft/business/memInfo/bean/MemberInfoRedisBean.java
View file @
568848fb
...
...
@@ -12,10 +12,16 @@ public class MemberInfoRedisBean {
public
static
final
String
USER_LIKE_ALL
=
"user:likeAll:"
;
//对每个人点赞的key
public
static
final
String
USER_LIKE
=
"user:like:"
;
//查看用户详情key
public
static
final
String
USER_LOOK_DETAIL_COUNT
=
"user:lookDetail:"
;
//点赞锁
public
static
final
String
USER_LIKE_LOCK
=
"user:leaveMessage:lock:"
;
//微信任务锁
public
static
final
String
USER_WECHAT_TASK_LOCK
=
"user:task:lock:"
;
//点赞锁时间限制
public
static
final
String
USER_LIKE_LOCK_WAIT_TIME
=
"20"
;
public
static
final
String
USER_LIKE_LOCK_LEASE_TIME
=
"10"
;
//微信任务锁时间限制
public
static
final
String
USER_WECHAT_TASK_LOCK_WAIT_TIME
=
"20"
;
public
static
final
String
USER_WECHAT_LOCK_LEASE_TIME
=
"10"
;
}
src/main/java/org/rcisoft/business/memInfo/dao/MemInfoRepository.java
View file @
568848fb
...
...
@@ -176,5 +176,20 @@ public interface MemInfoRepository extends CyBaseMapper<MemInfo> {
* 分页查询会员热度表
*/
IPage
<
MemInfo
>
queryMemHostPaged
(
CyPageInfo
cyPageInfo
,
@Param
(
"entity"
)
MemInfo
memInfo
);
/**
* 添加索要微信任务
*/
int
addWeChatTask
(
@Param
(
"entity"
)
MemUserTaskDTO
memUserTaskDTO
);
/**
* 修改索要微信任务
*/
int
updateWeChatTask
(
MemUserTaskDTO
memUserTaskDTO
);
/**
* 查询互换微信任务记录
*/
MemUserTaskDTO
selectWeChatTask
(
@Param
(
"entity"
)
MemUserTaskDTO
memUserTaskDTO
);
}
src/main/java/org/rcisoft/business/memInfo/entity/MemUserTaskDTO.java
0 → 100644
View file @
568848fb
package
org
.
rcisoft
.
business
.
memInfo
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.util.Date
;
@Data
public
class
MemUserTaskDTO
{
/**
* 用户id
*/
private
Integer
businessId
;
/**
* 创建人
*/
private
Integer
createBy
;
/**
* 创建时间
*/
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
createDate
;
/**
* 消息类型 1:发送请求 2:接受请求
*/
private
String
type
;
/**
* 对方的消息状态 1:同意 2:拒绝
*/
private
String
status
;
/**
* 目标人id
*/
private
Integer
targetId
;
/**
* 登录人的wxOpenid
*/
private
String
wxOpenid
;
}
src/main/java/org/rcisoft/business/memInfo/service/MemInfoService.java
View file @
568848fb
...
...
@@ -116,4 +116,14 @@ public interface MemInfoService {
*/
IPage
<
MemInfo
>
findMemHostByPagination
(
CyPageInfo
<
MemInfo
>
paginationUtility
,
MemInfo
memInfo
);
/**
* 互换微信任务
*/
CyPersistModel
weChatTask
(
MemUserTaskDTO
memUserTaskDTO
);
/***
* 查询互换微信任务
*/
MemUserTaskDTO
queryWeChatTaskRecord
(
MemUserTaskDTO
memUserTaskDTO
);
}
src/main/java/org/rcisoft/business/memInfo/service/impl/MemInfoServiceImpl.java
View file @
568848fb
...
...
@@ -237,8 +237,43 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
*/
@Override
public
MemInfo
findById
(
int
id
){
//查询基本信息
//获取当前登录人id
Integer
userId
=
Integer
.
valueOf
(
CyUserUtil
.
getAuthenBusinessId
());
//获取当天时间 例2025/2/20 后获取0220
LocalDate
today
=
LocalDate
.
now
();
DateTimeFormatter
monthFormatter
=
DateTimeFormatter
.
ofPattern
(
"MM"
);
DateTimeFormatter
dayFormatter
=
DateTimeFormatter
.
ofPattern
(
"dd"
);
// 格式化并获取月份和日期
String
month
=
today
.
format
(
monthFormatter
);
String
day
=
today
.
format
(
dayFormatter
);
String
date
=
month
+
day
;
//查询redis限制次数
//获取查看用户详情限制数量
List
<
DictData
>
userLikeConfig
=
dictionaryService
.
selectByTypes
(
"user_config"
);
DictData
dictData
=
userLikeConfig
.
stream
().
filter
(
item
->
item
.
getDictLabel
().
equals
(
"look_user_detail_count"
)).
findFirst
().
orElse
(
null
);
Integer
lookDetailCount
=
Integer
.
valueOf
(
dictData
.
getDictValue
());
//每天最大查看用户详情数量
Map
<
Object
,
Object
>
hmget
=
cyRedisServiceImpl
.
hmget
(
MemberInfoRedisBean
.
USER_LOOK_DETAIL_COUNT
+
date
+
":"
+
userId
);
if
(
hmget
.
size
()
>=
lookDetailCount
)
{
//超出今日查看数量
//判断是否已查看了目标用户或者查看的是自己,直接放过
MemInfo
memInfo
=
baseMapper
.
selectDetailById
(
id
);
if
(
hmget
.
containsKey
(
String
.
valueOf
(
memInfo
.
getUserId
()))
||
userId
.
equals
(
memInfo
.
getUserId
()))
{
//查询我喜欢的 喜欢我的 互相喜欢的数量
MemInfo
memInfo1
=
baseMapper
.
selectUserFollowCount
(
memInfo
.
getUserId
());
memInfo
.
setFollowMeCount
(
memInfo1
.
getFollowMeCount
());
memInfo
.
setMeFollowCount
(
memInfo1
.
getMeFollowCount
());
memInfo
.
setEachFollowCount
(
memInfo1
.
getEachFollowCount
());
return
memInfo
;
}
else
{
throw
new
CyServiceException
(
1001
,
"今天查看用户详情数量已达上限"
);
}
}
//没超出今日查看数量
MemInfo
memInfo
=
baseMapper
.
selectDetailById
(
id
);
//排除当前登录人
if
(!
userId
.
equals
(
memInfo
.
getUserId
())){
cyRedisServiceImpl
.
hset
(
MemberInfoRedisBean
.
USER_LOOK_DETAIL_COUNT
+
date
+
":"
+
userId
,
String
.
valueOf
(
memInfo
.
getUserId
()),
1
);
}
//查询我喜欢的 喜欢我的 互相喜欢的数量
MemInfo
memInfo1
=
baseMapper
.
selectUserFollowCount
(
memInfo
.
getUserId
());
memInfo
.
setFollowMeCount
(
memInfo1
.
getFollowMeCount
());
...
...
@@ -829,4 +864,101 @@ public class MemInfoServiceImpl extends ServiceImpl<MemInfoRepository,MemInfo>
return
baseMapper
.
queryMemHostPaged
(
paginationUtility
,
memInfo
);
}
/**
* 索要微信任务
*
* @param memUserTaskDTO
*/
@Override
public
CyPersistModel
weChatTask
(
MemUserTaskDTO
memUserTaskDTO
)
{
Integer
createBy
=
Integer
.
valueOf
(
CyUserUtil
.
getAuthenBusinessId
());
memUserTaskDTO
.
setCreateBy
(
createBy
);
memUserTaskDTO
.
setCreateDate
(
new
Date
());
//获取数据字典中的消耗金币数
List
<
DictData
>
userLikeConfig
=
dictionaryService
.
selectByTypes
(
"user_config"
);
DictData
dictData1
=
userLikeConfig
.
stream
().
filter
(
item
->
item
.
getDictLabel
().
equals
(
"request_exchange_wechat"
)).
findFirst
().
orElse
(
null
);
DictData
dictData2
=
userLikeConfig
.
stream
().
filter
(
item
->
item
.
getDictLabel
().
equals
(
"accept_exchange_wechat"
)).
findFirst
().
orElse
(
null
);
Integer
requestGoldCoinCount
=
Integer
.
valueOf
(
dictData1
.
getDictValue
());
//发起请求需消耗的金币数
Integer
acceptGoldCoinCount
=
Integer
.
valueOf
(
dictData2
.
getDictValue
());
//接收需消耗的金币数
if
(
memUserTaskDTO
.
getType
().
equals
(
"1"
)){
//发起请求
//扣除该用户的金币数量
int
line
=
0
;
boolean
isGetLock
=
false
;
RLock
lock
=
redissonClient
.
getLock
(
MemberInfoRedisBean
.
USER_WECHAT_TASK_LOCK
+
memUserTaskDTO
.
getCreateBy
());
try
{
isGetLock
=
lock
.
tryLock
(
Long
.
parseLong
(
MemberInfoRedisBean
.
USER_WECHAT_TASK_LOCK_WAIT_TIME
),
Long
.
parseLong
(
MemberInfoRedisBean
.
USER_WECHAT_LOCK_LEASE_TIME
),
TimeUnit
.
SECONDS
);
if
(
isGetLock
)
{
MemInfo
memInfo
=
memInfoRepository
.
selectByOpenId
(
memUserTaskDTO
.
getWxOpenid
());
if
(
memInfo
.
getGoldCoinsCount
()
-
acceptGoldCoinCount
<
0
){
throw
new
CyServiceException
(
1003
,
"金币余额不足,请先充值"
);
}
memInfo
.
setGoldCoinsCount
(
memInfo
.
getGoldCoinsCount
()
-
acceptGoldCoinCount
);
memInfoRepository
.
updateById
(
memInfo
);
//添加索要微信任务
memUserTaskDTO
.
setStatus
(
"0"
);
line
=
baseMapper
.
addWeChatTask
(
memUserTaskDTO
);
}
lock
.
unlock
();
}
catch
(
InterruptedException
e
)
{
Thread
.
currentThread
().
interrupt
();
lock
.
unlock
();
isGetLock
=
false
;
throw
new
CyServiceException
(
1004
,
"服务器繁忙,请稍后再试"
);
}
return
new
CyPersistModel
(
line
);
}
else
{
MemUserTaskDTO
memUserTaskDTO1
=
baseMapper
.
selectWeChatTask
(
memUserTaskDTO
);
memUserTaskDTO
.
setBusinessId
(
memUserTaskDTO1
.
getBusinessId
());
//接收请求
//判断是同意还是拒绝
int
line
=
0
;
if
(
memUserTaskDTO
.
getStatus
().
equals
(
"1"
)){
//同意
//扣除该用户的金币数量
boolean
isGetLock
=
false
;
RLock
lock
=
redissonClient
.
getLock
(
MemberInfoRedisBean
.
USER_WECHAT_TASK_LOCK
+
memUserTaskDTO
.
getCreateBy
());
try
{
isGetLock
=
lock
.
tryLock
(
Long
.
parseLong
(
MemberInfoRedisBean
.
USER_WECHAT_TASK_LOCK_WAIT_TIME
),
Long
.
parseLong
(
MemberInfoRedisBean
.
USER_WECHAT_LOCK_LEASE_TIME
),
TimeUnit
.
SECONDS
);
if
(
isGetLock
)
{
MemInfo
memInfo
=
memInfoRepository
.
selectByOpenId
(
memUserTaskDTO
.
getWxOpenid
());
if
(
memInfo
.
getGoldCoinsCount
()
-
requestGoldCoinCount
<
0
){
throw
new
CyServiceException
(
1003
,
"金币余额不足,请先充值"
);
}
memInfo
.
setGoldCoinsCount
(
memInfo
.
getGoldCoinsCount
()
-
requestGoldCoinCount
);
memInfoRepository
.
updateById
(
memInfo
);
//修改微信任务
line
=
baseMapper
.
updateWeChatTask
(
memUserTaskDTO
);
}
}
catch
(
InterruptedException
e
)
{
Thread
.
currentThread
().
interrupt
();
isGetLock
=
false
;
throw
new
CyServiceException
(
1004
,
"服务器繁忙,请稍后再试"
);
}
finally
{
lock
.
unlock
();
log
.
error
(
"释放成功"
);
return
new
CyPersistModel
(
line
);
}
}
else
{
//拒绝
//修改微信任务
line
=
baseMapper
.
updateWeChatTask
(
memUserTaskDTO
);
}
return
new
CyPersistModel
(
line
);
}
}
/***
* 查询互换微信任务
* @param memUserTaskDTO
*/
@Override
public
MemUserTaskDTO
queryWeChatTaskRecord
(
MemUserTaskDTO
memUserTaskDTO
)
{
memUserTaskDTO
.
setCreateBy
(
Integer
.
valueOf
(
CyUserUtil
.
getAuthenBusinessId
()));
MemUserTaskDTO
memUserTaskDTO1
=
baseMapper
.
selectWeChatTask
(
memUserTaskDTO
);
return
memUserTaskDTO1
;
}
}
src/main/resources/mapper/business/memInfo/mapper/MemInfoMapper.xml
View file @
568848fb
...
...
@@ -763,4 +763,25 @@
</when>
</choose>
</select>
<insert
id=
"addWeChatTask"
>
insert into mem_user_task (create_by,create_date,type,status,target_id)
values(#{entity.createBy},#{entity.createDate},#{entity.type},#{entity.status},#{entity.targetId})
</insert>
<insert
id=
"updateWeChatTask"
>
update mem_user_task
set create_by = #{entity.createBy},
create_date = #{entity.createDate},
type = #{entity.type},
status = #{entity.status},
target_id = #{entity.targetId}
where 1=1
and business_id = #{entity.businessId}
</insert>
<select
id=
"selectWeChatTask"
resultType=
"org.rcisoft.business.memInfo.entity.MemUserTaskDTO"
>
select *
from mem_user_task
where 1=1
and target_id = #{entity.targetId}
and create_by = #{entity.createBy}
</select>
</mapper>
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