Pu Zhibing
2025-08-01 c8b503726415980e5fa9a5ffc0e4e751eb7466e9
UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/TaskUtil.java
@@ -11,14 +11,18 @@
import com.stylefeng.guns.modular.system.service.IUserCouponRecordService;
import com.stylefeng.guns.modular.system.service.IUserInfoService;
import com.stylefeng.guns.modular.system.service.IUserMerchantCouponService;
import com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.SMSUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.SendSmsRequest;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.*;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -27,6 +31,7 @@
/**
 * 定时任务工具类
 */
@Slf4j
@Component
public class TaskUtil {
@@ -59,7 +64,6 @@
    private IUserInfoService userInfoService;
    /**
     * 每隔一分钟去处理的定时任务
     */
@@ -70,6 +74,8 @@
            userCouponRecordService.updateTimeOut();
            //修改过期的商家优惠券
            userMerchantCouponService.updateExpired();
         //处理超时未支付的订单
        } catch (Exception e) {
            e.printStackTrace();
        }
@@ -82,7 +88,6 @@
    @Scheduled(fixedRate = 1000 * 60)
    public void taskDay(){
    }
    /**
@@ -121,4 +126,44 @@
            e.printStackTrace();
        }
    }
   /**
    * 大于24小时未支付的订单
    */
   public void timoutNoPayment() {
      List<OrderPrivateCar> orderPrivateCars = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().eq("state", 7)
            .eq("isDelete", 1).eq("recoveryOrder", 0).last(" and now() >= DATE_ADD(insertTime, INTERVAL 24 HOUR)"));
      for (OrderPrivateCar orderPrivateCar : orderPrivateCars) {
         //使用备付金进行支付订单
         TradePayOffData tradePayOffData = new TradePayOffData();
         tradePayOffData.setPartnerPayId("PR" + orderPrivateCar.getId());
         tradePayOffData.setTotalFee(Double.valueOf(orderPrivateCar.getOrderMoney() * 100).intValue() + "");
         tradePayOffData.setOrderDesc("完成订单");
         PayInfo payInfo = OrderUtil.tradePayOff(tradePayOffData);
         String retCode = payInfo.getRetCode();
         if(!"000000".equals(retCode)){
            log.error("备付金支付失败:{}", payInfo.getRetMsg());
            continue;
         }
         PayInfoData data = payInfo.getData();
         String status = data.getStatus();
         if("3".equals(status)){
            log.error("备付金支付失败:{}", payInfo.getRetMsg());
            continue;
         }
         //copy原始订单后生成追缴单
         OrderPrivateCar orderPrivateCar1 = new OrderPrivateCar();
         BeanUtils.copyProperties(orderPrivateCar, orderPrivateCar1);
         orderPrivateCar1.setId(null);
         orderPrivateCar1.setRecoveryOrder(1);
         //修改原始订单为支付状态
         orderPrivateCar.setState(8);
         orderPrivateCar.setPayType(5);
         orderPrivateCar.setPayMoney(orderPrivateCar.getOrderMoney());
         orderPrivateCarService.updateById(orderPrivateCar);
         orderPrivateCarService.insert(orderPrivateCar1);
      }
   }
}