package com.yonge.cooleshow.biz.dal.service;

import com.microsvc.toolkit.config.jwt.utils.JwtUserInfo;
import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentResp;
import com.microsvc.toolkit.middleware.payment.common.api.entity.RefundResp;
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
import com.yonge.cooleshow.biz.dal.wrapper.UserPaymentOrderWrapper;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户支付订单服务
 * Created by Eric.Shang on 2022/12/22.
 */
public interface UserPaymentCoreService {

    /**
     * 支付回调消息
     * @param paymentResp PaymentResp
     */
    void executePaymentCallback(PaymentResp paymentResp);


    /**
     * 支付成功处理流程
     * @param paymentOrder UserPaymentOrderWrapper.UserPaymentOrder
     * @param paymentResp PaymentResp
     */
    void executePaymentSuccess(UserPaymentOrderWrapper.UserPaymentOrder paymentOrder, PaymentResp paymentResp);

    /**
     * 取消订单支付
     * @param paymentOrder UserPaymentOrderWrapper.UserPaymentOrder
     * @param paymentResp PaymentResp
     */
    void cancelPayment(UserPaymentOrderWrapper.UserPaymentOrder paymentOrder, PaymentResp paymentResp);

    /**
     * 用户下单请求
     * @param orderReq UserPaymentOrderWrapper.UserPaymentOrder
     */
    UserPaymentOrderWrapper.PaymentConfig executeOrderCreate(UserPaymentOrderWrapper.UserPaymentOrder orderReq);


    int getActivityCount(Long userId, ClientEnum client, Long activityId);

    /**
     * 用户支付请求
     * @param userInfo JwtUserInfo
     * @param reqConfig UserPaymentOrderWrapper.PaymentOrderReqConfig
     * @return UserPaymentOrderWrapper.PaymentReq
     */
    UserPaymentOrderWrapper.PaymentReq executePayment(JwtUserInfo<?> userInfo, UserPaymentOrderWrapper.PaymentOrderReqConfig reqConfig);

    UserPaymentOrderWrapper.PaymentConfig executeOrder(UserPaymentOrderWrapper.UserPaymentOrder orderReq);

    /**
     * 用户支付请求
     * @param reqConfig UserPaymentOrderWrapper.PaymentOrderReqConfig
     * @return UserPaymentOrderWrapper.PaymentReq
     */
    UserPaymentOrderWrapper.PaymentReq executePayment(UserPaymentOrderWrapper.PaymentOrderReqConfig reqConfig);

    /**
     * 用户支付取消
     * @param userInfo JwtUserInfo
     * @param orderNo 订单编号
     */
    void cancelPayment(JwtUserInfo<?> userInfo, String orderNo);


    /**
     * 扫描支付超时定时
     */
    void scanPaymentTimeoutOrderRecord();

    /**
     * 检测订单支付方式
     *
     * @param payTypeReq UserPaymentOrderWrapper.OrderPayTypeReq
     */
    UserPaymentOrderWrapper.OrderPayTypeResp orderPayType(UserPaymentOrderWrapper.OrderPayTypeReq payTypeReq);

    /**
     * 退款回调
     *
     */
    void refundPaymentCallback(RefundResp refundResp);

    void refundPayment(String orderNo, String reason, List<Long> orderDetailIds);

    void refundOnly(String reason, String orderNo);


    /**
     * 退款
     */
    void refundOnly(String reason, String orderNo, List<Long> oredrDetilIds);

    /**
     * 关闭订单
     *
     * @param userInfo     JwtUserInfo
     * @param paymentOrder UserPaymentOrder
     * @return PaymentResp
     */
    PaymentResp closedPayment( UserPaymentOrderWrapper.UserPaymentOrder paymentOrder);

    /**
     * 刷新订单状态
     * @param orderNo 订单编号
     */
    void paymentStatus(String orderNo);
}
