1.cashOut定时任务修改
This commit is contained in:
@@ -2,12 +2,14 @@ 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.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 org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -23,19 +25,32 @@ public class TempCashOutTask{
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
public void run(String params) {
|
||||
@Scheduled(cron = "0 0/8 * * * ? ")
|
||||
public void run() {
|
||||
logger.info("提现开始");
|
||||
List<CashOut> cashOuts = cashOutDao.selectTemp();
|
||||
List<CashOut> cashOuts = cashOutDao.selectTemp(DateUtil.offsetMinute(DateUtil.date(), 5));
|
||||
for (CashOut cashOut : cashOuts) {
|
||||
BaseResp baseResp = wuyouPay.queryExtractOrder(cashOut.getOrderNumber(), cashOut.getUserId(), cashOut.getUserType() != 2, 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.updateById(cashOut);
|
||||
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)) {
|
||||
cashOut.setState(2);
|
||||
cashOutDao.update(cashOut, new LambdaQueryWrapper<CashOut>().eq(CashOut::getUserId, cashOut.getUserId()).eq(CashOut::getId, cashOut.getId()));
|
||||
}
|
||||
}catch (Exception e) {
|
||||
logger.error("体现定时任务查询出错", e);
|
||||
}
|
||||
}
|
||||
logger.info("提现结束");
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.sqx.modules.pay.dao;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.pay.entity.CashOut;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -22,7 +23,7 @@ public interface CashOutDao extends BaseMapper<CashOut> {
|
||||
|
||||
List<CashOut> selectYesterday();
|
||||
|
||||
List<CashOut> selectTemp();
|
||||
List<CashOut> selectTemp(@Param("time")DateTime time);
|
||||
|
||||
Double selectCashOutSum(@Param("userId") Long userId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<select id="selectTemp" resultType="com.sqx.modules.pay.entity.CashOut">
|
||||
SELECT * FROM cash_out
|
||||
WHERE
|
||||
state = 0 and order_number is not null and order_number != ''
|
||||
(state = 0 or state=4) and order_number is not null and order_number != '' and create_at < #{time}
|
||||
</select>
|
||||
|
||||
<select id="selectCashOutSum" resultType="Double">
|
||||
|
||||
Reference in New Issue
Block a user