package com.dxhy.extend.service.bb.impl;

import cn.hutool.http.HttpRequest;
import com.dxhy.extend.service.bb.VouncherSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @Author wangzhikun
 * @Date 2023/3/30 2023/3/30
 */
@Service
@Slf4j
public class VouncherSyncServiceImpl implements VouncherSyncService {
    @Value("${sdny.snYxUrl}")
    private String url;
    @Value("${po.userName}")
    private String userName;

    @Value("${po.password}")
    private String password;

    @Override
    public String sendPo(String request) {
        long startTime = System.currentTimeMillis();
        log.info("请求同步凭证号数据{}",request);
        HttpRequest httpRequest = new HttpRequest(url);
        httpRequest.basicAuth(userName,password);
        String body = httpRequest.body(request).timeout(300000).header("Content-Type","application/json").execute().body();
        long endTime = System.currentTimeMillis();
        log.debug("以字符串调用post请求url:{},耗时:{},返回参数{}", url, endTime - startTime,body);
        return body;

    }
}
