分账提现接口
This commit is contained in:
@@ -75,6 +75,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
private MkDistributionAmountFlowService distributionAmountFlowService;
|
||||
@Resource
|
||||
private MkDistributionFlowService distributionFlowService;
|
||||
@Resource
|
||||
private MkDistributionWithdrawFlowService withdrawFlowService;
|
||||
|
||||
@Resource
|
||||
private AppWxServiceImpl appWxService;
|
||||
@@ -447,9 +449,33 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
@Override
|
||||
public Boolean withdraw(long userId, MkDistributionWithdrawFlowDTO withdrawFlowDTO) {
|
||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(withdrawFlowDTO.getShopId(), userId);
|
||||
UserInfo userInfo = userInfoService.getById(shopUserInfo.getUserId());
|
||||
MkDistributionUser distributionUser = getOne(new QueryWrapper().eq(MkDistributionUser::getShopUserId, shopUserInfo.getId()));
|
||||
AssertUtil.isNull(distributionUser, "分销员不存在");
|
||||
// if (distributionUser.get)
|
||||
return null;
|
||||
if (distributionUser.getReceivedIncome().subtract(withdrawFlowDTO.getAmount()).compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new CzgException("可提现金额不足");
|
||||
}
|
||||
BigDecimal fee = withdrawFlowDTO.getAmount().multiply(BigDecimal.valueOf(0.08));
|
||||
BigDecimal finalAmount = withdrawFlowDTO.getAmount().subtract(fee);
|
||||
|
||||
MkDistributionWithdrawFlow withdrawFlow = new MkDistributionWithdrawFlow().setShopId(withdrawFlowDTO.getShopId()).setShopUserId(shopUserInfo.getId())
|
||||
.setAmount(finalAmount).setServiceFee(fee).setBillNo(IdUtil.simpleUUID()).setStatus(TableValueConstant.DistributionWithdrawFlow.Status.PENDING.getCode());
|
||||
JSONObject jsonObject = appWxService.transferBalance(userInfo.getWechatOpenId(), userInfo.getRealName(), finalAmount, "提现", withdrawFlow.getBillNo());
|
||||
withdrawFlow.setPackageInfo(jsonObject.getString("package_info"));
|
||||
return withdrawFlowService.save(withdrawFlow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> withdrawDetail(long userId, Long shopId, Long id) {
|
||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(shopId, userId);
|
||||
MkDistributionWithdrawFlow flow = withdrawFlowService.getOne(new QueryWrapper().eq(MkDistributionWithdrawFlow::getId, id).eq(MkDistributionWithdrawFlow::getShopUserId, shopUserInfo.getId()));
|
||||
AssertUtil.isNull(flow, "提现记录不存在");
|
||||
AssertUtil.isTrue(TableValueConstant.DistributionWithdrawFlow.Status.FINISH.getCode().equals(flow.getStatus()), "已经提现");
|
||||
|
||||
return Map.of(
|
||||
"mchId", appWxService.config.mchId,
|
||||
"appId", appWxService.config.appId,
|
||||
"package", flow.getPackageInfo()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user