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


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

import java.util.List;

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

    /**
     * 查询列表
     *
     * @param query
     * @return
     */
    List<RefundItem> selectList(RefundItemQuery query);

    /**
     * 根据退款单号或者订单号查询查询
     *
     * @param refundNo 退款单号
     * @param orderNo  订单号
     * @return
     */
    List<RefundItem> selectByRefundNo(@Param("refundNo") String refundNo, @Param("orderNo") String orderNo);

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

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

    /**
     * 更新商家ID
     * @param list
     * @return:
     * @Date: 2021/4/8 3:25 下午
     */
    int updateSellerId(@Param("list") List<RefundItem> list);

    /**
     * 更新
     * @param list
     * @return:
     * @Date: 2021/4/8 3:25 下午
     */
    int updateBizType(@Param("list") List<RefundItem> list);

    /**
     * 更新商家id bizType itemType isDeleted
     * @param list
     * @param sellerId
     * @return:
     * @Date: 2021/4/8 3:25 下午
     */
    int updateBatch(@Param("list") List<RefundItem> list, @Param("sellerId") Long sellerId);

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

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

    /**
     * 批量插入
     *
     * @param refundItemList
     * @return
     */
    int inserts(@Param("refundItemList") List<RefundItem> refundItemList);

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

    int update(RefundItem refundItem);

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

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