package cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.electronicInvoice.service;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.electronicInvoice.dto.env.SzhtxxElectronicInvoiceConstant;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.electronicInvoice.dto.request._SzhtxxElectronicInvoiceBaseRequest;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Description: 拦截去改requestBody不合适，目前就用这种方法吧
 * @Author: linjinyu
 * @CreateDate: 2022/3/28 1:37 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/3/28 1:37 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class _SzhtxxElectronicInvoiceAuthService {

    @Autowired
    protected SzhtxxElectronicInvoiceConstant szhtxxElectronicInvoiceConstant;

    protected void addAuth(_SzhtxxElectronicInvoiceBaseRequest baseRequest) {

        baseRequest.setTaxpayerId(szhtxxElectronicInvoiceConstant.getAccessKeyId());
        baseRequest.setPassWord(szhtxxElectronicInvoiceConstant.getAccessKeySecret());
    }

    protected void tmpLogWithFpqqlsh(String targetFullPath, String relativePath, String type, String fpqqlsh, String jsonBody, String now) {

        String targetResponseFileName          = StrUtil.format("{}_{}_{}.json", fpqqlsh, type, now);
        String targetResponseWriteFileFullPath = targetFullPath + relativePath + targetResponseFileName;
        targetResponseWriteFileFullPath  = targetResponseWriteFileFullPath.replaceAll(":","_");
        FileUtil.touch(targetResponseWriteFileFullPath);
        FileUtil.writeUtf8String(jsonBody, targetResponseWriteFileFullPath);// CharsetUtil.CHARSET_UTF_8

    }

    protected void tmpLog(String targetFullPath, String relativePath, String type, String jsonBody, String now) {

        String targetWriteFileName     = StrUtil.format("{}_{}.json", type, now);
        String targetWriteFileFullPath = targetFullPath + relativePath + targetWriteFileName;
        targetWriteFileFullPath = targetWriteFileFullPath.replaceAll(":","_");
        FileUtil.touch(targetWriteFileFullPath);
        FileUtil.writeUtf8String(jsonBody, targetWriteFileFullPath);// CharsetUtil.CHARSET_UTF_8

    }
}
