package com.yonge.cooleshow.portal.service;

import com.yonge.cooleshow.mall.common.api.CommonPage;
import com.yonge.cooleshow.mbg.model.OmsOrder;
import com.yonge.cooleshow.portal.domain.ConfirmOrderResult;
import com.yonge.cooleshow.portal.domain.OmsOrderDetail;
import com.yonge.cooleshow.portal.domain.OrderParam;
import com.yonge.cooleshow.portal.dto.OrderPayReq;
import com.yonge.cooleshow.portal.dto.OrderPayRes;
import com.yonge.toolset.payment.base.model.callback.PaymentCallBack;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 前台订单管理Service
 * Created by macro on 2018/8/30.
 */
public interface OmsPortalOrderService {
    /**
     * 根据用户购物车信息生成确认单信息
     * @param cartIds
     */
    ConfirmOrderResult generateConfirmOrder(List<Long> cartIds);

    /**
     * 根据提交信息生成订单
     */
    @Transactional
    Map<String, Object> generateOrder(OrderParam orderParam);

    /**
     * 支付成功后的回调
     */
    @Transactional
    Integer paySuccess(Long orderId, Integer payType);

    /**
     * 自动取消超时订单
     */
    @Transactional
    Integer cancelTimeOutOrder();

    /**
     * 取消单个超时订单
     */
    @Transactional
    void cancelOrder(Long orderId, String message, PaymentCallBack data);

    /**
     * 发送延迟消息取消订单
     */
    @Transactional
    void sendDelayMessageCancelOrder(Long orderId);

    /**
     * 确认收货
     */
    @Transactional
    void confirmReceiveOrder(Long orderId);

    /**
     * 分页获取用户订单
     */
    CommonPage<OmsOrderDetail> list(String status, Integer pageNum, Integer pageSize);

    /**
     * 根据订单ID获取订单详情
     */
    OmsOrderDetail detail(Long orderId);

    OmsOrderDetail detail(String orderSn);

    /**
     * 用户根据订单ID删除订单
     */
    @Transactional
    void deleteOrder(Long orderId);

    /**
     * 订单拉起支付
     *
     * @param payReq 支付信息
     * @return
     */
    @Transactional
    OrderPayRes orderPay(OrderPayReq payReq);
    /**
     * 获取订单信息
     *
     * @param orderId 订单号
     * @return
     */
    OmsOrder getOrderById(Long orderId);

    /**
     * 支付回调
     *
     * @param data
     */
    @Transactional
    void executePaymentCallBack(PaymentCallBack data);

    /**
     * 关闭订单
     *
     * @param data
     */
    @Transactional
    void closePaymentCallBack(PaymentCallBack data);


    /**
     * 设置自动收货
     *
     * @return
     */
    @Transactional
    Integer autoReceive();

    /**
     * 设置分润，不可申请售后
     *
     * @return
     */
    @Transactional
    Integer shareProfit();
}
