package com.yn.bftl.thirdparty.common.repository;

import com.yn.bftl.common.modules.order.entity.AfterSale;
import com.yn.bftl.common.modules.order.enums.AfterSaleStatus;
import com.yn.bftl.common.modules.order.enums.RefundStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * 售后Repository
 *
 * @author 补充说明
 * @create 2022/9/3  15:23
 **/
@Repository
public interface AfterSaleRepository extends JpaRepository<AfterSale, Long> {

    AfterSale findFirstByOrdersIdAndRefundStatus(Long orderId, RefundStatus refundStatus);

    /**
     * 售后单-根据发货单和售后状态查询
     *
     * @param shippingId:发货单ID
     * @param afterSaleStatus:售后单状态
     * @return 售后单
     * @author huabiao
     * @create 2022/9/24  16:21
     */
    AfterSale findFirstByShippingIdAndAfterSaleStatus(Long shippingId, AfterSaleStatus afterSaleStatus);

    /**
     * 售后单-根据订单和售后状态查询
     *
     * @param orderId:订单ID
     * @param afterSaleStatus:售后单状态
     * @return 售后单
     * @author huabiao
     * @create 2022/9/3  15:24
     */
    AfterSale findFirstByOrdersIdAndAfterSaleStatus(Long orderId, AfterSaleStatus afterSaleStatus);

    /**
     * 售后单-根据订单ID和状态查询
     *
     * @param orderId         订单ID
     * @param afterSaleStatus 售后单状态
     * @return 售后单列表
     * @author huabiao
     * @create 2022/12/22  17:43
     */
    List<AfterSale> findAllByOrdersIdAndAfterSaleStatus(Long orderId, AfterSaleStatus afterSaleStatus);

    /**
     * 售后单-根据发货单ID和状态查询
     *
     * @param shippingId 发货单ID
     * @param afterSaleStatus 售后单状态
     * @return 售后单列表
     * @author huabiao
     * @create 2022/12/28  12:24
     */
    List<AfterSale> findAllByShippingIdAndAfterSaleStatus(Long shippingId, AfterSaleStatus afterSaleStatus);

}
