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
8ba5b6c4
Commit
8ba5b6c4
authored
Mar 12, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信分佣比例计算调整*1000000
parent
cb4266dd
Pipeline
#71496
passed with stages
in 1 minute 5 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
170 additions
and
112 deletions
+170
-112
DrmSharerConfig.java
...e/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
+153
-112
SharerProductCommission.java
...ore/sharer/dal/meta/model/po/SharerProductCommission.java
+13
-0
WeChatApi.java
...nxuan/wx/store/sharer/integration/constant/WeChatApi.java
+4
-0
No files found.
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
View file @
8ba5b6c4
...
@@ -20,12 +20,16 @@ import com.netease.yanxuan.wx.store.sharer.biz.meta.enums.CommissionChangeOptTyp
...
@@ -20,12 +20,16 @@ import com.netease.yanxuan.wx.store.sharer.biz.meta.enums.CommissionChangeOptTyp
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
;
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
;
import
com.netease.yanxuan.wx.store.sharer.dal.meta.model.po.SharerInfo
;
import
com.netease.yanxuan.wx.store.sharer.dal.meta.model.po.SharerInfo
;
import
com.netease.yanxuan.wx.store.sharer.dal.meta.model.po.SharerProductCommission
;
import
com.netease.yanxuan.wx.store.sharer.dal.meta.model.po.SharerProductCommissionRecord
;
import
com.netease.yanxuan.wx.store.sharer.dal.meta.model.po.SharerProductCommissionRecord
;
import
com.netease.yanxuan.wx.store.sharer.integration.constant.WeChatApi
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatSetSharerCommissionRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatSetSharerCommissionRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatSetSharerProductCommissionRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatSetSharerProductCommissionRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatSharerListRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatSharerListRequest
;
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.WeChatSharerInfoVO
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatSharerListVO
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatSharerListVO
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -54,6 +58,7 @@ import java.util.stream.Collectors;
...
@@ -54,6 +58,7 @@ import java.util.stream.Collectors;
@EnableAutoUpdateApolloConfig
(
"sharer-config"
)
@EnableAutoUpdateApolloConfig
(
"sharer-config"
)
public
class
DrmSharerConfig
{
public
class
DrmSharerConfig
{
private
final
SharerInfoMapper
sharerInfoMapper
;
private
final
SharerInfoMapper
sharerInfoMapper
;
private
final
SharerProductCommissionMapper
sharerProductCommissionMapper
;
private
final
SharerProductCommissionRecordMapper
sharerProdutcCommissionRecordMapper
;
private
final
SharerProductCommissionRecordMapper
sharerProdutcCommissionRecordMapper
;
private
final
WeChatSharerListRequest
weChatSharerListRequest
;
private
final
WeChatSharerListRequest
weChatSharerListRequest
;
private
final
WeChatSetSharerCommissionRequest
weChatSetSharerCommissionRequest
;
private
final
WeChatSetSharerCommissionRequest
weChatSetSharerCommissionRequest
;
...
@@ -138,8 +143,8 @@ public class DrmSharerConfig {
...
@@ -138,8 +143,8 @@ public class DrmSharerConfig {
* 设置推客的的分佣类型和比例信息
* 设置推客的的分佣类型和比例信息
*/
*/
private
void
setSharerDefaultCommissionInfo
(
ConfigChange
change
,
WeChatSharerInfoVO
sharerInfoVO
)
{
private
void
setSharerDefaultCommissionInfo
(
ConfigChange
change
,
WeChatSharerInfoVO
sharerInfoVO
)
{
// 分佣比例为小数, 微信接口参数应当分佣比例*
1000
为整数
// 分佣比例为小数, 微信接口参数应当分佣比例*
倍数
为整数
BigDecimal
commissionRatio
=
new
BigDecimal
(
change
.
getNewValue
()).
divide
(
BigDecimal
.
valueOf
(
1000
));
BigDecimal
commissionRatio
=
new
BigDecimal
(
change
.
getNewValue
()).
divide
(
BigDecimal
.
valueOf
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
));
// 设置推客分佣比例
// 设置推客分佣比例
boolean
isSuccess
=
false
;
boolean
isSuccess
=
false
;
try
{
try
{
...
@@ -149,24 +154,10 @@ public class DrmSharerConfig {
...
@@ -149,24 +154,10 @@ public class DrmSharerConfig {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
LoginUserInfo
loginUserInfo
=
LoginUserContextHolder
.
get
();
// 保存记录
if
(
null
!=
loginUserInfo
)
{
saveSharerProductCommissionRecord
(
sharerInfoVO
.
getSharer_appid
(),
null
,
Date
now
=
new
Date
();
new
BigDecimal
(
change
.
getOldValue
()),
new
BigDecimal
(
change
.
getNewValue
()),
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
CommissionChangeOptTypeEnum
.
DEFAULT_CHANGE
,
isSuccess
);
record
.
setOpenId
(
loginUserInfo
.
getOpenId
());
record
.
setSharerAppid
(
sharerInfoVO
.
getSharer_appid
());
record
.
setProductId
(
""
);
record
.
setOptType
(
CommissionChangeOptTypeEnum
.
DEFAULT_CHANGE
.
getCode
());
record
.
setOptInfo
(
change
.
getOldValue
()
+
"&"
+
change
.
getNewValue
());
record
.
setOptTime
(
now
);
record
.
setOptStatus
(
isSuccess
?
"1"
:
"2"
);
record
.
setExtInfo
(
""
);
record
.
setCreateTime
(
now
);
record
.
setUpdateTime
(
now
);
sharerProdutcCommissionRecordMapper
.
insert
(
record
);
}
else
{
log
.
error
(
"用户登录状态过期,保存记录失败"
);
}
}
}
}
}
...
@@ -216,7 +207,7 @@ public class DrmSharerConfig {
...
@@ -216,7 +207,7 @@ public class DrmSharerConfig {
return
;
return
;
}
}
// 分佣比例为小数, 微信接口参数应当分佣比例*1000 为整数
// 分佣比例为小数, 微信接口参数应当分佣比例*1000 为整数
BigDecimal
commissionRatio
=
newCommissionSharer
.
getCommissionRatio
().
divide
(
BigDecimal
.
valueOf
(
1000
));
BigDecimal
commissionRatio
=
newCommissionSharer
.
getCommissionRatio
().
divide
(
BigDecimal
.
valueOf
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
));
// 设置推客分佣比例
// 设置推客分佣比例
boolean
isSuccess
=
false
;
boolean
isSuccess
=
false
;
try
{
try
{
...
@@ -226,25 +217,10 @@ public class DrmSharerConfig {
...
@@ -226,25 +217,10 @@ public class DrmSharerConfig {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
LoginUserInfo
loginUserInfo
=
LoginUserContextHolder
.
get
();
// 保存记录
if
(
null
!=
loginUserInfo
)
{
saveSharerProductCommissionRecord
(
sharerAppid
,
null
,
Date
now
=
new
Date
();
oldCommissionSharer
.
getCommissionRatio
(),
newCommissionSharer
.
getCommissionRatio
(),
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
CommissionChangeOptTypeEnum
.
SET
,
isSuccess
);
record
.
setOpenId
(
loginUserInfo
.
getOpenId
());
record
.
setSharerAppid
(
sharerAppid
);
record
.
setProductId
(
""
);
record
.
setOptType
(
CommissionChangeOptTypeEnum
.
SET
.
getCode
());
record
.
setOptInfo
(
oldCommissionSharer
.
getCommissionRatio
().
toPlainString
()
+
"&"
+
newCommissionSharer
.
getCommissionRatio
().
toPlainString
());
record
.
setOptTime
(
now
);
record
.
setOptStatus
(
isSuccess
?
"1"
:
"2"
);
record
.
setExtInfo
(
""
);
record
.
setCreateTime
(
now
);
record
.
setUpdateTime
(
now
);
sharerProdutcCommissionRecordMapper
.
insert
(
record
);
}
else
{
log
.
error
(
"用户登录状态过期,保存记录失败"
);
}
}
}
}
}
...
@@ -257,8 +233,9 @@ public class DrmSharerConfig {
...
@@ -257,8 +233,9 @@ public class DrmSharerConfig {
log
.
error
(
"微信用户暂未绑定微信小店,openId={}"
,
oldCommissionSharer
.
getOpenId
());
log
.
error
(
"微信用户暂未绑定微信小店,openId={}"
,
oldCommissionSharer
.
getOpenId
());
return
;
return
;
}
}
// 分佣比例为小数, 微信接口参数应当分佣比例*1000 为整数
// 分佣比例为小数, 微信接口参数应当分佣比例*倍数 为整数
BigDecimal
commissionRatio
=
defaultCommissionRatio
.
divide
(
BigDecimal
.
valueOf
(
1000
));
BigDecimal
sharerCommissionRatio
=
getSharerCommissionRatio
(
oldCommissionSharer
.
getOpenId
(),
null
);
BigDecimal
commissionRatio
=
sharerCommissionRatio
.
divide
(
BigDecimal
.
valueOf
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
));
// 设置推客分佣比例
// 设置推客分佣比例
boolean
isSuccess
=
false
;
boolean
isSuccess
=
false
;
try
{
try
{
...
@@ -268,24 +245,10 @@ public class DrmSharerConfig {
...
@@ -268,24 +245,10 @@ public class DrmSharerConfig {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
LoginUserInfo
loginUserInfo
=
LoginUserContextHolder
.
get
();
// 保存记录
if
(
null
!=
loginUserInfo
)
{
saveSharerProductCommissionRecord
(
sharerAppid
,
null
,
Date
now
=
new
Date
();
oldCommissionSharer
.
getCommissionRatio
(),
sharerCommissionRatio
,
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
CommissionChangeOptTypeEnum
.
UNSET
,
isSuccess
);
record
.
setOpenId
(
loginUserInfo
.
getOpenId
());
record
.
setSharerAppid
(
sharerAppid
);
record
.
setProductId
(
""
);
record
.
setOptType
(
CommissionChangeOptTypeEnum
.
UNSET
.
getCode
());
record
.
setOptInfo
(
oldCommissionSharer
.
getCommissionRatio
().
toPlainString
()
+
"&"
+
defaultCommissionRatio
.
toPlainString
());
record
.
setOptTime
(
now
);
record
.
setOptStatus
(
isSuccess
?
"1"
:
"2"
);
record
.
setExtInfo
(
""
);
record
.
setCreateTime
(
now
);
record
.
setUpdateTime
(
now
);
sharerProdutcCommissionRecordMapper
.
insert
(
record
);
}
else
{
log
.
error
(
"用户登录状态过期,保存记录失败"
);
}
}
}
}
}
...
@@ -310,10 +273,18 @@ public class DrmSharerConfig {
...
@@ -310,10 +273,18 @@ 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
)
{
...
@@ -321,15 +292,64 @@ public class DrmSharerConfig {
...
@@ -321,15 +292,64 @@ 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
();
}
}
/**
/**
* 获取推客分佣比例
*/
private
BigDecimal
getSharerCommissionRatio
(
String
openId
,
Integer
productId
)
{
Optional
<
CommissionSharerProductBO
>
sharerProductCommissionOpt
=
Optional
.
ofNullable
(
commissionSharerProductList
)
.
orElseGet
(
ArrayList:
:
new
)
.
stream
()
.
filter
(
item
->
item
.
getOpenId
().
equals
(
openId
))
.
filter
(
item
->
null
==
productId
||
item
.
getProductId
().
equals
(
productId
))
.
findFirst
();
if
(
sharerProductCommissionOpt
.
isPresent
()){
// 返回推客商品分佣
return
sharerProductCommissionOpt
.
get
().
getCommissionRatio
();
}
Optional
<
CommissionSharerBO
>
sharerCommissionOpt
=
Optional
.
ofNullable
(
commissionSharerList
)
.
orElseGet
(
ArrayList:
:
new
)
.
stream
()
.
filter
(
item
->
item
.
getOpenId
().
equals
(
openId
))
.
findFirst
();
if
(
sharerCommissionOpt
.
isPresent
()){
// 返回推客分佣
return
sharerCommissionOpt
.
get
().
getCommissionRatio
();
}
// 返回默认分佣金
return
defaultCommissionRatio
;
}
/**
* 设置推客的的分佣类型和比例信息
* 设置推客的的分佣类型和比例信息
*/
*/
private
void
setSharerProductCommissionInfo
(
CommissionSharerProductBO
newBo
,
private
void
setSharerProductCommissionInfo
(
CommissionSharerProductBO
newBo
,
...
@@ -339,8 +359,8 @@ public class DrmSharerConfig {
...
@@ -339,8 +359,8 @@ public class DrmSharerConfig {
log
.
error
(
"微信用户暂未绑定微信小店,openId={}"
,
newBo
.
getOpenId
());
log
.
error
(
"微信用户暂未绑定微信小店,openId={}"
,
newBo
.
getOpenId
());
return
;
return
;
}
}
// 分佣比例为小数, 微信接口参数应当分佣比例*
1000
为整数
// 分佣比例为小数, 微信接口参数应当分佣比例*
倍数
为整数
BigDecimal
commissionRatio
=
newBo
.
getCommissionRatio
().
divide
(
BigDecimal
.
valueOf
(
1000
));
BigDecimal
commissionRatio
=
newBo
.
getCommissionRatio
().
divide
(
BigDecimal
.
valueOf
(
WeChatApi
.
WECHAT_COMMISSION_RATIO_MULTIPLIER
));
// 设置推客分佣比例
// 设置推客分佣比例
boolean
isSuccess
=
false
;
boolean
isSuccess
=
false
;
try
{
try
{
...
@@ -350,25 +370,10 @@ public class DrmSharerConfig {
...
@@ -350,25 +370,10 @@ public class DrmSharerConfig {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
LoginUserInfo
loginUserInfo
=
LoginUserContextHolder
.
get
();
// 保存记录
if
(
null
!=
loginUserInfo
)
{
saveSharerProductCommissionRecord
(
sharerAppid
,
oldBo
.
getProductId
(),
Date
now
=
new
Date
();
oldBo
.
getCommissionRatio
(),
newBo
.
getCommissionRatio
(),
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
CommissionChangeOptTypeEnum
.
SET
,
isSuccess
);
record
.
setOpenId
(
loginUserInfo
.
getOpenId
());
record
.
setSharerAppid
(
sharerAppid
);
record
.
setProductId
(
newBo
.
getProductId
().
toString
());
record
.
setOptType
(
CommissionChangeOptTypeEnum
.
SET
.
getCode
());
record
.
setOptInfo
(
oldBo
.
getCommissionRatio
().
toPlainString
()
+
"&"
+
newBo
.
getCommissionRatio
().
toPlainString
());
record
.
setOptTime
(
now
);
record
.
setOptStatus
(
isSuccess
?
"1"
:
"2"
);
record
.
setExtInfo
(
""
);
record
.
setCreateTime
(
now
);
record
.
setUpdateTime
(
now
);
sharerProdutcCommissionRecordMapper
.
insert
(
record
);
}
else
{
log
.
error
(
"用户登录状态过期,保存记录失败"
);
}
}
}
}
}
...
@@ -390,42 +395,79 @@ public class DrmSharerConfig {
...
@@ -390,42 +395,79 @@ public class DrmSharerConfig {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
log
.
error
(
"设置推客的的分佣类型和比例信息失败"
,
e
);
}
finally
{
}
finally
{
LoginUserInfo
loginUserInfo
=
LoginUserContextHolder
.
get
();
// 保存记录
if
(
null
!=
loginUserInfo
)
{
saveSharerProductCommissionRecord
(
sharerAppid
,
oldBo
.
getProductId
(),
Date
now
=
new
Date
();
oldBo
.
getCommissionRatio
(),
null
,
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
CommissionChangeOptTypeEnum
.
UNSET
,
isSuccess
);
record
.
setOpenId
(
loginUserInfo
.
getOpenId
());
record
.
setSharerAppid
(
sharerAppid
);
record
.
setProductId
(
oldBo
.
getProductId
().
toString
());
record
.
setOptType
(
CommissionChangeOptTypeEnum
.
UNSET
.
getCode
());
record
.
setOptInfo
(
oldBo
.
getCommissionRatio
().
toPlainString
()
+
"&"
);
record
.
setOptTime
(
now
);
record
.
setOptStatus
(
isSuccess
?
"1"
:
"2"
);
record
.
setExtInfo
(
""
);
record
.
setCreateTime
(
now
);
record
.
setUpdateTime
(
now
);
sharerProdutcCommissionRecordMapper
.
insert
(
record
);
}
else
{
log
.
error
(
"用户登录状态过期,保存记录失败"
);
}
}
}
}
}
/**
/**
*
根据 openId 获取推客的 SharerAppid
*
保存推客商品分佣记录
*/
*/
private
String
getSharerAppidByOpenId
(
String
openId
)
{
private
void
saveSharerProductCommissionRecord
(
String
sharerAppid
,
Integer
productId
,
String
sharerAppid
=
sharerAppidMap
.
get
(
openId
);
BigDecimal
oldCommissionRatio
,
BigDecimal
newCommissionRatio
,
CommissionChangeOptTypeEnum
optTypeEnum
,
boolean
isSuccess
)
{
LoginUserInfo
loginUserInfo
=
LoginUserContextHolder
.
get
();
if
(
null
!=
loginUserInfo
)
{
Date
now
=
new
Date
();
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
record
.
setOpenId
(
loginUserInfo
.
getOpenId
());
record
.
setSharerAppid
(
sharerAppid
);
record
.
setProductId
(
null
!=
productId
?
productId
.
toString
()
:
""
);
record
.
setOptType
(
optTypeEnum
.
getCode
());
record
.
setOptInfo
(
oldCommissionRatio
.
toPlainString
()
+
"&"
+
(
null
==
newCommissionRatio
?
""
:
newCommissionRatio
.
toPlainString
()));
record
.
setOptTime
(
now
);
record
.
setOptStatus
(
isSuccess
?
"1"
:
"2"
);
record
.
setExtInfo
(
""
);
record
.
setCreateTime
(
now
);
record
.
setUpdateTime
(
now
);
sharerProdutcCommissionRecordMapper
.
insert
(
record
);
}
else
{
log
.
error
(
"用户登录状态过期,保存记录失败"
);
}
}
/**
* 保存推客商品分佣金表
*/
private
void
saveSharerProductCommissionInfo
(
String
openId
,
Integer
productId
,
BigDecimal
commissionRatio
,
SharerProductCommission
.
UnsetEnum
unsetEnum
)
{
String
sharerAppid
=
getSharerAppidByOpenId
(
openId
);
if
(
StringUtils
.
isBlank
(
sharerAppid
))
{
if
(
StringUtils
.
isBlank
(
sharerAppid
))
{
LambdaQueryWrapper
<
SharerInfo
>
sharerInfoLqw
=
Wrappers
.
lambdaQuery
();
log
.
error
(
"微信用户暂未绑定微信小店,openId={}"
,
openId
);
sharerInfoLqw
.
eq
(
SharerInfo:
:
getOpenId
,
openId
);
return
;
sharerInfoLqw
.
last
(
"LIMIT 1"
);
}
SharerInfo
sharerInfo
=
sharerInfoMapper
.
selectOne
(
sharerInfoLqw
);
LambdaQueryWrapper
<
SharerProductCommission
>
lqw
=
Wrappers
.
lambdaQuery
();
if
(
null
!=
sharerInfo
&&
StringUtils
.
isNotBlank
(
sharerInfo
.
getSharerAppid
()))
{
lqw
.
eq
(
SharerProductCommission:
:
getOpenId
,
openId
);
sharerAppid
=
sharerInfo
.
getSharerAppid
();
lqw
.
eq
(
SharerProductCommission:
:
getProductId
,
productId
);
sharerAppidMap
.
put
(
openId
,
sharerAppid
);
lqw
.
last
(
"LIMIT 1"
);
}
SharerProductCommission
sharerProductCommission
=
sharerProductCommissionMapper
.
selectOne
(
lqw
);
Date
now
=
new
Date
();
if
(
null
==
sharerProductCommission
)
{
sharerProductCommission
=
new
SharerProductCommission
();
sharerProductCommission
.
setOpenId
(
openId
);
sharerProductCommission
.
setSharerAppid
(
sharerAppid
);
sharerProductCommission
.
setProductId
(
productId
.
toString
());
sharerProductCommission
.
setCommissionRatio
(
commissionRatio
);
sharerProductCommission
.
setCommissionType
(
CommissionTypeEnum
.
PLATFORM
.
getCode
());
sharerProductCommission
.
setUnset
(
unsetEnum
.
getCode
());
sharerProductCommission
.
setCreateTime
(
now
);
sharerProductCommission
.
setUpdateTime
(
now
);
sharerProductCommissionMapper
.
insert
(
sharerProductCommission
);
}
else
{
sharerProductCommission
.
setSharerAppid
(
sharerAppid
);
sharerProductCommission
.
setCommissionRatio
(
commissionRatio
);
sharerProductCommission
.
setCommissionType
(
CommissionTypeEnum
.
PLATFORM
.
getCode
());
sharerProductCommission
.
setUnset
(
unsetEnum
.
getCode
());
sharerProductCommission
.
setUpdateTime
(
now
);
sharerProductCommissionMapper
.
updateById
(
sharerProductCommission
);
}
}
return
sharerAppid
;
}
}
}
}
\ No newline at end of file
yanxuan-wx-store-sharer-dal/src/main/java/com/netease/yanxuan/wx/store/sharer/dal/meta/model/po/SharerProductCommission.java
View file @
8ba5b6c4
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
...
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
...
@@ -57,5 +59,16 @@ public class SharerProductCommission implements Serializable {
...
@@ -57,5 +59,16 @@ public class SharerProductCommission implements Serializable {
* 更新时间
* 更新时间
*/
*/
private
Date
updateTime
;
private
Date
updateTime
;
@Getter
@RequiredArgsConstructor
public
enum
UnsetEnum
{
UNSET
(
"1"
,
"未配置,取默认佣金比例"
),
SET
(
"0"
,
"已配置"
);
private
final
String
code
;
private
final
String
desc
;
}
}
}
yanxuan-wx-store-sharer-integration/src/main/java/com/netease/yanxuan/wx/store/sharer/integration/constant/WeChatApi.java
View file @
8ba5b6c4
...
@@ -7,6 +7,10 @@ package com.netease.yanxuan.wx.store.sharer.integration.constant;
...
@@ -7,6 +7,10 @@ package com.netease.yanxuan.wx.store.sharer.integration.constant;
*/
*/
public
class
WeChatApi
{
public
class
WeChatApi
{
public
static
final
String
WECHAT_REQUEST_SUCCESS_CODE
=
"0"
;
public
static
final
String
WECHAT_REQUEST_SUCCESS_CODE
=
"0"
;
/**
* 微信分佣倍数
*/
public
static
final
int
WECHAT_COMMISSION_RATIO_MULTIPLIER
=
1000000
;
/**
/**
* 获取用户认证信息
* 获取用户认证信息
...
...
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