|
@@ -4,12 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.qs.mp.channel.domain.Channel;
|
|
import com.qs.mp.channel.domain.Channel;
|
|
import com.qs.mp.channel.domain.ChannelBankCard;
|
|
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.ChannelWithdraw;
|
|
import com.qs.mp.channel.mapper.ChannelWithdrawMapper;
|
|
import com.qs.mp.channel.mapper.ChannelWithdrawMapper;
|
|
import com.qs.mp.channel.service.IChannelBankCardService;
|
|
import com.qs.mp.channel.service.IChannelBankCardService;
|
|
|
|
+import com.qs.mp.channel.service.IChannelMoneyLogService;
|
|
import com.qs.mp.channel.service.IChannelService;
|
|
import com.qs.mp.channel.service.IChannelService;
|
|
import com.qs.mp.channel.service.IChannelWithdrawService;
|
|
import com.qs.mp.channel.service.IChannelWithdrawService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qs.mp.common.enums.ChannelMoneyBizTypeEnum;
|
|
|
|
+import com.qs.mp.common.enums.ChannelMoneyEnum;
|
|
|
|
+import java.util.Date;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -31,6 +36,9 @@ public class ChannelWithdrawServiceImpl extends ServiceImpl<ChannelWithdrawMappe
|
|
@Autowired
|
|
@Autowired
|
|
private IChannelService channelService;
|
|
private IChannelService channelService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IChannelMoneyLogService channelMoneyLogService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public boolean apply(Channel channel, ChannelWithdraw channelWithdraw) {
|
|
public boolean apply(Channel channel, ChannelWithdraw channelWithdraw) {
|
|
@@ -51,14 +59,34 @@ public class ChannelWithdrawServiceImpl extends ServiceImpl<ChannelWithdrawMappe
|
|
bankCard.setUserName(channelWithdraw.getUserName());
|
|
bankCard.setUserName(channelWithdraw.getUserName());
|
|
channelBankCardService.updateById(bankCard);
|
|
channelBankCardService.updateById(bankCard);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ boolean rst = save(channelWithdraw);
|
|
// 冻结账户余额,乐观锁
|
|
// 冻结账户余额,乐观锁
|
|
channelService.update(new LambdaUpdateWrapper<Channel>()
|
|
channelService.update(new LambdaUpdateWrapper<Channel>()
|
|
.set(Channel::getFrozenMoney, channel.getFrozenMoney() + channelWithdraw.getMoney())
|
|
.set(Channel::getFrozenMoney, channel.getFrozenMoney() + channelWithdraw.getMoney())
|
|
.set(Channel::getMoney, channel.getMoney() - channelWithdraw.getMoney())
|
|
.set(Channel::getMoney, channel.getMoney() - channelWithdraw.getMoney())
|
|
.eq(Channel::getChannelId, channel.getChannelId()).eq(Channel::getMoney, channel.getMoney()));
|
|
.eq(Channel::getChannelId, channel.getChannelId()).eq(Channel::getMoney, channel.getMoney()));
|
|
|
|
|
|
|
|
+ ChannelMoneyLog moneyLog = new ChannelMoneyLog();
|
|
|
|
+ moneyLog.setChannelId(channel.getChannelId());
|
|
|
|
+ moneyLog.setType(ChannelMoneyEnum.WITHDRAW);
|
|
|
|
+ moneyLog.setLogMoney(channelWithdraw.getMoney());
|
|
|
|
+ moneyLog.setBizTime(new Date());
|
|
|
|
+ moneyLog.setRefType(ChannelMoneyBizTypeEnum.WITHDRAW);
|
|
|
|
+ moneyLog.setRefId(String.valueOf(channelWithdraw.getId()));
|
|
|
|
+ channelMoneyLogService.changeMoney(moneyLog);
|
|
|
|
+
|
|
|
|
+ if (channelWithdraw.getChargeAmt() > 0) {
|
|
|
|
+ // 手续费
|
|
|
|
+ ChannelMoneyLog feeMoneyLog = new ChannelMoneyLog();
|
|
|
|
+ feeMoneyLog.setChannelId(channel.getChannelId());
|
|
|
|
+ feeMoneyLog.setType(ChannelMoneyEnum.WITHDRAW_FEE);
|
|
|
|
+ feeMoneyLog.setLogMoney(channelWithdraw.getChargeAmt());
|
|
|
|
+ feeMoneyLog.setBizTime(new Date());
|
|
|
|
+ feeMoneyLog.setRefType(ChannelMoneyBizTypeEnum.WITHDRAW);
|
|
|
|
+ feeMoneyLog.setRefId(String.valueOf(channelWithdraw.getId()));
|
|
|
|
+ channelMoneyLogService.changeMoney(moneyLog);
|
|
|
|
+ }
|
|
// 创建提现记录
|
|
// 创建提现记录
|
|
- return save(channelWithdraw);
|
|
|
|
|
|
+ return rst;
|
|
}
|
|
}
|
|
}
|
|
}
|