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
7e29f010
Commit
7e29f010
authored
Mar 18, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分佣配置结构调整
parent
5a983be6
Pipeline
#71750
passed with stages
in 1 minute 4 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
54 deletions
+41
-54
DrmSharerConfig.java
...e/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
+41
-54
No files found.
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
View file @
7e29f010
...
@@ -17,9 +17,9 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
...
@@ -17,9 +17,9 @@ 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.model.bo.CommissionSharerProductListBO
;
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.biz.meta.model.bo.CommissionSharerProductListBO
;
import
com.netease.yanxuan.wx.store.sharer.dal.mapper.SharerInfoMapper
;
import
com.netease.yanxuan.wx.store.sharer.dal.mapper.SharerInfoMapper
;
import
com.netease.yanxuan.wx.store.sharer.dal.mapper.SharerProductCommissionMapper
;
import
com.netease.yanxuan.wx.store.sharer.dal.mapper.SharerProductCommissionMapper
;
import
com.netease.yanxuan.wx.store.sharer.dal.mapper.SharerProductCommissionRecordMapper
;
import
com.netease.yanxuan.wx.store.sharer.dal.mapper.SharerProductCommissionRecordMapper
;
...
@@ -43,7 +43,6 @@ import java.math.BigDecimal;
...
@@ -43,7 +43,6 @@ import java.math.BigDecimal;
import
java.math.RoundingMode
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -175,19 +174,11 @@ public class DrmSharerConfig {
...
@@ -175,19 +174,11 @@ public class DrmSharerConfig {
*/
*/
private
void
sharerCommissionRatioChange
(
ConfigChange
change
)
{
private
void
sharerCommissionRatioChange
(
ConfigChange
change
)
{
log
.
info
(
"ProductCommissionConfig:sharerCommissionRatioChange, change = {}"
,
JSON
.
toJSONString
(
change
));
log
.
info
(
"ProductCommissionConfig:sharerCommissionRatioChange, change = {}"
,
JSON
.
toJSONString
(
change
));
List
<
CommissionSharerBO
>
oldCommissionSharerList
=
JSON
.
parseArray
(
change
.
getOldValue
(),
CommissionSharerBO
.
class
);
// 过滤禁用,转换成Map
if
(
null
==
oldCommissionSharerList
)
{
Map
<
String
,
CommissionSharerBO
>
oldCommissionMap
=
convertCommissionSharerMap
(
change
.
getOldValue
());
oldCommissionSharerList
=
new
ArrayList
<>();
Map
<
String
,
CommissionSharerBO
>
newCommissionMap
=
convertCommissionSharerMap
(
change
.
getNewValue
());
}
oldCommissionMap
.
forEach
((
openId
,
oldInfo
)
->
{
List
<
CommissionSharerBO
>
newCommissionSharerList
=
JSON
.
parseArray
(
change
.
getNewValue
(),
CommissionSharerBO
.
class
);
CommissionSharerBO
newInfo
=
newCommissionMap
.
get
(
openId
);
if
(
null
==
newCommissionSharerList
)
{
newCommissionSharerList
=
Collections
.
emptyList
();
}
// 将 newCommissionSharerList 转换为 Map,以减少流操作的开销
Map
<
String
,
CommissionSharerBO
>
newCommissionSharerMap
=
newCommissionSharerList
.
stream
()
.
collect
(
Collectors
.
toMap
(
CommissionSharerBO:
:
getOpenId
,
Function
.
identity
()));
for
(
CommissionSharerBO
oldInfo
:
oldCommissionSharerList
)
{
CommissionSharerBO
newInfo
=
newCommissionSharerMap
.
get
(
oldInfo
.
getOpenId
());
if
(
newInfo
!=
null
)
{
if
(
newInfo
!=
null
)
{
// 修改
// 修改
if
(
newInfo
.
getCommissionRatio
().
compareTo
(
oldInfo
.
getCommissionRatio
())
!=
0
)
{
if
(
newInfo
.
getCommissionRatio
().
compareTo
(
oldInfo
.
getCommissionRatio
())
!=
0
)
{
...
@@ -197,13 +188,15 @@ public class DrmSharerConfig {
...
@@ -197,13 +188,15 @@ public class DrmSharerConfig {
// 删除
// 删除
deleteSharerCommissionInfo
(
oldInfo
);
deleteSharerCommissionInfo
(
oldInfo
);
}
}
}
}
);
for
(
CommissionSharerBO
newInfo
:
newCommissionSharerList
)
{
newCommissionMap
.
forEach
((
openId
,
newInfo
)
->
{
// 新增
// 新增
if
(
oldCommissionSharerList
.
stream
().
noneMatch
(
item
->
item
.
getOpenId
().
equals
(
newInfo
.
getOpenId
())))
{
boolean
isExists
=
oldCommissionMap
.
containsKey
(
openId
);
// 新增
if
(!
isExists
)
{
setSharerCommissionInfo
(
newInfo
,
null
);
setSharerCommissionInfo
(
newInfo
,
null
);
}
}
}
}
);
}
}
/**
/**
...
@@ -282,23 +275,9 @@ public class DrmSharerConfig {
...
@@ -282,23 +275,9 @@ 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
));
boolean
isOldBlank
=
StringUtils
.
isBlank
(
change
.
getOldValue
());
boolean
isNewBlank
=
StringUtils
.
isBlank
(
change
.
getNewValue
());
if
(
isOldBlank
&&
isNewBlank
)
{
return
;
}
List
<
CommissionSharerProductListBO
>
oldCommissionSharerList
=
new
ArrayList
<>(
0
);
if
(!
isOldBlank
)
{
oldCommissionSharerList
=
JSON
.
parseArray
(
change
.
getOldValue
(),
CommissionSharerProductListBO
.
class
);
}
List
<
CommissionSharerProductListBO
>
newCommissionSharerList
=
new
ArrayList
<>(
0
);
if
(!
isNewBlank
)
{
newCommissionSharerList
=
JSON
.
parseArray
(
change
.
getNewValue
(),
CommissionSharerProductListBO
.
class
);
}
// 过滤禁用,转换成Map
// 过滤禁用,转换成Map
Map
<
String
,
CommissionSharerProductBO
>
oldCommissionMap
=
convertCommissionSharerProductBO
(
oldCommissionSharerList
);
Map
<
String
,
CommissionSharerProductBO
>
oldCommissionMap
=
convertCommissionSharerProductMap
(
change
.
getOldValue
());
Map
<
String
,
CommissionSharerProductBO
>
newCommissionMap
=
convertCommissionSharerProductBO
(
newCommissionSharerList
);
Map
<
String
,
CommissionSharerProductBO
>
newCommissionMap
=
convertCommissionSharerProductMap
(
change
.
getNewValue
());
oldCommissionMap
.
forEach
((
mapKey
,
oldInfo
)
->
{
oldCommissionMap
.
forEach
((
mapKey
,
oldInfo
)
->
{
CommissionSharerProductBO
newInfo
=
newCommissionMap
.
get
(
mapKey
);
CommissionSharerProductBO
newInfo
=
newCommissionMap
.
get
(
mapKey
);
if
(
null
!=
newInfo
)
{
if
(
null
!=
newInfo
)
{
...
@@ -331,21 +310,6 @@ public class DrmSharerConfig {
...
@@ -331,21 +310,6 @@ public class DrmSharerConfig {
/**
/**
* 获取推客分佣比例
* 获取推客分佣比例
*/
*/
private
BigDecimal
getSharerCommissionRatio
(
String
openId
,
Long
productId
)
{
if
(
null
!=
productId
)
{
Map
<
String
,
CommissionSharerProductBO
>
commissionMap
=
convertCommissionSharerProductBO
(
commissionSharerProductList
);
CommissionSharerProductBO
bo
=
commissionMap
.
get
(
getSharerProductCommissionMapKey
(
openId
,
String
.
valueOf
(
productId
)));
if
(
null
!=
bo
)
{
// 返回推客商品分佣
return
bo
.
getCommissionRatio
();
}
}
return
getSharerCommissionRatio
(
openId
);
}
/**
* 获取推客分佣比例
*/
private
BigDecimal
getSharerCommissionRatio
(
String
openId
)
{
private
BigDecimal
getSharerCommissionRatio
(
String
openId
)
{
Optional
<
CommissionSharerBO
>
sharerCommissionOpt
=
Optional
.
ofNullable
(
commissionSharerList
)
Optional
<
CommissionSharerBO
>
sharerCommissionOpt
=
Optional
.
ofNullable
(
commissionSharerList
)
.
orElseGet
(
ArrayList:
:
new
)
.
orElseGet
(
ArrayList:
:
new
)
...
@@ -550,9 +514,18 @@ public class DrmSharerConfig {
...
@@ -550,9 +514,18 @@ public class DrmSharerConfig {
sharerInfoMapper
.
update
(
null
,
sharerInfoLuw
);
sharerInfoMapper
.
update
(
null
,
sharerInfoLuw
);
}
}
private
Map
<
String
,
CommissionSharerProductBO
>
convertCommissionSharerProductBO
(
List
<
CommissionSharerProductListBO
>
list
)
{
private
Map
<
String
,
CommissionSharerProductBO
>
convertCommissionSharerProductMap
(
String
val
)
{
if
(
StringUtils
.
isNotBlank
(
val
))
{
List
<
CommissionSharerProductListBO
>
list
=
JSON
.
parseArray
(
val
,
CommissionSharerProductListBO
.
class
);
// 过滤禁用,转换成Map
return
convertCommissionSharerProductMap
(
list
);
}
return
new
HashMap
<>(
0
);
}
private
Map
<
String
,
CommissionSharerProductBO
>
convertCommissionSharerProductMap
(
List
<
CommissionSharerProductListBO
>
list
)
{
// 过滤禁用,转换成Map
// 过滤禁用,转换成Map
Map
<
String
,
CommissionSharerProductBO
>
resultMap
=
Optional
.
ofNullable
(
list
)
return
Optional
.
ofNullable
(
list
)
.
orElseGet
(
ArrayList:
:
new
).
stream
()
.
orElseGet
(
ArrayList:
:
new
).
stream
()
.
filter
(
CommissionSharerProductListBO:
:
getEnable
)
.
filter
(
CommissionSharerProductListBO:
:
getEnable
)
.
filter
(
item
->
StringUtils
.
isNotBlank
(
item
.
getOpenId
()))
.
filter
(
item
->
StringUtils
.
isNotBlank
(
item
.
getOpenId
()))
...
@@ -567,7 +540,20 @@ public class DrmSharerConfig {
...
@@ -567,7 +540,20 @@ public class DrmSharerConfig {
result
.
setEnable
(
item
.
getEnable
());
result
.
setEnable
(
item
.
getEnable
());
return
result
;
return
result
;
}))
}))
.
collect
(
Collectors
.
toMap
(
this
::
getSharerProductCommissionMapKey
,
Function
.
identity
()));
.
collect
(
Collectors
.
toMap
(
this
::
getSharerProductCommissionMapKey
,
item
->
item
,
(
key1
,
key2
)
->
key2
));
return
CollectionUtils
.
isEmpty
(
resultMap
)
?
new
HashMap
<>(
0
)
:
resultMap
;
}
private
Map
<
String
,
CommissionSharerBO
>
convertCommissionSharerMap
(
String
val
)
{
if
(
StringUtils
.
isNotBlank
(
val
))
{
List
<
CommissionSharerBO
>
list
=
JSON
.
parseArray
(
val
,
CommissionSharerBO
.
class
);
// 过滤禁用,转换成Map
return
Optional
.
ofNullable
(
list
)
.
orElseGet
(
ArrayList:
:
new
).
stream
()
.
filter
(
item
->
StringUtils
.
isNotBlank
(
item
.
getOpenId
()))
.
filter
(
item
->
null
!=
item
.
getCommissionRatio
())
.
collect
(
Collectors
.
toMap
(
CommissionSharerBO:
:
getOpenId
,
item
->
item
,
(
key1
,
key2
)
->
key2
));
}
return
new
HashMap
<>(
0
);
}
}
}
}
\ No newline at end of file
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