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

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

import java.util.List;

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


    /**
     * 查询
     *
     * @param orderNo 订单号
     * @param userId  用户id
     * @return
     */
    List<OrderDiscount> selectByOrderNo(@Param("orderNo") String orderNo,
                                        @Param("userId") Long userId);


    /**
     * 查询列表
     *
     * @param orderDiscountQuery
     * @return
     */
    List<OrderDiscount> selectList(OrderDiscountQuery orderDiscountQuery);

    OrderDiscount selectOne(@Param("id") Long id, @Param("userId") Long userId);

    /**
     * 查询列表
     *
     * @param orderDiscountQuery
     * @return
     */
    List<OrderDiscount> selectListByUserIds(OrderDiscountQuery orderDiscountQuery);


    /**
     * 查询列表
     *
     * @param orderDiscountQuery
     * @return
     */
    OrderDiscount selectOne(OrderDiscountQuery orderDiscountQuery);

    /**
     * 批量插入
     *
     * @param discountList 折扣列表
     * @return
     */
    int inserts(@Param("discountList") List<OrderDiscount> discountList);

    int insertList(@Param("discountList") List<OrderDiscount> discountList);


    /**
     * 修改优惠
     *
     * @param query
     * @return
     */
    int update(OrderDiscountQuery query);


    /**
     * 修改优惠
     *
     * @param query
     * @return
     */
    int updateDiscountAmount(OrderDiscountQuery query);

//    /**
//     * 更新
//     *
//     * @param query
//     * @return
//     */
//    int updateUserId(OrderDiscountQuery query);

    /**
     * 更新用户id
     * @param id
     * @param userId
     * @param newUserId
     * @return
     */
    int updateUserId(@Param("id") Long id,
                     @Param("userId") Long userId,
                     @Param("newUserId") Long newUserId);


    /**
     * 修改优惠
     *
     * @param discount
     * @return
     */
    int updateDiscountAmountTwo(OrderDiscount discount);

    /**d
     * 更新
     *
     * @param record
     * @return
     */
    int updateTwo(OrderDiscount record);


    /**
     * 修改bizType
     *
     * @param bizType
     * @param userId
     * @param orderNo
     * @return
     */
    int updateBizType(@Param("bizType") Integer bizType, @Param("userId") Long userId, @Param("orderNo") String orderNo);


    /**
     * 批量删除
     *
     * @param idList
     * @param userId
     * @param deleteType
     * @return
     */
    int deletes(@Param("idList") List<Long> idList,
                @Param("userId") Long userId,
                @Param("deleteType") Integer deleteType);


    /**
      *
      * @date 2021/12/28 15:02
      * @param orderNo
      * @param userId
      * @return int
     **/
    int deleteTemp(@Param("orderNo") String orderNo,
                   @Param("userId") Long userId);


    /**
      *
      * @date 2021/12/28 15:02
      * @param orderNo
      * @param userId
      * @return int
     **/
    int deleteByOrderNo(@Param("orderNo") String orderNo,
                   @Param("userId") Long userId);


    /**
     * 更新主键
     * @param id
     * @param userId
     * @param newId
     * @return
     */
    int updateId(@Param("id") Long id,
                 @Param("userId") Long userId,
                 @Param("newId") Long newId);

    /**
     * 更新时间
     * @param id
     * @param userId
     * @return
     */
    int updateUpdatedAt(@Param("id") Long id,
                 @Param("userId") Long userId);

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


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

}