package shop.alien.second.service;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import shop.alien.entity.result.BusinessException;
import shop.alien.entity.second.SecondTradeRecord;
import shop.alien.entity.second.vo.SecondEntrustUserDTO;
import shop.alien.entity.second.vo.SecondTradeRecordVo;
import shop.alien.entity.second.vo.SellerEvaluationVo;

import java.util.List;

/**
 * <p>
 * 二手交易记录表 服务类
 * </p>
 *
 * @author qrs
 * @since 2025-07-07
 */
public interface SecondTradeRecordService extends IService<SecondTradeRecord> {
    boolean createTrade(SecondEntrustUserDTO entity) throws Exception;

    boolean goodsTradeConfirm(int goodsId) throws Exception;

    boolean tradeConfirm(int tradeId, int messageId, int type) throws BusinessException, Exception;

    boolean cancelTrade(int tradeId, String cancelReason, String cancelReasonSupplement) throws Exception;

    boolean whetherCanSignIn(int tradeId) throws Exception;

    boolean tradeSignIn(int tradeId, int messageId, String signInLatitudeLongitude, String signInLatitudeLongitudeAddress) throws BusinessException, Exception;

    SecondTradeRecordVo getUserTradeStatus(int tradeId) throws Exception;

    boolean tradeCompleteConfirm(int tradeId, int type, String evaluate, Integer rating) throws Exception;

    List<SecondTradeRecordVo> getTradeRecord(int sideId) throws Exception;

    SecondTradeRecord hasInTradeRecord(Integer sideId) throws Exception;

    boolean modifyTradeRecord(int type, Integer tradeId, String transactionTime, String transactionLatitudeLongitude, String transactionLatitudeLongitudeAddress, String transactionLocation, String messageId,
                              String userPhone, String userName, String idCard, Integer entrustId, String idCardImg) throws Exception;

    /**
     * 获取用户作为卖家的交易评价列表（分页）
     *
     * @param sellerId 卖家ID（用户ID，必传）
     * @param pageNum 页码
     * @param pageSize 每页条数
     * @return 卖家评价分页列表，包含买家信息、评价内容、评分、风控评分等级等
     */
    IPage<SellerEvaluationVo> getSellerEvaluationList(Integer sellerId, Integer pageNum, Integer pageSize) throws Exception;

    void locationShareAdd(Integer otherUserId) throws Exception;

    void locationShareDel(Integer otherUserId) throws Exception;

    boolean locationShareHas(Integer otherUserId) throws Exception;

    /**
     * 买家按用户ID与主键 id 逻辑删除 second_trade_record（匹配 buyer_id、id）
     */
    boolean logicDeleteByBuyerAndTradeId(Integer userId, Integer tradeId);
}
