package com.heyu.api.data.dao.vv;
/**
 * <p>
 * 购物车 服务类
 * </p>
 *
 * @author quyixiao
 * @since 2025-08-23
 */

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.heyu.api.data.entity.vv.VvTradeOrderLineEntity;
import com.lz.mybatis.plugin.annotations.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface VvTradeOrderLineDao extends BaseMapper<VvTradeOrderLineEntity> {


    VvTradeOrderLineEntity selectVvTradeOrderLineById(@Param("id") Long id);


    Long insertVvTradeOrderLine(VvTradeOrderLineEntity vvTradeOrderLine);


    Long insertOrUpdateVvTradeOrderLine(VvTradeOrderLineEntity vvTradeOrderLine);


    int updateVvTradeOrderLineById(VvTradeOrderLineEntity vvTradeOrderLine);


    int updateCoverVvTradeOrderLineById(VvTradeOrderLineEntity vvTradeOrderLine);


    int deleteVvTradeOrderLineById(@Param("id") Long id);

    @OrderBy(VvTradeOrderLineEntity.id_)
    @GroupBy(VvTradeOrderLineEntity.trade_order_id)
    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByProductName(@LIKE String productName);


    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTradeOrderIds(@IN List<Long> tradeOrderId,
                                                                       @IF String status);


    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTradeOrderIdSkuId(Long tradeOrderId, Long skuId);

    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByIds(@IN List<Long> id);


    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTradeOrderId(Long tradeOrderId);


    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTradeOrderIdNEStatus(Long tradeOrderId,
                                                                              @IF @NE String status);


    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTradeOrderIdNEStatusList(Long tradeOrderId,
                                                                                  @IF @NE List<String> status);

    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTradeOrderIdStatus(Long tradeOrderId,
                                                                            @IF String status);


    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTradeOrderIdStatusAndReverseStatus(Long tradeOrderId,
                                                                                            @LBracket String status,
                                                                                            @RBracket @IN List<String> reverseStatus);

    @OrderBy(VvTradeOrderLineEntity.id_)
    @GroupBy(VvTradeOrderLineEntity.trade_order_id)
    List<VvTradeOrderLineEntity> selectByAdminCondition(IPage page,
                                                        @IF @IN List<Long> tradeOrderId,
                                                        @IF @LIKE String buyerPhone,
                                                        @IF @LIKE String buyerName,
                                                        @IF @LIKE String buyerWeixin,
                                                        @IF @GE @Column(VvTradeOrderLineEntity.promotion_price) BigDecimal minPromotionPrice,
                                                        @IF @LE @Column(VvTradeOrderLineEntity.promotion_price) BigDecimal maxPromotionPrice,
                                                        @IF String status,
                                                        @IF Integer settleStatus,
                                                        @IF @GE @Column(VvTradeOrderLineEntity.create_timestamp) Long minCreateTimestamp,
                                                        @IF @LE @Column(VvTradeOrderLineEntity.create_timestamp) Long maxCreateTimestamp,
                                                        @IF @LIKE String productName,
                                                        @IF Integer refundCount,
                                                        @IF Long productId,
                                                        @IF Long sellerId,
                                                        @IF @LIKE String sellerName,
                                                        @IF Long buyerId,
                                                        @IF @OrderBy(VvTradeOrderLineEntity.create_timestamp) String createTimestampSort,
                                                        @IF @OrderBy(VvTradeOrderLineEntity.modify_timestamp) String modifyTimestampSort
    );



    @OrderBy(VvTradeOrderLineEntity.id_)
    List<VvTradeOrderLineEntity> selectByAdminConditionList(
                                                        @IF @IN List<Long> tradeOrderId,
                                                        @IF @LIKE String buyerPhone,
                                                        @IF @LIKE String buyerName,
                                                        @IF @LIKE String buyerWeixin,
                                                        @IF @GE @Column(VvTradeOrderLineEntity.promotion_price) BigDecimal minPromotionPrice,
                                                        @IF @LE @Column(VvTradeOrderLineEntity.promotion_price) BigDecimal maxPromotionPrice,
                                                        @IF String status,
                                                        @IF Integer settleStatus,
                                                        @IF @GE @Column(VvTradeOrderLineEntity.create_timestamp) Long minCreateTimestamp,
                                                        @IF @LE @Column(VvTradeOrderLineEntity.create_timestamp) Long maxCreateTimestamp,
                                                        @IF @LIKE String productName,
                                                        @IF  Long productId,
                                                        @IF Long sellerId,
                                                        @IF @LIKE String sellerName,
                                                        @IF Long buyerId,
                                                        @IF @OrderBy(VvTradeOrderLineEntity.create_timestamp) String createTimestampSort,
                                                        @IF @OrderBy(VvTradeOrderLineEntity.modify_timestamp) String modifyTimestampSort);





    @OrderBy(VvTradeOrderLineEntity.id_)
    @GroupBy(VvTradeOrderLineEntity.trade_order_id)
    @ExludeColumn({
            VvTradeOrderLineEntity.profit_amount,
            VvTradeOrderLineEntity.settle_status,
            VvTradeOrderLineEntity.is_delete,
            VvTradeOrderLineEntity.origin_price
    })
    List<VvTradeOrderLineEntity> selectByAppCondition(IPage page,
                                                      @IF @IN List<Long> tradeOrderId,
                                                      @IF String status,
                                                      @IF Integer commentStatus,
                                                      @IF @NE @Column(VvTradeOrderLineEntity.status_) String deleteStatus,
                                                      @IF @GE @Column(VvTradeOrderLineEntity.create_timestamp) Long minCreateTimestamp,
                                                      @IF @LE @Column(VvTradeOrderLineEntity.create_timestamp) Long maxCreateTimestamp,
                                                      @IF @LIKE String productName,
                                                      @IFNullReturnEmpty Long buyerId,
                                                      @IF @IsNotEmpty String reverseStatus,
                                                      @IF @OrderBy(VvTradeOrderLineEntity.create_timestamp) String createTimestampSort);


    @OrderBy(VvTradeOrderLineEntity.id_)
    @GroupBy(VvTradeOrderLineEntity.trade_order_id)
    @ExludeColumn({
            VvTradeOrderLineEntity.profit_amount,
            VvTradeOrderLineEntity.settle_status,
            VvTradeOrderLineEntity.is_delete,
            VvTradeOrderLineEntity.origin_price
    })
    List<VvTradeOrderLineEntity> selectByAppCount(IPage page,
                                                      @IF String status,
                                                      @IFNullReturnEmpty  Long buyerId
    );


    @GroupBy(VvTradeOrderLineEntity.sku_id)
    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTrackNumberGroupBySkuId(String trackNumber);

    int updateVvTradeOrderLineCommentIdById(Long commentId,@By Long id);



    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTrackNumber(String trackNumber);


    List<VvTradeOrderLineEntity> selectVvTradeOrderByTradeOrderIds(@IN List<Long> tradeOrderId);


    @OrderBy(VvTradeOrderLineEntity.id_)
    @ExludeColumn({
            VvTradeOrderLineEntity.profit_amount,
            VvTradeOrderLineEntity.settle_status,
            VvTradeOrderLineEntity.is_delete,
            VvTradeOrderLineEntity.origin_price
    })
    List<VvTradeOrderLineEntity> selectAppTradeOrderByTradeOrderIds(@IN List<Long> tradeOrderId);


    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByBuyerIdTrackNumber(Long buyerId, String trackNumber);

    List<VvTradeOrderLineEntity> selectByTradeOrderIdAndTransactionId(Long tradeOrderId, @IF String transactionId);

    Integer updateByBuerIdAndIds(String status,@By Long buyerId,@By Long id);

    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTrackNumberBuyerId(String trackNumber,Long buyerId);

    List<VvTradeOrderLineEntity> selectVvTradeOrderLineByTradeOrderIdBuyerId(Long tradeOrderId,Long buyerId);

}