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.
105 lines
5.1 KiB
105 lines
5.1 KiB
import cn.hutool.json.JSONUtil;
|
|
import com.dxhy.order.model.newsk.discinfo.DiscInfoResponse;
|
|
import com.dxhy.order.model.newsk.vehicle.VehicleInvoiceExpResponse;
|
|
import com.dxhy.order.consumer.ConsumerStarter;
|
|
import com.dxhy.order.invoice.module.invoice.model.bo.VehicleInvoiceExpBo;
|
|
import com.dxhy.order.invoice.utils.HttpInvoiceRequestUtil;
|
|
import com.dxyun.invoice.protocol.InterfaceData;
|
|
import com.dxyun.invoice.protocol.ProtocolUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.junit.Test;
|
|
import org.junit.runner.RunWith;
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
/**
|
|
* @author: <a href="yaoxuguang@ele-cloud.com">yaoxuguang</a>
|
|
* @createDate: Created in 2021-07-26
|
|
*/
|
|
@RunWith(SpringRunner.class)
|
|
@SpringBootTest(classes = ConsumerStarter.class)
|
|
@Slf4j
|
|
public class HttpInvoiceRequestUtilTest {
|
|
// private static final String url = "http://10.1.2.51:9077/accept/invoice/V1.0/";
|
|
private static final String url = "http://10.1.23.170:9077/accept/invoice/V1.0/";
|
|
|
|
@Test
|
|
public void vehicleInvoiceExp() {
|
|
String requestUrl = url + "vehicleInvoiceExp";
|
|
String requestStr = "{" +
|
|
" \"nsrsbh\":\"140301206111099566\"," +
|
|
" \"fjh\":\"0\"," +
|
|
" \"qqsj\":\"20210701\"," +
|
|
" \"zzsj\":\"20210730\"" +
|
|
"}";
|
|
String terminalCode = "002";
|
|
VehicleInvoiceExpBo vehicleInvoiceExpBo = JSONUtil.toBean(requestStr, VehicleInvoiceExpBo.class);
|
|
VehicleInvoiceExpResponse response = HttpInvoiceRequestUtil.vehicleInvoiceExp(requestUrl, vehicleInvoiceExpBo, terminalCode);
|
|
log.info("机动车专票导出加密数据,返回结果:" + JSONUtil.toJsonStr(response));
|
|
}
|
|
|
|
@Test
|
|
public void queryDiscInfo() {
|
|
String requestUrl = url + "queryDiscInfo";
|
|
String terminalCode = "014";
|
|
String nsrsbh = "110108202007090012";
|
|
String fjh = "";
|
|
DiscInfoResponse discInfoResponse = HttpInvoiceRequestUtil.queryDiscInfo(requestUrl, nsrsbh, fjh, terminalCode);
|
|
log.info("税盘信息查询,返回结果:" + JSONUtil.toJsonStr(discInfoResponse));
|
|
}
|
|
|
|
@Test
|
|
public void parseInvoiceControlReturn() {
|
|
String response = "{" +
|
|
" \"machineType\":\"A9\"," +
|
|
" \"key\":\"0454267656P8q6+KbpXvzs4uAbkj/ojQ==\"," +
|
|
" \"taxpayerNo\":\"140301206111099566\"," +
|
|
" \"terminalCode\":\"0\"," +
|
|
" \"machineNo\":\"\"," +
|
|
" \"encryCode\":\"1\"," +
|
|
" \"returnCode\":\"0000\"," +
|
|
" \"returnMsg\":\"成功\"," +
|
|
" \"data\":\"rR5s9sDe8TeEfSxeF5Mj/aRZewnijFHx8EXqqwuan1hMyJY2edf5SBzD173zvrGXiLnl/nCSoj/lqvILGH9aTqoW+pOlYjXoX2UWhH3sbdS+H1Cs9tO6Ei+NrVXTl/k6s8KFN8C5sMCYai4bkRGyzTqZVQK5Mt0EWIEO/c/r5mWLRjguFNCWLpU2XFyScV+EzhQApp18dr8gEC4dtBpC+mrsiKXbp/N+3j8/h2NOBhk1LMmF4gvVLVAq23xj6zt734aFK+d2TeaRvV2UHB+e47BjUmuTqByiMhPpn9kQGghNVZ3evD2F1TQeb65a+IglTzpPFvCw8x+f2oaW8fG0VM/sdXGvrUSKgsesm2cPp1TYvfneREsGh62FcjUhJzA8OFYPP40PRifMGulAxHUM1QnPJDn1N4V4fg4/x4NsiPHi6en8iOeZtYqNev9cDZ2q8X9b6I3BD7zKYtVwX6vo4zayAPY/lN9N/9Xp3duCMWGyzIeDAtWD4i96IvdROFHcHC2lIa37CGnbh2f9cg2xzaMz50MoapXtxFmeK2smyP2XR8yTUeHxEyycv7tLCO89dMOygJ6x2+Ymd0iTxj4//t4gRW3xCkt3fST+4y46cB0=\"," +
|
|
" \"version\":\"1.2\"," +
|
|
" \"checkCode\":\"6AC2\"" +
|
|
"}";
|
|
try {
|
|
InterfaceData interfaceData = ProtocolUtil.decodeData(response);
|
|
log.info("新版税控,解析返回结果:" + JSONUtil.toJsonStr(interfaceData));
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void encryptRequestParam(){
|
|
String requestStr = "{" +
|
|
" \"FPLB\":\"2\"," +
|
|
" \"FPQQLSH\":\"712807865741094912001\"," +
|
|
" \"KPRQ\":\"20220729092701\"," +
|
|
" \"FPKJ_MS\":\"发票赋码成功\"," +
|
|
" \"FPKJ_ZT\":\"2100\"," +
|
|
" \"HJBHSJE\":\"5.35\"," +
|
|
" \"KPLX\":\"0\"," +
|
|
" \"FPLX\":\"1\"," +
|
|
" \"EWM\":\"\"," +
|
|
" \"FP_HM\":\"00924618\"," +
|
|
" \"FWM\":\"033<7-*05<47<7-89-0/9>2/-3/574>6/4*>11-41-7+090//+475>>-310-<+/722*96+89>2282>1791/5+9*/4/25/601407206+981*8716/\"," +
|
|
" \"KPHJSE\":\"0.27\"," +
|
|
" \"FP_DM\":\"011111111007\"," +
|
|
" \"JYM\":\"13986795859659759017\"," +
|
|
" \"FAILDETAIL\":{" +
|
|
" \"CWDM\":\"\"," +
|
|
" \"CWMS\":\"\"," +
|
|
" \"SFXYCS\":\"1\"" +
|
|
" }" +
|
|
"}";
|
|
try {
|
|
String requestParam = ProtocolUtil.packageProtocol("110108202007090012",
|
|
"499000172123", "1", "FGKP", requestStr, "712807865741094912001");
|
|
System.out.println(requestParam);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|