package com.yonge.cooleshow.portal.service;

import com.ym.mec.common.entity.HttpResponseResult;
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 org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
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);

    /**
     * 发送延迟消息取消订单
     */
    @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
    HttpResponseResult orderPay(Map payReq) throws Exception;
    /**
     * 获取订单信息
     *
     * @param orderId 订单号
     * @return
     */
    OmsOrder getOrderById(Long orderId);


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

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

    void paymentSucceededHandle(String orderNo, BigDecimal payAmount, String payChannel);

    void paymentFailedHandle(String orderNo, Map<String, Object> notifyMap);

    /**
     * 根据支付订单号查询订单列表
     */
    List<OmsOrderDetail> list(List<String> adapayNoList);
}
