package com.zm.order.tool.server.handler;

import com.zm.order.tool.server.dto.OrderDTO;
import com.zm.order.tool.server.dto.RefundDTO;
import com.zm.order.tool.server.model.BaseIndexOrder;
import com.zm.order.tool.server.model.Order;
import com.zm.order.tool.server.query.SearchOrderQuery;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;

import java.util.List;

/**
 * @Description 业务处理 模板模式
 * @Author: ph
 * @Date: 2019/12/9 19:43
 */
public interface BusinessHandler {

    /**
     * 业务类型
     *
     * @return
     */
    Integer bizType();

    /**
     * 构建索引对象
     *
     * @param order
     * @return
     */
    BaseIndexOrder buildIndexOrder(Order order);

    /**
     * 组装搜索参数
     * @param searchOrderQuery
     * @return
     */
    SearchSourceBuilder buildSearchSourceBuilder(SearchOrderQuery searchOrderQuery);

    /**
     * 解析返回
     *
     * @param searchHits
     * @return
     */
    List<BaseIndexOrder> parseIndexOrder(SearchHit[] searchHits);

    /**
     * 获取退款总金额（单个订单）
     * @param refundDTO 退款订单
     * @return: java.lang.Integer
     * @Date:   2020/3/23 11:46 AM
     */
    Integer getRefundAmount(RefundDTO refundDTO);

    /**
     * 获取订单信息
     *
     * @param baseIndexOrder
     * @param orderDTO
     * @param order
     * @return: java.util.List<com.zm.order.biz.dto.view.OrderDTO>
     * @Date: 2020/3/24 8:12 PM
     */
    BaseIndexOrder getOrderDto(BaseIndexOrder baseIndexOrder, OrderDTO orderDTO, Order order);

}
