package cn.pluss.platform.notice;

import cn.pluss.platform.api.Result;
import cn.pluss.platform.entity.Notice;
import cn.pluss.platform.mapper.NoticeMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;

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

/**
 * @author nb2020
 */
public interface NoticeService extends IService<Notice> {

    default Notice queryNotice(Notice notice) {
        return ((NoticeMapper) getBaseMapper()).queryNotice(notice);
    }

    default List<Notice> queryNoticeList(Notice notice) {
        return ((NoticeMapper) getBaseMapper()).queryNoticeList(notice);
    }

    void saveNotice(Notice notice);

    default void updateNotice(Notice notice) {
        ((NoticeMapper) getBaseMapper()).updateNotice(notice);
    }

    default void deleteNotice(Notice notice) {
        ((NoticeMapper) getBaseMapper()).deleteNotice(notice);
    }

    default List<Notice> queryNoticePage(Map<String, Object> map) {
        return ((NoticeMapper) getBaseMapper()).queryNoticePage(map);
    }

    default Integer queryNoticePageCount(Map<String, Object> map) {
        return ((NoticeMapper) getBaseMapper()).queryNoticePageCount(map);
    }

    /**
     * 保存身份证认证的通知
     */
    default Integer saveIdCardAuthNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(Notice.TYPE_ID_CARD_AUTH);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存商家认证的通知
     */
    default Integer saveMerAuthNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(Notice.TYPE_MERCHANT_AUTH);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存员工退款申请的通知
     */
    default Integer saveMerStaffRefundNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(Notice.TYPE_STAFF_REFUND);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存银行卡认证的通知
     */
    default Integer saveBankAuthNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(Notice.TYPE_BANK_AUTH);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存商户进件修改信息的通知
     */
    default Integer saveMerChangeDataNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(Notice.TYPE_MER_DATA_CHANGE);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存商户银行卡变更结果的通知
     * @param notice 通知内容
     */
    default Integer saveMerBankChangeNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(Notice.TYPE_MER_BANK_CHANGE);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存系统通知
     * @param notice
     * @return
     */
    default Integer saveSystemNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(-1);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存商户违规的通知
     */
    default Integer saveMerOutLineNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(Notice.TYPE_MER_OUT_LINE);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存商户异常的通知
     */
    default Integer saveMerExceptionNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(Notice.TYPE_MER_EXCEPTION);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存商户冻结的通知
     */
    default Integer saveMerFreezeNotice(Notice notice) {
        notice.setTypeFirst(1);
        notice.setTypeSecond(Notice.TYPE_MER_FREEZE);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存商户分润的通知
     * @param notice    通知内容
     */
    default Integer saveMerProfitNotice(Notice notice) {
        notice.setTypeFirst(0);
        notice.setTypeSecond(Notice.TYPE_MER_PROFIT);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * 保存商户升级分润的通知
     * @param notice    通知内容
     */
    default Integer saveMerUpdateProfitNotice(Notice notice) {
        notice.setTypeFirst(0);
        notice.setTypeSecond(Notice.TYPE_MER_UPDATE_PROFIT);
        return (getBaseMapper()).insert(notice);
    }

    /**
     * @description:
     * @date: 2021/8/31 16:50
     * @param notice:
     * @return cn.pluss.platform.api.Result<?>
     */
    void sendTempNotice(Notice notice);

    /**
     * 保存定时的通知
     * @param notice            通知信息
     * @param scheduleFlag      定时参数
     */
    void sendTempNotice(Notice notice, String scheduleFlag);

    /**
     * 给单个用户发送模板通知
     */
    void sendTempNotice(String templateTitle, String templateDesc, String content, String url, String userId, Object... args);

    /**
     * 给单个用户发送模板通知
     */
    void sendTempNotice(String templateTitle, String templateDesc, String content, String url, String userId, Map<String, Object> mapArgs);

    /**
     * 给单个用户发送模板通知
     */
    void sendTempNotice(String templateTitle, String templateDesc, String content, String url, String userId, Map<String, Object> mapArgs, boolean pushFlag);

    void sendEditApplyNotice(String userId, String alias, String settleName);

    void sendEditApplySuccessNotice(String userId, String alias, String settleName);
}

