Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yanxuan-wx-store-sharer
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wx
yanxuan-wx-store-sharer
Commits
75aca2a5
Commit
75aca2a5
authored
Mar 17, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分佣配置结构调整
parent
d0ec777a
Pipeline
#71709
passed with stages
in 1 minute 7 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
61 deletions
+78
-61
DrmSharerConfig.java
...e/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
+44
-39
CommissionConfigStateEnum.java
...tore/sharer/biz/meta/enums/CommissionConfigStateEnum.java
+0
-20
CommissionSharerProductBO.java
...e/sharer/biz/meta/model/bo/CommissionSharerProductBO.java
+2
-2
CommissionSharerProductsBO.java
.../sharer/biz/meta/model/bo/CommissionSharerProductsBO.java
+32
-0
No files found.
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
View file @
75aca2a5
...
@@ -17,7 +17,7 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
...
@@ -17,7 +17,7 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
import
com.ctrip.framework.apollo.spring.annotation.EnableAutoUpdateApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.EnableAutoUpdateApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ValueMapping
;
import
com.ctrip.framework.apollo.spring.annotation.ValueMapping
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.enums.CommissionChangeOptTypeEnum
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.enums.CommissionChangeOptTypeEnum
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.
enums.CommissionConfigStateEnum
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.
model.bo.CommissionSharerProductsBO
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.model.bo.CommissionSharerBO
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.model.bo.CommissionSharerBO
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.model.bo.CommissionSharerProductBO
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.model.bo.CommissionSharerProductBO
;
import
com.netease.yanxuan.wx.store.sharer.dal.mapper.SharerInfoMapper
;
import
com.netease.yanxuan.wx.store.sharer.dal.mapper.SharerInfoMapper
;
...
@@ -80,7 +80,7 @@ public class DrmSharerConfig {
...
@@ -80,7 +80,7 @@ public class DrmSharerConfig {
* 用户商品分佣比例
* 用户商品分佣比例
*/
*/
@ValueMapping
(
"${commissionratio.sharerproduct:}"
)
@ValueMapping
(
"${commissionratio.sharerproduct:}"
)
private
List
<
CommissionSharerProductBO
>
commissionSharerProductList
;
private
List
<
CommissionSharerProduct
s
BO
>
commissionSharerProductList
;
/**
/**
* 监听
* 监听
...
@@ -282,27 +282,14 @@ public class DrmSharerConfig {
...
@@ -282,27 +282,14 @@ public class DrmSharerConfig {
*/
*/
private
void
sharerProductCommissionRatioChange
(
ConfigChange
change
)
{
private
void
sharerProductCommissionRatioChange
(
ConfigChange
change
)
{
log
.
info
(
"ProductCommissionConfig:sharerProductCommissionRatioChange, change = {}"
,
JSON
.
toJSONString
(
change
));
log
.
info
(
"ProductCommissionConfig:sharerProductCommissionRatioChange, change = {}"
,
JSON
.
toJSONString
(
change
));
List
<
CommissionSharerProductBO
>
oldCommissionSharerList
=
JSON
.
parseArray
(
change
.
getOldValue
(),
CommissionSharerProductBO
.
class
);
List
<
CommissionSharerProductsBO
>
oldCommissionSharerList
=
JSON
.
parseArray
(
change
.
getOldValue
(),
CommissionSharerProductsBO
.
class
);
if
(
null
==
oldCommissionSharerList
)
{
List
<
CommissionSharerProductsBO
>
newCommissionSharerList
=
JSON
.
parseArray
(
change
.
getNewValue
(),
CommissionSharerProductsBO
.
class
);
oldCommissionSharerList
=
new
ArrayList
<>();
// 过滤禁用,转换成Map
}
Map
<
String
,
CommissionSharerProductBO
>
oldCommissionMap
=
convertCommissionSharerProductBO
(
oldCommissionSharerList
);
List
<
CommissionSharerProductBO
>
newCommissionSharerList
=
JSON
.
parseArray
(
change
.
getNewValue
(),
CommissionSharerProductBO
.
class
);
Map
<
String
,
CommissionSharerProductBO
>
newCommissionMap
=
convertCommissionSharerProductBO
(
newCommissionSharerList
);
if
(
null
==
newCommissionSharerList
)
{
newCommissionSharerList
=
Collections
.
emptyList
();
}
// 过滤禁用
oldCommissionSharerList
=
oldCommissionSharerList
.
stream
()
.
filter
(
item
->
CommissionConfigStateEnum
.
ENABLED
.
getCode
().
equals
(
item
.
getState
()))
.
collect
(
Collectors
.
toList
());
newCommissionSharerList
=
newCommissionSharerList
.
stream
()
.
filter
(
item
->
CommissionConfigStateEnum
.
ENABLED
.
getCode
().
equals
(
item
.
getState
()))
.
collect
(
Collectors
.
toList
());
// 将 newCommissionSharerList 转换为 Map,以减少流操作的开销
oldCommissionMap
.
forEach
((
mapKey
,
oldInfo
)
->
{
Map
<
String
,
CommissionSharerProductBO
>
newCommissionSharerMap
=
newCommissionSharerList
.
stream
()
CommissionSharerProductBO
newInfo
=
newCommissionMap
.
get
(
mapKey
);
.
collect
(
Collectors
.
toMap
(
this
::
getSharerProductCommissionMapKey
,
Function
.
identity
()));
for
(
CommissionSharerProductBO
oldInfo
:
oldCommissionSharerList
)
{
CommissionSharerProductBO
newInfo
=
newCommissionSharerMap
.
get
(
getSharerProductCommissionMapKey
(
oldInfo
));
if
(
newInfo
!=
null
)
{
if
(
newInfo
!=
null
)
{
// 修改
// 修改
if
(
newInfo
.
getCommissionRatio
().
compareTo
(
oldInfo
.
getCommissionRatio
())
!=
0
)
{
if
(
newInfo
.
getCommissionRatio
().
compareTo
(
oldInfo
.
getCommissionRatio
())
!=
0
)
{
...
@@ -312,35 +299,35 @@ public class DrmSharerConfig {
...
@@ -312,35 +299,35 @@ public class DrmSharerConfig {
// 删除
// 删除
deleteSharerProductCommissionInfo
(
oldInfo
);
deleteSharerProductCommissionInfo
(
oldInfo
);
}
}
}
});
for
(
CommissionSharerProductBO
newInfo
:
newCommissionSharerList
)
{
newCommissionMap
.
forEach
((
mapKey
,
newInfo
)
->
{
boolean
isExists
=
oldCommissionMap
.
containsKey
(
mapKey
);
// 新增
// 新增
if
(
oldCommissionSharerList
.
stream
().
noneMatch
(
item
->
item
.
getOpenId
().
equals
(
newInfo
.
getOpenId
())
if
(!
isExists
)
{
&&
item
.
getProductId
().
equals
(
newInfo
.
getProductId
())))
{
setSharerProductCommissionInfo
(
newInfo
,
null
);
setSharerProductCommissionInfo
(
newInfo
,
null
);
}
}
}
}
);
}
}
private
String
getSharerProductCommissionMapKey
(
CommissionSharerProductBO
bo
)
{
private
String
getSharerProductCommissionMapKey
(
CommissionSharerProductBO
bo
)
{
return
bo
.
getOpenId
()
+
"&"
+
bo
.
getProductId
();
return
getSharerProductCommissionMapKey
(
bo
.
getOpenId
(),
bo
.
getProductId
());
}
private
String
getSharerProductCommissionMapKey
(
String
openId
,
String
productId
)
{
return
openId
+
"&"
+
productId
;
}
}
/**
/**
* 获取推客分佣比例
* 获取推客分佣比例
*/
*/
private
BigDecimal
getSharerCommissionRatio
(
String
openId
,
Long
productId
)
{
private
BigDecimal
getSharerCommissionRatio
(
String
openId
,
Long
productId
)
{
Optional
<
CommissionSharerProductBO
>
sharerProductCommissionOpt
=
Optional
.
ofNullable
(
commissionSharerProductList
)
if
(
null
!=
productId
)
{
.
orElseGet
(
ArrayList:
:
new
)
Map
<
String
,
CommissionSharerProductBO
>
commissionMap
=
convertCommissionSharerProductBO
(
commissionSharerProductList
);
.
stream
()
CommissionSharerProductBO
bo
=
commissionMap
.
get
(
getSharerProductCommissionMapKey
(
openId
,
String
.
valueOf
(
productId
)));
.
filter
(
item
->
StringUtils
.
isNotBlank
(
item
.
getOpenId
()))
if
(
null
!=
bo
)
{
.
filter
(
item
->
StringUtils
.
isNotBlank
(
item
.
getProductId
()))
// 返回推客商品分佣
.
filter
(
item
->
item
.
getOpenId
().
equals
(
openId
))
return
bo
.
getCommissionRatio
();
.
filter
(
item
->
null
==
productId
||
item
.
getProductId
().
equals
(
String
.
valueOf
(
productId
)))
}
.
findFirst
();
if
(
sharerProductCommissionOpt
.
isPresent
())
{
// 返回推客商品分佣
return
sharerProductCommissionOpt
.
get
().
getCommissionRatio
();
}
}
return
getSharerCommissionRatio
(
openId
);
return
getSharerCommissionRatio
(
openId
);
}
}
...
@@ -544,4 +531,21 @@ public class DrmSharerConfig {
...
@@ -544,4 +531,21 @@ public class DrmSharerConfig {
sharerInfoLuw
.
eq
(
SharerInfo:
:
getId
,
sharerInfo
.
getId
());
sharerInfoLuw
.
eq
(
SharerInfo:
:
getId
,
sharerInfo
.
getId
());
sharerInfoMapper
.
update
(
null
,
sharerInfoLuw
);
sharerInfoMapper
.
update
(
null
,
sharerInfoLuw
);
}
}
private
Map
<
String
,
CommissionSharerProductBO
>
convertCommissionSharerProductBO
(
List
<
CommissionSharerProductsBO
>
list
)
{
// 过滤禁用,转换成Map
return
Optional
.
ofNullable
(
list
)
.
orElseGet
(
ArrayList:
:
new
).
stream
()
.
filter
(
CommissionSharerProductsBO:
:
getEnable
)
.
flatMap
(
item
->
Arrays
.
stream
(
item
.
getProductIds
().
split
(
","
))
.
map
(
productId
->
{
CommissionSharerProductBO
result
=
new
CommissionSharerProductBO
();
result
.
setOpenId
(
item
.
getOpenId
());
result
.
setProductId
(
productId
);
result
.
setCommissionRatio
(
item
.
getCommissionRatio
());
result
.
setEnable
(
item
.
getEnable
());
return
result
;
}))
.
collect
(
Collectors
.
toMap
(
this
::
getSharerProductCommissionMapKey
,
Function
.
identity
()));
}
}
}
\ No newline at end of file
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/meta/enums/CommissionConfigStateEnum.java
deleted
100644 → 0
View file @
d0ec777a
package
com
.
netease
.
yanxuan
.
wx
.
store
.
sharer
.
biz
.
meta
.
enums
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
/**
* @Description 分佣配置状态
* @Author fanjiaxin
* @Date 2025/3/3 13:58
*/
@Getter
@RequiredArgsConstructor
public
enum
CommissionConfigStateEnum
{
ENABLED
(
"1"
,
"启用"
),
DISABLED
(
"0"
,
"禁用"
);
private
final
String
code
;
private
final
String
desc
;
}
\ No newline at end of file
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/meta/model/bo/CommissionSharerProductBO.java
View file @
75aca2a5
...
@@ -27,7 +27,7 @@ public class CommissionSharerProductBO implements Serializable {
...
@@ -27,7 +27,7 @@ public class CommissionSharerProductBO implements Serializable {
*/
*/
private
BigDecimal
commissionRatio
;
private
BigDecimal
commissionRatio
;
/**
/**
* 状态,1启用,0禁用
*
启用
状态,1启用,0禁用
*/
*/
private
String
stat
e
;
private
Boolean
enabl
e
;
}
}
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/meta/model/bo/CommissionSharerProductsBO.java
0 → 100644
View file @
75aca2a5
package
com
.
netease
.
yanxuan
.
wx
.
store
.
sharer
.
biz
.
meta
.
model
.
bo
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
/**
* @Description 用户商品分佣比例-业务对象
* @Author fanjiaxin
* @Date 2025/3/9 13:44
*/
@Data
public
class
CommissionSharerProductsBO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
6353220469962589464L
;
/**
* 用户ID
*/
private
String
openId
;
/**
* 商品ID
*/
private
String
productIds
;
/**
* 分佣比例
*/
private
BigDecimal
commissionRatio
;
/**
* 启用状态,1启用,0禁用
*/
private
Boolean
enable
;
}
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