package org.springblade.modules.payment.plugin;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springblade.core.tool.api.R;
import org.springblade.modules.ldt.billrecord.entity.BillRecord;
import org.springblade.modules.ldt.billrecord.service.IBillRecordService;
import org.springblade.modules.payment.entity.PayParam;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: lianghanqiang
 * @description: 支付插件抽象层
 * @since: 7/29/21 -- 2:08 PM
 */
public interface Payment {

	String CALLBACK_DOMAIN = "https://ldt.guosen-fumao.cn/api";

	String CALLBACK_PREFIX = "/payment/callback/";
	/**
	 * 	扫码支付
	 * */
	R nativePay(PayParam payParam);

	/**
	 * 	收款码支付
	 * */
	R payCode(PayParam payParam);

	/**
	 * 	对公户打款
	 * */
	R transfer(PayParam payParam);

	/**
	 * 	支付回调
	 * */
	void callback(HttpServletRequest request);

	/**
	 * 	获取回调地址
	 * */
	default String callbackUrl(String paymentType){
		return CALLBACK_DOMAIN + CALLBACK_PREFIX + paymentType;
	}

	/**
	 * 	获取订单详情
	 * */
	default BillRecord getOrderDetail(PayParam payParam, IBillRecordService billRecordService){
		return billRecordService.getById(payParam.getOrderId());
	}

	R miniProgram(PayParam payParam);
}
