|
@@ -1,11 +1,13 @@
|
|
|
package com.qs.mp.channel.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.qs.mp.channel.domain.Channel;
|
|
|
import com.qs.mp.channel.domain.ChannelBankCard;
|
|
|
import com.qs.mp.channel.domain.ChannelMoneyLog;
|
|
|
import com.qs.mp.channel.domain.ChannelWithdraw;
|
|
|
+import com.qs.mp.channel.domain.vo.ChannelWithdrawVO;
|
|
|
import com.qs.mp.channel.mapper.ChannelWithdrawMapper;
|
|
|
import com.qs.mp.channel.service.IChannelBankCardService;
|
|
|
import com.qs.mp.channel.service.IChannelMoneyLogService;
|
|
@@ -13,10 +15,14 @@ import com.qs.mp.channel.service.IChannelService;
|
|
|
import com.qs.mp.channel.service.IChannelWithdrawService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qs.mp.common.enums.ChannelMoneyEnum;
|
|
|
+import com.qs.mp.common.enums.ChannelWithdrawStatusEnum;
|
|
|
+import com.qs.mp.common.utils.LogUtil;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.Assert;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -84,4 +90,54 @@ public class ChannelWithdrawServiceImpl extends ServiceImpl<ChannelWithdrawMappe
|
|
|
// 创建提现记录
|
|
|
return rst;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ChannelWithdrawVO> listWithdrawVO(Wrapper<ChannelWithdraw> queryWrapper) {
|
|
|
+ return getBaseMapper().listWithdrawVO(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public boolean verify(ChannelWithdraw withdraw, ChannelWithdrawStatusEnum status, String verifyContent) {
|
|
|
+ if (status == ChannelWithdrawStatusEnum.FINISHED) {
|
|
|
+ boolean rtn = update(new LambdaUpdateWrapper<ChannelWithdraw>()
|
|
|
+ .set(ChannelWithdraw::getStatus, status)
|
|
|
+ .set(ChannelWithdraw::getTransferTime, new Date())
|
|
|
+ .eq(ChannelWithdraw::getId, withdraw.getId())
|
|
|
+ .eq(ChannelWithdraw::getStatus, ChannelWithdrawStatusEnum.WITHDRAWING));
|
|
|
+ Assert.isTrue(rtn, "提现申请审核通过,更新提现申请状态失败。id:" + withdraw.getId());
|
|
|
+
|
|
|
+ // 更新冻结金额
|
|
|
+ Channel channel = channelService.getById(withdraw.getChannelId());
|
|
|
+ Assert.isTrue(channel.getFrozenMoney() >= withdraw.getMoney() + withdraw.getChargeAmt(),
|
|
|
+ "提现申请审核通过,更新冻结金额时冻结金额为:" + channel.getFrozenMoney() + ",本次要释放冻结金额为:" + withdraw.getMoney() + withdraw.getChargeAmt());
|
|
|
+
|
|
|
+ boolean updateRtn = channelService.update(new LambdaUpdateWrapper<Channel>()
|
|
|
+ .set(Channel::getFrozenMoney, channel.getFrozenMoney() - withdraw.getMoney() - withdraw.getChargeAmt())
|
|
|
+ .eq(Channel::getChannelId, withdraw.getChannelId())
|
|
|
+ .eq(Channel::getFrozenMoney, channel.getFrozenMoney()));
|
|
|
+ Assert.isTrue(updateRtn, "提现申请审核通过,更新账号冻结金额。channelId:" + channel.getChannelId());
|
|
|
+ } else if (status == ChannelWithdrawStatusEnum.FAILED) {
|
|
|
+ boolean rtn = update(new LambdaUpdateWrapper<ChannelWithdraw>()
|
|
|
+ .set(ChannelWithdraw::getStatus, status)
|
|
|
+ .set(ChannelWithdraw::getVerifyContent, verifyContent)
|
|
|
+ .eq(ChannelWithdraw::getId, withdraw.getId())
|
|
|
+ .eq(ChannelWithdraw::getStatus, ChannelWithdrawStatusEnum.WITHDRAWING));
|
|
|
+ Assert.isTrue(rtn, "提现申请审核不通过,更新提现申请状态失败。id:" + withdraw.getId());
|
|
|
+
|
|
|
+ // 退回冻结金额
|
|
|
+ Channel channel = channelService.getById(withdraw.getChannelId());
|
|
|
+ Assert.isTrue(channel.getFrozenMoney() >= withdraw.getMoney() + withdraw.getChargeAmt(),
|
|
|
+ "提现申请审核不通过,解冻冻结金额时冻结金额为:" + channel.getFrozenMoney() + ",本次要解冻金额为:" + withdraw.getMoney() + withdraw.getChargeAmt());
|
|
|
+ ChannelMoneyLog moneyLog = new ChannelMoneyLog();
|
|
|
+ moneyLog.setChannelId(channel.getChannelId());
|
|
|
+ moneyLog.setType(ChannelMoneyEnum.WITHDRAW_BACK);
|
|
|
+ moneyLog.setLogMoney(withdraw.getMoney() + withdraw.getChargeAmt());
|
|
|
+ moneyLog.setBizTime(new Date());
|
|
|
+ moneyLog.setRefId(String.valueOf(withdraw.getId()));
|
|
|
+ moneyLog.setLogText(null);
|
|
|
+ channelMoneyLogService.changeMoney(moneyLog);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|