package com.game.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Collections;
import java.util.List;

import com.game.common.annotation.DataSource;
import com.game.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.game.business.mapper.AppUsersCashrecordMapper;
import com.game.business.domain.AppUsersCashrecord;
import com.game.business.service.IAppUsersCashrecordService;

/**
 * 提现记录Service业务层处理
 *
 * @author game
 * @date 2024-06-18
 */
@Service
public class AppUsersCashrecordServiceImpl extends ServiceImpl<AppUsersCashrecordMapper, AppUsersCashrecord> implements IAppUsersCashrecordService {
    @Autowired
    private AppUsersCashrecordMapper appUsersCashrecordMapper;

    /**
     * 查询提现记录
     *
     * @param id 提现记录主键
     * @return 提现记录
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public AppUsersCashrecord selectAppUsersCashrecordById(Long id) {
        return appUsersCashrecordMapper.selectAppUsersCashrecordById(id);
    }

    /**
     * 查询提现记录列表
     *
     * @param appUsersCashrecord 提现记录
     * @return 提现记录
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<AppUsersCashrecord> selectAppUsersCashrecordList(AppUsersCashrecord appUsersCashrecord) {
        return appUsersCashrecordMapper.selectAppUsersCashrecordList(appUsersCashrecord);
    }

    /**
     * 新增提现记录
     *
     * @param appUsersCashrecord 提现记录
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int insertAppUsersCashrecord(AppUsersCashrecord appUsersCashrecord) {
            return appUsersCashrecordMapper.insertAppUsersCashrecord(appUsersCashrecord);
    }

    /**
     * 修改提现记录
     *
     * @param appUsersCashrecord 提现记录
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int updateAppUsersCashrecord(AppUsersCashrecord appUsersCashrecord) {
        return appUsersCashrecordMapper.updateAppUsersCashrecord(appUsersCashrecord);
    }

    /**
     * 批量删除提现记录
     *
     * @param ids 需要删除的提现记录主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int deleteAppUsersCashrecordByIds(Long[] ids) {
        return appUsersCashrecordMapper.deleteAppUsersCashrecordByIds(ids);
    }

    /**
     * 删除提现记录信息
     *
     * @param id 提现记录主键
     * @return 结果
     */
    @Override
    @DataSource(DataSourceType.SLAVE)
    public int deleteAppUsersCashrecordById(Long id) {
        return appUsersCashrecordMapper.deleteAppUsersCashrecordById(id);
    }

    @Override
    @DataSource(DataSourceType.SLAVE)
    public List<AppUsersCashrecord> getUserCashList(Long userId, String beginTime, String endTime) {
        LambdaQueryWrapper<AppUsersCashrecord> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AppUsersCashrecord::getCashOutStatus,"1");
        queryWrapper.eq(AppUsersCashrecord::getCashType,"7");//余额提现
        queryWrapper.between(AppUsersCashrecord::getAddtime,beginTime,endTime);
        return appUsersCashrecordMapper.selectList(queryWrapper);
    }
}