package com.fs.user.service.impl;

import java.util.List;
import com.fs.common.utils.DateUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fs.user.domain.FsUserComplaint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.user.mapper.FsUserComplaintMsgMapper;
import com.fs.user.domain.FsUserComplaintMsg;
import com.fs.user.service.IFsUserComplaintMsgService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 投诉消息记录Service业务层处理
 *
 * @author fs
 * @date 2025-09-08
 */
@Service
public class FsUserComplaintMsgServiceImpl extends ServiceImpl<FsUserComplaintMsgMapper, FsUserComplaintMsg> implements IFsUserComplaintMsgService {

    /**
     * 查询投诉消息记录
     *
     * @param id 投诉消息记录主键
     * @return 投诉消息记录
     */
    @Override
    public FsUserComplaintMsg selectFsUserComplaintMsgById(Long id)
    {
        return baseMapper.selectFsUserComplaintMsgById(id);
    }

    /**
     * 查询投诉消息记录列表
     *
     * @param fsUserComplaintMsg 投诉消息记录
     * @return 投诉消息记录
     */
    @Override
    public List<FsUserComplaintMsg> selectFsUserComplaintMsgList(FsUserComplaintMsg fsUserComplaintMsg)
    {
        return baseMapper.selectFsUserComplaintMsgList(fsUserComplaintMsg);
    }

    /**
     * 新增投诉消息记录
     *
     * @param fsUserComplaintMsg 投诉消息记录
     * @return 结果
     */
    @Override
    @Transactional
    public int insertFsUserComplaintMsg(FsUserComplaintMsg fsUserComplaintMsg)
    {
        fsUserComplaintMsg.setCreateTime(DateUtils.getNowDate());
        //修改投诉 状态
        Long complaintId = fsUserComplaintMsg.getComplaintId();
        FsUserComplaint fsUserComplaint = new FsUserComplaint();
        fsUserComplaint.setId(complaintId);
        fsUserComplaint.setUpdateTime(fsUserComplaintMsg.getCreateTime());
        Integer sendType = fsUserComplaintMsg.getSendType();
        switch (sendType){
            case 1:
                fsUserComplaint.setIsReadPlatform(0);
                fsUserComplaint.setIsReadStore(0);
                break;
            case 2:
                fsUserComplaint.setIsHandlePlatform(1);
                fsUserComplaint.setIsReadPlatform(1);
                fsUserComplaint.setIsReadUser(0);
                break;
            case 3:
                fsUserComplaint.setIsHandleStore(1);
                fsUserComplaint.setIsReadStore(1);
                fsUserComplaint.setIsReadUser(0);
                break;
            default:
                return 0;
        }

        return baseMapper.insertFsUserComplaintMsg(fsUserComplaintMsg);
    }

    /**
     * 修改投诉消息记录
     *
     * @param fsUserComplaintMsg 投诉消息记录
     * @return 结果
     */
    @Override
    public int updateFsUserComplaintMsg(FsUserComplaintMsg fsUserComplaintMsg)
    {
        return baseMapper.updateFsUserComplaintMsg(fsUserComplaintMsg);
    }

    /**
     * 批量删除投诉消息记录
     *
     * @param ids 需要删除的投诉消息记录主键
     * @return 结果
     */
    @Override
    public int deleteFsUserComplaintMsgByIds(Long[] ids)
    {
        return baseMapper.deleteFsUserComplaintMsgByIds(ids);
    }

    /**
     * 删除投诉消息记录信息
     *
     * @param id 投诉消息记录主键
     * @return 结果
     */
    @Override
    public int deleteFsUserComplaintMsgById(Long id)
    {
        return baseMapper.deleteFsUserComplaintMsgById(id);
    }
}
