package com.qxgmat.help;

import com.nuliji.tools.pay.Alipay;
import com.nuliji.tools.pay.WechatPay;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class PayHelp {
    private Alipay alipay;
    private String alipayPid;

    @Autowired
    private void getAlipay(
            @Value("${pay.alipay.appId}") String appId,
            @Value("${pay.alipay.appKey}") String appKey,
            @Value("${pay.alipay.appPublicKey}") String appPublicKey,
            @Value("${pay.alipay.pid}") String pid
    ) {
        this.alipay = new Alipay(appId, appKey, appPublicKey);
        this.alipayPid = pid;
    }

    private WechatPay wechatPay;
    private String wechatPid;

    @Autowired
    private void getWechatPay(
            @Value("${pay.wechat.appId}") String appId,
            @Value("${pay.wechat.appKey}") String appKey,
            @Value("${pay.wechat.pid}") String pid
    ) {
        this.wechatPay = new WechatPay(appId, appKey, pid);
        this.wechatPid = pid;
    }

    @Autowired
    @Value("${pay.notifyUrl}")
    private String notifyUrl;

    public Alipay getAlipay() {
        return alipay;
    }

    public String getAlipayPid() {
        return alipayPid;
    }

    public WechatPay getWechatPay() {
        return wechatPay;
    }

    public String getNotifyUrl() {
        return notifyUrl;
    }

    public String getWechatPid() {
        return wechatPid;
    }
}
