Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
zhangshaowu
/
pipi-helper
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4775603b
authored
Oct 16, 2022
by
weiss
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
f24b5258
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
24 deletions
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
src/main/java/com/pipihelper/project/feishu/entity/Pain.java
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
src/main/resources/mybatis/PainMapper.xml
src/main/java/com/pipihelper/project/feishu/controller/FeiShuEventController.java
View file @
4775603
package
com
.
pipihelper
.
project
.
feishu
.
controller
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -23,7 +22,6 @@ import com.pipihelper.project.feishu.service.massage.MassageMsgCardSerivce;
import
com.pipihelper.project.feishu.service.massage.MassageService
;
import
com.pipihelper.project.feishu.utils.FeiShuEventDataDecrypter
;
import
com.pipihelper.project.utils.CacheUtil
;
import
jdk.nashorn.internal.ir.CatchNode
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -108,7 +106,7 @@ public class FeiShuEventController {
// 都需要返回 不能点击的卡片json
if
(
"revice"
.
equals
(
actionTypeSecond
))
{
// 接受按摩
String
fileName
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json
.json
"
);
String
fileName
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName
,
"感谢支持"
);
}
else
if
(
"giveUp"
.
equals
(
actionTypeSecond
))
{
...
...
@@ -116,11 +114,11 @@ public class FeiShuEventController {
FeiShuMsgDTO
feiShuMsgDTO
=
new
FeiShuMsgDTO
();
feiShuMsgDTO
.
setMsgType
(
"interactive"
);
feiShuMsgDTO
.
setReceiveId
(
feiShuConfig
.
getChatId
());
String
fileName
=
String
.
format
(
"/templates/massage-msg-card-rob.json
.json
"
);
String
fileName
=
String
.
format
(
"/templates/massage-msg-card-rob.json"
);
String
msgCardContent
=
String
.
format
(
massageMsgCardSerivce
.
getInteractiveCardStr
(
fileName
),
feiShuMsgCardEventDTO
.
getOpen_id
());
feiShuMsgDTO
.
setContent
(
msgCardContent
);
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json
.json
"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"遗憾放弃"
);
}
else
if
(
"wait"
.
equals
(
actionTypeSecond
))
{
...
...
@@ -131,7 +129,7 @@ public class FeiShuEventController {
massageService
.
updateMassageMsgCardToPiPiChat
(
feiShuConfig
.
getChatId
());
//没有按摩群的id
// massageService.updateMassageMsgCardToPiPiChat();
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json
.json
"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已为你推迟到最后"
);
}
else
if
(
"rob"
.
equals
(
actionTypeSecond
))
{
// 抢名额 - 掉延迟更新卡片接口 更新大群、按摩群的按摩时间安排卡片
...
...
@@ -144,14 +142,14 @@ public class FeiShuEventController {
Pain
oldPain
=
painService
.
findByOpenId
(
endUserId
);
oldPain
.
setStatus
(
2
);
painService
.
update
(
oldPain
);
List
<
Pain
>
painList
=
painService
.
findBackIndex
(
oldPain
.
get
I
ndex
(),
1
);
List
<
Pain
>
painList
=
painService
.
findBackIndex
(
oldPain
.
get
Pi
ndex
(),
1
);
if
(
CollectionUtil
.
isNotEmpty
(
painList
))
{
Pain
noticePain
=
CollectionUtil
.
getFirst
(
painList
);
noticePain
.
setStatus
(
1
);
painService
.
update
(
noticePain
);
massageService
.
updateSingleMassageMsgCardWhenBegin
(
noticePain
.
getMessageId
());
}
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json
.json
"
);
String
fileName1
=
String
.
format
(
"/templates/massage-singel-msg-card-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"欢迎下次光临~"
);
}
default
:
...
...
@@ -170,7 +168,7 @@ public class FeiShuEventController {
feiShuChatDTO
.
setIdList
(
new
String
[]{
feiShuMsgCardEventDTO
.
getOpen_id
()});
feiShuApiService
.
joinChatList
(
feiShuChatDTO
);
//ToDo 更新大群和按摩群的大卡片,异步
String
fileName1
=
String
.
format
(
"/templates/massage-msg-card-rob-end.json
.json.json
"
);
String
fileName1
=
String
.
format
(
"/templates/massage-msg-card-rob-end.json"
);
return
getInteractiveCardStr
(
fileName1
,
"已经被抢啦啦啦~"
);
}
...
...
@@ -237,7 +235,7 @@ public class FeiShuEventController {
pain
.
setStatus
(
0
);
pain
.
setFloor
(
Optional
.
ofNullable
(
it
.
getFloor
()).
orElse
(
14
));
int
increment
=
i
.
getAndIncrement
();
pain
.
set
I
ndex
(
increment
);
pain
.
set
Pi
ndex
(
increment
);
pain
.
setName
(
it
.
getName
());
String
departMentName
=
departmentMap
.
getOrDefault
(
it
.
getDepartmentId
(),
new
FeiShuDepartmentDTO
()).
getName
();
pain
.
setDepartMentName
(
departMentName
);
...
...
src/main/java/com/pipihelper/project/feishu/entity/Pain.java
View file @
4775603
...
...
@@ -8,7 +8,7 @@ import java.util.Date;
public
class
Pain
{
private
Integer
id
;
private
String
openId
;
private
Integer
index
;
private
Integer
p
index
;
private
String
name
;
private
Integer
status
;
private
Date
startTime
;
...
...
src/main/java/com/pipihelper/project/feishu/service/massage/MassageService.java
View file @
4775603
...
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.pipihelper.project.feishu.bo.PushPainBO
;
import
com.pipihelper.project.feishu.dto.FeiShuConfig
;
import
com.pipihelper.project.feishu.dto.msg.FeiShuMsgDTO
;
import
com.pipihelper.project.feishu.entity.ChatMessage
;
import
com.pipihelper.project.feishu.entity.Pain
;
import
com.pipihelper.project.feishu.service.ChatMessageService
;
import
com.pipihelper.project.feishu.service.FeiShuApiService
;
...
...
@@ -76,7 +77,14 @@ public class MassageService {
feiShuMsgDTO
.
setContent
(
content
);
feiShuMsgDTO
.
setReceiveId
(
chatId
);
log
.
info
(
feiShuMsgDTO
.
toString
());
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
JSONObject
rep
=
feiShuApiService
.
sendMsg
(
feiShuMsgDTO
,
"chat_id"
);
String
messageId
=
rep
.
getJSONObject
(
"data"
).
getString
(
"message_id"
);
ChatMessage
chatMessage
=
new
ChatMessage
();
chatMessage
.
setChatId
(
chatId
);
chatMessage
.
setMessageId
(
messageId
);
chatMessage
.
setType
(
1
);
chatMessageService
.
create
(
chatMessage
);
}
...
...
@@ -96,10 +104,10 @@ public class MassageService {
for
(
Pain
pain:
pains
){
List
<
String
>
user
=
new
ArrayList
<>();
//构建给大群发送的名单
user
.
add
(
pain
.
get
I
ndex
().
toString
());
user
.
add
(
pain
.
get
Pi
ndex
().
toString
());
user
.
add
(
pain
.
getName
());
user
.
add
(
pain
.
getDepartMentName
());
user
.
add
(
pain
.
getTimeRange
()
);
user
.
add
(
"15:00-18:00"
);
user
.
add
(
""
);
pushUser
.
add
(
user
);
}
...
...
src/main/resources/mybatis/PainMapper.xml
View file @
4775603
...
...
@@ -12,7 +12,7 @@
<result
column=
"message_id"
property=
"messageId"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"depart_ment_name"
property=
"departMentName"
/>
<result
column=
"
index"
property=
"
index"
/>
<result
column=
"
pindex"
property=
"p
index"
/>
</resultMap>
<!-- <resultMap id="BuffConfigResultBOMap" type="com.pipihelper.project.feishu.entity.Deployee"
...
...
@@ -20,7 +20,8 @@
</resultMap>-->
<sql
id=
"Base_Column_List"
>
id,open_id,start_time,end_time,status,floor,message_id,name,depart_ment_name
id
,open_id,start_time,end_time,status,floor,message_id,name,depart_ment_name,`pindex`
</sql>
<select
id=
"findById"
parameterType=
"java.lang.Integer"
resultMap=
"PainResultMap"
>
...
...
@@ -37,9 +38,9 @@
<include
refid=
"Base_Column_List"
/>
from t_pain
<where>
index >= #{
index}
pindex >= #{p
index}
and status = 0
order by index asc
order by
p
index asc
limit #{limit}
</where>
</select>
...
...
@@ -50,7 +51,7 @@
from t_pain
<where>
status = 0
order by index asc
order by
p
index asc
limit #{limit}
</where>
</select>
...
...
@@ -65,7 +66,9 @@
</select>
<delete
id=
"deleteAllByFloor"
>
delete from t_pain where floor = #{floor}
delete
from t_pain
where floor = #{floor}
</delete>
<select
id=
"findByIndex"
parameterType=
"java.lang.String"
resultMap=
"PainResultMap"
>
...
...
@@ -73,7 +76,7 @@
<include
refid=
"Base_Column_List"
/>
from t_pain
<where>
index = #{
index}
pindex = #{p
index}
</where>
</select>
...
...
@@ -92,12 +95,12 @@
<insert
id=
"create"
useGeneratedKeys=
"true"
keyProperty=
"id"
parameterType=
"com.pipihelper.project.feishu.entity.Pain"
>
insert into t_pain (open_id, start_time, end_time, status, floor,
message_id,name,depart_ment_name
)
values (#{openId}, #{startTime}, #{endTime}, #{status},
#{floor},#{messageId},#{name},#{departMentName
})
insert into t_pain (open_id, start_time, end_time, status, floor,
message_id, name, depart_ment_name, pindex
)
values (#{openId}, #{startTime}, #{endTime}, #{status},
#{floor}, #{messageId}, #{name}, #{departMentName},#{pindex
})
</insert>
<update
id=
"waitPain"
parameterType=
"com.pipihelper.project.feishu.entity.Pain"
>
UPDATE t_pain set
`index` = ((SELECT selected_value FROM (SELECT MAX(`index`
) AS selected_value FROM t_pain) AS
UPDATE t_pain set
pindex = ((SELECT selected_value FROM (SELECT MAX(pindex
) AS selected_value FROM t_pain) AS
sub_selected_value) + 1)
<where>
open_id = #{openId}
...
...
@@ -133,6 +136,9 @@
<if
test=
"departMentName != null"
>
depart_ment_name = #{departMentName},
</if>
<if
test=
"pindex != null"
>
pindex = #{pindex},
</if>
</set>
<where>
id = #{id}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment