package com.cyksj.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cyksj.model.entity.AppleAutoRegisterData;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/*
 *项目名: netflix
 *文件名: AppleAutoRegisterDataMapper
 *创建者: JavaZou
 *创建时间:2022/11/22 16:15
 */
public interface AppleAutoRegisterDataMapper extends BaseMapper<AppleAutoRegisterData> {
	@Select("select count(*)" +
			" from apple_auto_register_data" +
			" where status is false and country_or_area = #{countryOrArea}")
	Integer selectAreaDataView(AppleAutoRegisterData.CountryOrArea countryOrArea);

	@Select("select ad.id from apple_auto_register_data ad left join register_order_don rd on rd.id = ad.order_id" +
			" where ad.user_id = #{userId} and ad.status = true" +
			" and ad.country_or_area = #{countryOrArea}" +
			" and rd.status = 'noPayment'")
	Integer checkNoPayOrder(@Param("userId") long userId, @Param("countryOrArea") AppleAutoRegisterData.CountryOrArea countryOrArea);

	@Select("select id from register_order_don where status = 'noPayment' and created_time <= #{newDate}")
	List<Long> getAllNoPayOrders(Date newDate);
}
