package com.hzs.system.config.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.CacheConstants;
import com.hzs.common.core.service.RedisService;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.domain.system.config.BdWithdrawalAuto;
import com.hzs.system.config.mapper.BdWithdrawalAutoMapper;
import com.hzs.system.config.service.IBdWithdrawalAutoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 自动提现明细表 服务实现类
 * </p>
 *
 * @author zhangjing
 * @since 2022-08-31
 */
@Service
public class BdWithdrawalAutoServiceImpl extends ServiceImpl<BdWithdrawalAutoMapper, BdWithdrawalAuto> implements IBdWithdrawalAutoService {

    private RedisService redisService;

    @Autowired
    public void setRedisService(RedisService redisService) {
        this.redisService = redisService;
    }
    /**
     * @description: 根据国家查询自动提现明细列表
     * @author: zhang jing
     * @date: 2022/9/27 14:59
     * @param: [pkCountry]
     * @return: java.util.List<com.hzs.common.domain.system.config.BdWithdrawalAuto>
     **/
    @Override
    public List<BdWithdrawalAuto> queryWithdrawalAuto(Integer pkCountry) {
        List<BdWithdrawalAuto> withdrawalAuto = redisService.getCacheObject(CacheConstants.BD_WITHDRAWAL_AUTO + pkCountry);
        if(CollectionUtil.isEmpty(withdrawalAuto)){
            QueryWrapper<BdWithdrawalAuto> queryWrapper = new QueryWrapper();
            queryWrapper.eq("PK_COUNTRY",pkCountry);
            withdrawalAuto = baseMapper.selectList(queryWrapper);
            if(CollectionUtil.isNotEmpty(withdrawalAuto)){
                redisService.setCacheObject(CacheConstants.BD_WITHDRAWAL_AUTO + pkCountry, withdrawalAuto);
            }
        }
        return withdrawalAuto;
    }


}
