package com.yc.ship.module.trade.dal.mysql.order;


import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.tenant.core.aop.TenantIgnore;
import com.yc.ship.module.trade.dal.dataobject.order.TradeDetailBaseDO;
import com.yc.ship.module.trade.dal.dataobject.order.TradeDetailDO;
import com.yc.ship.module.trade.service.order.bo.TradeOrderDetailBaseBO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 订单明细基础 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface TradeDetailBaseMapper extends BaseMapperX<TradeDetailBaseDO> {

    List<TradeOrderDetailBaseBO> selectNeedSupplierOrderList(@Param("orderId") Long orderId);

    List<TradeDetailBaseDO> selectBaseListFromOrder(@Param("orderId") Long orderId, @Param("baseBo") TradeOrderDetailBaseBO baseBo);

    List<TradeDetailBaseDO> selectDistinctBaseListBySupplierOrderId(@Param("platSupplierOrderId") Long platSupplierOrderId);
    List<TradeDetailBaseDO> selectBaseListBySupplierOrderNo(@Param("supplierVoucherCode") String supplierVoucherCode);
    List<Map<String, Object>> getProjectCodeOrderId(@Param("platSupplierOrderId") Long platSupplierOrderId);
    TradeDetailBaseDO selectDetailBaseBySupplierVoucherCode(@Param("supplierVoucherCode") String supplierVoucherCode);
    List<TradeDetailDO> getDistinctDetailListBySupplierOrderId(@Param("platSupplierOrderId") Long platSupplierOrderId);

    Integer selectCountBySpecType(@Param("platSupplierOrderId") Long platSupplierOrderId, @Param("specType") String specType);

    void updateStatusByOrderId(@Param("orderId") Long orderId, @Param("status") Integer status);

    @TenantIgnore
    void updateStatusByDetailId(@Param("detailId") Long detailId);

    List<Long> selectDetailIdByPlatSupplierId(@Param("platSupplierOrderId") Long platSupplierOrderId);

    int updateRefundingBatch(@Param("tradeDetailBaseList") List<TradeDetailBaseDO> tradeDetailBaseDOList, @Param("refundStatus") Integer refundStatus);

    List<TradeOrderDetailBaseBO> selectProductBaseByOrder(@Param("orderId") Long orderId);
    List<TradeOrderDetailBaseBO> getProductBaseBySupplierVoucherCode(@Param("supplierVoucherCode") String supplierVoucherCode);

    List<TradeDetailBaseDO> selectProductBaseList(@Param("detailId") Long detailId, @Param("channelId") Long channelId);

    List<Map<String, Object>> selectVisitorOrderProductBaseCount(@Param("productBaseId") Long productBaseId, @Param("useDate") LocalDateTime useDate, @Param("credentialNoList") List<String> credentialNoList,@Param("excludeOrderId") Long excludeOrderId);
    @TenantIgnore
    void updateDeleted(@Param("orderId") Long orderId, @Param("deleted")  int deleted);

}