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
f79e9257
Commit
f79e9257
authored
Mar 14, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
联调问题处理
parent
c93fb097
Pipeline
#71623
passed with stages
in 1 minute 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
134 additions
and
94 deletions
+134
-94
DrmSharerConfig.java
...e/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
+134
-94
No files found.
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
View file @
f79e9257
...
@@ -8,7 +8,9 @@ package com.netease.yanxuan.wx.store.sharer.biz.config;
...
@@ -8,7 +8,9 @@ package com.netease.yanxuan.wx.store.sharer.biz.config;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
...
@@ -28,8 +30,6 @@ import com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatShopSe
...
@@ -28,8 +30,6 @@ import com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatShopSe
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatShopSetSharerProductCommissionRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatShopSetSharerProductCommissionRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatShopSharerListRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatShopSharerListRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.enums.CommissionTypeEnum
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.enums.CommissionTypeEnum
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatSharerInfoVO
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatSharerListVO
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -63,7 +63,7 @@ public class DrmSharerConfig {
...
@@ -63,7 +63,7 @@ public class DrmSharerConfig {
private
final
WeChatShopSetSharerCommissionRequest
weChatShopSetSharerCommissionRequest
;
private
final
WeChatShopSetSharerCommissionRequest
weChatShopSetSharerCommissionRequest
;
private
final
WeChatShopSetSharerProductCommissionRequest
weChatShopSetSharerProductCommissionRequest
;
private
final
WeChatShopSetSharerProductCommissionRequest
weChatShopSetSharerProductCommissionRequest
;
private
final
Map
<
String
,
S
tring
>
sharerAppid
Map
=
new
ConcurrentHashMap
<>(
0
);
private
final
Map
<
String
,
S
harerInfo
>
sharerInfo
Map
=
new
ConcurrentHashMap
<>(
0
);
/**
/**
* 默认分佣比例
* 默认分佣比例
...
@@ -121,23 +121,18 @@ public class DrmSharerConfig {
...
@@ -121,23 +121,18 @@ public class DrmSharerConfig {
if
(
StringUtils
.
isBlank
(
change
.
getNewValue
())
||
change
.
getNewValue
().
equals
(
change
.
getOldValue
()))
{
if
(
StringUtils
.
isBlank
(
change
.
getNewValue
())
||
change
.
getNewValue
().
equals
(
change
.
getOldValue
()))
{
return
;
return
;
}
}
// 获取推客绑定的所有用户
int
pageNum
=
1
;
String
nextKey
=
null
;
int
pageSize
=
10
;
int
pageSize
=
10
;
Page
<
SharerInfo
>
sharerInfoPage
;
while
(
true
)
{
while
(
true
)
{
WeChatSharerListVO
sharerListVO
=
weChatShopSharerListRequest
.
handle
(
null
,
nextKey
,
pageSize
);
sharerInfoPage
=
sharerInfoMapper
.
selectPage
(
new
Page
<>(
pageNum
++,
pageSize
),
null
);
if
(
sharerListVO
==
null
)
{
if
(
null
==
sharerInfoPage
||
CollectionUtils
.
isEmpty
(
sharerInfoPage
.
getRecords
()))
{
break
;
// 如果返回值为空,直接终止循环
// 如果返回值为空,直接终止循环
break
;
}
}
nextKey
=
sharerListVO
.
getNext_key
();
for
(
SharerInfo
sharerInfo
:
sharerInfoPage
.
getRecords
())
{
if
(!
CollectionUtils
.
isEmpty
(
sharerListVO
.
getSharer_info_list
()))
{
// 处理每个 sharerInfoVO
for
(
WeChatSharerInfoVO
sharerInfoVO
:
sharerListVO
.
getSharer_info_list
())
{
setSharerDefaultCommissionInfo
(
change
,
sharerInfo
);
// 处理每个 sharerInfoVO
setSharerDefaultCommissionInfo
(
change
,
sharerInfoVO
);
}
}
if
(
CollectionUtils
.
isEmpty
(
sharerListVO
.
getSharer_info_list
())
||
sharerListVO
.
getSharer_info_list
().
size
()
<
pageSize
)
{
break
;
// 如果列表为空或小于 pageSize,终止循环
}
}
}
}
}
}
...
@@ -145,7 +140,7 @@ public class DrmSharerConfig {
...
@@ -145,7 +140,7 @@ public class DrmSharerConfig {
/**
/**
* 设置推客的的分佣类型和比例信息
* 设置推客的的分佣类型和比例信息
*/
*/
private
void
setSharerDefaultCommissionInfo
(
ConfigChange
change
,
WeChatSharerInfoVO
sharerInfoVO
)
{
private
void
setSharerDefaultCommissionInfo
(
ConfigChange
change
,
SharerInfo
sharerInfo
)
{
// 分佣比例为小数, 微信接口参数应当分佣比例*倍数 为整数
// 分佣比例为小数, 微信接口参数应当分佣比例*倍数 为整数
BigDecimal
commissionRatio
=
new
BigDecimal
(
change
.
getNewValue
())
BigDecimal
commissionRatio
=
new
BigDecimal
(
change
.
getNewValue
())
.
multiply
(
new
BigDecimal
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
))
.
multiply
(
new
BigDecimal
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
))
...
@@ -154,13 +149,16 @@ public class DrmSharerConfig {
...
@@ -154,13 +149,16 @@ public class DrmSharerConfig {
boolean
isSuccess
=
false
;
boolean
isSuccess
=
false
;
try
{
try
{
// 设置推客分佣比例
// 设置推客分佣比例
weChatShopSetSharerCommissionRequest
.
handle
(
sharerInfoVO
.
getSharer_appid
(),
commissionRatio
.
longValue
());
if
(
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
weChatShopSetSharerCommissionRequest
.
handle
(
sharerInfo
.
getSharerAppid
(),
commissionRatio
.
longValue
());
}
updateSharerInfo
(
sharerInfo
,
change
.
getNewValue
());
isSuccess
=
true
;
isSuccess
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
// 保存记录
// 保存记录
saveSharerProductCommissionRecord
(
sharerInfo
VO
.
getSharer_a
ppid
(),
null
,
saveSharerProductCommissionRecord
(
sharerInfo
.
getOpenId
(),
sharerInfo
.
getSharerA
ppid
(),
null
,
new
BigDecimal
(
change
.
getOldValue
()),
new
BigDecimal
(
change
.
getNewValue
()),
new
BigDecimal
(
change
.
getOldValue
()),
new
BigDecimal
(
change
.
getNewValue
()),
CommissionChangeOptTypeEnum
.
DEFAULT_CHANGE
,
isSuccess
);
CommissionChangeOptTypeEnum
.
DEFAULT_CHANGE
,
isSuccess
);
}
}
...
@@ -207,9 +205,8 @@ public class DrmSharerConfig {
...
@@ -207,9 +205,8 @@ public class DrmSharerConfig {
*/
*/
private
void
setSharerCommissionInfo
(
CommissionSharerBO
newCommissionSharer
,
private
void
setSharerCommissionInfo
(
CommissionSharerBO
newCommissionSharer
,
CommissionSharerBO
oldCommissionSharer
)
{
CommissionSharerBO
oldCommissionSharer
)
{
String
sharerAppid
=
getSharerAppidByOpenId
(
newCommissionSharer
.
getOpenId
());
SharerInfo
sharerInfo
=
getSharerInfoByOpenId
(
newCommissionSharer
.
getOpenId
());
if
(
StringUtils
.
isBlank
(
sharerAppid
))
{
if
(
null
==
sharerInfo
)
{
log
.
error
(
"微信用户暂未绑定微信小店,openId={}"
,
newCommissionSharer
.
getOpenId
());
return
;
return
;
}
}
// 分佣比例为小数, 微信接口参数应当分佣比例*1000 为整数
// 分佣比例为小数, 微信接口参数应当分佣比例*1000 为整数
...
@@ -219,14 +216,19 @@ public class DrmSharerConfig {
...
@@ -219,14 +216,19 @@ public class DrmSharerConfig {
// 设置推客分佣比例
// 设置推客分佣比例
boolean
isSuccess
=
false
;
boolean
isSuccess
=
false
;
try
{
try
{
// 设置推客分佣比例
if
(
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
weChatShopSetSharerCommissionRequest
.
handle
(
sharerAppid
,
commissionRatio
.
longValue
());
// 设置推客分佣比例
weChatShopSetSharerCommissionRequest
.
handle
(
sharerInfo
.
getSharerAppid
(),
commissionRatio
.
longValue
());
}
// 更新推客分佣比例
updateSharerInfo
(
sharerInfo
,
newCommissionSharer
.
getCommissionRatio
()
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toPlainString
());
isSuccess
=
true
;
isSuccess
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
// 保存记录
// 保存记录
saveSharerProductCommissionRecord
(
sharer
Appid
,
null
,
saveSharerProductCommissionRecord
(
sharer
Info
.
getOpenId
(),
sharerInfo
.
getSharerAppid
()
,
null
,
oldCommissionSharer
.
getCommissionRatio
(),
newCommissionSharer
.
getCommissionRatio
(),
oldCommissionSharer
.
getCommissionRatio
(),
newCommissionSharer
.
getCommissionRatio
(),
CommissionChangeOptTypeEnum
.
SET
,
isSuccess
);
CommissionChangeOptTypeEnum
.
SET
,
isSuccess
);
}
}
...
@@ -236,27 +238,30 @@ public class DrmSharerConfig {
...
@@ -236,27 +238,30 @@ public class DrmSharerConfig {
* 删除推客的的分佣类型和比例信息
* 删除推客的的分佣类型和比例信息
*/
*/
private
void
deleteSharerCommissionInfo
(
CommissionSharerBO
oldCommissionSharer
)
{
private
void
deleteSharerCommissionInfo
(
CommissionSharerBO
oldCommissionSharer
)
{
String
sharerAppid
=
getSharerAppidByOpenId
(
oldCommissionSharer
.
getOpenId
());
SharerInfo
sharerInfo
=
getSharerInfoByOpenId
(
oldCommissionSharer
.
getOpenId
());
if
(
StringUtils
.
isBlank
(
sharerAppid
))
{
if
(
null
==
sharerInfo
)
{
log
.
error
(
"微信用户暂未绑定微信小店,openId={}"
,
oldCommissionSharer
.
getOpenId
());
return
;
return
;
}
}
// 分佣比例为小数, 微信接口参数应当分佣比例*倍数 为整数
// 分佣比例为小数, 微信接口参数应当分佣比例*倍数 为整数
BigDecimal
sharerCommissionRatio
=
getSharerCommissionRatio
(
oldCommissionSharer
.
getOpenId
()
,
null
);
BigDecimal
sharerCommissionRatio
=
getSharerCommissionRatio
(
oldCommissionSharer
.
getOpenId
());
BigDecimal
commissionRatio
=
sharerCommissionRatio
BigDecimal
commissionRatio
=
sharerCommissionRatio
.
multiply
(
new
BigDecimal
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
))
.
multiply
(
new
BigDecimal
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
))
.
setScale
(
0
,
RoundingMode
.
DOWN
);
.
setScale
(
0
,
RoundingMode
.
DOWN
);
// 设置推客分佣比例
// 设置推客分佣比例
boolean
isSuccess
=
false
;
boolean
isSuccess
=
false
;
try
{
try
{
// 设置推客分佣比例
if
(
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
weChatShopSetSharerCommissionRequest
.
handle
(
sharerAppid
,
commissionRatio
.
longValue
());
// 设置推客分佣比例
weChatShopSetSharerCommissionRequest
.
handle
(
sharerInfo
.
getSharerAppid
(),
commissionRatio
.
longValue
());
}
// 更新推客分佣比例
updateSharerInfo
(
sharerInfo
,
sharerCommissionRatio
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toPlainString
());
isSuccess
=
true
;
isSuccess
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
// 保存记录
// 保存记录
saveSharerProductCommissionRecord
(
sharer
Appid
,
null
,
saveSharerProductCommissionRecord
(
sharer
Info
.
getOpenId
(),
sharerInfo
.
getSharerAppid
()
,
null
,
oldCommissionSharer
.
getCommissionRatio
(),
sharerCommissionRatio
,
oldCommissionSharer
.
getCommissionRatio
(),
sharerCommissionRatio
,
CommissionChangeOptTypeEnum
.
UNSET
,
isSuccess
);
CommissionChangeOptTypeEnum
.
UNSET
,
isSuccess
);
}
}
...
@@ -284,18 +289,10 @@ public class DrmSharerConfig {
...
@@ -284,18 +289,10 @@ public class DrmSharerConfig {
// 修改
// 修改
if
(
newInfo
.
getCommissionRatio
().
compareTo
(
oldInfo
.
getCommissionRatio
())
!=
0
)
{
if
(
newInfo
.
getCommissionRatio
().
compareTo
(
oldInfo
.
getCommissionRatio
())
!=
0
)
{
setSharerProductCommissionInfo
(
newInfo
,
oldInfo
);
setSharerProductCommissionInfo
(
newInfo
,
oldInfo
);
// 保存推客商品记录
saveSharerProductCommissionInfo
(
newInfo
.
getOpenId
(),
newInfo
.
getProductId
(),
newInfo
.
getCommissionRatio
(),
SharerProductCommission
.
UnsetEnum
.
SET
);
}
}
}
else
{
}
else
{
// 删除
// 删除
deleteSharerProductCommissionInfo
(
oldInfo
);
deleteSharerProductCommissionInfo
(
oldInfo
);
// 获取推客的分佣比例
BigDecimal
sharerCommissionRatio
=
getSharerCommissionRatio
(
oldInfo
.
getOpenId
(),
null
);
// 保存推客商品记录
saveSharerProductCommissionInfo
(
oldInfo
.
getOpenId
(),
oldInfo
.
getProductId
(),
sharerCommissionRatio
,
SharerProductCommission
.
UnsetEnum
.
UNSET
);
}
}
}
}
for
(
CommissionSharerProductBO
newInfo
:
newCommissionSharerList
)
{
for
(
CommissionSharerProductBO
newInfo
:
newCommissionSharerList
)
{
...
@@ -303,32 +300,10 @@ public class DrmSharerConfig {
...
@@ -303,32 +300,10 @@ public class DrmSharerConfig {
if
(
oldCommissionSharerList
.
stream
().
noneMatch
(
item
->
item
.
getOpenId
().
equals
(
newInfo
.
getOpenId
())
if
(
oldCommissionSharerList
.
stream
().
noneMatch
(
item
->
item
.
getOpenId
().
equals
(
newInfo
.
getOpenId
())
&&
item
.
getProductId
().
equals
(
newInfo
.
getProductId
())))
{
&&
item
.
getProductId
().
equals
(
newInfo
.
getProductId
())))
{
setSharerProductCommissionInfo
(
newInfo
,
null
);
setSharerProductCommissionInfo
(
newInfo
,
null
);
// 保存推客商品记录
saveSharerProductCommissionInfo
(
newInfo
.
getOpenId
(),
newInfo
.
getProductId
(),
newInfo
.
getCommissionRatio
(),
SharerProductCommission
.
UnsetEnum
.
SET
);
}
}
}
}
}
}
/**
* 根据 openId 获取推客的 SharerAppid
*/
private
String
getSharerAppidByOpenId
(
String
openId
)
{
String
sharerAppid
=
sharerAppidMap
.
get
(
openId
);
if
(
StringUtils
.
isBlank
(
sharerAppid
))
{
LambdaQueryWrapper
<
SharerInfo
>
sharerInfoLqw
=
Wrappers
.
lambdaQuery
();
sharerInfoLqw
.
eq
(
SharerInfo:
:
getOpenId
,
openId
);
sharerInfoLqw
.
last
(
"LIMIT 1"
);
SharerInfo
sharerInfo
=
sharerInfoMapper
.
selectOne
(
sharerInfoLqw
);
if
(
null
!=
sharerInfo
&&
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
sharerAppid
=
sharerInfo
.
getSharerAppid
();
sharerAppidMap
.
put
(
openId
,
sharerAppid
);
}
}
return
sharerAppid
;
}
private
String
getSharerProductCommissionMapKey
(
CommissionSharerProductBO
bo
)
{
private
String
getSharerProductCommissionMapKey
(
CommissionSharerProductBO
bo
)
{
return
bo
.
getOpenId
()
+
"&"
+
bo
.
getProductId
();
return
bo
.
getOpenId
()
+
"&"
+
bo
.
getProductId
();
}
}
...
@@ -347,6 +322,13 @@ public class DrmSharerConfig {
...
@@ -347,6 +322,13 @@ public class DrmSharerConfig {
// 返回推客商品分佣
// 返回推客商品分佣
return
sharerProductCommissionOpt
.
get
().
getCommissionRatio
();
return
sharerProductCommissionOpt
.
get
().
getCommissionRatio
();
}
}
return
getSharerCommissionRatio
(
openId
);
}
/**
* 获取推客分佣比例
*/
private
BigDecimal
getSharerCommissionRatio
(
String
openId
)
{
Optional
<
CommissionSharerBO
>
sharerCommissionOpt
=
Optional
.
ofNullable
(
commissionSharerList
)
Optional
<
CommissionSharerBO
>
sharerCommissionOpt
=
Optional
.
ofNullable
(
commissionSharerList
)
.
orElseGet
(
ArrayList:
:
new
)
.
orElseGet
(
ArrayList:
:
new
)
.
stream
()
.
stream
()
...
@@ -365,9 +347,8 @@ public class DrmSharerConfig {
...
@@ -365,9 +347,8 @@ public class DrmSharerConfig {
*/
*/
private
void
setSharerProductCommissionInfo
(
CommissionSharerProductBO
newBo
,
private
void
setSharerProductCommissionInfo
(
CommissionSharerProductBO
newBo
,
CommissionSharerProductBO
oldBo
)
{
CommissionSharerProductBO
oldBo
)
{
String
sharerAppid
=
getSharerAppidByOpenId
(
newBo
.
getOpenId
());
SharerInfo
sharerInfo
=
getSharerInfoByOpenId
(
newBo
.
getOpenId
());
if
(
StringUtils
.
isBlank
(
sharerAppid
))
{
if
(
null
==
sharerInfo
)
{
log
.
error
(
"微信用户暂未绑定微信小店,openId={}"
,
newBo
.
getOpenId
());
return
;
return
;
}
}
// 分佣比例为小数, 微信接口参数应当分佣比例*倍数 为整数
// 分佣比例为小数, 微信接口参数应当分佣比例*倍数 为整数
...
@@ -377,16 +358,22 @@ public class DrmSharerConfig {
...
@@ -377,16 +358,22 @@ public class DrmSharerConfig {
// 设置推客分佣比例
// 设置推客分佣比例
boolean
isSuccess
=
false
;
boolean
isSuccess
=
false
;
try
{
try
{
// 设置推客分佣比例
if
(
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
weChatShopSetSharerProductCommissionRequest
.
handle
(
sharerAppid
,
// 设置推客分佣比例
Long
.
valueOf
(
newBo
.
getProductId
()),
weChatShopSetSharerProductCommissionRequest
.
handle
(
sharerInfo
.
getSharerAppid
(),
commissionRatio
.
longValue
());
Long
.
valueOf
(
newBo
.
getProductId
()),
commissionRatio
.
longValue
());
}
// 保存推客商品记录
saveSharerProductCommissionInfo
(
sharerInfo
.
getOpenId
(),
newBo
.
getProductId
(),
commissionRatio
,
SharerProductCommission
.
UnsetEnum
.
SET
);
isSuccess
=
true
;
isSuccess
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
// 保存记录
// 保存记录
saveSharerProductCommissionRecord
(
sharerAppid
,
oldBo
.
getProductId
(),
saveSharerProductCommissionRecord
(
sharerInfo
.
getOpenId
(),
sharerInfo
.
getSharerAppid
(),
oldBo
.
getProductId
(),
oldBo
.
getCommissionRatio
(),
newBo
.
getCommissionRatio
(),
oldBo
.
getCommissionRatio
(),
newBo
.
getCommissionRatio
(),
CommissionChangeOptTypeEnum
.
SET
,
isSuccess
);
CommissionChangeOptTypeEnum
.
SET
,
isSuccess
);
}
}
...
@@ -396,23 +383,27 @@ public class DrmSharerConfig {
...
@@ -396,23 +383,27 @@ public class DrmSharerConfig {
* 删除推客的的分佣类型和比例信息
* 删除推客的的分佣类型和比例信息
*/
*/
private
void
deleteSharerProductCommissionInfo
(
CommissionSharerProductBO
oldBo
)
{
private
void
deleteSharerProductCommissionInfo
(
CommissionSharerProductBO
oldBo
)
{
String
sharerAppid
=
getSharerAppidByOpenId
(
oldBo
.
getOpenId
());
SharerInfo
sharerInfo
=
getSharerInfoByOpenId
(
oldBo
.
getOpenId
());
if
(
StringUtils
.
isBlank
(
sharerAppid
))
{
log
.
error
(
"微信用户暂未绑定微信小店,openId={}"
,
oldBo
.
getOpenId
());
return
;
}
// 设置推客分佣比例
// 设置推客分佣比例
boolean
isSuccess
=
false
;
boolean
isSuccess
=
false
;
try
{
try
{
// 设置推客分佣比例
if
(
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
weChatShopSetSharerProductCommissionRequest
.
handle
(
sharerAppid
,
// 设置推客分佣比例
Long
.
valueOf
(
oldBo
.
getProductId
()),
null
);
weChatShopSetSharerProductCommissionRequest
.
handle
(
sharerInfo
.
getSharerAppid
(),
Long
.
valueOf
(
oldBo
.
getProductId
()),
null
);
}
// 获取推客的分佣比例
BigDecimal
sharerCommissionRatio
=
getSharerCommissionRatio
(
sharerInfo
.
getOpenId
(),
null
);
// 保存推客商品记录
saveSharerProductCommissionInfo
(
sharerInfo
.
getOpenId
(),
oldBo
.
getProductId
(),
sharerCommissionRatio
,
SharerProductCommission
.
UnsetEnum
.
UNSET
);
isSuccess
=
true
;
isSuccess
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
// 保存记录
// 保存记录
saveSharerProductCommissionRecord
(
sharerAppid
,
oldBo
.
getProductId
(),
saveSharerProductCommissionRecord
(
sharerInfo
.
getOpenId
(),
sharerInfo
.
getSharerAppid
(),
oldBo
.
getProductId
(),
oldBo
.
getCommissionRatio
(),
null
,
oldBo
.
getCommissionRatio
(),
null
,
CommissionChangeOptTypeEnum
.
UNSET
,
isSuccess
);
CommissionChangeOptTypeEnum
.
UNSET
,
isSuccess
);
}
}
...
@@ -422,20 +413,9 @@ public class DrmSharerConfig {
...
@@ -422,20 +413,9 @@ public class DrmSharerConfig {
/**
/**
* 保存推客商品分佣记录
* 保存推客商品分佣记录
*/
*/
private
void
saveSharerProductCommissionRecord
(
String
sharerAppid
,
String
productId
,
private
void
saveSharerProductCommissionRecord
(
String
openId
,
String
sharerAppid
,
String
productId
,
BigDecimal
oldCommissionRatio
,
BigDecimal
oldCommissionRatio
,
BigDecimal
newCommissionRatio
,
BigDecimal
newCommissionRatio
,
CommissionChangeOptTypeEnum
optTypeEnum
,
boolean
isSuccess
)
{
CommissionChangeOptTypeEnum
optTypeEnum
,
boolean
isSuccess
)
{
String
openId
=
null
;
LambdaQueryWrapper
<
SharerInfo
>
sharerInfoLqw
=
Wrappers
.
lambdaQuery
();
sharerInfoLqw
.
select
(
SharerInfo:
:
getOpenId
);
sharerInfoLqw
.
eq
(
SharerInfo:
:
getSharerAppid
,
sharerAppid
);
sharerInfoLqw
.
last
(
"LIMIT 1"
);
SharerInfo
sharerInfo
=
sharerInfoMapper
.
selectOne
(
sharerInfoLqw
);
if
(
null
!=
sharerInfo
&&
StringUtils
.
isNotBlank
(
sharerInfo
.
getOpenId
()))
{
openId
=
sharerInfo
.
getOpenId
();
}
Date
now
=
new
Date
();
Date
now
=
new
Date
();
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
record
.
setOpenId
(
openId
);
record
.
setOpenId
(
openId
);
...
@@ -487,4 +467,63 @@ public class DrmSharerConfig {
...
@@ -487,4 +467,63 @@ public class DrmSharerConfig {
sharerProductCommissionMapper
.
updateById
(
sharerProductCommission
);
sharerProductCommissionMapper
.
updateById
(
sharerProductCommission
);
}
}
}
}
/**
* 根据 openId 获取推客信息
*/
private
SharerInfo
getSharerInfoByOpenId
(
String
openId
)
{
SharerInfo
sharerInfo
=
sharerInfoMap
.
get
(
openId
);
if
(
null
==
sharerInfo
)
{
LambdaQueryWrapper
<
SharerInfo
>
sharerInfoLqw
=
Wrappers
.
lambdaQuery
();
sharerInfoLqw
.
eq
(
SharerInfo:
:
getOpenId
,
openId
);
sharerInfoLqw
.
last
(
"LIMIT 1"
);
sharerInfo
=
sharerInfoMapper
.
selectOne
(
sharerInfoLqw
);
if
(
null
!=
sharerInfo
)
{
sharerInfoMap
.
put
(
openId
,
sharerInfo
);
}
}
return
sharerInfo
;
}
/**
* 根据 openId 获取推客的 SharerAppid
*/
private
String
getSharerAppidByOpenId
(
String
openId
)
{
SharerInfo
sharerInfo
=
sharerInfoMap
.
get
(
openId
);
if
(
null
==
sharerInfo
)
{
LambdaQueryWrapper
<
SharerInfo
>
sharerInfoLqw
=
Wrappers
.
lambdaQuery
();
sharerInfoLqw
.
eq
(
SharerInfo:
:
getOpenId
,
openId
);
sharerInfoLqw
.
last
(
"LIMIT 1"
);
sharerInfo
=
sharerInfoMapper
.
selectOne
(
sharerInfoLqw
);
if
(
null
!=
sharerInfo
)
{
sharerInfoMap
.
put
(
openId
,
sharerInfo
);
}
}
return
null
!=
sharerInfo
?
sharerInfo
.
getSharerAppid
()
:
null
;
}
private
String
getOpenIdBySharerAppid
(
String
sharerAppid
)
{
LambdaQueryWrapper
<
SharerInfo
>
sharerInfoLqw
=
Wrappers
.
lambdaQuery
();
sharerInfoLqw
.
select
(
SharerInfo:
:
getOpenId
);
sharerInfoLqw
.
eq
(
SharerInfo:
:
getSharerAppid
,
sharerAppid
);
sharerInfoLqw
.
last
(
"LIMIT 1"
);
SharerInfo
sharerInfo
=
sharerInfoMapper
.
selectOne
(
sharerInfoLqw
);
if
(
null
!=
sharerInfo
&&
StringUtils
.
isNotBlank
(
sharerInfo
.
getOpenId
()))
{
return
sharerInfo
.
getOpenId
();
}
return
null
;
}
private
void
updateSharerInfo
(
SharerInfo
sharerInfo
,
String
commissionRatio
)
{
String
openId
=
sharerInfo
.
getOpenId
();
if
(
StringUtils
.
isNotBlank
(
openId
))
{
BigDecimal
sharerCommissionRatio
=
getSharerCommissionRatio
(
openId
);
commissionRatio
=
sharerCommissionRatio
.
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toPlainString
();
}
LambdaUpdateWrapper
<
SharerInfo
>
sharerInfoLuw
=
Wrappers
.
lambdaUpdate
();
sharerInfoLuw
.
set
(
SharerInfo:
:
getCommissionRatio
,
commissionRatio
);
sharerInfoLuw
.
set
(
SharerInfo:
:
getUpdateTime
,
new
Date
());
sharerInfoLuw
.
eq
(
SharerInfo:
:
getId
,
sharerInfo
.
getId
());
sharerInfoMapper
.
update
(
null
,
sharerInfoLuw
);
}
}
}
\ 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