Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fit-finance
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fitness-server
fit-finance
Commits
8fdc6548
Commit
8fdc6548
authored
Jun 07, 2024
by
程裕兵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:refund
parent
c5991810
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
1 deletions
+46
-1
service/src/main/java/com/jiejing/fitness/finance/service/pay/impl/RefundServiceImpl.java
+46
-1
No files found.
service/src/main/java/com/jiejing/fitness/finance/service/pay/impl/RefundServiceImpl.java
View file @
8fdc6548
package
com
.
jiejing
.
fitness
.
finance
.
service
.
pay
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.google.common.collect.Lists
;
import
com.jiejing.common.exception.BizException
;
import
com.jiejing.common.utils.collection.CollectionUtil
;
import
com.jiejing.common.utils.text.StringUtil
;
import
com.jiejing.common.utils.time.TimeUtil
;
import
com.jiejing.fitness.enums.auth.AuthDomainEnum
;
import
com.jiejing.fitness.enums.finance.BrandCashierTransStateEnum
;
...
...
@@ -43,6 +46,7 @@ import java.util.concurrent.Executor;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.support.TransactionTemplate
;
...
...
@@ -154,7 +158,10 @@ public class RefundServiceImpl implements RefundService {
TransStateEnums
state
=
TransStateEnums
.
getByCode
(
event
.
getRefundState
());
switch
(
state
)
{
case
SUCCESS:
executor
.
execute
(()
->
this
.
sendRefundMessage
(
event
,
record
,
"CASHIER_REFUND_SUCCESS"
));
executor
.
execute
(()
->
{
this
.
sendRefundMessage
(
event
,
record
,
"CASHIER_REFUND_SUCCESS"
);
this
.
sendRefundMessageToMember
(
event
,
record
,
"MEMBER_REFUND_SUCCESS"
);
});
break
;
case
FAIL:
executor
.
execute
(()
->
this
.
sendRefundMessage
(
event
,
record
,
"CASHIER_REFUND_FAIL"
));
...
...
@@ -165,6 +172,44 @@ public class RefundServiceImpl implements RefundService {
}
private
void
sendRefundMessageToMember
(
RefundEvent
e
,
StudioCashierRecord
record
,
String
bizType
)
{
if
(
StringUtil
.
isBlank
(
e
.
getExtra
()))
{
return
;
}
JSONObject
extra
=
JSON
.
parseObject
(
e
.
getExtra
());
Boolean
notice
=
extra
.
getBoolean
(
"notice_member"
);
if
(
null
==
notice
||
!
notice
)
{
return
;
}
String
targetId
;
Long
memberId
=
extra
.
getLong
(
"notice_member_id"
);
List
<
MsgChannelEnum
>
channels
=
Lists
.
newArrayList
(
MsgChannelEnum
.
SMS
);
if
(
null
!=
memberId
)
{
targetId
=
memberId
.
toString
();
channels
.
add
(
MsgChannelEnum
.
WE_CHAT
);
}
else
{
targetId
=
record
.
getBuyerPhone
();
}
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>(
1
);
paramMap
.
put
(
"targetId"
,
targetId
);
paramMap
.
put
(
"studioId"
,
record
.
getStudioId
());
paramMap
.
put
(
"name"
,
record
.
getBuyerName
());
paramMap
.
put
(
"amount"
,
record
.
getTransAmount
());
paramMap
.
put
(
"reason"
,
record
.
getRemark
());
paramMap
.
put
(
"time"
,
DateFormatUtils
.
format
(
record
.
getSuccessTime
(),
"yyyy-MM-dd HH:mm:ss"
));
List
<
Map
<
String
,
Object
>>
paramList
=
Lists
.
newArrayList
(
paramMap
);
SendCommonMsgEvent
event
=
new
SendCommonMsgEvent
();
event
.
setChannelEnums
(
channels
);
event
.
setCovertTarget
(
true
);
event
.
setEventId
(
IdWorker
.
getId
());
event
.
setSourceId
(
record
.
getStudioId
());
event
.
setBizType
(
bizType
);
event
.
setParams
(
paramList
);
EventAgent
.
of
(
SendCommonMsgEvent
.
class
).
triggerEvent
(
event
);
}
private
void
sendRefundMessage
(
RefundEvent
e
,
StudioCashierRecord
record
,
String
bizType
)
{
List
<
Long
>
targetIds
=
this
.
getAdminIds
(
record
.
getStudioId
());
if
(
CollectionUtil
.
isEmpty
(
targetIds
))
{
...
...
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