package com.yonge.cooleshow.biz.dal.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
import com.yonge.cooleshow.biz.dal.vo.UserOrderDetailVo;
import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
import com.yonge.cooleshow.common.entity.HttpResponseResult;
import com.yonge.toolset.utils.easyexcel.ExcelDataReaderProperty;
import org.springframework.transaction.annotation.Transactional;

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

/**
 * 机构激活码
 * 2023-07-21 17:32:49
 */
public interface TenantActivationCodeService extends IService<TenantActivationCode> {

    /**
     * 查询详情
     *
     * @param id 详情ID
     * @return TenantActivationCode
     */
    TenantActivationCode detail(Long id);

    /**
     * 分页查询
     *
     * @param page  IPage<TenantActivationCode>
     * @param query TenantActivationCodeWrapper.TenantActivationCodeQuery
     * @return IPage<TenantActivationCode>
     */
    IPage<TenantActivationCodeWrapper.TenantActivationCode> selectPage(IPage<TenantActivationCodeWrapper.TenantActivationCode> page,
                                                                       TenantActivationCodeWrapper.TenantActivationCodeQuery query);

    /**
     * 添加
     *
     * @param tenantActivationCode TenantActivationCodeWrapper.TenantActivationCode
     * @return Boolean
     */
    Boolean add(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode);

    /**
     * 更新
     *
     * @param tenantActivationCode TenantActivationCodeWrapper.TenantActivationCode
     * @return Boolean
     */
    Boolean update(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode);

    void sendActivationCode(Long tenantId, Long tenantAlbumPurchaseId, List<String> activationCodeList,
                            List<Long> studentIdList);

    void sendCancelActivationCodeMessage(Map<Long, String> receivers, String tenantName);

    void active(String activationCode, Long studentId);


    /**
     * 添加用户机构专辑激活记录
     *
     * @param studentId         学生ID
     * @param userOrderDetailVo 订单详情
     */
    void addUserTenantAlbumRecord(Long studentId, UserOrderDetailVo userOrderDetailVo);

    /**
     * 导入激活码
     *
     * @param dataList              数据列表
     * @param tenantId              机构ID
     * @param userId                机构管理员用户ID
     * @param tenantAlbumPurchaseId 专辑购买的ID
     */
    HttpResponseResult<Object> importActiveCode(List<ExcelDataReaderProperty<TenantActivationCodeWrapper.ImportTemplate>> dataList,
                                                    Long tenantId, Long userId, Long tenantAlbumPurchaseId);

    void activeById(String id, Long userId);

    void resend(String code, Long userId, Long tenantId, Long tenantAlbumPurchaseId);

    @Transactional(rollbackFor = Exception.class)
    void sendCancel(TenantInfo tenantInfo, TenantActivationCode activationCode);

    void batchSendCancel(TenantInfo tenantInfo, String ids);

    void batchResend(TenantInfo tenantInfo, Long tenantAlbumPurchaseId, List<String> activationCodeList, List<Long> studentIdList);
}