package com.fs.hisStore.service;

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

import com.alibaba.fastjson.JSONObject;
import com.fs.api.param.OrderListParam;
import com.fs.api.vo.OrderListVO;
import com.fs.common.core.domain.R;
import com.fs.company.domain.CompanyUser;
import com.fs.course.dto.FsOrderDeliveryNoteDTO;
import com.fs.erp.domain.ErpOrder;
import com.fs.his.domain.FsStorePayment;
import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
import com.fs.his.param.FsStoreOrderSalesParam;
import com.fs.his.vo.FsStoreOrderAmountScrmStatsVo;
import com.fs.his.vo.FsStoreOrderExcelVO;
import com.fs.hisStore.domain.FsStoreOrderItemScrm;
import com.fs.hisStore.domain.FsStoreOrderLogsScrm;
import com.fs.hisStore.domain.FsStoreOrderScrm;
import com.fs.hisStore.domain.FsStorePaymentScrm;
import com.fs.hisStore.dto.ExpressNotifyDTO;
import com.fs.hisStore.dto.ExpressResultDTO;
import com.fs.hisStore.dto.FsStoreOrderComputeDTO;
import com.fs.hisStore.dto.StoreOrderExpressExportDTO;
import com.fs.hisStore.param.*;
import com.fs.hisStore.vo.*;

import com.fs.his.vo.FsPrescribeVO;

/**
 * 订单Service接口
 *
 * @author fs
 * @date 2022-03-15
 */
public interface IFsStoreOrderScrmService
{

    /**
     * 查询订单
     *
     * @param id 订单ID
     * @return 订单
     */
    public FsStoreOrderScrm selectFsStoreOrderById(Long id);

    /**
     * 查询订单列表
     *
     * @param fsStoreOrder 订单
     * @return 订单集合
     */
    public List<FsStoreOrderScrm> selectFsStoreOrderList(FsStoreOrderScrm fsStoreOrder);

    /**
     * 新增订单
     *
     * @param fsStoreOrder 订单
     * @return 结果
     */
    public int insertFsStoreOrder(FsStoreOrderScrm fsStoreOrder);

    /**
     * 修改订单
     *
     * @param fsStoreOrder 订单
     * @return 结果
     */
    public int updateFsStoreOrder(FsStoreOrderScrm fsStoreOrder);

    /**
     * 批量删除订单
     *
     * @param ids 需要删除的订单ID
     * @return 结果
     */
    public int deleteFsStoreOrderByIds(Long[] ids);

    /**
     * 删除订单信息
     *
     * @param id 订单ID
     * @return 结果
     */
    public int deleteFsStoreOrderById(Long id);

    List<FsStoreOrderVO> selectFsStoreOrderListVO(FsStoreOrderParam param);

    List<FsStoreOrderVO> selectFsStoreOrderAllListVO(FsStoreOrderParam param);

    List<FsStoreOrderVO> selectPayRemainListVO(FsStoreOrderParam param);


    List<FsPromotionOrderVO> selectFsPromotionOrderListVO(FsStoreOrderParam param);

    R confirmOrder(long uid, FsStoreConfirmOrderParam cartParam);

    FsStoreOrderComputeDTO computedOrder(long parseLong, FsStoreOrderComputedParam param);

    R createOrder(long userId, FsStoreOrderCreateParam param);

    R createOrderByPrescribe(Long prescribeId);

    void cancelOrder(Long orderId);

    void refundPrescribeOrder(Long orderId);

    void refundOrder(Long orderId);

    void deliveryOrder(String orderCode,String deliveryId,String deliverCode,String deliverName);

    void updateDeliveryOrder(Long id,String deliveryId,String deliverCode,String deliverName);

    List<FsMyStoreOrderListQueryVO> selectFsMyStoreOrderListVO(FsMyStoreOrderQueryParam param);

    FsStoreOrderScrm selectFsStoreOrderByOrderCode(String orderCode);

