package com.jsowell.alipay.service;

import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipayEncrypt;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.easysdk.base.oauth.Client;
import com.alipay.easysdk.base.oauth.models.AlipaySystemOauthTokenResponse;
import com.alipay.easysdk.factory.Factory;
import com.jsowell.alipay.config.AliPayConfig;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.Map;

/**
 * 支付宝小程序service
 */
@Slf4j
@Service
public class AliAppletRemoteService {

    /**
     * 通过authCode获取手机号
     * @param code
     * @return
     * @throws Exception
     */
    public String getMobileNumberByCode(String code) throws Exception {
        AlipaySystemOauthTokenResponse token = Factory.Base.OAuth().getToken(code);
        log.info("AlipaySystemOauthTokenResponse:{}", JSON.toJSONString(token));

        String accessToken = token.getAccessToken();

        return "";
    }

    /**
     * 通过openIdCode获取openId
     * @param openIdCode
     * @return
     */
    public String getOpenId(String openIdCode) {
        return "";
    }


}
