package com.limap.core.basic.service.impl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.limap.core.basic.domain.AquPayDevice;
import com.limap.core.basic.domain.AquPayOrder;
import com.limap.core.basic.mapper.AquPayOrderMapper;
import com.limap.core.basic.service.IAquPayOrderService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.Duration;
import java.util.List;
import java.util.Date;

/**
 * 分润记录Service业务层处理
 *
 * @author jjb
 * @date 2025-04-11
 */
@Service
@DS("test")
public class AquPayOrderServiceImpl extends ServiceImpl<AquPayOrderMapper, AquPayOrder> implements IAquPayOrderService {
    @Autowired
    private AquPayOrderMapper aquPayOrderMapper;


    /**
     * 查询指定小时内的支付订单
     *
     * @param hour 小时内的订单
     * @return 支付订单列表
     */
    @Override
    public List<AquPayOrder> selectByHour(Integer hour) {
        Date date = new Date(System.currentTimeMillis() - Duration.ofHours(hour).toMillis());
        return this.list(new QueryWrapper<AquPayOrder>().eq("OrderStatus",2).between("SuccessTime", date,new Date()));
    }

    @Override
    public List<AquPayDevice> selectInfoByHour(Integer hour) {
        return aquPayOrderMapper.selectInfoByHour(hour);
    }

    @Override
    public List<AquPayDevice> selectInfoForBackfill(Integer hour) {
        return aquPayOrderMapper.selectInfoForBackfill(hour);
    }

    @Override
    public void updatePayDeviceStatus(List<AquPayDevice> list) {
        aquPayOrderMapper.updatePayDeviceStatus(list);
    }

    @Override
    public void dealRechargeWarnCode() {
        aquPayOrderMapper.dealRechargeWarnCode();
    }
}
