/**
* @ClassName PayFactory
* @Description 支付工厂
* @Author ninghq
* @Date 2020/11/15 13:20
* @Version 1.0.0
**/
public class PayFactory {
public static Pay createPay(String type){
if(type.equalsIgnoreCase("ALI_PAY")){
return new AliPay();
} else if(type.equalsIgnoreCase("WECHATE_PAY")){
return new WeChatPay();
}
return null;
}
}
main函数主类
/**
* @ClassName PayMain
* @Description TODO
* @Author ninghq
* @Date 2020/11/15 13:23
* @Version 1.0.0
**/
public class PayMain {
public static void main(String[] args) {
PayFactory.createPay("WECHATE_PAY").unifiedorder();
PayFactory.createPay("ALI_PAY").unifiedorder();
}
}
Connected to the target VM, address: '127.0.0.1:17101', transport: 'socket'
微信统一支付
支付宝统一支付
Disconnected from the target VM, address: '127.0.0.1:17101', transport: 'socket'
Process finished with exit code 0