package com.ai.da.service;

import com.ai.da.common.response.PageBaseResponse;
import com.ai.da.mapper.primary.entity.Account;
import com.ai.da.mapper.primary.entity.AccountExtend;
import com.ai.da.mapper.primary.entity.TrialOrder;
import com.ai.da.model.dto.*;
import com.ai.da.model.vo.AccountLoginVO;
import com.ai.da.model.vo.AccountPreLoginVO;
import com.ai.da.model.vo.BindEmailVO;
import com.ai.da.model.vo.PersonalHomepageVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 服务类
 *
 * @author easy-generator
 * @since 2022-08-11
 */
public interface AccountService extends IService<Account> {

    /**
     * 账户预先登入
     *
     * @param accountDTO
     * @return
     */
    AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO);

    /**
     * 账户登入
     *
     * @param accountLoginDTO
     * @return
     */
    AccountLoginVO login(AccountLoginDTO accountLoginDTO, HttpServletRequest request);

    /**
     * 绑定邮箱
     *
     * @param accountBindEmailDTO
     * @return
     */
    BindEmailVO bindEmail(AccountBindEmailDTO accountBindEmailDTO, HttpServletRequest request);

    BindEmailVO bindEmail(String email);

    /**
     * 忘记密码
     *
     * @param accountDTO
     * @return
     */
    Boolean forgetPwd(AccountRegisterDTO accountDTO);

    /**
     * 发送邮件
     *
     * @param emailSendDTO
     * @return
     */
    Boolean sendEmail(EmailSendDTO emailSendDTO);

    /**
     * 登出
     *
     * @param accountLogoutDTO
     * @return
     */
    Boolean logout(AccountLogoutDTO accountLogoutDTO);

    /**
     * 判断是否登出 Boolean为登入
     *
     * @param accountLogoutDTO
     * @return
     */
    Boolean isLogin(AccountLogoutDTO accountLogoutDTO);

    /**
     * 添加用户信息
     *
     * @param accountAddDTO
     * @return
     */
    Boolean addUser(AccountAddDTO accountAddDTO);

    /**
     * 编辑用户信息
     *
     * @param accountEditDTO
     * @return
     */
    Boolean editUser(AccountEditDTO accountEditDTO);

    String getUserLanguage();

    String changeUserLanguage(String language);

    Boolean trialUserLogout();

    Boolean completeGuidance();

    Boolean addTrialUser(AccountTrialDTO accountTrialDTO, HttpServletRequest request);

    IPage<TrialOrder> trialOrderList(TrialOrderDTO trialOrderDTO);

    Boolean trialOrderApproval(List<Long> ids);

    Boolean getIsAutoApproval();

    Boolean switchIsAutoApproval();

    Boolean trialOrderRefuse(List<Long> ids);

    Long getExpiredTime();

    Boolean addNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO);

    Boolean deleteNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO);

    AccountLoginVO noLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);

    Boolean existNoLoginRequired(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);

    String addNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);

    Boolean deleteNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);

    void upgradeNotification();

    void moveLibraryDate();

    void updateCreditsAndEndTime(Account account, String value, Long endTime, BigDecimal creditsUsage);

    Boolean designWorksRegister(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO);

    AccountLoginVO designWorksRegisterCode(AccountDesignWorksRegisterDTO accountDesignWorksRegisterDTO,
                                           HttpServletRequest request);

    Boolean extendValidityForCC();

    Boolean collectQuestionnaires(String questionnaireInfo);

    void refreshCreditsMonthly();

    List<Account> getExpiredUserBySystemUser(Integer systemUserNum);

    String getActivityBenefits();

    void toVisitor(Account account);

    List<Long> setUserValidToDayEnd();

    IPage<Account> getPageByDateAndUserType(String startTime, String endTime, Integer type, int pageNum, int size);

    Map<String, Long> getByDateAndUserType(String startTime, String endTime, Integer type);

    IPage<Account> getPageByIds(List<Long> ids, int pageNum, int size);
    List<Account> getByIds(List<Long> ids);

    String uploadAvatar(MultipartFile file);

    PersonalHomepageVO getPersonalHomepage(Long accountId);

    Boolean viewsIncrease(Long id);

    void registerUserToVisitor();

    Long getNicknameModifyTimes();

    void editUserName(String newUserName);

    /*void verifyUserEmail(String verifyCode);

    void changeUserEmail(String newMailbox);

    void activateNewEmail(String token);*/

    String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);

    void halfPricePromotion();

    String googleCallback(String code, HttpSession session);

    List<String> getPaidCustomerEmail();

    void temporaryUpgrade();

    AccountPreLoginVO enterpriseLogin(AccountLoginDTO accountDTO);

    AccountPreLoginVO schoolLogin(AccountLoginDTO accountDTO);

    Boolean addSubAccount(AddSubAccountDTO addSubAccountDTO);

//    Boolean deleteSubAccount(AddSubAccountDTO addSubAccountDTO);

    void removeSubAccount(AddSubAccountDTO addSubAccountDTO, Long adminAccId);

    PageBaseResponse<Account> subAccountList(SubAccountPageDTO subAccountPageDTO);

    Account accountDetail(Long id);

    AccountLoginVO parseGoogleCredential(String credential, Integer type);

    AccountLoginVO parseWeChatCode(String code, Integer type);

    AccountLoginVO getAccountDetail();

    AccountExtend bindGoogle(String credential);

    AccountExtend bindWeChat(String code);

    Boolean unbindWeChat();

    Boolean unbindGoogle();

    boolean updateAccountValidity(Long accountId, Long currentPeriodEnd);

    void updateUserRoleAndCredits(Long accountId, String orderNo);

    Boolean updateUserInfo(UpdateUserInfoDTO updateUserInfoDTO);

    void subAccountImportExcelDownload(HttpServletResponse response);

    void exportAccountsToExcel(HttpServletResponse response);

    Boolean subAccountImport(MultipartFile file);

    Set<String> organizationNameSearch(String type, String name);

    /*void send618PromotionEmailTemp();*/

    void checkEduAdminExpireStatus();

    void setEduAdminToExpire(Account adminAccount);

    String getOrganizationTypeByRole(Integer roleNum);
}
