Commit a0e1bb3f authored by hanfeng's avatar hanfeng

Merge remote-tracking branch 'origin/master-invoice-modular' into master-invoice-modular

parents 3f9e700c ed6ac5f8
......@@ -2,7 +2,6 @@ package com.xxfc.platform.universal.entity.vo;
import com.xxfc.platform.universal.entity.OrderData;
import lombok.Data;
import lombok.ToString;
import java.util.List;
......
package com.xxfc.platform.universal.service;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.xxfc.platform.order.entity.OrderInvoice;
import com.xxfc.platform.order.feign.OrderFeign;
......@@ -24,9 +21,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
......
......@@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.constant.RestCode;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.google.common.collect.Lists;
import com.xxfc.platform.universal.entity.Invoice;
......@@ -19,7 +18,6 @@ import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
......@@ -82,17 +80,12 @@ public class InvoiceDaoImpl implements InvoiceDao {
// 唯一标识,由企业自己生成32位随机码
String senid = UUID.randomUUID().toString().replace("-", "");
String result = sdk.sendPostSyncRequest(url, senid, appKey, appSecret, getTokenJS(), taxnum, method, content);
try {
JSONObject jsonObject = JSON.parseObject(result);
List<Map<String, String>> mapList = (List<Map<String, String>>) jsonObject.get("result");
if (CollectionUtil.isNotEmpty(mapList)) {
return mapList;
}
throw new BaseException(result);
} catch (Exception e) {
throw new BaseException(result);
}
return new ArrayList<>();
}
/**
......@@ -115,13 +108,9 @@ public class InvoiceDaoImpl implements InvoiceDao {
// 唯一标识,由企业自己生成32位随机码
String senid = UUID.randomUUID().toString().replace("-", "");
String result = sdk.sendPostSyncRequest(url, senid, appKey, appSecret, getTokenJS(), taxnum, method, content);
try {
JSONObject jsonObject = JSON.parseObject(result);
Map<String, String> resultMap = (Map<String, String>) jsonObject.get("result");
return resultMap.get("kpCode");
} catch (Exception e) {
throw new BaseException(result);
}
}
......@@ -188,8 +177,9 @@ public class InvoiceDaoImpl implements InvoiceDao {
String jsonString = JSON.toJSONString(orderMap);
//调用第三方接口
String result = sdk.sendPostSyncRequest(invoiceUrl, senid, appKey2, appSecret2, token, taxnum2, method, jsonString);
log.info("第三方响应信息={}",result);
//把字符串json数据转换为map
try {
JSONObject jsonObject = JSON.parseObject(result);
Map<String, String> data = (Map<String, String>) jsonObject.get("result");
......@@ -227,7 +217,7 @@ public class InvoiceDaoImpl implements InvoiceDao {
List<Map<String, Object>> mapList = (List<Map<String, Object>>) jsonObject.get("result");
return mapList;
} catch (Exception e) {
throw new BaseException("发票请求流水号错误-");
throw new BaseException("发票请求流水号错误");
}
}
return null;
......@@ -245,7 +235,7 @@ public class InvoiceDaoImpl implements InvoiceDao {
/**
* 获取诺诺发票token
*/
private String getTokenFP() {
public String getTokenFP() {
return getToken(appKey2, appSecret2);
}
......@@ -263,20 +253,8 @@ public class InvoiceDaoImpl implements InvoiceDao {
redisTemplate.opsForValue().set(appKey, token, 23, TimeUnit.HOURS);
}
return token;
}
@PostConstruct
public void deleteTokenJS(){
System.out.println("deleteTokenJS");
setToken(appKey);
setToken(appKey2);
}
private void setToken(String appKey) {
redisTemplate.delete(appKey);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment