|
@@ -88,12 +88,23 @@ public class ChannelWithdrawController extends BaseApiController {
|
|
|
@ApiOperation(value = "提现" , notes = "提现计费")
|
|
|
public AjaxResult settle(@Valid @RequestBody ChannelWithdrawParam param) {
|
|
|
String feeRateValue = configService.selectConfigByKey(FEE_RATE_CONFIG_KEY);
|
|
|
- BigDecimal feeRate = new BigDecimal(StringUtils.isNotBlank(feeRateValue) ? feeRateValue : FEE_RATE_DEFAULT_VALUE);
|
|
|
+ BigDecimal feeRate = new BigDecimal(
|
|
|
+ StringUtils.isNotBlank(feeRateValue) ? feeRateValue : FEE_RATE_DEFAULT_VALUE);
|
|
|
Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+ Channel channel = channelService.getById(channelId);
|
|
|
+ if (channel.getMoney() < 50000) {
|
|
|
+ return AjaxResult.error("账户余额不足500元");
|
|
|
+ }
|
|
|
+ int feeAmt = new BigDecimal(param.getMoney()).multiply(feeRate)
|
|
|
+ .divide(new BigDecimal(100), 0, RoundingMode.HALF_UP).intValue();
|
|
|
ChannelWithdraw channelWithdraw = new ChannelWithdraw();
|
|
|
- channelWithdraw.setMoney(param.getMoney());
|
|
|
- BigDecimal feeAmt = new BigDecimal(param.getMoney()).multiply(feeRate).divide(new BigDecimal(100), 2, RoundingMode.DOWN);
|
|
|
- channelWithdraw.setChargeAmt(feeAmt.intValue());
|
|
|
+ if (param.getMoney() + feeAmt > channel.getMoney()) {
|
|
|
+ channelWithdraw.setMoney(new BigDecimal(channel.getMoney()).divide(new BigDecimal(1).add(feeRate.divide(new BigDecimal(100), 4, RoundingMode.HALF_UP)), 0, RoundingMode.HALF_UP).intValue());
|
|
|
+ channelWithdraw.setChargeAmt(channel.getMoney() - channelWithdraw.getMoney());
|
|
|
+ } else {
|
|
|
+ channelWithdraw.setMoney(param.getMoney());
|
|
|
+ channelWithdraw.setChargeAmt(feeAmt);
|
|
|
+ }
|
|
|
channelWithdraw.setUserName(param.getUserName());
|
|
|
channelWithdraw.setCardNo(param.getCardNo());
|
|
|
channelWithdraw.setBranchName(param.getBranchName());
|
|
@@ -119,12 +130,12 @@ public class ChannelWithdrawController extends BaseApiController {
|
|
|
return AjaxResult.error("申请已过期,请重新提交");
|
|
|
}
|
|
|
Channel channel = channelService.getById(channelId);
|
|
|
- if (channelWithdraw.getMoney() > channel.getMoney() ) {
|
|
|
+ if (channelWithdraw.getMoney() + channelWithdraw.getChargeAmt() > channel.getMoney() ) {
|
|
|
return AjaxResult.error("提现金额超出账户余额");
|
|
|
}
|
|
|
|
|
|
channelWithdraw.setChannelId(channelId);
|
|
|
- channelWithdraw.setLogMoney(channel.getMoney());
|
|
|
+ channelWithdraw.setAvailableMoney(channel.getMoney());
|
|
|
|
|
|
channelWithdrawService.apply(channel, channelWithdraw);
|
|
|
|