Commit e4c6aa40 by fanjiaxin

刷新用户信息接口加入已经绑定判断,已绑定不去更新分佣比例

parent 9de611df
Pipeline #72600 passed with stages
in 1 minute 10 seconds
...@@ -30,9 +30,4 @@ public interface IUserService { ...@@ -30,9 +30,4 @@ public interface IUserService {
* 查询平台默认的分佣比例 * 查询平台默认的分佣比例
*/ */
UserCommissionRatioVO getCommissionRatioDefault(); UserCommissionRatioVO getCommissionRatioDefault();
/**
* 绑定平台默认的分佣比例
*/
void bindCommissionRatioDefault();
} }
...@@ -11,7 +11,6 @@ import com.netease.yanxuan.wx.store.sharer.biz.meta.model.vo.SharerInfoVO; ...@@ -11,7 +11,6 @@ import com.netease.yanxuan.wx.store.sharer.biz.meta.model.vo.SharerInfoVO;
import com.netease.yanxuan.wx.store.sharer.biz.meta.model.vo.UserCommissionRatioVO; import com.netease.yanxuan.wx.store.sharer.biz.meta.model.vo.UserCommissionRatioVO;
import com.netease.yanxuan.wx.store.sharer.biz.meta.model.vo.UserTokenVO; import com.netease.yanxuan.wx.store.sharer.biz.meta.model.vo.UserTokenVO;
import com.netease.yanxuan.wx.store.sharer.biz.service.IUserService; import com.netease.yanxuan.wx.store.sharer.biz.service.IUserService;
import com.netease.yanxuan.wx.store.sharer.common.exception.NoBindSharerException;
import com.netease.yanxuan.wx.store.sharer.common.exception.WeChatException; import com.netease.yanxuan.wx.store.sharer.common.exception.WeChatException;
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.meta.model.po.SharerInfo; import com.netease.yanxuan.wx.store.sharer.dal.meta.model.po.SharerInfo;
...@@ -114,8 +113,9 @@ public class UserServiceImpl implements IUserService { ...@@ -114,8 +113,9 @@ public class UserServiceImpl implements IUserService {
Date now = new Date(); Date now = new Date();
// 用户分佣比例 // 用户分佣比例
BigDecimal sharerCommissionRatio = drmSharerConfig.getSharerCommissionRatioOrDefault(loginUserInfo.getOpenId()); BigDecimal sharerCommissionRatio = drmSharerConfig.getSharerCommissionRatioOrDefault(loginUserInfo.getOpenId());
// 已绑定 // 推客ID为空,则需要更新推客信息
if (SharerInfoVO.bindStatus.BIND.getCode().equals(result.getBindStatus())) { if (StringUtils.isBlank(sharerInfo.getSharerAppid())
&& SharerInfoVO.bindStatus.BIND.getCode().equals(result.getBindStatus())) {
// 获取绑定信息 // 获取绑定信息
WeChatSharerListVO sharerListVO = weChatShopSharerListRequest.handle(loginUserInfo.getOpenId(), "", 1); WeChatSharerListVO sharerListVO = weChatShopSharerListRequest.handle(loginUserInfo.getOpenId(), "", 1);
if (null != sharerListVO && !CollectionUtils.isEmpty(sharerListVO.getSharer_info_list())) { if (null != sharerListVO && !CollectionUtils.isEmpty(sharerListVO.getSharer_info_list())) {
...@@ -134,15 +134,15 @@ public class UserServiceImpl implements IUserService { ...@@ -134,15 +134,15 @@ 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());
Date bindTime = null != sharerInfoVO.getBind_time() ? new Date(sharerInfoVO.getBind_time()) : now; sharerInfo.setBindTime(now);
sharerInfo.setBindTime(bindTime);
// 微信分佣比例倍数 // 微信分佣比例倍数
BigDecimal wechatMultiplier = new BigDecimal(WeChatApi.WECHAT_COMMISSION_RATIO_MULTIPLIER); BigDecimal wechatMultiplier = new BigDecimal(WeChatApi.WECHAT_COMMISSION_RATIO_MULTIPLIER);
BigDecimal commissionRatio = sharerInfoVO.getCommission_ratio() BigDecimal commissionRatio = sharerInfoVO.getCommission_ratio()
.divide(wechatMultiplier) .divide(wechatMultiplier)
.setScale(2, RoundingMode.HALF_UP); .setScale(2, RoundingMode.HALF_UP);
sharerInfo.setCommissionRatio(commissionRatio.toPlainString()); sharerInfo.setCommissionRatio(commissionRatio.toPlainString());
Integer commissionType = null != sharerInfoVO.getCommission_type() ? sharerInfoVO.getCommission_type() : CommissionTypeEnum.PLATFORM.getCode(); Integer commissionType = null != sharerInfoVO.getCommission_type()
? sharerInfoVO.getCommission_type() : CommissionTypeEnum.PLATFORM.getCode();
sharerInfo.setCommissionType(commissionType); sharerInfo.setCommissionType(commissionType);
// 刷新缓存 // 刷新缓存
loginUserHelper.setLoginUserInfo(loginUserInfo.getAccessToken(), sharerInfoVO.getSharer_appid()); loginUserHelper.setLoginUserInfo(loginUserInfo.getAccessToken(), sharerInfoVO.getSharer_appid());
...@@ -185,23 +185,6 @@ public class UserServiceImpl implements IUserService { ...@@ -185,23 +185,6 @@ public class UserServiceImpl implements IUserService {
return UserCommissionRatioVO.builder().commissionRatio(defaultCommissionRatio).build(); return UserCommissionRatioVO.builder().commissionRatio(defaultCommissionRatio).build();
} }
@Override
public void bindCommissionRatioDefault() {
// 获取用户信息
LoginUserInfo loginUserInfo = LoginUserContextHolder.get();
if (StringUtils.isBlank(loginUserInfo.getSharerAppId())) {
throw new NoBindSharerException("未绑定推客");
}
log.info("op:bindCommissionRatioDefault:setSharerCommission,openId:{}", loginUserInfo.getOpenId());
BigDecimal sharerCommissionRatio = drmSharerConfig.getSharerCommissionRatioOrDefault(loginUserInfo.getOpenId());
BigDecimal commissionRatio = sharerCommissionRatio
.multiply(new BigDecimal(WeChatApi.WECHAT_COMMISSION_RATIO_MULTIPLIER))
.setScale(0, RoundingMode.DOWN);
// 设置推客分佣比例
weChatShopSetSharerCommissionRequest.handle(loginUserInfo.getSharerAppId(),
commissionRatio.longValue());
}
private SharerInfoVO getSharerRegisterBindInfo(String openId) { private SharerInfoVO getSharerRegisterBindInfo(String openId) {
// 获取推客注册与绑定信息 // 获取推客注册与绑定信息
WeChatSharerRegisterBindVO sharerRegisterBindVO = weChatShopSharerRegisterBindRequest.handle(openId); WeChatSharerRegisterBindVO sharerRegisterBindVO = weChatShopSharerRegisterBindRequest.handle(openId);
......
...@@ -63,14 +63,4 @@ public class UserController extends BaseController { ...@@ -63,14 +63,4 @@ public class UserController extends BaseController {
UserCommissionRatioVO result = iUserService.getCommissionRatioDefault(); UserCommissionRatioVO result = iUserService.getCommissionRatioDefault();
return Result.ok(result); return Result.ok(result);
} }
/**
* 绑定平台默认的分佣比例
*/
@PostMapping("/bindCommissionRatioDefault")
public Result<UserCommissionRatioVO> bindCommissionRatioDefault() {
log.info("[op:bindCommissionRatioDefault] bind ratioDefault bind");
iUserService.bindCommissionRatioDefault();
return Result.ok();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment