PayRpc.java 4.43 KB
package com.diligrp.etrade.rpc;

import com.diligrp.etrade.core.domain.Message;
import com.diligrp.etrade.rpc.config.PayServiceFeignConfig;
import com.diligrp.etrade.rpc.dto.*;
import com.diligrp.etrade.rpc.dto.request.CancelTradeRequestDto;
import com.diligrp.etrade.rpc.dto.request.CreateTradeRequestDto;
import com.diligrp.etrade.rpc.dto.response.BalanceResponseDto;
import com.diligrp.etrade.rpc.dto.response.EcapWeChatRefundVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Map;

/**
 * 支付服务调用
 * @author :dengjf
 * @date : 2023-08-28
 */
@FeignClient(name = "pay-service" , contextId = "payRpc", configuration = PayServiceFeignConfig.class)
public interface PayRpc {

    /**
     * 查询余额
     * @author dengjf
     * @Date 2023-08-18
     */
    @RequestMapping(value = "/payment/api/gateway.do?service=payment.fund.service:query", method = RequestMethod.POST)
    Message<BalanceResponseDto> getAccountBalance(@RequestBody CreateTradeRequestDto requestDto, @RequestHeader(name = "mchId") String mchId);

    /**
     *创建交易
     * @param requestDto
     * @param headers
     * @return
     */
    @RequestMapping(value = "/payment/api/gateway.do?service=payment.trade.service:prepare", method = RequestMethod.POST)
    Message<Map<String,String >> prepare(@RequestBody CreateTradeRequestDto requestDto, @RequestHeader HttpHeaders headers);

    /**
     *提交交易
     * @param commitDto
     * @param headers
     * @return
     */
    @RequestMapping(value = "/payment/api/gateway.do?service=payment.trade.service:commit", method = RequestMethod.POST)
    Message<BalanceResponseDto> submit(@RequestBody PaymentTradeCommitDto commitDto, @RequestHeader HttpHeaders headers);

    /**
     * 撤销交易
     * @param cancelDto
     * @param headers
     * @return
     */
    @RequestMapping(value = "/payment/api/gateway.do?service=payment.trade.service:cancel", method = RequestMethod.POST)
    Message<BalanceResponseDto> cancel(@RequestBody CancelTradeRequestDto cancelDto, @RequestHeader HttpHeaders headers);

    /**
     * 微信预支付
     * @param requestDto
     * @param headers
     * @return
     */
    @RequestMapping(value = "/wechat/api/gateway.do?service=wechat.payment.service:prepare", method = RequestMethod.POST)
    Message<WeChatPayTradeBackDto> wechatPay(@RequestBody WeChatPayTradeDto requestDto, @RequestHeader HttpHeaders headers);

    /**
     * 微信预支付状态查询
     * @param requestDto
     * @param headers
     * @return
     */
    @RequestMapping(value = "/wechat/api/gateway.do?service=wechat.payment.service:state", method = RequestMethod.POST)
    Message<WeChatPayFunctionBackDto> wechatPayCheckState(@RequestBody WeChatPayFunctionDto requestDto, @RequestHeader HttpHeaders headers);

    /**
     * 微信预支付关闭
     * @param requestDto
     * @param headers
     * @return
     */
    @RequestMapping(value = "/wechat/api/gateway.do?service=wechat.payment.service:close", method = RequestMethod.POST)
    Message<WeChatPayFunctionBackDto> wechatPayClose(@RequestBody WeChatPayFunctionDto requestDto, @RequestHeader HttpHeaders headers);

    /**
     * 微信预支付历史流水查询
     * @param requestDto
     * @param headers
     * @return
     */
    @RequestMapping(value = "/wechat/api/gateway.do?service=wechat.payment.service:statement", method = RequestMethod.POST)
    Message<WeChatPayInfoDto> wechatPayInfo(@RequestBody WeChatPayFunctionDto requestDto, @RequestHeader HttpHeaders headers);

    /**
     * 微信退款
     * @param requestDto
     * @param headers
     * @return
     */
    @RequestMapping(value = "/wechat/api/gateway.do?service=wechat.payment.service:refund", method = RequestMethod.POST)
    Message<EcapWeChatRefundVo> refund(@RequestBody WeChatPayTradeDto requestDto, @RequestHeader HttpHeaders headers);

    /**
     * 微信退款
     * @param requestDto
     * @param headers
     * @return
     */
    @RequestMapping(value = "/wechat/api/gateway.do?service=wechat.payment.service:exists", method = RequestMethod.POST)
    Message<WeChatPayFunctionBackDto> checkWeChatPayChannel(@RequestBody WeChatPayFunctionDto requestDto, @RequestHeader HttpHeaders headers);
}