package com.hai.service.impl;

import com.hai.dao.HighActivityAwardUserMapper;
import com.hai.entity.HighActivityAwardSerialNum;
import com.hai.entity.HighActivityAwardUser;
import com.hai.service.HighActivityAwardSerialNumService;
import com.hai.service.HighActivityAwardUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service("highActivityAwardUserService")
public class HighActivityAwardUserServiceImpl implements HighActivityAwardUserService {

    @Resource
    private HighActivityAwardUserMapper highActivityAwardUserMapper;

    @Resource
    private HighActivityAwardSerialNumService highActivityAwardSerialNumService;

    @Override
    public void insertAwardUser(Long serialNumId,Long userId) {
        // 查询中奖号码
        HighActivityAwardSerialNum detail = highActivityAwardSerialNumService.getDetail(serialNumId);
        if (detail != null) {
            HighActivityAwardUser awardUser = new HighActivityAwardUser();
            awardUser.setCreateTime(new Date());
            awardUser.setActivityAwardSerialNumId(serialNumId);
            awardUser.setUserId(userId);
            awardUser.setActivityInfoId(detail.getActivityInfoId());
            awardUser.setActivityAwardId(detail.getActivityAwardId());
            highActivityAwardUserMapper.insert(awardUser);
        }
    }

    @Override
    public List<Map<String, Object>> getWinLotteryList(Long activityId) {
        return highActivityAwardUserMapper.selectWinLotteryList(activityId);
    }

    @Override
    public List<Map<String, Object>> getWinLotteryUserList(Long activityId, Map<String, Object> param) {
        return highActivityAwardUserMapper.selectWinLotteryUserList(activityId,param);
    }
}
