Commit 89502599 authored by jiaorz's avatar jiaorz

Merge remote-tracking branch 'origin/dev' into dev

parents 86b8a5f2 cb917d0c
......@@ -2,6 +2,7 @@ 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.controller;
import com.alibaba.fastjson.JSONException;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
......@@ -35,8 +34,14 @@ public class InvoiceController extends BaseController<InvoiceBiz, Invoice> {
*/
@GetMapping("/dutyParagraph")
public ObjectRestResponse getDutyParagraphByCode(@RequestParam("code") String code) {
String dutyParagraph = baseBiz.getDutyParagraphByCode(code);
return ObjectRestResponse.succ(dutyParagraph);
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 +52,14 @@ public class InvoiceController extends BaseController<InvoiceBiz, Invoice> {
*/
@GetMapping("/corporateName")
public ObjectRestResponse corporateName(@RequestParam("name") String name) {
List<Map<String, String>> mapList = baseBiz.corporateName(name);
return ObjectRestResponse.succ(mapList);
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, "获取公司全名失败");
}
}
/**
......@@ -60,7 +71,7 @@ public class InvoiceController extends BaseController<InvoiceBiz, Invoice> {
*/
@PostMapping("/invoicing")
public ObjectRestResponse invoicing(@RequestBody InvoiceVo invoiceVo) {
log.info("开票信息={}",invoiceVo);
try {
String invoicing = baseBiz.Invoicing(invoiceVo);
return ObjectRestResponse.succ(invoicing);
......
......@@ -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);
JSONObject jsonObject = JSON.parseObject(result);
List<Map<String, String>> mapList = (List<Map<String, String>>) jsonObject.get("result");
if (CollectionUtil.isNotEmpty(mapList)) {
return mapList;
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<>();
}
/**
......@@ -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);
JSONObject jsonObject = JSON.parseObject(result);
Map<String, String> resultMap = (Map<String, String>) jsonObject.get("result");
return resultMap.get("kpCode");
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