//package com.jxy.order.task;
//
//import com.jxy.common.core.utils.DateUtils;
//import com.jxy.common.core.utils.StringUtils;
//import com.jxy.common.redis.service.RedisService;
//import com.jxy.order.dto.WithdrawPraviteDto;
//import com.jxy.order.mapper.OrderMapper;
//import com.jxy.order.mapper.WithdrawMapper;
//import com.jxy.order.service.OrderService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//
//import java.util.Calendar;
//import java.util.Date;
//import java.util.List;
//
//
///**
// * @Description 超时订单定时任务
// * @Date 2022/7/7 18:03
// * @Author 杜懿
// */
//@Configuration
//@EnableScheduling
//public class ExpireOrderTask {
//
//    @Autowired
//    private OrderService orderService;
//
//    @Autowired
//    private OrderMapper orderMapper;
//
//    @Autowired
//    private WithdrawMapper withdrawMapper;
//
//
//    /** 查询超时未处理的待处理充值订单 */
//    @Scheduled(cron = "0 22 0/4 * * ?")
//    //@Scheduled(cron = "0 0/5 * * * ?")
//    public void ExpireAddCredit(){
//
//
//        //orderMapper.getAddCreditOrderByStatus();
//    }
//
//    /** 查询并处理超时未处理的待处理提现订单 */
//    //@Scheduled(cron = "0 0/5 * * * ?")
//    @Scheduled(cron = "0 0/5 * * * ?")
//    public void ExpireWithdraw(){
//        Date date = new Date();
//        Calendar calendar = Calendar.getInstance();
//        calendar.setTime(date);
//        calendar.add(Calendar.DATE,-1);
//
//        System.out.println("扫描超时订单,时间："+calendar.getTime());
//
//        List<WithdrawPraviteDto> list= withdrawMapper.getExpireNoHandleWithdrawOrder(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, calendar.getTime()));
//        System.out.println("超时提现订单有："+list);
//
//        if(list.size()>0){
//            int count = withdrawMapper.batchUpdateExpireWithdraw(list);
//            for (int i=0; i< list.size();i++) {
//                WithdrawPraviteDto dto = list.get(i);
//                orderService.updateUserAccountAfterRefuseWithdraw(dto.getUserId(), dto.getCoin(), dto.getAmount());
//            }
//            System.out.println("处理了"+count+"条超时提现订单");
//        }
//        //orderMapper.getAddCreditOrderByStatus();
//    }
//
//}
