/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.finance.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springblade.modules.api.response.UserOrderDetailResponse;
import org.springblade.modules.api.response.UserOrderResponse;
import org.springblade.modules.api.vo.LogisticVO;
import org.springblade.modules.finance.entity.Order;
import org.springblade.modules.finance.vo.OrderVO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 订单主表 服务类
 *
 * @author BladeX
 * @since 2023-02-14
 */
public interface IOrderService extends IService<Order> {

	/**
	 * 初始化订单数据
	 * @return
	 */
	Order init();

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param order
	 * @return
	 */
	IPage<OrderVO> selectOrderPage(IPage<OrderVO> page, OrderVO order);

	/**
	 * 取消订单
	 * @param orderId
	 */
	Order orderCancel(Long orderId);

	/**
	 * 根据订单号查询订单
	 */
	Order getByOrderNo(String orderNo);

	/**
	 * 订单支付成功
	 * @param order 订单实体
	 * @param payType 支付类型
	 */
	void orderPaySuccess(Order order, String payType);

	/**
	 * 确认收货
	 * @param id
	 */
    void confirm(Serializable id);

	/**
	 * 申请退款
	 * @param id
	 */
	void orderRefund(Long id);

	/**
	 * 通用退款
	 * @param order
	 */
	void commonRefund(Order order, Long afterSalesId);

	void commonRefund(String orderNo, Long orderId, BigDecimal refundAmount, BigDecimal totalAmount, Long afterSalesId);

	/**
	 * 查询订单物流
	 * @param orderId 订单id
	 * @return
	 */
	LogisticVO logistic(Long orderId);


	/**
	 * 订单超时处理
	 */
	void orderTimeout(Long orderId, Long transactionId);

	IPage<UserOrderResponse> getUserOrder(IPage<UserOrderResponse> page, Long userId, Integer orderState);

	UserOrderDetailResponse getUserOrderDetail(Long orderId, Long afterSalesId, Double longitude, Double latitude);

    void modifySelfTake(Long orderId, Long selfTakeId);

    Page<Order> getOrderByExpirationTime(Page page, Date time);
}
