package com.sonic.lion.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.sonic.common.auth.domains.Session;
import com.sonic.common.rpc.Page;
import com.sonic.lion.domain.entity.AccountBuff;
import com.sonic.lion.domain.entity.AccountBuffBill;
import com.sonic.lion.domain.entity.PayTrade;
import com.sonic.lion.domain.req.BillListReq;
import com.sonic.lion.domain.resp.BillOutput;
import com.sonic.lion.domain.resp.SummaryBillListResp;

/**
 * @author: code
 * @date: 2025/07/17
 * @Description:
 * @version: 1.0.0
 */
public interface AccountBuffBillService extends IService<AccountBuffBill> {


    /**
     * 流水列表及汇总
     *
     * @param req
     * @param session
     * @return
     */
    SummaryBillListResp billListSummary(BillListReq req, Session session);

    /**
     * 获取流水的汇总数据
     *
     * @param billListReq
     * @return
     */
    default SummaryBillListResp summary(BillListReq billListReq, Long userId, Page<BillOutput> page) {
        return summary(billListReq, userId, page, false);
    }

    SummaryBillListResp summary(BillListReq billListReq, Long userId, Page<BillOutput> page, boolean excludCharge);


    /**
     * 为提现预生成流水表
     *
     * @param input
     * @param accountBuff
     * @return
     */
    Long insertBillWhenWithdraw(PayTrade input, AccountBuff accountBuff);

    /**
     * 当提现失败时，增加返还流水
     * @param id
     * @param accountBuff
     */
    void insertBillWhenWithdrawFail(Long id, AccountBuff accountBuff);

    /**
     * 更新提现状态
     *
     * @param billId
     * @param after
     * @param message
     * @return
     */
    boolean updateWithdrawStatus(Long billId, AccountBuffBill.WithdrawStatus after, String message);


    boolean updateWithdrawBillAmount(Long billId, Long occurAmount);

    /**
     * 如果为退款且全额退款时，更新商家入帐流水为已退款
     * @param tradeNo
     */
    void updateBuffTypeToRefund(String tradeNo);
}
