package com.iformall.service;

import java.util.*;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxCUser;
import com.iformall.domain.po.WxMerchantBUser;
import com.iformall.domain.po.WxPayOrder;
import com.iformall.enums.EnumPayWay;

public interface WxPayOrderService {

    /**
     * 创建支付订单
     *
     * @param record 支付订单请求
     * @param payWay
     * @return
     */
    ResultData createPayOrder(WxAppinfo appInfo, WxCUser user, WxPayOrder record, EnumPayWay payWay);

    /**
     * 刷卡支付订单
     *
     * @param record 支付订单请求
     * @param payWay
     * @return
     */
    ResultData createMicroPayOrder(WxMerchantBUser user, WxPayOrder record, EnumPayWay payWay);

    /**
     * 微信支付订单查询
     * @param record   支付订单
     */
    ResultData payOrderQuery(WxPayOrder record);

    /**
     * 微信支付关闭订单
     * @param appInfo  支付订单Appinfo
     * @param record   支付订单
     */
    ResultData payOrderClose(WxAppinfo appInfo, WxPayOrder record);

    /**
     * 微信支付刷卡支付撤销订单
     * @param record   支付订单
     */
    ResultData payOrderReverse(WxPayOrder record);

    /**
     * 异步通知
     *
     * @param paramMap 异步通知参数
     * @param payWay   支付方式
     * @return
     */
    String notify(Map<String, String> paramMap, EnumPayWay payWay);

    /**
     * 支付成功处理
     *
     * @param record
     * @param transactionId
     * @param from
     */
    void handleOrderPaySuccess(WxPayOrder record, String transactionId, Integer from);

    /**
     * 刷卡支付成功处理
     *
     * @param record
     * @param transactionId
     */
    void handleMicroOrderPaySuccess(WxPayOrder record, String transactionId, String openId, String isSubscribe);

    /**
     * 支付状态处理
     *
     * @param record
     */
    void handlePayOrderFail(WxPayOrder record, int status);

    /**
     * 支付状态处理(免费券)
     *
     * @param record
     */
    void handlePayOrderStatusUpdateFree(WxPayOrder record);

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

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

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

    /**
     * 根据obj获得实体
     *
     * @param payOrder
     * @return
     */
    WxPayOrder getByObj(WxPayOrder payOrder);



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


}
