package com.zm.order.tool.server.dao;

import com.zm.order.tool.server.model.Refund;
import com.zm.order.tool.server.query.RefundQuery;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author penghui
 */
@Repository
public interface RefundDao {


    /**
     * 根据id查询
     *
     * @param refundNo 主键
     * @return
     */
    Refund selectByRefundNo(@Param("refundNo") String refundNo);

    Refund selectById(@Param("id") Long id);


    /**
     * 统计
     *
     * @param query
     * @return
     */
    int count(RefundQuery query);

    /**
     * 查询列表
     *
     * @param query 查询参数
     * @return
     */
    List<Refund> selectList(RefundQuery query);

    List<Long> selectIdList(RefundQuery query);

    /**
     * 查询列表
     *
     * @param query 查询参数
     * @return
     */
    List<Refund> selectListBaseWhere(RefundQuery query);

    List<Refund> selectRespIdList(RefundQuery query);

    List<Refund> selectByIdList(@Param("list") List<Long> idList);

    List<Refund> selectByOrderNoList(@Param("orderNoList") List<String> orderNoList);

    /**
     * 修改用户id
     *
     * @param id
     * @param userId
     * @return
     */
    int updateUserId(@Param("id") Long id,
                     @Param("userId") Long userId,
                     @Param("sellerId") Long sellerId,
                     @Param("storeId") Long storeId);

    int updateStoreId(@Param("storeId") Long storeId, @Param("userId") Long userId, @Param("orderNo") String orderNo);

    /**
     * 更新退款明细
     *
     * @param refund
     * @return
     */
    int updateRefundDetail(Refund refund);

    /**
     * 查询支提款付金额
     *
     * @param query 查询参数
     * @return
     */
    Integer sumRefundAmount(RefundQuery query);

    /**
     * 更新
     * @param refund
     * @return
     */
    int update(Refund refund);

    int updateBizType(@Param("bizType") Integer bizType, @Param("orderNoList") List<String> orderNoList);

    int updateBizRefundType(@Param("bizType") Integer bizType, @Param("orderNoList") List<String> orderNoList);

    /**
     * 更新
     * @param refund
     * @return
     */
    int updateDealAt(Refund refund);

    int updateDetailInfo(Refund refund);

    /**
     * 批量更新退款单处理时间
     * @param list
     * @return:
     * @Date: 2021/2/25 10:41 上午
     */
    int batchUpdateDealAt(List<Refund> list);

    /**
     * 批量更新退款单
     * @param list
     * @param bizType
     * @param sellerId
     * @return:
     * @Date: 2021/2/25 10:41 上午
     */
    int updateBatch(@Param("list")List<Refund> list, @Param("bizType")Integer bizType, @Param("sellerId")Long sellerId);

    /**
     * 批量更新退款单
     * @param list
     * @return:
     */
    int updateVersion(@Param("list")List<Refund> list);


    /**
     * 更新系统来源
     * @param list
     * @return:
     * @Date: 2021/3/5 2:55 下午
     */
    int batchUpdateFromSystem(List<Refund> list);

    /**
     * 更新支付类型
     * @param refund
     * @return
     */
    int updatePayType(Refund refund);

    /**
     *
     * @param list
     * @return
     * Date: 2021/5/24 9:50 上午
     */
    int updateExtraMap(List<Refund> list);
    int updateBatchToBaking(List<Refund> list);

    int updateBakingJiFen(List<Refund> list);

    int delete(@Param("id") Long id, @Param("deleteType") Integer deleteType);

    /**
     * 插入
     *
     * @param record
     * @return
     */
    int insert(Refund record);
    int replace(Refund record);

    int insertList(List<Refund> list);


    int deleteTemp(@Param("orderNo") String orderNo,
                   @Param("userId") Long userId);

    /**
     * 通过订单号查询退款单
     *
     * @param orderNo
     * @return
     */
    List<Refund> selectByOrderNo(@Param("orderNo") String orderNo);

    int deleteByIdList(@Param("idList") List<Long> idList, @Param("deleteType") Integer deleteType);

    int realDelete(@Param("idList") List<Long> idList);

    int deleteByOrderNos(@Param("orderNoList") List<String> orderNoList);

    int updateSellerUser(
            @Param("sellerId") Long sellerId,
            @Param("storeId") Long storeId,
            @Param("oldUserId") Long oldUserId,
            @Param("newUserId") Long newUserId,
            @Param("orderNo") String orderNo);

}