修改 提现回调处理逻辑
This commit is contained in:
@@ -8,12 +8,19 @@ import com.sqx.modules.app.dao.UserMoneyDao;
|
||||
import com.sqx.modules.app.dao.UserMoneyDetailsDao;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.pay.dao.CashOutDao;
|
||||
import com.sqx.modules.pay.entity.CashOut;
|
||||
import com.sqx.modules.pay.service.WuyouCallbackService;
|
||||
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 com.sqx.modules.sys.entity.SysUserMoneyDetails;
|
||||
import com.sqx.modules.sys.service.SysUserMoneyDetailsService;
|
||||
import com.sqx.modules.sys.service.SysUserMoneyService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -23,81 +30,45 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Profile({"prod"})
|
||||
public class TempCashOutTask{
|
||||
public class TempCashOutTask {
|
||||
|
||||
@Resource
|
||||
private CashOutDao cashOutDao;
|
||||
@Resource
|
||||
private WuyouPay wuyouPay;
|
||||
@Resource
|
||||
private WuyouCallbackService wuyouCallbackService;
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@Autowired
|
||||
private UserMoneyDao userMoneyDao;
|
||||
@Autowired
|
||||
private SysUserMoneyDao sysUserMoneyDao;
|
||||
@Autowired
|
||||
private UserMoneyDetailsDao userMoneyDetailsDao;
|
||||
|
||||
|
||||
@Scheduled(cron = "0 0/8 * * * ? ")
|
||||
public void run() {
|
||||
logger.info("提现开始");
|
||||
List<CashOut> cashOuts = cashOutDao.selectTemp(DateUtil.offsetMinute(DateUtil.date(), 15));
|
||||
logger.info("待处理订单: {}", JSONObject.toJSONString(cashOuts));
|
||||
logger.info("定时查询提现订单 待处理订单: {}", cashOuts.size());
|
||||
|
||||
List<String> sucOrderList = new ArrayList<>();
|
||||
List<String> failOrderList = new ArrayList<>();
|
||||
for (CashOut cashOut : cashOuts) {
|
||||
try {
|
||||
BaseResp baseResp;
|
||||
// if (DateUtil.parse(cashOut.getCreateAt()).compareTo(DateUtil.parse("2025-01-06 16:50:00")) > 0) {
|
||||
baseResp = wuyouPay.queryExtractOrder(cashOut.getOrderNumber(), cashOut.getUserId(), cashOut.getUserType() != 2, cashOut.getMoney());
|
||||
// }else {
|
||||
// baseResp = wuyouPay.queryExtractOrder(cashOut.getOrderNumber(), cashOut.getMoney());
|
||||
// }
|
||||
logger.info("baseResp:{} ", JSONUtil.toJsonStr(baseResp));
|
||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))){
|
||||
logger.info("success:{} ", cashOut.getOrderNumber());
|
||||
cashOut.setState(1);
|
||||
cashOut.setOutAt(DateUtil.now());
|
||||
cashOut.setRefund(null);
|
||||
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.setOutAt(DateUtil.date().toString());
|
||||
cashOut.setState(2);
|
||||
cashOut.setRefund(baseResp.getMsg());
|
||||
cashOutDao.update(cashOut, new LambdaQueryWrapper<CashOut>().eq(CashOut::getUserId, cashOut.getUserId()).eq(CashOut::getId, cashOut.getId()));
|
||||
|
||||
UserMoneyDetails details = new UserMoneyDetails();
|
||||
details.setUserId(cashOut.getUserId());
|
||||
details.setTitle("提现失败存入余额" + cashOut.getMoney() + "元");
|
||||
details.setClassify(4);
|
||||
details.setType(1);
|
||||
details.setState(2);
|
||||
details.setMoney(new BigDecimal(cashOut.getMoney()));
|
||||
details.setContent("提现失败存入余额");
|
||||
details.setMoneyType(1);
|
||||
details.setCreateTime(DateUtil.date().toString());
|
||||
userMoneyDetailsDao.insert(details);
|
||||
BaseResp baseResp = wuyouPay.queryExtractOrder(cashOut.getOrderNumber(), cashOut.getUserId(), cashOut.getUserType() != 2, cashOut.getMoney());
|
||||
int i = wuyouCallbackService.executeExtractCallback(cashOut, baseResp);
|
||||
if (i == 1) {
|
||||
sucOrderList.add(cashOut.getOrderNumber());
|
||||
} else {
|
||||
failOrderList.add(cashOut.getOrderNumber());
|
||||
}
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
logger.error("体现定时任务查询出错", e);
|
||||
}
|
||||
}
|
||||
logger.info("提现结束");
|
||||
|
||||
logger.info("定时查询提现订单 提现结束, 成功:{}条, 失败:{}条", sucOrderList.size(), failOrderList.size());
|
||||
logger.info("定时查询提现订单 提现结束, 成功:{}, 失败:{}", JSONUtil.toJsonStr(sucOrderList), JSONUtil.toJsonStr(failOrderList));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user