修改单据推送,增加返回报文弹窗,修改销方appkey和appScore可以后台配置

master
xuefeilong 2024-05-22 17:11:22 +08:00
parent 38981db060
commit 9744e4b4cf
6 changed files with 104 additions and 39 deletions

View File

@ -1,6 +1,8 @@
package net.htjs.pt4.zzsxt.controller.xxgl.xmkpgl.kpsq;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@ -505,18 +507,27 @@ public class KpsqController extends BaseController{
public Object insertZZSGL_XX_KPSQ(@RequestParam Map userMap, String callback, HttpSession session) throws Exception{
int code;
String msg = "操作成功!";
String message = "";
Map mapModel = new HashMap();
try {
Map userObj= (Map) session.getAttribute("userInfo");
userMap.put("gsdm",userObj.get("GSDM"));
userMap.put("yhdm",userObj.get("USERNAME"));
Integer successCount =iBoKpsqService.insertZZSGL_XX_KPSQ(userMap);
mapModel.put("data", successCount);
message =iBoKpsqService.insertZZSGL_XX_KPSQ(userMap);
mapModel.put("data", message);
code=1;
msg =StrUtil.isBlank(message)?msg: msg+ "请求报文:"+message;
}catch (Exception e){
logger.error(e.getMessage());
code = -1;
msg = "新增开票申请信息失败!" + e.getMessage();
if(!JSONUtil.isNull(message)&&JSONUtil.isJson(message)){
JSONObject jsonObject1 = JSONUtil.parseObj(message);
jsonObject1.put("sbyy", e.getMessage());
msg = "新增开票申请信息失败!" + jsonObject1;
}else{
msg = e.getMessage();
}
}
return getResult(mapModel, code, msg, callback);
}
@ -1044,12 +1055,14 @@ public class KpsqController extends BaseController{
public Object djts(@RequestParam Map userMap, String callback, HttpSession session) throws Exception{
int code;
String msg = "操作成功!";
String responseStr = "";
Map mapModel = new HashMap();
try {
String itea = MapUtil.getStr(userMap, "itea");
cn.hutool.json.JSONArray objects = JSONUtil.parseArray(itea);
List listStr= JSONArray.parseArray((String) userMap.get("itea"));
String responseStr = iBoKpsqService.djts(objects);
responseStr = iBoKpsqService.djts(objects);
// List listObj=new ArrayList();
// for (int i = 0; i < listStr.size(); i++) {
// Map maplist= (Map) listStr.get(i);
@ -1062,8 +1075,11 @@ public class KpsqController extends BaseController{
// userMap.put("CSMC","DJTS_URL");
// Map xycsMap=iBoKpsqService.selectZZSGL_XT_CSSZ(userMap);
// String responseStr=HttpClientUtil.postRequestMap((String) xycsMap.get("CSZ"),mapModel);
String qqcode = "";
if(JSONUtil.isJson(responseStr)){
cn.hutool.json.JSONObject resObj = JSONUtil.parseObj(responseStr);
if(!"200".equals(resObj.getStr("code"))){
qqcode = resObj.getJSONObject("result").getStr("code");
}else{
throw new RuntimeException(responseStr);
}
// Map jsonMap= JSON.parseObject(responseStr);
@ -1071,13 +1087,13 @@ public class KpsqController extends BaseController{
// 5 推送成功 6.推送失败
String kpzt = "5";
if("200".equals(resObj.getStr("code"))){
if("200".equals(qqcode)){
code=0;
}else {
code=-1;
msg= resObj.getStr("message");
kpzt = "6";
}
msg= msg+responseStr;
// 更新推送状态
for (int i = 0; i < listStr.size(); i++) {
Map maplist= (Map) listStr.get(i);
@ -1090,7 +1106,15 @@ public class KpsqController extends BaseController{
}catch (Exception e){
logger.error(e.getMessage());
code = -1;
msg = "推送失败!" + e.getMessage();
if(StrUtil.isNotBlank(responseStr)&&JSONUtil.isJson(responseStr)){
cn.hutool.json.JSONObject resObj = JSONUtil.parseObj(responseStr);
resObj.put("sbyy",e.getMessage());
responseStr =resObj.toString();
}else{
responseStr =e.getMessage();
}
msg = "推送失败!" + responseStr;
}
return getResult(mapModel, code, msg, callback);
}

View File

@ -119,6 +119,10 @@ public class XxKpsqDO implements Serializable {
private String sjlx;
private String ssyt;
private String appKey;
private String APPSECRET;
public String getDjlx() {
return djlx;
}

View File

@ -79,6 +79,10 @@ public class BoKpsqServiceImpl implements IBoKpsqService {
private PtDeptAuthorizeMapper ptDeptAuthorizeMapper;
@Resource
private IBoSpbmwhService iBoSpbmwhService;
@Resource
private IBoQyxxglService iBoQyxxglService;
private String results = "";
@Override
@ -140,9 +144,10 @@ public class BoKpsqServiceImpl implements IBoKpsqService {
@Override
@Transactional
public Integer insertZZSGL_XX_KPSQ(Map userMap) throws SaveException {
public String insertZZSGL_XX_KPSQ(Map userMap) throws SaveException {
try {
log.info("开票申请信息入参:"+JSON.toJSONString(userMap));
this.results = "";
int result = 0;
if(userMap.get("SQID")==null||userMap.get("SQID").toString().isEmpty()) {
throw new RuntimeException("单据编号不能为空");
@ -195,11 +200,18 @@ public class BoKpsqServiceImpl implements IBoKpsqService {
}
result = kpsqMapper.insertZZSGL_XX_KPSQ(CommonUtil.replaceLDhOfMap(userMap));
return result;
return result>0?results:"";
}catch (Exception e){
log.error("新增开票申请和明细信息出错", e);
throw new SaveException(e);
if(StrUtil.isNotBlank(results)&&JSONUtil.isJson(results)){
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(results);
jsonObject.put("sbyy",e.getMessage());
results =jsonObject.toString();
}else{
results =e.getMessage();
}
log.error("新增开票申请和明细信息出错:", e);
throw new SaveException(results);
}
}
@ -349,10 +361,11 @@ public class BoKpsqServiceImpl implements IBoKpsqService {
jsonObject.put("callBackUrl",MapUtil.getStr(userMap,"callBackUrl"));
cn.hutool.json.JSONObject fpkjObject = new cn.hutool.json.JSONObject();
fpkjObject.put("kpzddm","20231129001");//是 开票终端代码 沟通后确认
List<Map> maps = null;
if(StrUtil.isNotBlank(MapUtil.getStr(userMap,"QYID"))){
Map<String,Object> map = new HashMap<>();
map.put("QYID",MapUtil.getStr(userMap,"QYID"));
List<Map> maps = null;
try {
maps = iBoQyxxglService.selectZZSGL_XT_QYXX(map);
} catch (SaveException e) {
@ -485,10 +498,17 @@ public class BoKpsqServiceImpl implements IBoKpsqService {
fpkjObject.put("fpmxs",jsonArray);
jsonObject.put("fpkj",fpkjObject);
StaticLog.info("新增开票申请和明细信息入参:"+jsonObject);
cn.hutool.json.JSONObject resJSON = new cn.hutool.json.JSONObject();
resJSON.put("kjUrl", BasicConstant.DJTS_URL);
resJSON.put("appkey",MapUtil.getStr(maps.get(0),"APPID"));
resJSON.put("appSecret", MapUtil.getStr(maps.get(0),"APPSECRET"));
resJSON.put("body", jsonObject.toJSONString(1));
//获取token
cn.hutool.json.JSONObject tokenJsonObReq = new cn.hutool.json.JSONObject();
tokenJsonObReq.put("app_key","ede5cdc0ae7b70c0814906b2d82f0955");
tokenJsonObReq.put("app_secret","2b993487212d372c6281f4c50508add996a5265b");
tokenJsonObReq.put("app_key",MapUtil.getStr(maps.get(0),"APPID"));
tokenJsonObReq.put("app_secret",MapUtil.getStr(maps.get(0),"APPSECRET"));
String post = HttpRequest.post("https://f7-demo.jchl.com/taxshare/api/comApi/getToken")
.header("Content-Type", "application/json")
.body(tokenJsonObReq).execute().body();
@ -503,6 +523,8 @@ public class BoKpsqServiceImpl implements IBoKpsqService {
if(!"200".equals(resObj.getStr("code"))){
throw new RuntimeException(res);
}
resJSON.put("result",res);
this.results = resJSON.toString();
StaticLog.info("新增开票申请和明细信息成功:{}",res);
cn.hutool.json.JSONObject jsonObject1 = resObj.getJSONObject("result");
userMap.put("FPDM",jsonObject1.getStr("fpdm"));
@ -1413,31 +1435,44 @@ public class BoKpsqServiceImpl implements IBoKpsqService {
Map map = kpsqMapper.selectZZSGL_XT_CSSZ(cszzMap);
jsonObject.put("callBackUrl",MapUtil.getStr(map,"CSZ"));
cn.hutool.json.JSONArray array = JSONUtil.createArray();
StringBuilder res = new StringBuilder();
for (XxKpsqDO xxKpsqDO : list) {
cn.hutool.json.JSONArray djArray = buildDepotParams(xxKpsqDO, array);
jsonObject.put("list",djArray);
}
StaticLog.info("新增异步开票申请和明细信息入参:"+jsonObject);
//获取token
cn.hutool.json.JSONObject tokenJsonObReq = new cn.hutool.json.JSONObject();
tokenJsonObReq.put("app_key", BasicConstant.TOKEN_APP_KEY);
tokenJsonObReq.put("app_secret",BasicConstant.TOKEN_APP_SECRET);
cn.hutool.json.JSONObject jsonObject1 = JSONUtil.parseObj(jsonObject);
JSONObject resJSON = new JSONObject();
resJSON.put("tsUrl", BasicConstant.DJTS_URL);
resJSON.put("appkey", JSONUtil.parseObj(jsonObject1.getJSONArray("list").get(0)).getStr("appKey"));
resJSON.put("appSecret", JSONUtil.parseObj(jsonObject1.getJSONArray("list").get(0)).getStr("appSecret"));
resJSON.put("body", JSONUtil.parseObj(jsonObject1.getJSONArray("list").get(0)).toString());
StaticLog.info("appkey:{}",JSONUtil.parseObj(jsonObject1.getJSONArray("list").get(0)).getStr("appKey"));
StaticLog.info("app_secret:{}",JSONUtil.parseObj(jsonObject1.getJSONArray("list").get(0)).getStr("appSecret"));
tokenJsonObReq.put("app_key", JSONUtil.parseObj(jsonObject1.getJSONArray("list").get(0)).getStr("appKey"));
tokenJsonObReq.put("app_secret",JSONUtil.parseObj(jsonObject1.getJSONArray("list").get(0)).getStr("appSecret"));
String post = HttpRequest.post(BasicConstant.TOKEN_URL)
.header("Content-Type", "application/json")
.body(tokenJsonObReq).execute().body();
cn.hutool.json.JSONObject tokenJsonObjRes = JSONUtil.parseObj(post);
String res = HttpRequest.post(BasicConstant.DJTS_URL)
String reslut = HttpRequest.post(BasicConstant.DJTS_URL)
.header("X-Access-Token", tokenJsonObjRes.getJSONObject("result").getStr("token"))
.body(jsonObject)
.execute().body();
StaticLog.info("新增异步开票申请和明细信息成功:{}",res);
return res;
resJSON.put("result",reslut);
res.append(resJSON);
StaticLog.info("新增异步开票申请和明细信息成功:{}",reslut);
}
@Resource
private IBoQyxxglService iBoQyxxglService;
return res.toString();
}
private cn.hutool.json.JSONArray buildDepotParams(XxKpsqDO xxKpsqDO,cn.hutool.json.JSONArray array) {
//转换成金财参数
@ -1506,6 +1541,8 @@ public class BoKpsqServiceImpl implements IBoKpsqService {
fpkjObject.put("xfyh",MapUtil.getStr(map1,"KHHMC"));//是 string 销方开户银行
fpkjObject.put("xfzh",MapUtil.getStr(map1,"YHZH"));//是 string 销方银行账号
fpkjObject.put("kpzddm",MapUtil.getStr(map1,"KPDDM"));//是 string 销方开票终端代码
fpkjObject.put("appKey",MapUtil.getStr(map1,"APPID"));//是 string 销方开票终端代码
fpkjObject.put("appSecret",MapUtil.getStr(map1,"APPSECRET"));//是 string 销方开票终端代码
}
}

View File

@ -66,7 +66,7 @@ public interface IBoKpsqService {
*@param map
*<p/>
*/
Integer insertZZSGL_XX_KPSQ(Map map) throws SaveException;
String insertZZSGL_XX_KPSQ(Map map) throws SaveException;
Integer payKpsqAndUpdateStatus(Map map) throws SaveException;

View File

@ -187,7 +187,7 @@ var kpsq_list = (function() {
success: function (jsonObj) {
console.log(jsonObj)
if(jsonObj.code==0){
sctTools.successMsg("推送成功");
sctTools.successMsg(jsonObj.msg);
layui.table.reload("table_sb", {page: {curr: $(".layui-laypage-em").next().html()}});
}else if(jsonObj.code==-1){
sctTools.errorMsg(jsonObj.msg);

View File

@ -191,7 +191,7 @@ var kpsq_add =(function(){
callback: [function (jsonObj,xhrArgs) {
if(jsonObj.code==1){
kpsq_add.calPareFuc();
parent.layer.msg("添加成功", {
parent.layer.msg(jsonObj.msg, {
icon: 6,
time: 3000
});