    R getExpress(FsStoreOrderScrm order);

    R createUserOrder(FsStoreOrderCreateUserParam param);

    List<FsMyStoreOrderListQueryVO> selectFsCompanyStoreOrderListVO(FsMyStoreOrderQueryParam param);

    FsStoreOrderScrm selectFsStoreOrderByExtendOrderId(String orderId);

    List<FsStoreOrderTuiVO> selectFsStoreOrderTuiListVO(String userId);

    R confirmPackageOrder(long userId, FsStoreConfirmPackageIdOrderParam param);

    R createPackageOrder(long userId, FsStorePackageOrderCreateParam param);

    R finishOrder(Long orderId);

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

    Integer selectFsStoreOrderCount(long userId, int status);

    /**
     * 根据时间查询订单总数
     * @param param
     * @return
     */
    Integer selectFsStoreOrderCount(FsStoreOrderStatisticsParam param);

    R computedPackageOrder(long userId, FsStoreComputedPackageIdOrderParam param);

    FsStoreOrderScrm selectFsStoreOrderByDeliveryId(String logisticCode);

    String importExpress(List<StoreOrderExpressExportDTO> list, boolean updateSupport) throws InterruptedException;

    R createOmsOrder(Long orderId) throws ParseException;

    ErpOrder getErpOrder(FsStoreOrderScrm order) throws ParseException;

    FsStoreOrderVO selectFsStoreOrderVOByOrderCode(String orderCode);

    Long selectFsStoreOrderTotalCount(int type,Long companyId,Long companyUserId);

    R editTuiMoney(FsStoreOrderEditTuiMoneyParam param);

    List<OrderListVO> selectCompanyStoreOrderListAPI(OrderListParam param);

    List<FsStoreOrderScrm> selectFsStoreOrderByCompanyId(Long companyId);

    List<FsStoreOrderScrm> selectFsStoreOrderListByDeliveryId(String logisticCode);

    R refundOrderMoney(Long orderId);

    R updateExpress(FsStoreOrderExpressEditParam param);

    R syncExpress(FsStoreOrderExpressEditParam param);

    R addTuiMoney(FsStoreOrderAddTuiMoneyParam param);

    R createSalesOrder(CompanyUser companyUser, String cateIds,Integer orderType,Integer orderMedium);

    R getSalesOrder(String createOrderKey);

    R addUserCart(long userId, String createOrderKey);

    R updateSalseOrderMoney(String createOrderKey, BigDecimal money,BigDecimal payAmount,Integer payType);

    Integer selectFsStoreOrderCountByType(Long companyId, long userId, int type);

    List<FsCustomerStoreOrderListQueryVO> selectFsCustomerStoreOrderListQuery(FsCustomerStoreOrderListQueryParam param);

    List<JSONObject> selectFsStoreOrderCounts(Map<String, Object> toMap);

    List<FsStoreOrderStatisticsVO> selectFsStoreOrderStatisticsList(FsStoreStatisticsParam param);

    List<FsStoreOrderErpExportVO> selectFsStoreOrderListVOByExport(FsStoreOrderParam param);

    List<FsStoreOrderPromotionExportVO> selectFsPromotionOrderListVOByExport(FsStoreOrderParam param);

    List<FsStorePayRemainOrderExportVO> selectFsStorePayRemainOrderListVOByExport(FsStoreOrderParam param);

    List<FsStoreOrderScrm> selectFsStoreOrderListByFinish7Day();

    List<FsStoreOrderVO> selectFsCustomerStoreOrderListVO(FsStoreOrderParam param);

    String payRemainConfirm(String payCode,String tradeNo,String bankTransactionId,String bankSerialNo);

    R auditPayRemain(Long orderId);

    Boolean isEntityNull(FsStoreOrderParam param);

    int uploadCredentials(FsStoreOrderScrm order);

    String getCredentialsById(Long id);

