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
18033f54
Commit
18033f54
authored
Apr 27, 2024
by
程裕兵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:bind when open merchant success
parent
9b9683d9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
24 deletions
+67
-24
repository/src/main/java/com/jiejing/fitness/finance/repository/service/PartyToMerchantRpService.java
+15
-0
repository/src/main/java/com/jiejing/fitness/finance/repository/service/StudioMerchantApplyRpService.java
+6
-2
service/src/main/java/com/jiejing/fitness/finance/service/merchant/BrandMerchantService.java
+9
-0
service/src/main/java/com/jiejing/fitness/finance/service/merchant/StudioMerchantService.java
+8
-0
service/src/main/java/com/jiejing/fitness/finance/service/merchant/impl/BrandMerchantServiceImpl.java
+8
-0
service/src/main/java/com/jiejing/fitness/finance/service/merchant/impl/StudioMerchantServiceImpl.java
+21
-22
No files found.
repository/src/main/java/com/jiejing/fitness/finance/repository/service/PartyToMerchantRpService.java
View file @
18033f54
...
@@ -21,6 +21,7 @@ import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
...
@@ -21,6 +21,7 @@ import com.jiejing.fitness.finance.repository.entity.PartyToMerchant;
import
com.jiejing.fitness.finance.repository.mapper.PartyToMerchantMapper
;
import
com.jiejing.fitness.finance.repository.mapper.PartyToMerchantMapper
;
import
com.jiejing.mbp.MapperRepoService
;
import
com.jiejing.mbp.MapperRepoService
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
/**
/**
...
@@ -97,4 +98,18 @@ public class PartyToMerchantRpService extends
...
@@ -97,4 +98,18 @@ public class PartyToMerchantRpService extends
wrapper
.
eq
(
PartyToMerchant
.
PARTY_TYPE
,
partyType
.
getCode
());
wrapper
.
eq
(
PartyToMerchant
.
PARTY_TYPE
,
partyType
.
getCode
());
this
.
baseMapper
.
delete
(
wrapper
);
this
.
baseMapper
.
delete
(
wrapper
);
}
}
public
void
deleteByMerchantIds
(
Set
<
Long
>
merchantIds
,
PartyTypeEnum
partyType
)
{
QueryWrapper
<
PartyToMerchant
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
in
(
PartyToMerchant
.
MERCHANT_ID
,
merchantIds
);
wrapper
.
eq
(
PartyToMerchant
.
PARTY_TYPE
,
partyType
.
getCode
());
this
.
baseMapper
.
delete
(
wrapper
);
}
public
void
deleteByMerchantIds
(
Set
<
Long
>
merchantIds
)
{
QueryWrapper
<
PartyToMerchant
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
in
(
PartyToMerchant
.
MERCHANT_ID
,
merchantIds
);
this
.
baseMapper
.
delete
(
wrapper
);
}
}
}
repository/src/main/java/com/jiejing/fitness/finance/repository/service/StudioMerchantApplyRpService.java
View file @
18033f54
...
@@ -148,13 +148,17 @@ public class StudioMerchantApplyRpService extends
...
@@ -148,13 +148,17 @@ public class StudioMerchantApplyRpService extends
}
}
public
StudioMerchantApply
getLatestSuccessApply
(
Long
studioId
)
{
public
StudioMerchantApply
getLatestSuccessApply
(
Long
studioId
)
{
return
this
.
listSuccessApplyByStudioId
(
studioId
).
stream
().
findFirst
().
orElse
(
null
);
}
public
List
<
StudioMerchantApply
>
listSuccessApplyByStudioId
(
Long
studioId
)
{
QueryWrapper
<
StudioMerchantApply
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
StudioMerchantApply
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
StudioMerchantApply
.
STUDIO_ID
,
studioId
);
wrapper
.
eq
(
StudioMerchantApply
.
STUDIO_ID
,
studioId
);
wrapper
.
in
(
StudioMerchantApply
.
APPLY_TYPE
,
wrapper
.
in
(
StudioMerchantApply
.
APPLY_TYPE
,
Lists
.
newArrayList
(
ApplyTypeEnum
.
OPEN
.
getCode
(),
ApplyTypeEnum
.
RE_OPEN
.
getCode
()));
Lists
.
newArrayList
(
ApplyTypeEnum
.
OPEN
.
getCode
(),
ApplyTypeEnum
.
RE_OPEN
.
getCode
()));
wrapper
.
eq
(
StudioMerchantApply
.
OPEN_STATE
,
OpenStateEnums
.
SUCCESS
.
getCode
());
wrapper
.
eq
(
StudioMerchantApply
.
OPEN_STATE
,
OpenStateEnums
.
SUCCESS
.
getCode
());
wrapper
.
orderByDesc
(
StudioMerchantApply
.
ID
);
wrapper
.
orderByDesc
(
StudioMerchantApply
.
ID
);
return
Optional
.
ofNullable
(
this
.
baseMapper
.
selectList
(
wrapper
)).
orElse
(
new
ArrayList
<>(
1
)).
stream
()
return
Optional
.
ofNullable
(
this
.
baseMapper
.
selectList
(
wrapper
)).
orElse
(
new
ArrayList
<>(
1
));
.
findFirst
().
orElse
(
null
);
}
}
}
}
service/src/main/java/com/jiejing/fitness/finance/service/merchant/BrandMerchantService.java
View file @
18033f54
...
@@ -3,6 +3,7 @@ package com.jiejing.fitness.finance.service.merchant;
...
@@ -3,6 +3,7 @@ package com.jiejing.fitness.finance.service.merchant;
import
com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO
;
import
com.jiejing.fitness.finance.api.merchant.vo.BrandMerchantVO
;
import
com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO
;
import
com.jiejing.fitness.finance.api.merchant.vo.StudioMerchantVO
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
/**
/**
* 品牌商户服务
* 品牌商户服务
...
@@ -28,6 +29,14 @@ public interface BrandMerchantService {
...
@@ -28,6 +29,14 @@ public interface BrandMerchantService {
*/
*/
void
unbind
(
Long
brandId
,
Long
merchantId
);
void
unbind
(
Long
brandId
,
Long
merchantId
);
/**
* 解绑
*
* @param merchantIds 商户ID
*/
void
unbindAll
(
Set
<
Long
>
merchantIds
);
/**
/**
* 查看品牌绑定的所有商户
* 查看品牌绑定的所有商户
*
*
...
...
service/src/main/java/com/jiejing/fitness/finance/service/merchant/StudioMerchantService.java
View file @
18033f54
...
@@ -11,6 +11,7 @@ import com.jiejing.paycenter.common.enums.merchant.SubChannelAuthTypeEnums;
...
@@ -11,6 +11,7 @@ import com.jiejing.paycenter.common.enums.merchant.SubChannelAuthTypeEnums;
import
com.jiejing.paycenter.common.enums.merchant.SubChannelEnums
;
import
com.jiejing.paycenter.common.enums.merchant.SubChannelEnums
;
import
com.jiejing.paycenter.common.event.MerchantEvent
;
import
com.jiejing.paycenter.common.event.MerchantEvent
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
/**
/**
* @author chengyubing
* @author chengyubing
...
@@ -50,6 +51,13 @@ public interface StudioMerchantService {
...
@@ -50,6 +51,13 @@ public interface StudioMerchantService {
void
unbindAll
(
Long
merchantId
);
void
unbindAll
(
Long
merchantId
);
/**
/**
* 解绑绑定了指定商户的所有场馆
*
* @param merchantIds 商户ID
*/
void
unbindAll
(
Set
<
Long
>
merchantIds
);
/**
* 进件申请回调
* 进件申请回调
*
*
* @param event 事件
* @param event 事件
...
...
service/src/main/java/com/jiejing/fitness/finance/service/merchant/impl/BrandMerchantServiceImpl.java
View file @
18033f54
package
com
.
jiejing
.
fitness
.
finance
.
service
.
merchant
.
impl
;
package
com
.
jiejing
.
fitness
.
finance
.
service
.
merchant
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.jiejing.common.utils.collection.CollectionUtil
;
import
com.jiejing.common.utils.collection.CollectionUtil
;
import
com.jiejing.fitness.enums.finance.PartyTypeEnum
;
import
com.jiejing.fitness.enums.finance.PartyTypeEnum
;
...
@@ -18,6 +19,7 @@ import com.jiejing.paycenter.common.model.vo.MerchantVO;
...
@@ -18,6 +19,7 @@ import com.jiejing.paycenter.common.model.vo.MerchantVO;
import
com.jiejing.studio.api.studio.vo.StudioVO
;
import
com.jiejing.studio.api.studio.vo.StudioVO
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -72,6 +74,12 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
...
@@ -72,6 +74,12 @@ public class BrandMerchantServiceImpl implements BrandMerchantService {
}
}
@Override
@Override
public
void
unbindAll
(
Set
<
Long
>
merchantIds
)
{
log
.
info
(
"unbind all brand merchant {}"
,
JSON
.
toJSONString
(
merchantIds
));
partyToMerchantRpService
.
deleteByMerchantIds
(
merchantIds
,
PartyTypeEnum
.
BRAND
);
}
@Override
public
List
<
BrandMerchantVO
>
list
(
Long
brandId
)
{
public
List
<
BrandMerchantVO
>
list
(
Long
brandId
)
{
List
<
PartyToMerchant
>
relations
=
partyToMerchantRpService
.
listByParty
(
brandId
,
PartyTypeEnum
.
BRAND
,
List
<
PartyToMerchant
>
relations
=
partyToMerchantRpService
.
listByParty
(
brandId
,
PartyTypeEnum
.
BRAND
,
config
.
getCashier
());
config
.
getCashier
());
...
...
service/src/main/java/com/jiejing/fitness/finance/service/merchant/impl/StudioMerchantServiceImpl.java
View file @
18033f54
...
@@ -56,6 +56,7 @@ import java.util.List;
...
@@ -56,6 +56,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.Executor
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
...
@@ -164,6 +165,12 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
...
@@ -164,6 +165,12 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
partyToMerchantRpService
.
deleteByMerchantId
(
merchantId
,
PartyTypeEnum
.
STUDIO
);
partyToMerchantRpService
.
deleteByMerchantId
(
merchantId
,
PartyTypeEnum
.
STUDIO
);
}
}
@Override
public
void
unbindAll
(
Set
<
Long
>
merchantIds
)
{
log
.
info
(
"unbind all studio of merchantIds {}"
,
JSON
.
toJSONString
(
merchantIds
));
partyToMerchantRpService
.
deleteByMerchantIds
(
merchantIds
,
PartyTypeEnum
.
STUDIO
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
Exception
.
class
)
@Override
@Override
public
void
callback
(
MerchantEvent
event
)
{
public
void
callback
(
MerchantEvent
event
)
{
...
@@ -358,35 +365,27 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
...
@@ -358,35 +365,27 @@ public class StudioMerchantServiceImpl implements StudioMerchantService {
}
}
private
Long
unbindWhenOpenSuccess
(
StudioMerchantApply
apply
)
{
private
void
unbindHistoryMerchant
(
StudioMerchantApply
apply
)
{
PartyToMerchant
old
=
this
.
getRelation
(
apply
.
getStudioId
());
List
<
StudioMerchantApply
>
histories
=
studioMerchantApplyRpService
.
listSuccessApplyByStudioId
(
if
(
null
==
old
)
{
apply
.
getStudioId
());
return
null
;
if
(
CollectionUtil
.
isEmpty
(
histories
))
{
}
return
;
Long
oldMerchantId
=
old
.
getMerchantId
();
StudioMerchantApply
exist
=
studioMerchantApplyRpService
.
getLatestOneSuccessByMerchantId
(
oldMerchantId
);
log
.
info
(
"current bound merchant of studio : {}, and the merchant is from studio : {}"
,
JSON
.
toJSONString
(
old
),
exist
.
getStudioId
());
if
(!
exist
.
getStudioId
().
equals
(
apply
.
getStudioId
()))
{
// 之前绑定的商户不是自己的商户,不需要解绑
log
.
info
(
"exist merchant no is not studio self {}, {}, {}"
,
oldMerchantId
,
apply
.
getStudioId
(),
exist
.
getStudioId
());
return
oldMerchantId
;
}
}
// 1. 如果当前场馆绑定的是自己的商户号(old),则需要将绑定了该商户号的所有其他场馆进行解绑
Set
<
Long
>
historyMerchantIds
=
histories
.
stream
().
map
(
StudioMerchantApply:
:
getMerchantId
)
this
.
unbindAll
(
oldMerchantId
);
.
collect
(
Collectors
.
toSet
()
);
//
2. 场馆商户发生了变更,解绑掉绑定了老商户号的品牌
//
将绑定了当前场馆商户号的所有其他场馆/品牌进行解绑
brandMerchantService
.
unbind
(
apply
.
getBrandId
(),
oldMerchantId
);
partyToMerchantRpService
.
deleteByMerchantIds
(
historyMerchantIds
);
return
oldMerchantId
;
}
}
private
void
bindWhenOpenSuccess
(
MerchantEvent
event
,
StudioMerchantApply
apply
)
{
private
void
bindWhenOpenSuccess
(
MerchantEvent
event
,
StudioMerchantApply
apply
)
{
// 1. 解绑历史商户
Long
oldMerchantId
=
Optional
.
ofNullable
(
this
.
getRelation
(
apply
.
getStudioId
()))
Long
oldMerchantId
=
this
.
unbindWhenOpenSuccess
(
apply
);
.
map
(
PartyToMerchant:
:
getMerchantId
).
orElse
(
null
);
// 1. 解绑该场馆进件的历史商户所关联的所有其他场馆和品牌
this
.
unbindHistoryMerchant
(
apply
);
// 2. 绑定场馆
// 2. 绑定场馆
this
.
bind
(
apply
.
getStudioId
(),
event
.
getMerchantId
(),
false
);
this
.
bind
(
apply
.
getStudioId
(),
event
.
getMerchantId
(),
false
);
...
...
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