You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
235 lines
12 KiB
235 lines
12 KiB
package com.jianshui.invoice.utils;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.jianshui.common.utils.DateUtils;
|
|
import com.jianshui.common.utils.StringUtils;
|
|
import com.jianshui.common.utils.encrypt.AisinoInvoiceDecryptUtil;
|
|
import com.jianshui.common.utils.uuid.UUID;
|
|
|
|
import java.util.*;
|
|
|
|
/**
|
|
* @Description
|
|
* @Author 巩权林
|
|
* @Date 2022-03-30 8:56
|
|
**/
|
|
public class IncomeTest {
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
//----------------------普通电票----------------------------------------------------
|
|
// String key = "LTEO+oOgWMsuQAOUglqXuQ=="; // 1204
|
|
String key = "PzRRv8Gk4LBBWSzE7ZlUzg=="; // 1223 大象进项测试
|
|
// String key = "FIQKraT+UheC1GqQtgDM6g=="; // 1205
|
|
// String key = "zE9+TICzsrejfujj/BXjCQ=="; // 1206
|
|
|
|
System.out.println("-------------------单个发票查验-----------------------------");
|
|
String order = "{\n" +
|
|
" \"taxNo\": \"9T86Z09T5L0000TET6\n\",\n" +
|
|
" \"jym\": \"\",\n" +
|
|
" \"fpje\": \"100\",\n" +
|
|
" \"fpdm\": \"\",\n" +
|
|
" \"kprq\": \"20220727\",\n" +
|
|
" \"fphm\": \"2231700000000011\",\n" +
|
|
" \"fpzl\": \"61\"\n" +
|
|
"}";
|
|
// String order = "{\"jym\":\"165330\",\"fpje\":\"83.07\",\"fpdm\":\"011002100511\",\"kprq\":\"20220209\",\"fphm\":\"41985485\",\"fpzl\":\"10\",\"taxNo\":\"91370100664851254J\"}";
|
|
// String order = "{\"jym\":\"356607\",\"fpje\":\"259.23\",\"fpdm\":\"011002000711\",\"kprq\":\"20210111\",\"fphm\":\"66914035\",\"fpzl\":\"01\",\"taxNo\":\"91370102MA3UD2FG21\" }";
|
|
String m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : " + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------批量发票查验-----------------------------");
|
|
order = "{\"invoiceList\":[{\"fpdm\":\"3200211130\",\"fphm\":\"49523142\",\"fpje\":\"986359.73\",\"fpzl\":\"01\",\"kprq\":\"20210712\"}],\"pch\":\"761651651651651515151568438476\",\"taxNo\":\"91370102MA3UD2FG21\"}";
|
|
System.out.println("json : \n" + order);
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
|
|
System.out.println("-------------------批量发票查验结果查询-----------------------------");
|
|
order = "{\"pch\":\"761651651651651515151568438476\",\"taxNo\":\"91370102MA3UD2FG21\"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("------------------------进项-认证-------------------------------------");
|
|
|
|
System.out.println("-------------------企业档案查询-----------------------------");
|
|
order = "{\"SBH\":\"9111122223333CKFPT\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
|
|
// TODO-: 2022/10/24 待测试
|
|
System.out.println("-------------------申请认证-----------------------------");
|
|
// order = "{\"SBH\":\"9111122223333CKFPT\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
|
|
Map map = new HashMap<>();
|
|
// TODO-dxk: 2022/10/28 这里需要企业传输PCH
|
|
map.put("PCH", "");
|
|
map.put("GMFSBH", "9111122223333CKFPT");
|
|
map.put("FHHS", "1");
|
|
map.put("taxNo", "9111122223333CKFPT");
|
|
|
|
|
|
List<Map<String, String>> mapList = new ArrayList<>();
|
|
Map<String, String> llmap1 = new HashMap<>();
|
|
llmap1.put("FPDM", "3700194130");
|
|
llmap1.put("FPHM", "14097332");
|
|
llmap1.put("GMFSBH", "9111122223333CKFPT");
|
|
llmap1.put("SQRZLX", "1");
|
|
llmap1.put("FPLXDM", "01");
|
|
llmap1.put("SQSKSSQ", "202108");
|
|
llmap1.put("YXSE", "");
|
|
llmap1.put("BDKYY", "");
|
|
|
|
mapList.add(llmap1);
|
|
|
|
map.put("FPZHXX", mapList);
|
|
|
|
order = JSONUtil.toJsonStr(map);
|
|
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : " + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------获取认证结果-----------------------------");
|
|
// order = "{\"PCH\":\"3eb6645e2fc84b8384ac2db8c3fd78f7\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
order = "{\"PCH\":\"20220020021312341\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------申请确认-----------------------------");
|
|
order = "{\"GMFSBH\":\"9111122223333CKFPT\",\"PCH\":\""+ cn.hutool.core.lang.UUID.fastUUID().toString().replace("-","") +"\"," +
|
|
"\"QRBZ\":\"1\",\"TJSJ\":\"202209\",\"RZSKSSQ\":\"202209\",\"QRMM\":\"123456\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
|
|
order = "{\"GMFSBH\":\"9111122223333CKFPT\",\"PCH\":\""+ "67074fed71cc42da8fc12bdcd2111s99" +"\"," +
|
|
"\"QRBZ\":\"1\",\"TJSJ\":\"202209\",\"RZSKSSQ\":\"202209\",\"QRMM\":\"123456\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------获取确认结果-----------------------------");
|
|
order = "{\"GMFSBH\":\"9111122223333CKFPT\",\"PCH\":\"2d92821a9dfc4f1aaa744bcbd1696ebd\"," +
|
|
"\"QRBZ\":\"0\",\"TJSJ\":\"202209\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
order = "{\"PCH\":\"67074fed71cc42da8fc12bdcd2111s99\",\"TJSJ\":\"202209\",\"taxNo\":\"9111122223333CKFPT\",\"GMFSBH\":\"9111122223333CKFPT\",\"QRBZ\":\"1\"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------状态采集-----------------------------");
|
|
order = "{\"GMFSBH\":\"9111122223333CKFPT\",\"PCH\":\"0827f998cdfd40b0a5626150520b4dea\"," +
|
|
"\"ZTBGKSRQ\":\"20190101010120\",\"ZTBGJSRQ\":\"20191001010120\",\"ZTBZ\":\"1\",\"KSHS\":\"1\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------设置密码-----------------------------");
|
|
order = "{\"SBH\":\"9111122223333CKFPT\",\"YWMM\":\"123456\",\"NEWYWMM\":\"123456\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------重置密码-----------------------------");
|
|
order = "{\"SBH\":\"9111122223333CKFPT\",\"taxNo\":\"9111122223333CKFPT\"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
System.out.println("------------------------------------------------");
|
|
|
|
|
|
System.out.println("-------------------全票面采集-----------------------------");
|
|
Date yestday = DateUtil.offsetDay(new Date(), -1);
|
|
order = "{\n" +
|
|
" \"GMFSBH\": \"9111122223333CKFPT\",\n" + // 15或18位
|
|
" \"FPLXDM\": \"01\",\n" + // 增值税专用发票:01;机动车销售统一发票:03;增值税电子专用发票:08;通行费电子发票:14;电子发票(增值税专用发票):31;
|
|
" \"PCH\": \"" + UUID.fastUUID() + "\",\n" + // 32 位.代表一次请求,每次请求批次号不重复。如果数据一次性获取完成,批次号需要更换。如果一次性数据获取不完,批次号需保持一致。
|
|
" \"CJKSRQ\": \"20200501000000\",\n" + // YYYYMMDDHHMMSS 例如:20170101140245
|
|
" \"CJJSRQ\": \"" + DateUtil.format(yestday, "yyyyMMddHHmmss") + "\",\n" + // YYYYMMDDHHMMSS 例如:20170101140245
|
|
" \"KSHS\": 10,\n" + // 整数,第一次请求时为1.(若本次返回行数小于总行数,需再次请求,开始行数为 本次返回行数+ 1.类似分页获取)
|
|
" \"ZTBZ\": \"1\",\n" + // 当给 1 时继续请求,0 时结束请求。
|
|
" \"FHHS\": \"10\",\n" + // 当该参数有值时,接口按照参数返回发票条数,如果没值时,接口按照默认值返回发票条数
|
|
" \"taxNo\": \"9111122223333CKFPT\"\n" + // 测试税号
|
|
"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
|
|
System.out.println("-------------------主信息采集-----------------------------");
|
|
// 得到上一天的Date
|
|
order = "{\n" +
|
|
" \"GMFSBH\": \"9111122223333CKFPT\",\n" + // 15 或 18 位
|
|
" \"PCH\": \"12345678901234567890123456789013\",\n" + // 32 位如果多次重复的话,此值要一样,代表是一次请求
|
|
" \"CJKSRQ\": \"20200501000000\",\n" + // YYYYMMDDHHMMSS 例如:20170101140245
|
|
|
|
" \"CJJSRQ\": \"" + DateUtil.format(yestday, "yyyyMMddHHmmss") + "\",\n" + // YYYYMMDDHHMMSS 例如:20170101140345
|
|
" \"KSHS\": 10,\n" + // 整数,第一次请求时为1
|
|
" \"ZTBZ\": \"1\",\n" + // 当给 1 时继续请求,0 时结束请求
|
|
" \"taxNo\": \"9111122223333CKFPT\"\n" + // 测试税号
|
|
"}";
|
|
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------获取统计信息-----------------------------");
|
|
order = "{\n" +
|
|
" \"GMFSBH\": \"9111122223333CKFPT\",\n" +
|
|
" \"RZSKSSQ\": \"202209\",\n" +
|
|
" \"taxNo\": \"9111122223333CKFPT\"\n" + // 测试税号
|
|
"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------申请统计-----------------------------");
|
|
String uuid = StringUtils.replace(String.valueOf(UUID.fastUUID()), "-", "");
|
|
order = "{\n" +
|
|
" \"PCH\": \"" + uuid + "\",\n" +
|
|
" \"GMFSBH\": \"9111122223333CKFPT\",\n" +
|
|
" \"TJBZ\": \"1\",\n" +
|
|
" \"RZSKSSQ\": \"202209\",\n" +
|
|
" \"taxNo\": \"9111122223333CKFPT\"\n" +
|
|
"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
System.out.println("-------------------获取统计结果-----------------------------");
|
|
order = "{\n" +
|
|
// " \"PCH\": \"" + uuid + "\",\n" +
|
|
" \"PCH\": \"75954a76fd654c2daa8f91f9837cb448\",\n" +
|
|
" \"GMFSBH\": \"9111122223333CKFPT\",\n" +
|
|
" \"taxNo\": \"9111122223333CKFPT\"\n" +
|
|
"}";
|
|
m = AisinoInvoiceDecryptUtil.encrypt(order, key);
|
|
System.out.println("json : \n" + order);
|
|
System.out.println(m);
|
|
System.out.println("------------------------------------------------");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|