package com.flossom.system.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.flossom.common.core.domain.entity.ActivityChannelInfo;
import com.flossom.common.core.domain.entity.SysTag;
import com.flossom.common.core.mapper.ActivityChannelInfoMapper;
import com.flossom.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.flossom.system.service.IActivityChannelInfoService;

/**
 * 活动渠道信息Service业务层处理
 *
 * @author flossom
 * @date 2023-12-20
 */
@Service
public class ActivityChannelInfoServiceImpl implements IActivityChannelInfoService {
    @Autowired
    private ActivityChannelInfoMapper activityChannelInfoMapper;

    /**
     * 查询活动渠道信息
     *
     * @param id 活动渠道信息主键
     * @return 活动渠道信息
     */
    @Override
    public ActivityChannelInfo selectActivityChannelInfoById(Long id) {
        return activityChannelInfoMapper.selectActivityChannelInfoById(id);
    }

    /**
     * 查询活动渠道信息列表
     *
     * @param activityChannelInfo 活动渠道信息
     * @return 活动渠道信息
     */
    @Override
    public List<ActivityChannelInfo> selectActivityChannelInfoList(ActivityChannelInfo activityChannelInfo) {
        return activityChannelInfoMapper.selectActivityChannelInfoList(activityChannelInfo);
    }

    /**
     * 新增活动渠道信息
     *
     * @param activityChannelInfo 活动渠道信息
     * @return 结果
     */
    @Override
    public int insertActivityChannelInfo(ActivityChannelInfo activityChannelInfo) {
        activityChannelInfo.setCreateTime(DateUtils.getNowDate());
        return activityChannelInfoMapper.insertActivityChannelInfo(activityChannelInfo);
    }

    /**
     * 修改活动渠道信息
     *
     * @param activityChannelInfo 活动渠道信息
     * @return 结果
     */
    @Override
    public int updateActivityChannelInfo(ActivityChannelInfo activityChannelInfo) {
        return activityChannelInfoMapper.updateActivityChannelInfo(activityChannelInfo);
    }

    /**
     * 批量删除活动渠道信息
     *
     * @param ids 需要删除的活动渠道信息主键
     * @return 结果
     */
    @Override
    public int deleteActivityChannelInfoByIds(Long[] ids) {
        return activityChannelInfoMapper.deleteActivityChannelInfoByIds(ids);
    }

    /**
     * 删除活动渠道信息信息
     *
     * @param id 活动渠道信息主键
     * @return 结果
     */
    @Override
    public int deleteActivityChannelInfoById(Long id) {
        return activityChannelInfoMapper.deleteActivityChannelInfoById(id);
    }

    @Override
    public List<Map<String, Object>> getPurchaseChannel() {
        List<Map<String, Object>> channelList = new ArrayList<>();
        ActivityChannelInfo query = new ActivityChannelInfo();
        List<ActivityChannelInfo> activityChannelInfoList = activityChannelInfoMapper.selectActivityChannelInfoList(query);
        if (activityChannelInfoList != null && activityChannelInfoList.size() > 0) {
            Map<String, Object> map;
            for (ActivityChannelInfo activityChannelInfo : activityChannelInfoList) {
                map = new HashMap<>();
                map.put("label", activityChannelInfo.getChannelName());
                map.put("value", activityChannelInfo.getId());
                channelList.add(map);
            }
        }

        return channelList;
    }
}
