package com.iformall.service;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.*;
import com.iformall.domain.vo.PromotionCalc;
import com.iformall.domain.vo.WxCardSpendVo;
import com.iformall.exception.MallinkException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

public interface WxCardSpendService {

    /**
     *
     */
    WxCouponMerchant checkMerchantInCoupon(WxCardInfo cardInfo, Long merchantId);

    /**
     * 创建卡花费
     *
     * @param record
     * @param order
     * @return
     */
    ResultData createCardSpend(WxCardSpend record, WxOrder order, WxCouponMerchant couponMerchant);

    /**
     * 根据实体查询分页列表
     *
     * @param record
     * @param pageIndex
     * @param pageSize
     * @return
     */
    PageInfo<WxCardSpendVo> listAsPage(WxCardSpendVo record, Integer pageIndex, Integer pageSize);

    /**
     * 根据实体SUM
     *
     * @param record
     * @return
     */
    List<Map<String, Object>> sumCardSpendForMerchant(WxCardSpendVo record);

    /**
     * 根据实体SUM
     *
     * @param record
     * @return
     */
    List<Map<String, Object>> sumCardSpendForOwner(WxCardSpendVo record);

    /**
     * 根据Id获得实体
     *
     * @param id
     * @return
     */
    WxCardSpend getById(Long id);

    /**
     * 保存或更新实体
     *
     * @param record
     */
    void saveOrUpdate(WxCardSpend record);

    /**
     * 更新实体
     *
     * @param record
     */
    void update(WxCardSpend record);

    /**
     * 卡完结
     *
     * @param tenantId
     * @param cardId
     */
    int finishCard(String tenantId, Long cardId);

    /**
     * 根据Id删除实体
     *
     * @param id
     */
    void deleteById(Long id);

    /**
     * cardPay分账
     * @param tenantId
     * @param orderId
     * @param cardSpendId
     */
    void shareForCardPay(String tenantId, Long cardId, Long orderId, Long cardSpendId);

    /**
     * cardPay交易流水导出
     */
    void exportData(WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response);

    /**
     * POS 卡支付相关接口
     */
    WxCardSpend cardSpendForPosPrePay(WxCardSpend record) throws MallinkException;
    WxCardInfo cardSpendForPosPrePayCancel(WxCardInfo cardInfo, WxCardSpend record) throws MallinkException;
    WxCardSpend cardSpendForPosPay(PromotionCalc scoreCreditCalc, WxCardSpend record, WxMerchant merchant, WxMerchantBUser buUser) throws MallinkException;
}
