提现定时任务失败返还余额
This commit is contained in:
@@ -3,12 +3,17 @@ package com.sqx.modules.job.task;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.sqx.modules.app.dao.UserMoneyDao;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.pay.dao.CashOutDao;
|
||||
import com.sqx.modules.pay.entity.CashOut;
|
||||
import com.sqx.modules.pay.wuyou.BaseResp;
|
||||
import com.sqx.modules.pay.wuyou.WuyouPay;
|
||||
import com.sqx.modules.sys.dao.SysUserMoneyDao;
|
||||
import com.sqx.modules.sys.entity.SysUserMoney;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -24,6 +29,10 @@ public class TempCashOutTask{
|
||||
private WuyouPay wuyouPay;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@Autowired
|
||||
private UserMoneyDao userMoneyDao;
|
||||
@Autowired
|
||||
private SysUserMoneyDao sysUserMoneyDao;
|
||||
|
||||
@Scheduled(cron = "0 0/8 * * * ? ")
|
||||
public void run() {
|
||||
@@ -46,7 +55,21 @@ public class TempCashOutTask{
|
||||
cashOut.setOutAt(DateUtil.now());
|
||||
cashOutDao.update(cashOut, new LambdaQueryWrapper<CashOut>().eq(CashOut::getUserId, cashOut.getUserId()).eq(CashOut::getId, cashOut.getId()));
|
||||
}else if (baseResp.getStatus() != null && (baseResp.getStatus().equals(3) || baseResp.getStatus().equals(99999)) ){
|
||||
logger.info("提现失败, 返还余额, 用户: {}, {}, 金额: {}", cashOut.getUserId(), cashOut.getUserName(), cashOut.getMoney());
|
||||
if (cashOut.getUserType() != null && cashOut.getUserType().equals(2)) {
|
||||
SysUserMoney sysUserMoney = sysUserMoneyDao.selectOne(new LambdaQueryWrapper<SysUserMoney>().eq(SysUserMoney::getUserId, cashOut.getUserId()));
|
||||
if (sysUserMoney != null) {
|
||||
sysUserMoneyDao.incrMoney(cashOut.getMoney(), cashOut.getUserId());
|
||||
}
|
||||
}else {
|
||||
UserMoney userMoney = userMoneyDao.selectOne(new LambdaQueryWrapper<UserMoney>().eq(UserMoney::getUserId, cashOut.getUserId()));
|
||||
if (userMoney != null) {
|
||||
userMoneyDao.incrMoney(cashOut.getMoney(), cashOut.getUserId());
|
||||
}
|
||||
}
|
||||
|
||||
cashOut.setState(2);
|
||||
cashOut.setRefund(baseResp.getMsg());
|
||||
cashOutDao.update(cashOut, new LambdaQueryWrapper<CashOut>().eq(CashOut::getUserId, cashOut.getUserId()).eq(CashOut::getId, cashOut.getId()));
|
||||
}
|
||||
}catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user