package com.stylefeng.guns.modular.system.kaipiao;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.stylefeng.guns.modular.system.kaipiao.entity.ReturnData;
|
import com.stylefeng.guns.modular.system.kaipiao.util.CreatAndSendUtil;
|
|
|
import java.nio.charset.StandardCharsets;
|
import java.util.Base64;
|
|
public class SptBlueInvOpenDemo {
|
|
/**
|
* 调用数票通接口开具蓝字发票
|
* @param dataJson 需要开具发票的订单信息及明细组成的json字符串,具体字段见接口对接文档
|
* @param appSecret 企业密钥 由江苏航信分配获取
|
* @param appId 企业标识 由江苏航信分配获取
|
* @return ReturnData
|
*/
|
public static ReturnData blueInvOpen(String dataJson, String appSecret, String appId){
|
/*
|
TODO
|
校验订单流水号(orderNo),不能为空且不能与已开票据的重复
|
*/
|
|
//接口代码详见各业务接口说明 全电蓝字发票开具为:SALE.DZSJLZINVOPEN
|
String interfaceCode = "SALE.DZSJLZINVOPEN";
|
|
ReturnData returnData = CreatAndSendUtil.creatAndSend(dataJson, appSecret, appId, interfaceCode);
|
|
if (returnData != null){
|
if ("0000".equals(returnData.getReturn_info().getReturn_code())){
|
String data = returnData.getData();
|
byte[] decode = Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8));
|
returnData.setData(new String(decode));
|
JSONObject jsonObject = JSONObject.parseObject(new String(decode));
|
// System.out.println("发票号码:" + jsonObject.get("fphm"));
|
// System.out.println("开票日期:" + jsonObject.get("kprq"));
|
/*
|
TODO
|
开票成功,改变数据库中的数据等操作
|
*/
|
}else {
|
/*
|
开票失败,return_message查看失败原因
|
*/
|
}
|
return returnData;
|
}
|
return null;
|
}
|
|
|
public static ReturnData getUrl(String dataJson, String appSecret, String appId){
|
/*
|
TODO
|
校验订单流水号(orderNo),不能为空且不能与已开票据的重复
|
*/
|
|
//接口代码详见各业务接口说明 全电蓝字发票开具为:SALE.DZSJLZINVOPEN
|
String interfaceCode = "SALE.QDINVDOWNURL";
|
|
ReturnData returnData = CreatAndSendUtil.creatAndSend(dataJson, appSecret, appId, interfaceCode);
|
|
if (returnData != null){
|
if ("0000".equals(returnData.getReturn_info().getReturn_code())){
|
String data = returnData.getData();
|
byte[] decode = Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8));
|
returnData.setData(new String(decode));
|
JSONObject jsonObject = JSONObject.parseObject(new String(decode));
|
// System.out.println("发票号码:" + jsonObject.get("fphm"));
|
// System.out.println("开票日期:" + jsonObject.get("kprq"));
|
/*
|
TODO
|
开票成功,改变数据库中的数据等操作
|
*/
|
}else {
|
/*
|
开票失败,return_message查看失败原因
|
*/
|
}
|
return returnData;
|
}
|
return null;
|
}
|
|
public static ReturnData toEmail(String dataJson, String appSecret, String appId){
|
/*
|
TODO
|
校验订单流水号(orderNo),不能为空且不能与已开票据的重复
|
*/
|
|
//接口代码详见各业务接口说明 全电蓝字发票开具为:SALE.DZSJLZINVOPEN
|
String interfaceCode = "SALE.OWNEMAILDELIVERY";
|
|
ReturnData returnData = CreatAndSendUtil.creatAndSend(dataJson, appSecret, appId, interfaceCode);
|
|
if (returnData != null){
|
if ("0000".equals(returnData.getReturn_info().getReturn_code())){
|
String data = returnData.getData();
|
byte[] decode = Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8));
|
returnData.setData(new String(decode));
|
JSONObject jsonObject = JSONObject.parseObject(new String(decode));
|
// System.out.println("发票号码:" + jsonObject.get("fphm"));
|
// System.out.println("开票日期:" + jsonObject.get("kprq"));
|
/*
|
TODO
|
开票成功,改变数据库中的数据等操作
|
*/
|
}else {
|
/*
|
开票失败,return_message查看失败原因
|
*/
|
}
|
return returnData;
|
}
|
return null;
|
}
|
|
public static ReturnData checkEamil(String dataJson, String appSecret, String appId){
|
/*
|
TODO
|
校验订单流水号(orderNo),不能为空且不能与已开票据的重复
|
*/
|
|
//接口代码详见各业务接口说明 全电蓝字发票开具为:SALE.DZSJLZINVOPEN
|
String interfaceCode = "SALE.OWNEMAILDELIVERYQUERY";
|
|
ReturnData returnData = CreatAndSendUtil.creatAndSend(dataJson, appSecret, appId, interfaceCode);
|
|
if (returnData != null){
|
if ("0000".equals(returnData.getReturn_info().getReturn_code())){
|
String data = returnData.getData();
|
byte[] decode = Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8));
|
returnData.setData(new String(decode));
|
JSONObject jsonObject = JSONObject.parseObject(new String(decode));
|
// System.out.println("发票号码:" + jsonObject.get("fphm"));
|
// System.out.println("开票日期:" + jsonObject.get("kprq"));
|
/*
|
TODO
|
开票成功,改变数据库中的数据等操作
|
*/
|
}else {
|
/*
|
开票失败,return_message查看失败原因
|
*/
|
}
|
return returnData;
|
}
|
return null;
|
}
|
|
|
}
|