package com.czg.order.service;

import com.alibaba.fastjson2.JSONObject;
import com.czg.order.dto.*;
import com.czg.order.entity.OrderDetail;
import com.czg.order.entity.OrderInfo;
import com.czg.order.enums.PayEnums;
import com.czg.order.vo.HistoryOrderPrintVo;
import com.czg.order.vo.HistoryOrderVo;
import com.czg.order.vo.OrderInfoVo;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import jakarta.validation.constraints.NotBlank;
import org.jetbrains.annotations.NotNull;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 订单表 服务层。
 *
 * @author ww
 * @since 2025-02-13
 */
public interface OrderInfoService extends IService<OrderInfo> {

    Page<OrderInfoVo> getOrderByPage(OrderInfoQueryDTO param);

    CzgResult<HistoryOrderVo> getOrderDetails(Long orderId);

    CzgResult<HistoryOrderPrintVo> getOrderByIdPrint(Long orderId);

    HistoryOrderVo historyOrder(Long orderId, String tableCode);

    OrderInfo createOrder(OrderInfoAddDTO param);

    OrderInfo checkOrderPay(CheckOrderPay param);

    CzgResult<Object> mergeOrder(MergeOrderDTO param);

    void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);

    void refundCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);

    void upOrderInfo(OrderInfo orderInfo, BigDecimal payAmount, LocalDateTime payTime, Long payOrderId, PayEnums payType);

    void expired(Long orderId);

    OrderInfo createPayOrder(Long shopId, BigDecimal amount, String remark);

    void processOrderDetails2(List<OrderDetail> orderDetails, Map<Long, Integer> prodCouponMap,
                              BigDecimalDTO prodCouponAmount, BigDecimalDTO totalAmount, BigDecimalDTO packAmount,
                              boolean isAllPack, Integer userAllPack, boolean isVipPrice);


    Boolean printOrder(Long shopId, OrderInfoPrintDTO orderInfoPrintDTO);


    Boolean removeOrderDetail(Long shopId, Long orderId, Long detailId);

    Boolean cancelledOrder(Long shopId, Long orderId);

    Boolean cancelledPlaceOrder(Long shopId, Long orderId, Integer placeNum);
}
