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
2cd36a00
Commit
2cd36a00
authored
Mar 18, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分佣配置结构调整
parent
68c9bbea
Pipeline
#71755
passed with stages
in 1 minute 7 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
41 deletions
+46
-41
DrmSharerConfig.java
...e/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
+46
-41
No files found.
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
View file @
2cd36a00
...
...
@@ -208,20 +208,11 @@ public class DrmSharerConfig {
if
(
null
==
sharerInfo
)
{
return
;
}
// 分佣比例为小数, 微信接口参数应当分佣比例*比例 为整数
BigDecimal
commissionRatio
=
newCommissionSharer
.
getCommissionRatio
()
.
multiply
(
new
BigDecimal
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
))
.
setScale
(
0
,
RoundingMode
.
DOWN
);
// 设置推客分佣比例
boolean
isSuccess
=
false
;
try
{
if
(
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
// 设置推客分佣比例
weChatShopSetSharerCommissionRequest
.
handle
(
sharerInfo
.
getSharerAppid
(),
commissionRatio
.
longValue
());
}
// 更新推客分佣比例
updateSharerInfo
(
sharerInfo
,
newCommissionSharer
.
getCommissionRatio
()
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toPlainString
());
// 更新分佣比例,同步微信
updateSharerOrProductCommissionRatio
(
sharerInfo
,
newCommissionSharer
.
getCommissionRatio
());
isSuccess
=
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
...
...
@@ -246,19 +237,12 @@ public class DrmSharerConfig {
return
;
}
// 分佣比例为小数, 微信接口参数应当分佣比例*倍数 为整数
BigDecimal
sharerCommissionRatio
=
getSharerOrDefaultCommissionRatio
(
oldCommissionSharer
.
getOpenId
());
BigDecimal
commissionRatio
=
sharerCommissionRatio
.
multiply
(
new
BigDecimal
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
))
.
setScale
(
0
,
RoundingMode
.
DOWN
);
BigDecimal
sharerCommissionRatio
=
new
BigDecimal
(
sharerInfo
.
getCommissionRatio
());
// 设置推客分佣比例
boolean
isSuccess
=
false
;
try
{
if
(
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
// 设置推客分佣比例
weChatShopSetSharerCommissionRequest
.
handle
(
sharerInfo
.
getSharerAppid
(),
commissionRatio
.
longValue
());
}
// 更新推客分佣比例
updateSharerInfo
(
sharerInfo
,
sharerCommissionRatio
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toPlainString
());
// 更新分佣比例,同步微信
updateSharerOrProductCommissionRatio
(
sharerInfo
,
sharerCommissionRatio
);
isSuccess
=
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
...
...
@@ -270,6 +254,30 @@ public class DrmSharerConfig {
}
}
private
void
updateSharerOrProductCommissionRatio
(
SharerInfo
sharerInfo
,
BigDecimal
commissionRatio
)
{
if
(
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
// 分佣比例为小数, 微信接口参数应当分佣比例*比例 为整数
BigDecimal
weChatCommissionRatio
=
commissionRatio
.
multiply
(
new
BigDecimal
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
))
.
setScale
(
0
,
RoundingMode
.
DOWN
);
// 设置推客分佣比例
weChatShopSetSharerCommissionRequest
.
handle
(
sharerInfo
.
getSharerAppid
(),
weChatCommissionRatio
.
longValue
());
// 拿到未配置的商品,设置推客商品分佣比例
List
<
SharerProductCommission
>
unsetList
=
getSharerProductCommissionUnsetList
(
sharerInfo
.
getOpenId
());
if
(!
CollectionUtils
.
isEmpty
(
unsetList
))
{
for
(
SharerProductCommission
sharerProductCommission
:
unsetList
)
{
// 设置推客分佣比例
weChatShopSetSharerProductCommissionRequest
.
handle
(
sharerInfo
.
getSharerAppid
(),
Long
.
valueOf
(
sharerProductCommission
.
getProductId
()),
weChatCommissionRatio
.
longValue
());
}
}
}
// 更新推客分佣比例
updateSharerInfo
(
sharerInfo
,
commissionRatio
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toPlainString
());
}
/**
* 用户商品分佣比例变更
*/
...
...
@@ -311,27 +319,21 @@ public class DrmSharerConfig {
* 获取推客分佣比例
*/
private
BigDecimal
getSharerCommissionRatio
(
String
openId
)
{
Optional
<
CommissionSharerBO
>
sharerCommissionOpt
=
Optional
.
ofNullable
(
commissionSharerList
)
.
orElseGet
(
ArrayList:
:
new
)
.
stream
()
.
filter
(
item
->
StringUtils
.
isNotBlank
(
item
.
getOpenId
()))
.
filter
(
item
->
item
.
getOpenId
().
equals
(
openId
))
.
findFirst
();
Map
<
String
,
CommissionSharerBO
>
sharerCommissionMap
=
convertCommissionSharerMap
(
commissionSharerList
);
CommissionSharerBO
commissionSharerBO
=
sharerCommissionMap
.
get
(
openId
);
// 返回推客分佣
return
sharerCommissionOpt
.
map
(
CommissionSharerBO:
:
getCommissionRatio
).
orElse
(
null
)
;
return
null
!=
commissionSharerBO
?
commissionSharerBO
.
getCommissionRatio
()
:
null
;
}
/**
* 获取推客
分佣比例
* 获取推客
商品未配置的分佣比例集合
*/
private
BigDecimal
getSharerOrDefaultCommissionRatio
(
String
openId
)
{
// 返回推客分佣
BigDecimal
sharerCommissionRatio
=
getSharerCommissionRatio
(
openId
);
if
(
null
!=
sharerCommissionRatio
)
{
return
sharerCommissionRatio
;
}
// 返回默认分佣金
return
defaultCommissionRatio
;
private
List
<
SharerProductCommission
>
getSharerProductCommissionUnsetList
(
String
openId
)
{
// 返回推客商品分佣
LambdaQueryWrapper
<
SharerProductCommission
>
lqw
=
Wrappers
.
lambdaQuery
();
lqw
.
eq
(
SharerProductCommission:
:
getOpenId
,
openId
);
lqw
.
eq
(
SharerProductCommission:
:
getUnset
,
SharerProductCommission
.
UnsetEnum
.
UNSET
.
getCode
());
return
sharerProductCommissionMapper
.
selectList
(
lqw
);
}
/**
...
...
@@ -538,17 +540,21 @@ public class DrmSharerConfig {
.
collect
(
Collectors
.
toMap
(
this
::
getSharerProductCommissionMapKey
,
item
->
item
,
(
key1
,
key2
)
->
key2
));
}
private
Map
<
String
,
CommissionSharerBO
>
convertCommissionSharerMap
(
String
val
)
{
if
(
StringUtils
.
isNotBlank
(
val
))
{
List
<
CommissionSharerBO
>
list
=
JSON
.
parseArray
(
val
,
CommissionSharerBO
.
class
);
// 过滤禁用,转换成Map
return
convertCommissionSharerMap
(
list
);
}
return
new
HashMap
<>(
0
);
}
private
Map
<
String
,
CommissionSharerBO
>
convertCommissionSharerMap
(
List
<
CommissionSharerBO
>
list
)
{
// 过滤禁用,转换成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