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
7b535c89
Commit
7b535c89
authored
Mar 12, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码初始化
parent
51c8d319
Pipeline
#71429
passed with stages
in 1 minute 7 seconds
Changes
6
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
164 deletions
+24
-164
DrmSharerConfig.java
...e/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
+0
-0
ProductCommissionConfig.java
...n/wx/store/sharer/biz/config/ProductCommissionConfig.java
+0
-152
CommissionSharerBO.java
...wx/store/sharer/biz/meta/model/bo/CommissionSharerBO.java
+5
-1
CommissionSharerProductBO.java
...e/sharer/biz/meta/model/bo/CommissionSharerProductBO.java
+5
-1
UserServiceImpl.java
...uan/wx/store/sharer/biz/service/impl/UserServiceImpl.java
+10
-9
WeChatRestTemplateHandler.java
...sharer/integration/handler/WeChatRestTemplateHandler.java
+4
-1
No files found.
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/config/DrmSharerConfig.java
View file @
7b535c89
This diff is collapsed.
Click to expand it.
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/config/ProductCommissionConfig.java
deleted
100644 → 0
View file @
51c8d319
package
com
.
netease
.
yanxuan
.
wx
.
store
.
sharer
.
biz
.
config
;
import
com.alibaba.fastjson.JSON
;
import
com.ctrip.framework.apollo.model.ConfigChange
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
com.ctrip.framework.apollo.spring.annotation.EnableAutoUpdateApolloConfig
;
import
com.ctrip.framework.apollo.spring.annotation.ValueMapping
;
import
com.netease.yanxuan.wx.store.sharer.biz.core.LoginUserContextHolder
;
import
com.netease.yanxuan.wx.store.sharer.biz.core.LoginUserInfo
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.enums.CommissionChangeOptTypeEnum
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.model.bo.ProductCommissionSharerBO
;
import
com.netease.yanxuan.wx.store.sharer.biz.meta.model.bo.ProductCommissionSharerProductBO
;
import
com.netease.yanxuan.wx.store.sharer.dal.mapper.SharerProductCommissionRecordMapper
;
import
com.netease.yanxuan.wx.store.sharer.dal.meta.model.po.SharerProductCommissionRecord
;
import
lombok.Data
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* @Description 商品分佣金配置
* @Author fanjiaxin
* @Date 2025/3/10 17:26
*/
@Slf4j
@Data
@Component
@RequiredArgsConstructor
@EnableAutoUpdateApolloConfig
public
class
ProductCommissionConfig
{
private
final
SharerProductCommissionRecordMapper
sharerProdutcCommissionRecordMapper
;
/**
* 默认分佣比例
*/
@Value
(
"${application.commissionratio.default:10}"
)
private
BigDecimal
defaultCommissionRatio
;
/**
* 用户分佣比例
*/
@ValueMapping
(
"${application.commissionratio.sharer:}"
)
private
ProductCommissionSharerBO
productCommissionSharerBO
;
/**
* 用户商品分佣比例
*/
@ValueMapping
(
"${application.commissionratio.sharerproduct:}"
)
private
ProductCommissionSharerProductBO
productCommissionSharerProductBO
;
/**
* 监听
*/
@ApolloConfigChangeListener
(
"sv-channel.config"
)
public
void
onChange
(
ConfigChangeEvent
changeEvent
)
{
log
.
info
(
"ProductCommissionConfig:onChange, changeEvent = {}"
,
JSON
.
toJSONString
(
changeEvent
));
// 默认分佣比例
String
defaultCommissionratio
=
"application.commissionratio.default"
;
if
(
changeEvent
.
isChanged
(
defaultCommissionratio
))
{
ConfigChange
change
=
changeEvent
.
getChange
(
defaultCommissionratio
);
defaultCommissionratioChange
(
change
);
}
// 用户分佣比例
String
sharerCommissionratio
=
"application.commissionratio.sharer"
;
if
(
changeEvent
.
isChanged
(
sharerCommissionratio
))
{
ConfigChange
change
=
changeEvent
.
getChange
(
sharerCommissionratio
);
sharerCommissionratioChange
(
change
);
}
// 用户商品分佣比例
String
sharerproductCommissionratio
=
"application.commissionratio.sharerproduct"
;
if
(
changeEvent
.
isChanged
(
sharerproductCommissionratio
))
{
ConfigChange
change
=
changeEvent
.
getChange
(
sharerproductCommissionratio
);
sharerproductCommissionratioChange
(
change
);
}
}
/**
* 默认分佣比例变更
*/
private
void
defaultCommissionratioChange
(
ConfigChange
change
){
LoginUserInfo
loginUserInfo
=
LoginUserContextHolder
.
get
();
if
(
null
==
loginUserInfo
)
{
log
.
error
(
"用户登录状态过期"
);
return
;
}
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
record
.
setOpenId
(
loginUserInfo
.
getOpenId
());
record
.
setSharerAppid
(
loginUserInfo
.
getSharerAppId
());
record
.
setProductId
(
""
);
record
.
setOptType
(
CommissionChangeOptTypeEnum
.
DEFAULT_CHANGE
.
getCode
());
record
.
setOptInfo
(
change
.
getOldValue
()
+
"&"
+
change
.
getNewValue
());
record
.
setOptTime
(
new
Date
());
record
.
setOptStatus
(
"1"
);
record
.
setExtInfo
(
""
);
record
.
setCreateTime
(
new
Date
());
record
.
setUpdateTime
(
new
Date
());
sharerProdutcCommissionRecordMapper
.
insert
(
record
);
}
/**
* 用户分佣比例变更
*/
private
void
sharerCommissionratioChange
(
ConfigChange
change
){
LoginUserInfo
loginUserInfo
=
LoginUserContextHolder
.
get
();
if
(
null
==
loginUserInfo
)
{
log
.
error
(
"用户登录状态过期"
);
return
;
}
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
record
.
setOpenId
(
loginUserInfo
.
getOpenId
());
record
.
setSharerAppid
(
loginUserInfo
.
getSharerAppId
());
record
.
setProductId
(
""
);
record
.
setOptType
(
CommissionChangeOptTypeEnum
.
SET
.
getCode
());
record
.
setOptInfo
(
change
.
getOldValue
()
+
"&"
+
change
.
getNewValue
());
record
.
setOptTime
(
new
Date
());
record
.
setOptStatus
(
"1"
);
record
.
setExtInfo
(
""
);
record
.
setCreateTime
(
new
Date
());
record
.
setUpdateTime
(
new
Date
());
sharerProdutcCommissionRecordMapper
.
insert
(
record
);
}
/**
* 用户商品分佣比例变更
*/
private
void
sharerproductCommissionratioChange
(
ConfigChange
change
){
LoginUserInfo
loginUserInfo
=
LoginUserContextHolder
.
get
();
if
(
null
==
loginUserInfo
)
{
log
.
error
(
"用户登录状态过期"
);
return
;
}
SharerProductCommissionRecord
record
=
new
SharerProductCommissionRecord
();
record
.
setOpenId
(
loginUserInfo
.
getOpenId
());
record
.
setSharerAppid
(
loginUserInfo
.
getSharerAppId
());
record
.
setProductId
(
""
);
record
.
setOptType
(
CommissionChangeOptTypeEnum
.
SET
.
getCode
());
record
.
setOptInfo
(
change
.
getOldValue
()
+
"&"
+
change
.
getNewValue
());
record
.
setOptTime
(
new
Date
());
record
.
setOptStatus
(
"1"
);
record
.
setExtInfo
(
""
);
record
.
setCreateTime
(
new
Date
());
record
.
setUpdateTime
(
new
Date
());
sharerProdutcCommissionRecordMapper
.
insert
(
record
);
}
}
\ No newline at end of file
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/meta/model/bo/
Product
CommissionSharerBO.java
→
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/meta/model/bo/CommissionSharerBO.java
View file @
7b535c89
...
@@ -11,10 +11,14 @@ import java.math.BigDecimal;
...
@@ -11,10 +11,14 @@ import java.math.BigDecimal;
* @Date 2025/3/9 13:44
* @Date 2025/3/9 13:44
*/
*/
@Data
@Data
public
class
Product
CommissionSharerBO
implements
Serializable
{
public
class
CommissionSharerBO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1482990976577986435L
;
private
static
final
long
serialVersionUID
=
-
1482990976577986435L
;
/**
/**
* 用户ID
*/
private
String
openId
;
/**
* 推客ID
* 推客ID
*/
*/
private
String
sharerId
;
private
String
sharerId
;
...
...
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/meta/model/bo/
Product
CommissionSharerProductBO.java
→
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/meta/model/bo/CommissionSharerProductBO.java
View file @
7b535c89
...
@@ -11,10 +11,14 @@ import java.math.BigDecimal;
...
@@ -11,10 +11,14 @@ import java.math.BigDecimal;
* @Date 2025/3/9 13:44
* @Date 2025/3/9 13:44
*/
*/
@Data
@Data
public
class
Product
CommissionSharerProductBO
implements
Serializable
{
public
class
CommissionSharerProductBO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1482990976577986435L
;
private
static
final
long
serialVersionUID
=
-
1482990976577986435L
;
/**
/**
* 用户ID
*/
private
String
openId
;
/**
* 推客ID
* 推客ID
*/
*/
private
String
sharerId
;
private
String
sharerId
;
...
...
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/service/impl/UserServiceImpl.java
View file @
7b535c89
...
@@ -3,7 +3,7 @@ package com.netease.yanxuan.wx.store.sharer.biz.service.impl;
...
@@ -3,7 +3,7 @@ package com.netease.yanxuan.wx.store.sharer.biz.service.impl;
import
cn.dev33.satoken.stp.StpUtil
;
import
cn.dev33.satoken.stp.StpUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.netease.yanxuan.wx.store.sharer.biz.config.
ProductCommission
Config
;
import
com.netease.yanxuan.wx.store.sharer.biz.config.
DrmSharer
Config
;
import
com.netease.yanxuan.wx.store.sharer.biz.core.LoginUserContextHolder
;
import
com.netease.yanxuan.wx.store.sharer.biz.core.LoginUserContextHolder
;
import
com.netease.yanxuan.wx.store.sharer.biz.core.LoginUserHelper
;
import
com.netease.yanxuan.wx.store.sharer.biz.core.LoginUserHelper
;
import
com.netease.yanxuan.wx.store.sharer.biz.core.LoginUserInfo
;
import
com.netease.yanxuan.wx.store.sharer.biz.core.LoginUserInfo
;
...
@@ -18,6 +18,7 @@ import com.netease.yanxuan.wx.store.sharer.dal.meta.model.po.SharerInfo;
...
@@ -18,6 +18,7 @@ import com.netease.yanxuan.wx.store.sharer.dal.meta.model.po.SharerInfo;
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.handler.impl.WeChatSharerRegisterBindRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatSharerRegisterBindRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatUserInfoRequest
;
import
com.netease.yanxuan.wx.store.sharer.integration.handler.impl.WeChatUserInfoRequest
;
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
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatSharerRegisterBindVO
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatSharerRegisterBindVO
;
...
@@ -42,7 +43,7 @@ import java.util.Date;
...
@@ -42,7 +43,7 @@ import java.util.Date;
public
class
UserServiceImpl
implements
IUserService
{
public
class
UserServiceImpl
implements
IUserService
{
private
final
SharerInfoMapper
sharerInfoMapper
;
private
final
SharerInfoMapper
sharerInfoMapper
;
private
final
ProductCommissionConfig
productCommission
Config
;
private
final
DrmSharerConfig
drmSharer
Config
;
private
final
LoginUserHelper
jwtHelper
;
private
final
LoginUserHelper
jwtHelper
;
private
final
WeChatUserInfoRequest
weChatUserRequest
;
private
final
WeChatUserInfoRequest
weChatUserRequest
;
private
final
WeChatSharerRegisterBindRequest
weChatSharerRegisterBindRequest
;
private
final
WeChatSharerRegisterBindRequest
weChatSharerRegisterBindRequest
;
...
@@ -63,8 +64,8 @@ public class UserServiceImpl implements IUserService {
...
@@ -63,8 +64,8 @@ public class UserServiceImpl implements IUserService {
sharerInfo
=
new
SharerInfo
();
sharerInfo
=
new
SharerInfo
();
sharerInfo
.
setOpenId
(
userInfoVO
.
getOpenid
());
sharerInfo
.
setOpenId
(
userInfoVO
.
getOpenid
());
// 默认佣金比例
// 默认佣金比例
sharerInfo
.
setCommissionRatio
(
new
BigDecimal
(
10
));
sharerInfo
.
setCommissionRatio
(
drmSharerConfig
.
getDefaultCommissionRatio
(
));
sharerInfo
.
setCommissionType
(
"1"
);
sharerInfo
.
setCommissionType
(
CommissionTypeEnum
.
PLATFORM
.
getCode
()
);
sharerInfo
.
setCreateTime
(
now
);
sharerInfo
.
setCreateTime
(
now
);
sharerInfo
.
setUpdateTime
(
now
);
sharerInfo
.
setUpdateTime
(
now
);
sharerInfoMapper
.
insert
(
sharerInfo
);
sharerInfoMapper
.
insert
(
sharerInfo
);
...
@@ -97,8 +98,8 @@ public class UserServiceImpl implements IUserService {
...
@@ -97,8 +98,8 @@ public class UserServiceImpl implements IUserService {
sharerInfo
=
new
SharerInfo
();
sharerInfo
=
new
SharerInfo
();
sharerInfo
.
setOpenId
(
loginUserInfo
.
getOpenId
());
sharerInfo
.
setOpenId
(
loginUserInfo
.
getOpenId
());
// 默认佣金比例
// 默认佣金比例
sharerInfo
.
setCommissionRatio
(
new
BigDecimal
(
10
));
sharerInfo
.
setCommissionRatio
(
drmSharerConfig
.
getDefaultCommissionRatio
(
));
sharerInfo
.
setCommissionType
(
"1"
);
sharerInfo
.
setCommissionType
(
CommissionTypeEnum
.
PLATFORM
.
getCode
()
);
sharerInfo
.
setCreateTime
(
now
);
sharerInfo
.
setCreateTime
(
now
);
sharerInfo
.
setUpdateTime
(
now
);
sharerInfo
.
setUpdateTime
(
now
);
sharerInfoMapper
.
insert
(
sharerInfo
);
sharerInfoMapper
.
insert
(
sharerInfo
);
...
@@ -114,8 +115,8 @@ public class UserServiceImpl implements IUserService {
...
@@ -114,8 +115,8 @@ public class UserServiceImpl implements IUserService {
result
.
setSharerAppId
(
sharerInfoVO
.
getSharer_appid
());
result
.
setSharerAppId
(
sharerInfoVO
.
getSharer_appid
());
sharerInfo
.
setSharerAppid
(
sharerInfoVO
.
getSharer_appid
());
sharerInfo
.
setSharerAppid
(
sharerInfoVO
.
getSharer_appid
());
sharerInfo
.
setBindTime
(
new
Date
(
sharerInfoVO
.
getBind_time
()));
sharerInfo
.
setBindTime
(
new
Date
(
sharerInfoVO
.
getBind_time
()));
sharerInfo
.
setCommissionRatio
(
new
BigDecimal
(
10
));
sharerInfo
.
setCommissionRatio
(
sharerInfoVO
.
getCommission_ratio
(
));
sharerInfo
.
setCommissionType
(
"1"
);
sharerInfo
.
setCommissionType
(
sharerInfoVO
.
getCommission_type
().
toString
()
);
sharerInfo
.
setUpdateTime
(
now
);
sharerInfo
.
setUpdateTime
(
now
);
sharerInfoMapper
.
updateById
(
sharerInfo
);
sharerInfoMapper
.
updateById
(
sharerInfo
);
}
}
...
@@ -144,7 +145,7 @@ public class UserServiceImpl implements IUserService {
...
@@ -144,7 +145,7 @@ public class UserServiceImpl implements IUserService {
@Override
@Override
public
UserCommissionRatioVO
getCommissionRatioDefault
()
{
public
UserCommissionRatioVO
getCommissionRatioDefault
()
{
BigDecimal
defaultCommissionRatio
=
productCommission
Config
.
getDefaultCommissionRatio
();
BigDecimal
defaultCommissionRatio
=
drmSharer
Config
.
getDefaultCommissionRatio
();
return
UserCommissionRatioVO
.
builder
().
commissionRatio
(
defaultCommissionRatio
).
build
();
return
UserCommissionRatioVO
.
builder
().
commissionRatio
(
defaultCommissionRatio
).
build
();
}
}
...
...
yanxuan-wx-store-sharer-integration/src/main/java/com/netease/yanxuan/wx/store/sharer/integration/handler/WeChatRestTemplateHandler.java
View file @
7b535c89
...
@@ -2,6 +2,7 @@ package com.netease.yanxuan.wx.store.sharer.integration.handler;
...
@@ -2,6 +2,7 @@ package com.netease.yanxuan.wx.store.sharer.integration.handler;
import
com.netease.yanxuan.wx.store.sharer.common.exception.BizException
;
import
com.netease.yanxuan.wx.store.sharer.common.exception.BizException
;
import
com.netease.yanxuan.wx.store.sharer.common.handler.RestTemplateClient
;
import
com.netease.yanxuan.wx.store.sharer.common.handler.RestTemplateClient
;
import
com.netease.yanxuan.wx.store.sharer.integration.core.WeChatContextHolder
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatCoreVO
;
import
com.netease.yanxuan.wx.store.sharer.integration.meta.model.vo.WeChatCoreVO
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -18,9 +19,11 @@ import org.springframework.stereotype.Service;
...
@@ -18,9 +19,11 @@ import org.springframework.stereotype.Service;
@RequiredArgsConstructor
@RequiredArgsConstructor
public
class
WeChatRestTemplateHandler
{
public
class
WeChatRestTemplateHandler
{
private
final
RestTemplateClient
restTemplateClient
;
private
final
RestTemplateClient
restTemplateClient
;
private
final
WeChatContextHolder
weChatContextHolder
;
public
<
T
,
R
extends
WeChatCoreVO
>
R
execute
(
String
url
,
HttpMethod
method
,
T
params
,
Class
<
R
>
resType
)
{
public
<
T
,
R
extends
WeChatCoreVO
>
R
execute
(
String
url
,
HttpMethod
method
,
T
params
,
Class
<
R
>
resType
)
{
R
result
=
restTemplateClient
.
execute
(
url
,
method
,
params
,
resType
);
String
accessToken
=
weChatContextHolder
.
getAccessToken
();
R
result
=
restTemplateClient
.
execute
(
url
+
"?access_token="
+
accessToken
,
method
,
params
,
resType
);
if
(!
"0"
.
equals
(
result
.
getErrcode
()))
{
if
(!
"0"
.
equals
(
result
.
getErrcode
()))
{
throw
new
BizException
(
"调用微信接口失败,"
+
result
.
getErrmsg
());
throw
new
BizException
(
"调用微信接口失败,"
+
result
.
getErrmsg
());
}
}
...
...
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