package com.heyu.api.controller.financial;


import com.heyu.api.baidu.handle.financial.BVatInvoiceVerificationHandle;
import com.heyu.api.baidu.request.financial.BVatInvoiceVerificationRequest;
import com.heyu.api.baidu.response.financial.BAirTransportVatInvoiceVerificationResp;
import com.heyu.api.baidu.response.financial.BVatInvoiceVerificationResp;
import com.heyu.api.controller.BaseController;
import com.heyu.api.data.annotation.CacheResult;
import com.heyu.api.data.annotation.NotIntercept;
import com.heyu.api.data.utils.ApiR;
import com.heyu.api.data.utils.R;
import com.heyu.api.request.financial.AirTransportVatInvoiceVerificationRequest;
import com.heyu.api.resp.financial.AirTransportVatInvoiceVerificationResp;
import com.heyu.api.resp.financial.CommonVatInvoiceVerificationResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/***
 *https://console.bce.baidu.com/support/?_=1740494347073&timestamp=1740500368284#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E8%B4%A2%E5%8A%A1%E7%A5%A8%E6%8D%AEOCR&api=rest%2F2.0%2Focr%2Fv1%2Fvat_invoice_verification&method=post
 *
 *
 * 增值税发票验真
 *
 *
 *
 * 支持 14 种增值税发票的信息核验，包括增值税专票、电子专票、普票、电子普票、卷票、区块链发票（深圳地区）、全电发票（新版全国统一电子发票，专票/普票）、通行费增值税电子普通发票、货物运输业增值税专用发票、
 * 机动车销售发票、二手车销售发票、航空运输电子客票行程单（电子发票）、铁路电子客票（电子发票）等，支持返回票面的全部信息。同时可直接与同平台的发票识别能力对接，完成发票识别的同时进行自动化验真。
 *
 *
 * 视频教程请参见 智能财务票据识别+增值税发票验真使用教程
 *
 *
 */
@Slf4j
@RestController
@RequestMapping("/air/transport/vat/Invoice")
@NotIntercept
public class AirTransportVatInvoiceVerificationController extends BaseController {


    @Autowired
    private BVatInvoiceVerificationHandle bVatInvoiceVerificationHandle;


    @RequestMapping("/verification")
    @CacheResult
    public R verification(AirTransportVatInvoiceVerificationRequest req) {

        BVatInvoiceVerificationRequest bVatInvoiceVerificationRequest = new BVatInvoiceVerificationRequest();
        bVatInvoiceVerificationRequest.setInvoiceCode(req.getInvoiceCode());
        bVatInvoiceVerificationRequest.setInvoiceNum(req.getInvoiceNum());
        bVatInvoiceVerificationRequest.setInvoiceDate(req.getInvoiceDate());
        bVatInvoiceVerificationRequest.setInvoiceType(req.getInvoiceType());
        bVatInvoiceVerificationRequest.setCheckCode(req.getCheckCode());
        bVatInvoiceVerificationRequest.setTotalAmount(req.getTotalAmount());

        CommonVatInvoiceVerificationResp resp = new CommonVatInvoiceVerificationResp();

        ApiR<BVatInvoiceVerificationResp> bR = bVatInvoiceVerificationHandle.handle(bVatInvoiceVerificationRequest, AirTransportVatInvoiceVerificationResp.class);
        if (bR.isSuccess()) {
            BAirTransportVatInvoiceVerificationResp bAirTransportVatInvoiceVerificationResp = (BAirTransportVatInvoiceVerificationResp) bR.getData();

        }
        return R.ok();
    }


}
