shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.walker.pay;
 
import com.walker.infrastructure.arguments.Variable;
import com.walker.pay.exception.OrderException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import java.util.Map;
 
public abstract class AbstractOrderGenerator implements OrderGenerator {
 
    protected final transient Logger logger = LoggerFactory.getLogger(this.getClass());
 
    @Override
    public ResponsePay generate(String providerPayType, Order platformOrder, Map<String, Variable> configuration) throws OrderException {
        try {
            return this.invoke(providerPayType, platformOrder, configuration);
        } catch (Exception ex){
            throw new OrderException(String.valueOf(platformOrder.getId()), ex.getMessage(), ex);
        }
    }
 
    @Override
    public ResponsePay generate(PayContext payContext, Order platformOrder) throws OrderException {
        try {
            return this.invoke(payContext, platformOrder);
        } catch (Exception ex){
            throw new OrderException(String.valueOf(platformOrder.getId()), ex.getMessage(), ex);
        }
    }
 
    /**
     * 调用第三方获取订单信息。
     * @param payContext
     * @param platformOrder
     * @return
     * @date 2023-02-17
     */
    protected abstract ResponsePay invoke(PayContext payContext, Order platformOrder);
 
    /**
     * 提交请求第三方获取预订单。<p></p>
     * 该方法废弃,请使用 {@linkplain AbstractOrderGenerator#invoke(PayContext, Order)}
     * @param providerPayType 第三方定义的支付方式,如: 微信v2中的 NATIVE/APP等
     * @param platformOrder 平台定义的订单
     * @param configuration
     * @return
     */
    @Deprecated
    protected abstract ResponsePay invoke(String providerPayType, Order platformOrder, Map<String, Variable> configuration);
}