package com.jeequan.jeepay.core.interfaces.paychannel;

import com.jeequan.jeepay.core.entity.*;
import com.jeequan.jeepay.core.model.context.MchAppConfigContext;
import com.jeequan.jeepay.core.model.params.IsvParams;
import com.jeequan.jeepay.core.model.rqrs.msg.ChannelRetMsg;

import java.util.HashMap;
import java.util.List;

/**
* 分账接口
*
* @author terrfly
*
* @date 2021/8/22 08:59
*/
public interface IDivisionService {

    /** 是否在支付订单退款业务完成后在发起退分业务
     *
     * 返回 false :  先退分 --》 再 退款主订单
     * 返回 true: 先退款主订单，  并且明确退款成功后再退分。 退分模块：  （ 1. 直接响应成功，  2.渠道特殊处理 ）
     * **/
    boolean divisionRefundIsOrderRefundAfterProc();

    /** 获取到接口code **/
    String getIfCode();

    /** 获取实际使用的接口code，新增于克隆接口 **/
    String getIfCode(MchDivisionReceiver mchDivisionReceiver);

    /** 获取实际使用的接口code，新增于克隆接口 **/
    String getIfCode(PayOrder payOrder);

    /** 获取实际使用的接口code，新增于克隆接口 **/
    String getIfCode(PayOrderDivisionRecord payOrderDivisionRecord);

    /** 是否支持该分账 */
    boolean isSupport();

    /** 单次分账 （无需调用完结接口，或自动解冻商户资金)  **/
    ChannelRetMsg singleDivision(PayOrder payOrder, List<PayOrderDivisionRecord> recordList, MchAppConfigContext mchAppConfigContext);

    /** 查询分账结果  **/
    HashMap<Long, ChannelRetMsg> queryDivision(PayOrder payOrder, List<? extends PayOrderDivisionRecord> recordList, MchAppConfigContext mchAppConfigContext);

    /** 分账退回 **/
    ChannelRetMsg divisionRefund(PayOrderDivisionRecord payOrderDivisionRecord, PayOrderDivisionRefundRecord payOrderDivisionRefundRecord, RefundOrder refundOrder, PayOrder payOrder, MchAppConfigContext mchAppConfigContext);

    /** 查询分账账户余额  **/
    Long queryBalanceAmount(MchDivisionReceiver mchDivisionReceiver, MchAppConfigContext mchAppConfigContext);

    /** 账户提现  **/
    ChannelRetMsg cashout(MchDivisionReceiver mchDivisionReceiver, Long amount, MchAppConfigContext mchAppConfigContext);

    /** 分账完结  **/
    String divisionFinishAfterDivision(PayOrderDivisionRecord divisionRecord, MchAppConfigContext mchAppConfigContext);


    /** 新版绑定关系 **/
    ChannelRetMsg bind(DivisionSubjectEx subjectEx, String isvNo);

}