    List<Long> selectFsStoreOrderToPushByIds(String startTime);

    List<FsStoreOrderScrm> selectFsStoreOrderItemJson();

    int uploadItemJson(FsStoreOrderScrm order);

    ExpressResultDTO updateDeliveryItem(ExpressNotifyDTO notifyDTO);

    FsStoreOrderScrm selectOrderByUserIdLimit1(Long userId);


    List<FsStoreOrderScrm> selectFsStoreOrderStatisticsByUserId(List<Long> fsUserIdList);


    /**
     * 完成订单
     * @param orderId 订单id
     * @return R
     */
    R finishStoreOrder(Long orderId);

    /**
     * 根据时间查询实际支付金额
     *
     * @param param
     * @return
     */
    BigDecimal selectFsStoreOrderByPayPriceCount(FsStoreOrderStatisticsParam param);

    /**
     * 订单维度分页查询接口
     * @param param 查询条件
     * @return List<OrderStatisticsVo>
     * **/
    List<OrderStatisticsVo> selectOrderDimensionStatisticsList(OrderStatisticsParam param);

    List<FsStoreOrderCountsVO> selectFsStoreOrderCountsByDept(Map<String, Object> map,Long deptId);

    R updateSalesOrderMoneyByProduct(FsStoreOrderMoneyByProductParam param);

    List<FsStoreProductCountsVO> selectFsStoreProductCountsByDept(Map<String, Object> map, Long deptId);

    FsStoreOrderScrm selectFsStoreOrderByOrderId(Long storeOrderId);

    List<FsStoreOrderExcelVO> selectFsStoreOrderExcelListSVO(FsStoreOrderParam fsStoreOrder);

    String importSroreOrder(List<FsStoreProductDeliverExcelVO> list, Long storeID,Long companyId);

    int deleteFsStoreOrderByOrderIds(String[] orderIds);

    List<FsStoreOrderItemScrm> selectFsStoreOrderItemList(String orderId);

    List<FsStoreOrderLogsScrm> selectFsStoreOrderLogsList(String orderId);

    FsPrescribeVO selectFsPrescribeByPrescribeIdVO(Long prescribeId);

    List<FsStorePaymentScrm> selectFsStorePaymentByOrderId(Long orderId);

    int sendGoods(FsStoreOrderScrm fsStoreOrder);

    int getGoods(Long id);

    int updateMoney(FsStoreOrderScrm fsStoreOrder);

    int tuiOrder(Long id);

    int afterSales(FsStoreOrderSalesParam fsStoreOrder);

    /**
     * 批量导入更新微信订单发货状态
     * @param dtoList 订单数据
     * **/
    R importDeliveryNoteExpress(List<FsOrderDeliveryNoteDTO> dtoList);

    /**
     * 查询app商城订单金额统计信息
     * */
    FsStoreOrderAmountScrmStatsVo selectFsStoreOrderAmountScrmStats(FsStoreOrderAmountScrmStatsQueryDto queryDto);

    R pay(FsStoreOrderPayParam param);

    void cancelPay(FsStoreOrderPayParam param);

    R otherPaymentRemain(FsStoreOrderOtherPayParam param);

    R otherPayment(FsStoreOrderOtherPayParam param);

    R payRemain(FsStoreOrderPayParam param);

    R editPayType(FsStoreOrderPayParam param);

    /**
     * 跟进代服账户查询订单
     * @param param
     * @return
     */
    List<FsStoreOrderVO> selectFsStoreOrderListVOByErpAccount(FsStoreOrderParam param);

    int batchUpdateErpByOrderIds(FsStoreOrderScrmSetErpPhoneParam param);

    Map<String, BigDecimal> selectFsStoreOrderStatistics(FsStoreOrderParam param);

    String selectFsStoreOrderProductStatistics(FsStoreOrderParam param);

    int create(Long orderId, String type, String msg);

    R dfOrderResult(String body);

    R receiveWaybillPush(String body);
}
