package com.fs.live.service;

import com.fs.common.core.domain.R;
import com.fs.erp.domain.ErpOrder;
import com.fs.hisStore.domain.FsStoreOrderScrm;
import com.fs.hisStore.param.FsStoreOrderAddTuiMoneyParam;
import com.fs.hisStore.param.FsStoreOrderScrmSetErpPhoneParam;
import com.fs.hisStore.vo.FsStoreOrderVO;
import com.fs.live.domain.LiveAfterSales;
import com.fs.live.domain.LiveOrder;
import com.fs.live.dto.LiveOrderComputeDTO;
import com.fs.live.dto.LiveOrderDeliveryNoteDTO;
import com.fs.live.param.*;
import com.fs.live.vo.*;
import com.fs.live.vo.LiveOrderDeliveryNoteExportVO;
import com.fs.store.domain.FsStoreDelivers;
import org.springframework.web.bind.annotation.RequestBody;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * 订单Service接口
 *
 * @author fs
 * @date 2025-07-08
 */
public interface ILiveOrderService {
    /**
     * 查询订单
     *
     * @param orderId 订单主键
     * @return 订单
     */
    LiveOrder selectLiveOrderByOrderId(String orderId);
    void editLiveOrderDeliveryId(@RequestBody FsStoreDelivers deliveryDTO);

    /**
     * 查询订单列表
     *
     * @param liveOrder 订单
     * @return 订单集合
     */
    List<LiveOrder> selectLiveOrderList(LiveOrder liveOrder);


    /**
     * 新增订单
     *
     * @param liveOrder 订单
     * @return 结果
     */
    Long insertLiveOrder(LiveOrder liveOrder);

    /**
     * 修改订单
     *
     * @param liveOrder 订单
     * @return 结果
     */
    int updateLiveOrder(LiveOrder liveOrder);

    /**
     * 批量删除订单
     *
     * @param orderIds 需要删除的订单主键集合
     * @return 结果
     */
    //int deleteLiveOrderByOrderIds(String[] orderIds);

    /**
     * 删除订单信息
     *
     * @param
     * @return 结果
     */
    //int deleteLiveOrderByOrderId(String orderId);

    void handlePay(LiveOrder liveOrder);

    R liveOrderUser(String liveId);

    /**
     * 获取订单时间粒度
     * @param liveOrder
     */
    R getLiveOrderTimeGranularity(LiveOrderTimeVo liveOrder);

    /**
     * 同步物流信息
     * @param id
     * @return
     */
    R syncExpress(Long id);

    /**
     * 确认收货
     * @param orderId
     * @return
     */
    int getGoods(Long orderId);

    /**
     * 修改物流信息
     * @param orderId
     * @param mailNo
     * @param expressCode
     * @param expressName
     */
    void updateDeliveryOrder(Long orderId, String mailNo, String expressCode, String expressName);

    /**
     * 获取订单商品列表
     * @param orderId
     * @return
     */
    List<LiveGoodsVo> selectLiveOrderItemList(String orderId);

    /**
     * 创建订单
     * @param liveOrder
     * @return
     */
    R createLiveOrder(LiveOrder liveOrder);

    /**
     * 订单确认
     * @param param
     * @return
     */
    R confirmOrder(LiveOrderConfirmParam param);

    /**
     * 获取未推送的订单
     * @return
     */
    List<LiveOrder> selectNotPushedLiveOrder();

    /**
     * 推送订单
     * @param liveOrder
     */
    void pushLiveOrder(LiveOrder liveOrder)  throws ParseException;

//    R aliPayment(FsUserLiveOrderPayUParam param);

    String payConfirm(Integer type,Long orderId,String payCode,String tradeNo,String bankTransactionId,String bankSerialNo);

    R wxPayment(FsUserLiveOrderPayUParam param);


    int tuiOrder(Long orderId);

    R cancelOrder(LiveOrder order);

    List<LiveOrderListVo> selectLiveOrderListVo(LiveOrder liveOrder);

    R buy(LiveOrder liveOrder);

    R finishOrder(Long orderId);

    List<LiveOrder> selectLiveOrderByFinish();

    void autoFinishOrder(LiveOrderFinishParam param);

    LiveOrder getById(String orderId);

    R refundOrderMoney(Long orderId);
    R refundOrderMoney(Long orderId, LiveAfterSales liveAfterSales);

    List<LiveOrder> selectUpdateExpress();

    void syncDeliveryOrder(LiveOrder order);

    List<Long> selectSyncExpressIds();

    List<Long> selectOrderIdByNoErp();

    R createOmsOrder(Long id)  throws ParseException;
    ErpOrder getErpOrder(LiveOrder order) throws ParseException;


    List<LiveOrder> selectDeliverPenddingData();

    void deliveryOrder(String orderCode, String mailNo, String expressCode, String expressName);

    LiveOrderComputeDTO computedOrder(long l, LiveOrderComputedParam param);

    LiveOrder selectOrderIdByOrderCode(String platformCode);

    R auditPayRemain(Long orderId);

    R addTuiMoney(FsStoreOrderAddTuiMoneyParam param);

    R updateExpress(Long orderId);

    LiveOrder selectLiveOrderByExtendId(String extendOrderId);

    R editTuiMoney(Long orderId);

    LiveOrder selectLiveOrderByOrderCode(String soId);

    R getExpressMulti(LiveOrder order);

    R getExpress(LiveOrder order);

    void orderCancel();

    LiveOrderComputeDTO computedReward(long l, LiveOrderComputedParam param);

    R createRewardLiveOrder(LiveOrder liveOrder);

    boolean isEntityNull(LiveOrderParam param);

    List<LiveOrderVO> selectLiveOrderListVO(LiveOrderParam param);

    Map<String, BigDecimal> selectLiveOrderStatistics(LiveOrderParam param);

    String selectLiveOrderProductStatistics(LiveOrderParam param);

    int deleteLiveOrderByIds(Long[] ids);

    List<LiveOrderErpExportVO> selectLiveOrderListVOByExport(LiveOrderParam param);

    int batchUpdateErpByOrderIds(LiveOrderScrmSetErpPhoneParam param);

    List<FsMyLiveOrderListQueryVO> selectFsMyLiveOrderListVO(FsMyLiveOrderQueryParam param);

    List<FsMyLiveOrderListQueryVO> selectFsCompanyLiveOrderListVO(FsMyLiveOrderQueryParam param);

    Integer selectFsStoreOrderCount(long l, int i);

    R payConfirmReward(LiveOrder liveOrder);


    List<LiveOrderVoZm> selectLiveOrderListZm(LiveOrder liveOrder);

    R handleLiveOrderPay(LiveOrderPayParam param);

    List<LiveOrder> selectLiveOrderItemJson();

    void refreshOrderSettlementStatus();

    /**
     * 批量导入更新直播订单发货状态
     * @param dtoList 订单数据
     * **/
    R importDeliveryNoteExpress(List<LiveOrderDeliveryNoteDTO> dtoList,String appId);

    /**
     * 获取发货单数据
     * @param param 查询条件
     * @return list
     * **/
    List<LiveOrderDeliveryNoteExportVO> getDeliveryNote(LiveOrderParam param);
}
