package com.czg.order.service;

import com.czg.order.dto.CreditBuyerOrderDTO;
import com.czg.order.entity.CreditBuyerOrder;
import com.czg.order.entity.CreditPaymentRecord;
import com.czg.order.entity.OrderInfo;
import com.czg.order.param.CreditBuyerOrderQueryParam;
import com.czg.order.vo.CreditBuyerOrderSummaryVo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;

import java.math.BigDecimal;

/**
 * 挂账账单
 *
 * @author Tankaikai tankaikai@aliyun.com
 * @since 1.0 2025-03-04
 */
public interface CreditBuyerOrderService extends IService<CreditBuyerOrder> {
    /**
     * 分页查询挂账账单
     *
     * @param param 查询参数
     * @return 分页结果
     */
    Page<CreditBuyerOrderDTO> getCreditBuyerOrderPage(CreditBuyerOrderQueryParam param);

    /**
     * 挂账账单汇总
     *
     * @param param 查询参数
     * @return 汇总结果
     */
    CreditBuyerOrderSummaryVo summary(CreditBuyerOrderQueryParam param);

    /**
     * 支付挂账订单
     *
     * @param record 入参
     */
    void pay(CreditPaymentRecord record);

    /**
     * 保存挂账账单
     *
     * @param creditBuyerId 挂账人id
     * @param orderId       订单id
     */
    boolean save(OrderInfo orderInfo, String creditBuyerId, Long orderId);


    /**
     * 挂账人退款(部分退款)
     *
     * @param creditBuyerId 挂账人id
     * @param orderId       订单id
     * @param refundAmount  退款金额
     * @return
     */
    boolean partRefund(String creditBuyerId, Long orderId, String orderNo, BigDecimal refundAmount);

}