|
|
@@ -2,6 +2,7 @@ package com.ruoyi.logistics.service.impl;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.ruoyi.common.core.utils.StringUtils;
|
|
|
import com.ruoyi.common.redis.service.RedisIdGenerator;
|
|
|
import com.ruoyi.logistics.config.InvoiceConfig;
|
|
|
import com.ruoyi.logistics.domain.InvoiceRequest;
|
|
|
@@ -56,8 +57,8 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|
|
content.put("zsfs", "0"); // 征收方式:0=普通征税
|
|
|
content.put("khmc", invoiceRequest.getKhmc()); // 购货单位名称
|
|
|
content.put("hsje", invoiceRequest.getHsje()); // 含税金额(价税合计)
|
|
|
- content.put("gsdm", "7600"); // 公司代码
|
|
|
- content.put("yhdm", "ec014266e63344698642d6e5c5b8b556"); // 用户代码
|
|
|
+ content.put("gsdm", "3204"); // 公司代码
|
|
|
+ content.put("yhdm", "393e8941f3f1409e8cbc7fc981ca1774"); // 用户代码
|
|
|
content.put("sjlx", "1"); // 数据类型(批发系统,由平台提供)
|
|
|
content.put("sfwzzfp", "N"); // 非纸质发票(默认N)
|
|
|
content.put("hsbz", "1"); // 含税标志(1=含税,默认)
|
|
|
@@ -104,6 +105,9 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|
|
responseJson,
|
|
|
new TypeReference<Map<String, Object>>() {}
|
|
|
);
|
|
|
+
|
|
|
+ //这里成功后也要将单据编号进行回传月度报表
|
|
|
+
|
|
|
return invoiceMap;
|
|
|
}
|
|
|
|
|
|
@@ -117,28 +121,41 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|
|
|
|
|
@Override
|
|
|
public Map selectInvoice(Map param) throws JsonProcessingException {
|
|
|
- // 1. 组装正票申请的业务报文(content)
|
|
|
+ // 1.组装查询的报文
|
|
|
JSONObject content = new JSONObject();
|
|
|
- content.put("djbh",param.get("djbh"));
|
|
|
+ content.put("djbh",param.get("djbh").toString());
|
|
|
String contentBase64 = Base64Util.encode(content.toJSONString());
|
|
|
+ // 3. 构建签名参数,生成签名值
|
|
|
Map<String, String> signParams = new HashMap<>();
|
|
|
signParams.put("appid", invoiceConfig.getAppId());
|
|
|
signParams.put("serviceid", invoiceConfig.getServiceSelect());
|
|
|
signParams.put("content", contentBase64);
|
|
|
- String signature = SignUtil.sign(invoiceConfig.getSignType(), invoiceConfig.getAppSecret(), signParams);
|
|
|
+ String signature = SignUtil.sign("3", invoiceConfig.getAppSecret(), signParams);
|
|
|
+
|
|
|
JSONObject requestParam = new JSONObject();
|
|
|
requestParam.put("appid", invoiceConfig.getAppId());
|
|
|
requestParam.put("serviceid", invoiceConfig.getServiceSelect());
|
|
|
requestParam.put("content", contentBase64);
|
|
|
requestParam.put("signature", signature);
|
|
|
- requestParam.put("signType", invoiceConfig.getSignType());
|
|
|
+ requestParam.put("signType","3");
|
|
|
String responseJson = HttpUtil.doPostJson(invoiceConfig.getBaseUrl(), requestParam.toJSONString());
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
- // JsonNode jsonNode = objectMapper.readTree(responseJson);
|
|
|
Map<String, Object> invoiceMap = objectMapper.readValue(
|
|
|
responseJson,
|
|
|
new TypeReference<Map<String, Object>>() {}
|
|
|
);
|
|
|
+ if(StringUtils.isNotBlank(invoiceMap.get("data").toString())){
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> dataMap = objectMapper.readValue(
|
|
|
+ Base64Util.decode(invoiceMap.get("data").toString()),
|
|
|
+ new TypeReference<Map<String, Object>>() {}
|
|
|
+ );
|
|
|
+ invoiceMap.put("data",dataMap);
|
|
|
+ }
|
|
|
+ //这里 需要将查询到的信息进行回写月度报表里面
|
|
|
+
|
|
|
+
|
|
|
return invoiceMap;
|
|
|
}
|
|
|
}
|