Commit 665b5cb7 authored by hanfeng's avatar hanfeng

Merge branch 'master-invoice-modular' into dev

parents 59530044 3ed67b55
......@@ -35,8 +35,14 @@ public class InvoiceController extends BaseController<InvoiceBiz, Invoice> {
*/
@GetMapping("/dutyParagraph")
public ObjectRestResponse getDutyParagraphByCode(@RequestParam("code") String code) {
try {
String dutyParagraph = baseBiz.getDutyParagraphByCode(code);
return ObjectRestResponse.succ(dutyParagraph);
} catch (BaseException e) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, e.getMessage());
} catch (Exception e) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "获取公司全名失败");
}
}
/**
......@@ -47,8 +53,14 @@ public class InvoiceController extends BaseController<InvoiceBiz, Invoice> {
*/
@GetMapping("/corporateName")
public ObjectRestResponse corporateName(@RequestParam("name") String name) {
try {
List<Map<String, String>> mapList = baseBiz.corporateName(name);
return ObjectRestResponse.succ(mapList);
} catch (BaseException e) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, e.getMessage());
} catch (Exception e) {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "获取公司全名失败");
}
}
/**
......
......@@ -4,6 +4,7 @@ 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;
......@@ -18,6 +19,7 @@ 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;
......@@ -80,12 +82,17 @@ 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;
}
return new ArrayList<>();
throw new BaseException(result);
} catch (Exception e) {
throw new BaseException(result);
}
}
/**
......@@ -108,9 +115,13 @@ 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);
}
}
......@@ -178,8 +189,6 @@ public class InvoiceDaoImpl implements InvoiceDao {
//调用第三方接口
String result = sdk.sendPostSyncRequest(invoiceUrl, senid, appKey2, appSecret2, token, taxnum2, method, jsonString);
//把字符串json数据转换为map
try {
JSONObject jsonObject = JSON.parseObject(result);
Map<String, String> data = (Map<String, String>) jsonObject.get("result");
......@@ -217,7 +226,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;
......@@ -235,7 +244,7 @@ public class InvoiceDaoImpl implements InvoiceDao {
/**
* 获取诺诺发票token
*/
public String getTokenFP() {
private String getTokenFP() {
return getToken(appKey2, appSecret2);
}
......@@ -253,8 +262,20 @@ 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