package com.yunzhi.marketing.redpack.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yunzhi.marketing.base.ResponseBean;
import com.yunzhi.marketing.redpack.entity.ConsumeOrder;
import com.yunzhi.marketing.redpack.entity.RechargeOrder;
import com.yunzhi.marketing.redpack.entity.RefundOrder;
import com.yunzhi.marketing.redpack.entity.TaOrgOrder;
import com.yunzhi.marketing.redpack.entity.TaOrgRefundApplication;

import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 组织订单表  服务类
 * </p>
 *
 * @author fxf
 * @since 2020-06-03
 */
public interface ITaOrgOrderService extends IService<TaOrgOrder> {
    /**
     * 订单退款
     *
     * @param id
     * @param refundApplication
     * @param userId
     * @return
     */
    ResponseBean refundOrder(String id, TaOrgRefundApplication refundApplication, Integer userId);


    /**
     * 订单驳回
     *
     * @param id
     * @param refundApplication
     * @param userId
     * @return
     */
    ResponseBean rejectOrder(String id, TaOrgRefundApplication refundApplication, Integer userId);

    /**
     * 订单列表
     *
     * @param pg
     * @param orderType
     * @return
     */
    IPage<TaOrgOrder> listByCondition(IPage<TaOrgOrder> pg, String orderType, Integer orgId, String tradeNo, Integer isOffline, String tradingStatus, String receivePhone, String itemType, String startDate, String endDate, String miniAppName, String auditStatus, String payStartDate, String payEndDate);

    /**
     * 充值订单列表导出
     *
     * @return
     */
    List<RechargeOrder> rechargeListByConditionExport(String itemType, String tradeNo, Boolean isOffline, String tradingStatus, String startDate, String endDate, String miniAppName, Integer orgId);

    /**
     * 消费订单列表导出
     *
     * @return
     */
    List<ConsumeOrder> consumeListByConditionExport(String itemType, String tradeNo, String receivePhone, String tradingStatus, String startDate, String endDate, String miniAppName, Integer orgId);

    /**
     * 退款订单列表导出
     *
     * @return
     */
    List<RefundOrder> refundListByConditionExport(String itemType, String tradeNo, String startDate, String endDate, String miniAppName, Integer orgId, String auditStatus);


    /**
     * 微信支付
     *
     * @param taOrgOrder
     * @param remoteAddr
     * @return
     */
    ResponseBean payUnifiedOrder(TaOrgOrder taOrgOrder, String remoteAddr) throws Exception;

    /**
     * 创建充值订单
     *
     * @param amount
     * @param orgId
     * @param userId
     * @return
     */
    ResponseBean saveCzOrder(Integer amount, Integer orgId, Integer userId, String ip) throws Exception;

    /**
     * 创建退款订单
     *
     * @param amount
     * @param orgId
     * @param userId
     * @return
     */
    ResponseBean saveRefundOrder(Integer amount, Integer orgId, Integer userId);

    /**
     * 获取充值订单列表
     *
     * @param pageNum
     * @param pageSize
     * @param payStartTime
     * @param payEndTime
     * @param orderId
     * @param tradeNo
     * @param wxOrderId
     * @param isOffline
     * @param tradingStatus
     * @return
     */
    ResponseBean listCzOrderByCondition(Integer pageNum, Integer pageSize, LocalDateTime payStartTime, LocalDateTime payEndTime, String orderId, String tradeNo,
                                        String wxOrderId, Boolean isOffline, String tradingStatus, Integer orgId);

    /**
     * 导出充值订单列表
     *
     * @param payStartTime
     * @param payEndTime
     * @param orderId
     * @param tradeNo
     * @param wxOrderId
     * @param isOffline
     * @param tradingStatus
     * @return
     */
    void exportCzOrderByCondition(LocalDateTime payStartTime, LocalDateTime payEndTime, String orderId, String tradeNo, String wxOrderId,
                                  Boolean isOffline, String tradingStatus, Integer orgId, HttpServletResponse response) throws Exception;

    /**
     * 获取退款订单列表
     *
     * @param pageNum
     * @param pageSize
     * @param refundStartTime
     * @param refundEndTime
     * @param orderId
     * @param auditStatus
     * @param orgId
     * @return
     */
    ResponseBean listRefundOrderByCondition(Integer pageNum, Integer pageSize, LocalDateTime refundStartTime, LocalDateTime refundEndTime, String orderId, String auditStatus, String wxOrderId,
                                            String tradeNo, Integer orgId);

    /**
     * 导出退款订单列表
     *
     * @param refundStartTime
     * @param refundEndTime
     * @param orderId
     * @param auditStatus
     * @param orgId
     * @param response
     * @throws Exception
     */
    void exportRefundOrderByCondition(LocalDateTime refundStartTime, LocalDateTime refundEndTime, String orderId, String auditStatus, String wxOrderId,String tradeNo, Integer orgId, HttpServletResponse response) throws Exception;

    /**
     * 条件查询红包发送记录
     *
     * @param pageNum
     * @param pageSize
     * @param orderId
     * @param wxOrderId
     * @param tradeNo
     * @param tradingStatus
     * @param orgId
     * @return
     */
    ResponseBean listRedPacketRecords(Integer pageNum, Integer pageSize, String phone, String activityId, String orderId, String wxOrderId, String tradeNo, String tradingStatus, Integer orgId);

    /**
     * 获取消费订单列表
     *
     * @param pageNum
     * @param pageSize
     * @param startTime
     * @param endTime
     * @param orderId
     * @param tradingStatus
     * @param consumeType
     * @param phone
     * @param orgId
     * @return
     */
    ResponseBean listConsumeOrderByCondition(Integer pageNum, Integer pageSize, LocalDateTime startTime, LocalDateTime endTime, String orderId, String tradingStatus,
                                             String consumeType, String phone, String wxOrderId, String tradeNo, Integer orgId);

    /**
     * 导出消费订单列表
     *
     * @param startTime
     * @param endTime
     * @param orderId
     * @param tradingStatus
     * @param consumeType
     * @param phone
     * @param orgId
     * @param response
     * @throws Exception
     */
    void exportConsumeOrderByCondition(LocalDateTime startTime, LocalDateTime endTime, String orderId, String tradingStatus, String consumeType, String phone, String wxOrderId, String tradeNo, Integer orgId, HttpServletResponse response) throws Exception;
}
