推送bip接口增加 local_notax_de 组织本币无税金额

This commit is contained in:
yuxueliang0813 2025-02-17 17:30:12 +08:00
parent 8cd7fd6752
commit eeeeaeccb2
1 changed files with 77 additions and 0 deletions

View File

@ -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"));
}
}
}