package com.ywt.alipaympapi;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import com.ywt.rpc.core.RestServerStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@SpringBootApplication
@EnableAspectJAutoProxy
public class EmptyApplication {

    public static void main(String[] args) {
        SpringApplication.run(EmptyApplication.class, args);
        String serviceName = "com.ywt.AlipayMpRestService";
        System.out.println("--- RegisterService: " + serviceName);
        RestServerStarter.build(null).registry(serviceName, null, "支付宝小程序服务");
        initAlipayEasySdk();
    }

    /**
     * 初始化 alipay-easy-sdk
     * 后续开通多医院需要做动态读取配置处理
     */
    private static void initAlipayEasySdk() {
        Config config = new Config();
        config.protocol = "https";
        config.gatewayHost = "openapi.alipay.com";
        config.signType = "RSA2";

        config.appId = "2021003141662056";
        // 为避免私钥随源码泄露，推荐从文件中读取私钥字符串而不是写入源码中
        config.merchantPrivateKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDTrydAgG5HUwvoYE6L4WFlgIhX2fKPEFvlpDyCremBPk5Zp3OMpoj3cfcd36Im/0MndQII90hErcRqfUEPJhw+F2CSBpxkLTb/7J1iRyUiKjv5G+24qG4FQIo/yc0o7xQsNLJR7McbS3ROuuPg1jN5qL8XKCPxCHEL5QzzJCVp+Jz+GKeGYPPmPdALC1nxgOKjYjpJrwOGtaU+7WuaB9SVz98xU3FocLFDTqE0MCQySOxxB0CZgBEPahp2l2B6FcMBoRok2p1ODIlN1ihfEEIrAU9rmso7swxEo65oaCuZu/bkH1FvmcayjMJ0xBir8pBh96tKt8loU++LY9y1rq6tAgMBAAECggEAAqvUJ/k26wl+PflxJEy8yOYdUlZ6vBltv3EaHmAJcUsS/Aij6aN0WQMEJklbJ3jTJR1R4EEWlV9H+jwIZSOK+bGb01vn/0+ewQ4AUmwpaMv1o8gZcNoXQVO2KuXmA904ePJVSbleLdb+6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，则无需赋值上面的三个证书路径，改为赋值如下的支付宝公钥字符串即可
        config.alipayPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtUtjYn+V60um6GVF0ezsI4NCI8QAiM8BT7SQda3RDzIssPbU5U3GJo/5bbu+k+pOpCOUlGVve2VoO+AXMWizCA8U/RleN7fNE09yw7RdLfLssNp6J4zGfBHQBWMiTrJvGZ4LzZHiwJgf28CGwcovjAK6M8bjF30k5ChQ8YIi+YYuer8yae7XfORLiSTByakglURlVUZF7QgbLph9i/OBk83HribZh+B/n97vavrAUyTjbDE3TMsINsAfMSY1omweXuvqjndYI+XmiBM4nBPHlPsXEeaF9TE8LuIqWm5mnRKWa/0I31RkE+W19tFUx5mF3oHw6SvyVuUQVx0HWGIPKQIDAQAB";
        // 可设置异步通知接收服务地址（可选）
        config.notifyUrl = "https://pay-qa.ywtinfo.com";
        Factory.setOptions(config);
    }
}
