package com.clx.performance.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.dto.CancelOrderGoodsWeightDTO;
import com.clx.performance.dto.OrderGoodsCancelWeightDTO;
import com.clx.performance.mapper.OrderGoodsMapper;
import com.clx.performance.model.OrderGoods;
import com.clx.performance.model.OrderGoodsFleetOpenTruck;
import com.clx.performance.param.app.AppGoodsOrderSearchParam;
import com.clx.performance.param.app.OrderGoodsListPageParam;
import com.clx.performance.param.pc.GoodsOrderMapParam;
import com.clx.performance.param.pc.OrderGoodsEditParams;
import com.clx.performance.param.pc.PageOrderGoodsListParam;
import com.clx.performance.vo.app.OrderGoodsAPPVO;
import com.clx.performance.vo.pc.OrderGoodsVO;
import com.msl.common.base.Optional;
import com.msl.common.dao.BaseDao;

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

/**
 * @author kavin
 * Date 2023-09-17
 * Time 16:45
 */
public interface OrderGoodsDao extends BaseDao<OrderGoodsMapper, OrderGoods, Integer> {

    String getMaxOrderGoodsId();

    Optional<OrderGoods> getByOrderGoodsNo(String orderGoodsNo);

    Optional<OrderGoods> getOrderGoodsInfoByOrderGoodsNoForPC(String orderGoodsNo);

    Optional<OrderGoods> getOrderGoodsInfoByOrderGoodsNoForAPP(String orderGoodsNo);


    IPage<OrderGoodsVO> pageOrderGoodsList(PageOrderGoodsListParam param);

    void updateOrderGoodsReduceWeightAndStatus(Integer id, BigDecimal orderChildWeight, Integer orderGoodsStatus);

    void updateOrderGoodsWeightAlreadyAndStatus(Integer id, BigDecimal residueWeight,Integer orderGoodsStatus);

    IPage<OrderGoodsAPPVO> openOrderPageGoodsList(OrderGoodsListPageParam orderGoodsListPageParam,List<String> orderGoodsNoList);

    IPage<OrderGoodsAPPVO> exclusiveOrderPageGoodsList(OrderGoodsListPageParam orderGoodsListPageParam, List<String> orderGoodsNoList);

    void updateOrderGoodsStatusByOrderGoodsNo(String orderGoodsNo, Integer code);

    void saveBatchEntity(List<OrderGoods> orderGoodsList);

    List<OrderGoods> getOrderGoodsListByOrderNo(String orderNo);

    List<OrderGoods> getOrderGoodsListByOrderNoAndLastArriveSendTime(String orderNo, LocalDateTime lastArriveSendTime);

    Optional<List<OrderGoods>> getOrderGoodsList();

    List<OrderGoods> getSendAddressSelect(GoodsOrderMapParam param);

    List<OrderGoods> listIntegralOrderGoodsSync();

    boolean updatePendingOrderFreightById(Integer id, BigDecimal pendingOrderFreight);
    boolean updatePendingOrderFreightByIdList(BigDecimal pendingOrderFreight, List<Integer>idList);

    Boolean updateStopFlagByOrderNo(String orderNo, Integer stopFlag);

    boolean updateOrderGoodsStatusAndRollbackResidueWeightByOrderGoodsNo(Integer orderGoodsId, Integer status);

    Integer updateOrderGoodsSetAlreadyWeight(BigDecimal alreadyWeight,  Integer id);

    Integer updateOrderGoodsSetResidueWeightAndAlreadyWeight(BigDecimal residueWeight, BigDecimal alreadyWeight, Integer id);

    Integer updateOrderGoodsSetAlreadyWeightAndStatus( BigDecimal alreadyWeight, Integer status, Integer id);


    OrderGoodsVO findOrderGoodsById(Integer id);

    List<OrderGoods> selectListByOrderGoodsList(List<String> orderGoodsNo);

    Integer updateOrderGoods(OrderGoodsEditParams orderGoodsEditParams);

    boolean batchUpdateOrderGoodsStatus(Integer status, List<Integer> ids);



    void updateSendSystemAddress(Integer ownerAddressId, Integer systemAddressId);
    void updateReceiveSystemAddress(Integer ownerAddressId, Integer systemAddressId);

    List<OrderGoods> getOrderGoodsListByOrderNoAndStatus(String orderNo);

    List<OrderGoodsAPPVO> getCancelOrderGoods(List<String> list);

    BigDecimal sumAlreadyTransportWeightByOrderNo(String orderNo);

    List<Double> getFreightPrice( Integer sendAddressId,Integer receiveAddressId,String orderNo);

    IPage<OrderGoodsAPPVO> indexOrderGoodsListSearch(AppGoodsOrderSearchParam param);


    List<OrderGoodsFleetOpenTruck> queryProcessFleetOpenTruckList();

    void cancelOrderGoods(String orderNo);

    void batchCancel(List<Integer> idList);

    void batchCancelOrderGoods(List<CancelOrderGoodsWeightDTO> cancelOrderGoodsWeight);

    List<OrderGoods> listAfterCreatedByOrderNo(String orderNo);

    List<OrderGoods> listAllByOrderNo(String orderNo);

    void batchUpdateOrderGoodsPaying(List<OrderGoods> updateOrderGoods);

    void batchCancelOrderGoodsWeight(List<OrderGoodsCancelWeightDTO> cancelOrderGoodsList);

}
