From eeeeaeccb24e94499dcaaed6e77e051b945a11dc Mon Sep 17 00:00:00 2001 From: yuxueliang0813 <407010292@qq.com> Date: Mon, 17 Feb 2025 17:30:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E9=80=81bip=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20local=5Fnotax=5Fde=20=20=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=9C=AC=E5=B8=81=E6=97=A0=E7=A8=8E=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recon/opplugin/YongyouBIPOperation.java | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java b/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java index b2a7080..8fa3d8c 100644 --- a/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java +++ b/main/java/shkd/repc/recon/opplugin/YongyouBIPOperation.java @@ -185,6 +185,77 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen // payrequestinfo.getDynamicObjectType().getAlias();//获取数据库表名 } } + else if("submit".equals(eok)){ + DynamicObject[] dos = e.getDataEntities(); + DynamicObject prinfo = null; + for (int i = 0; i < dos.length; i++) { + prinfo = dos[i]; +// prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName()); + testBip(prinfo); + } + } + } + + private boolean testBip(DynamicObject prinfo){ + String accesstoken = null; + String eventName = "submit-test"; + APICurUtils apiutil = new APICurUtils();//处理认证接口的工具类(用友提供的第三方工具),得到accesstoken + apiutil.init(DobeDWUtils.yyip,DobeDWUtils.yyport,DobeDWUtils.bizcenter,DobeDWUtils.clientid,DobeDWUtils.clientsecret,DobeDWUtils.pubKey,DobeDWUtils.clientid,null); + try { + String tokenresult = apiutil.getTokenByClient(); + if(DobeDWUtils.isEmpty(tokenresult)){ + log.error("用友认证接口返回的accessToken为空"); + return false; + } + JSONObject json_reuslt = JSON.parseObject(tokenresult); + if(json_reuslt.getJSONObject("data") == null){ + log.error("用友认证接口返回的data为空"); + return false; + } + accesstoken = json_reuslt.getJSONObject("data").getString("access_token"); + } catch (Exception e) { + log.error(String.format("用友认证接口异常:%s", e.getMessage())); + throw new RuntimeException(e); + } + if(DobeDWUtils.isEmpty(accesstoken)){ + log.error("用友认证接口返回的accessToken为空"); + return false; + } + + JSONObject payData = JSONObject.parseObject(prinfo.getString("qeug_inputs")); + OkHttpClient client = new OkHttpClient(); + //付款单新增接口,上一步的accesstoken作为header + Request request = new Request.Builder().url(DobeDWUtils.payUrl) + .post(createFormRequestBody(payData)) + .header("Content-Type", "application/json;charset=utf-8") + .header("access_token", accesstoken) + .header("repeat_check", "Y") + .header("ucg_flag", "Y") + .header("client_id", DobeDWUtils.clientid) + .build(); + String yynum = null;//用友单据编号 + String yyid = null;//用友单据id + JSONObject json_reuslt = null; + try { + Response response = client.newCall(request).execute(); + json_reuslt = JSON.parseObject(response.body().string()); + if(!"true".equals(json_reuslt.getString("success"))){ + log.error(String.format("用友付款接口处理失败,具体原因:%s", json_reuslt.toString())); + //此时除了日志打印,增加日志记录 + DobeDWUtils.saveLog(prinfo.getString("number"),"用友BIP",payData.toString(),json_reuslt.toString(),false,eventName); + return false; + }else{ + yynum = json_reuslt.getJSONObject("data").getString("billno"); + yyid = json_reuslt.getJSONObject("data").getString("pk_bill"); + } + } catch (Exception e) { + log.error(String.format("用友付款接口异常:%s", e.getMessage())); +// throw new RuntimeException(e); + DobeDWUtils.saveLog(prinfo.getString("number"),"用友BIP",payData.toString(),e.getMessage(),false,eventName); + return false; + } + DobeDWUtils.saveLog(prinfo.getString("number"),"用友BIP",payData.toString(),json_reuslt.toString(),true,eventName); + return true; } private String getInvoiceNumber(DynamicObject payrequestinfo, boolean isnotext){ @@ -329,10 +400,12 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen items.put("local_tax_de",payrequestinfo.getBigDecimal("tax").toString());//税额 } items.put("notax_de",payrequestinfo.getBigDecimal("notaxamt").toString());//贷方无税金额,除税金额 + items.put("local_notax_de",payrequestinfo.getBigDecimal("notaxamt").toString());//组织本币无税金额 if("unaudit".equals(eventName)){ //如果此时是反审核,则需要将金额置为负数 items.put("local_tax_de","-"+items.getString("local_tax_de")); items.put("notax_de","-"+items.getString("notax_de")); + items.put("local_notax_de","-"+items.getString("notax_de")); } }else{ //付款申请单的处理方式 @@ -341,9 +414,11 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen items.put("taxrate","0");//税率 items.put("local_tax_de","0");//税额 items.put("notax_de",bcsqje.toString());//贷方无税金额,除税金额 + items.put("local_notax_de",bcsqje.toString());//组织本币无税金额 if("unaudit".equals(eventName)){ //如果此时是反审核,则需要将金额置为负数 items.put("notax_de","-"+bcsqje.toString()); + items.put("local_notax_de","-"+bcsqje.toString());//组织本币无税金额 } }else{ //不含税金额 @@ -352,10 +427,12 @@ public class YongyouBIPOperation extends AbstractOperationServicePlugIn implemen items.put("taxrate",invoicetax.divide(notaxv,10,RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).toString());//税率=税额/不含税 * 100 items.put("local_tax_de",invoicetax.toString());//税额 items.put("notax_de",notaxv.toString());//贷方无税金额,除税金额 + items.put("local_notax_de",notaxv.toString());//组织本币无税金额 if("unaudit".equals(eventName)){ //如果此时是反审核,则需要将金额置为负数 items.put("local_tax_de","-"+items.getString("local_tax_de")); items.put("notax_de","-"+items.getString("notax_de")); + items.put("local_notax_de","-"+items.getString("notax_de")); } } }