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

import com.alibaba.fastjson.JSON;
import com.jeequan.jeepay.core.entity.MchApplyment;
import com.jeequan.jeepay.core.entity.MchModifyApplyment;
import com.jeequan.jeepay.core.model.applyment.MchModifyApplymentModel;
import org.apache.commons.lang3.tuple.MutablePair;

public interface IIsvmchModifyApplymentService {

    /**
     * 本地基本信息变更
     */
    MutablePair<MchModifyApplyment, MchApplyment> localModifyBase(MutablePair<MchModifyApplyment, MchApplyment> mchDataPair);

    /**
     * 本地结算信息变更
     */
    MutablePair<MchModifyApplyment, MchApplyment> localModifySettlement(MutablePair<MchModifyApplyment, MchApplyment> mchDataPair);

    /**
     * 本地结算信息变更
     */
    MutablePair<MchModifyApplyment, MchApplyment> localModifyRate(MutablePair<MchModifyApplyment, MchApplyment> mchDataPair);


    default MutablePair<MchModifyApplyment, MchApplyment> localModifySettlementType(MutablePair<MchModifyApplyment, MchApplyment> mchDataPair) {
        String applyDetailInfo = mchDataPair.left.getApplyDetailInfo();
        MchModifyApplymentModel mchModifyData = JSON.parseObject(applyDetailInfo, MchModifyApplymentModel.class);
        mchDataPair.right.setSettlementType(mchModifyData.getSettlementType());
        mchDataPair.left.setState(MchApplyment.STATE_SUCCESS);
        return mchDataPair;
    }

    /**
     * 基本信息变更, 上游通道同步
     */
    MutablePair<MchModifyApplyment, MchApplyment> syncChannelModifyBase(MutablePair<MchModifyApplyment, MchApplyment> mchDataPair);

    /**
     * 结算信息变更, 上游通道同步
     */
    MutablePair<MchModifyApplyment, MchApplyment> syncChannelModifySettlement(MutablePair<MchModifyApplyment, MchApplyment> mchDataPair);

    /**
     * 费率变更, 上游通道同步
     */
    MutablePair<MchModifyApplyment, MchApplyment> syncChannelModifyRate(MutablePair<MchModifyApplyment, MchApplyment> mchDataPair);

    /**
     * 结算方式变更，上游通道同步
     *
     */
    MutablePair<MchModifyApplyment, MchApplyment> syncChannelModifySettlementType(MutablePair<MchModifyApplyment, MchApplyment> mchDataPair);

    MutablePair<MchModifyApplyment, MchApplyment> queryModifyResult(MutablePair<MchModifyApplyment, MchApplyment> mchDataPair);
}
