package com.zanxiang.game.module.sdk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zanxiang.game.module.base.pojo.enums.StatusEnum;
import com.zanxiang.game.module.mybatis.entity.GamePayStrategy;
import com.zanxiang.game.module.mybatis.mapper.GameStrategyMapper;
import com.zanxiang.game.module.sdk.pojo.param.UserData;
import com.zanxiang.game.module.sdk.service.IGamePayStrategyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 游戏策略 服务实现类
 *
 * @author xufeng
 * @date 2022-07-01 11:38
 */
@Slf4j
@Service
public class GamePayStrategyServiceImpl extends ServiceImpl<GameStrategyMapper, GamePayStrategy> implements IGamePayStrategyService {

    @Override
    public Boolean paySwitch(UserData user) {
        List<GamePayStrategy> list = super.list(new LambdaQueryWrapper<GamePayStrategy>()
                .eq(GamePayStrategy::getStatus, StatusEnum.YES.getCode())
                .eq(GamePayStrategy::getGameId, user.getGameId())
        );
        if (CollectionUtils.isEmpty(list)) {
            return false;
        }
        //存在切换则属于
        return true;
    }
}
