package com.fs.his.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fs.his.domain.FsPromotionalActiveLog;
import com.fs.his.mapper.FsPromotionalActiveLogMapper;
import com.fs.his.service.IFsPromotionalActiveLogService;
import com.fs.his.vo.FsPromotionalActiveStatVO;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@Service
public class FsPromotionalActiveLogServiceImpl extends ServiceImpl<FsPromotionalActiveLogMapper, FsPromotionalActiveLog>
        implements IFsPromotionalActiveLogService {

    /**
     * 记录用户点击行为
     */
    @Override
    public void saveClickActionLog(Long activeId, Long userId, Integer type, Integer productType, Long resourceId) {
        FsPromotionalActiveLog activeLog = new FsPromotionalActiveLog();
        activeLog.setActiveId(activeId);
        activeLog.setUserId(userId);
        activeLog.setType(type);
        activeLog.setProductType(productType);
        activeLog.setResourceId(resourceId);
        activeLog.setCreateTime(LocalDateTime.now());
        baseMapper.insert(activeLog);
    }

    /**
     * 活动行为统计
     */
    @Override
    public List<FsPromotionalActiveStatVO> getPromotionalActiveLogStatByMap(Map<String, Object> params) {
        return baseMapper.getPromotionalActiveLogStatByMap(params);
    }
}
