package com.cyksj.service.claude;

import com.cyksj.model.entity.ClaudeCodeUser;
import com.cyksj.model.entity.GoodsDonSku;
import com.cyksj.model.entity.GroupsRelation;
import com.cyksj.model.request.ClaudeCodeApiKeysReq;
import com.cyksj.model.request.ClaudeCodeCreditCardUseReq;
import com.cyksj.model.request.ClaudeCodeDelReq;
import com.cyksj.model.request.CreditResetReq;
import com.cyksj.model.response.ClaudeCodeRewardDetailsResp;
import com.cyksj.model.response.CreditResetResp;
import com.cyksj.model.response.TimeRateConfigsResp;
import com.cyksj.model.response.claudecode.ClaudeCodeResp;
import com.cyksj.model.views.ClaudeCodeUserApiKeysView;
import com.cyksj.model.views.ClaudeCodeUserCreditCardRecordView;
import com.cyksj.model.views.ClaudeCodeUserInfoView;
import com.cyksj.model.views.ClaudeCodeUserResetRecordView;
import com.ejlchina.searcher.SearchResult;

import java.util.Date;
import java.util.List;

/**
 * 项目名: yhlxj11111111
 * 文件名: ClaudeCodeService
 * 创建者: JavaZou
 * 创建时间:2025/8/8 10:55
 */
public interface ClaudeCodeService {

	/**
	 * 生成claude code用户套餐信息
	 */
	void generateOrUpdateClaudeCodeUserInfo(Long orderId, Long relationId, Long userId, GoodsDonSku sku, Integer orderType);

	/**
	 * 用户创建api keys
	 */
	ClaudeCodeResp createApiKeys(ClaudeCodeApiKeysReq req) throws Exception;

	/**
	 * 删除api key
	 */
	void deleteApiKeysById(ClaudeCodeDelReq delReq) throws Exception;

	/**
	 * 用户api keys列表
	 */
	List<ClaudeCodeUserApiKeysView> getUserApiKeys(long userId) throws Exception;

	ClaudeCodeResp getUserDashboard(Long userId) throws Exception;

	ClaudeCodeResp getUserBalance(Long userId) throws Exception;

	ClaudeCodeResp getCreditsAnalytics(Long userId, String start, String end, String tz, Integer page, Integer limit, String order, String type) throws Exception;

	void invalidateUserCache(Long relationUserId);

	ClaudeCodeUserInfoView getClaudeCodeUserSubsInfo(Long userId);

	Boolean checkClaudeCodeUser(Long userId);

	void updateClaudeCodeUserPackageInfo(ClaudeCodeUser claudeCodeUser, Date expiryTime, GoodsDonSku sku);

	/**
	 * 删除用户claude code 套餐
	 */
	Boolean delUserPackages(Long userId);

	/**
	 * 处理续费升级 TODO
	 */
	void handleClaudeCodeUserPackageSku(GroupsRelation relation, GoodsDonSku sku, Long orderId);

	/**
	 * 获取系统中所有的时间倍率配置列表（包括已启用和已禁用的配置）
	 */
	TimeRateConfigsResp getAllConfigs();

	/**
	 * 将指定用户的积分重置为满积分状态（used_credits设为0）
	 */
	CreditResetResp resetUserCredits(Long userId, CreditResetReq req) throws Exception;

	/**
	 * 用户使用重置次数
	 */
	void useResetCount(Long userId) throws Exception;

	/**
	 * 用户使用积分卡
	 */
	void useCreditCard(ClaudeCodeCreditCardUseReq req) throws Exception;

	/**
	 * 获取用户重置次数明细
	 */
	SearchResult<ClaudeCodeUserResetRecordView> getUserResetRecords(Long userId, Integer page, Integer limit);

	/**
	 * 获取用户积分卡使用明细
	 */
	SearchResult<ClaudeCodeUserCreditCardRecordView> getUserCreditCardRecords(Long userId, Integer page, Integer limit);

	/**
	 * 获取用户奖励明细
	 */
	ClaudeCodeRewardDetailsResp getUserRewardDetails(Long userId, Boolean general);

	/**
	 * 发送积分卡
	 */
	void sendCreditCard(Long orderId, Long userId, Integer points, String cardNumber, String remark);

	/**
	 * 增加或修改用户重置次数
	 * num为正增加 负扣除
	 */
	void adjUserRestNum(Long orderId, Long userId, Integer num, String remark);

	void useDayResetCount(Long userId) throws Exception;

	/**
	 * 用户是否存在订阅
	 */
	Boolean getUserSubs(long userId);
}
