package com.bohuikeji.delivery.backstage.service;

import com.alibaba.fastjson.JSONObject;
import com.bohuikeji.delivery.backstage.entity.TCustomerWallet;
import com.bohuikeji.delivery.backstage.entity.TOrder;
import com.bohuikeji.delivery.backstage.entity.TPay;
import com.bohuikeji.frame.module.admin.base.ServiceBase;
import com.bohuikeji.frame.module.admin.entity.back.APIEntity;
import com.bohuikeji.frame.module.admin.entity.vo.AliReturnPayVo;

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

/**
 * <p>
 * 支付交易信息表 服务类
 * </p>
 *
 * @author 10552
 * @since 2019-12-27
 */
public interface ITPayService extends ServiceBase<TPay> {

    /**
     * 按支付单号获取支付记录
     * @return
     */
    TPay getByNum(String payNum);


    /**
     * 订单业务创建预支付单（微信，支付宝）
     * @return
     */
    TPay createBeforePay(TOrder order,String scenario,String payMethod,String payWay);

    /**
     * 微信支付
     * @param rs
     * @param order
     * @param payScenario
     * @return
     */
    TPay wxUpdatePay(Map<String, String> rs, TOrder order,String payScenario,String payNum);


    /**
     * 微信&支付宝，扫码支付预支付订单修改
     * @param pay
     * @param tOrder
     * @param request
     * @return
     */
    boolean wxAlipay(TPay pay, TOrder tOrder, HttpServletRequest request);

    /**
     * 微信支付回调业务处理（不是微信扫码）
     * @param jsonObject
     * @param pay
     * @return
     */
    //TPay wxCallbackPay(JSONObject jsonObject,TPay pay);
    /**
     * 支付宝支付回调业务处理
     * @param req
     * @param pay
     * @return
     */
    //TPay aliCallbackPay(AliReturnPayVo req,TPay pay);

    /**
     * 订单支付回调处理集成
     * @param jsonObject
     * @param req
     * @param pay
     * @return
     */
    TPay callbackPayServis(JSONObject jsonObject,AliReturnPayVo req,TPay pay);



    /**
     * 钱包支付业务处理
     * @param pay
     * @return
     */
    TPay walletPay(TPay pay, TCustomerWallet tCustomerWallet,TOrder order);

    /**
     * 各端调起支付预支付订单
     * @param tOrder
     * @param type
     * @param request
     * @return
     * @throws Exception
     */
    APIEntity getPayAPIEntity(TOrder tOrder,HttpServletRequest request) throws Exception;

    /**
     * 获取最后一条支付记录
     * @param orderId 订单ID
     * @return
     */
    TPay lastWaitPay(Integer orderId);

}
