|
|
@@ -109,134 +109,135 @@ public class tinvoicebill extends PaoCust {
|
|
|
// if (getString("status").equals("2") && "红".equals(getString("frb"))) {
|
|
|
// return;
|
|
|
// }
|
|
|
- String finvoiceserialnum = getString("finvoiceserialnum");//发票流水号
|
|
|
- String foldstatus = getString("status");//原状态
|
|
|
-
|
|
|
- JSONObject contentObject = new JSONObject();
|
|
|
- contentObject.put("isOfferInvoiceDetail", "1");
|
|
|
- JSONArray serialNosArray = new JSONArray();
|
|
|
- serialNosArray.add(finvoiceserialnum);
|
|
|
- contentObject.put("serialNos", serialNosArray);
|
|
|
- JSONObject object = new OpenApi().requestApi("nuonuo.ElectronInvoice.queryInvoiceResult", contentObject.toString());
|
|
|
- if (object.getString("code").equalsIgnoreCase("E0000")) {
|
|
|
- JSONArray resultArray = object.getJSONArray("result");
|
|
|
- for (Object o : resultArray) {
|
|
|
- JSONObject resultObject = (JSONObject) o;
|
|
|
- String status = resultObject.getString("status");
|
|
|
- String statusMsg = resultObject.getString("statusMsg");
|
|
|
- setValue("status", status, 11L);
|
|
|
- setValue("msg", statusMsg, 11L);
|
|
|
- if (status.equals("2")) {
|
|
|
- if (resultObject.containsKey("pdfUrl")) {
|
|
|
- String pdfUrl = resultObject.getString("pdfUrl");
|
|
|
- if (getString("pdfUrl").equals("")) {
|
|
|
- upLoadDocUrl(pdfUrl, "发票pdf地址");
|
|
|
- }
|
|
|
- setValue("pdfUrl", pdfUrl, 11L);
|
|
|
- }
|
|
|
- if (resultObject.containsKey("paperPdfUrl")) {
|
|
|
- String paperPdfUrl = resultObject.getString("paperPdfUrl");
|
|
|
- if (getString("paperPdfUrl").equals("")) {
|
|
|
- upLoadDocUrl(paperPdfUrl, "纸票pdf地址");
|
|
|
- }
|
|
|
- setValue("paperPdfUrl", paperPdfUrl, 11L);
|
|
|
- }
|
|
|
- if (resultObject.containsKey("invoiceCode")) {
|
|
|
- String invoiceCode = resultObject.getString("invoiceCode");
|
|
|
- setValue("invoiceCode", invoiceCode, 11L);
|
|
|
- }
|
|
|
- if (resultObject.containsKey("invoiceNo")) {
|
|
|
- String invoiceNo = resultObject.getString("invoiceNo");
|
|
|
- setValue("invoiceNo", invoiceNo, 11L);
|
|
|
- }
|
|
|
- createPrintStr(getString("invoiceCode"), getString("invoiceNo"), Double.parseDouble(resultObject.getString("orderAmount")));
|
|
|
- if ("红".equals(getString("frb")) && !foldstatus.equals("2")) {
|
|
|
- //红票查询成功后,更新订单已开票数量
|
|
|
- DBConnect dbConnect = new DBConnect();
|
|
|
- Rows rows = dbConnect.runSqlQuery("select t3.saorderdetailid,sum(t2.taxincludedamount)as taxincludedamount from tinvoicebill t1\n" +
|
|
|
- "inner join tinvoicebillitem t2 on t1.siteid=t2.siteid and t1.tinvoiceapplyid=t2.tinvoiceapplyid and t1.tinvoicebillid=t2.tinvoicebillid\n" +
|
|
|
- "inner join tinvoiceapplyorder t3 on t2.siteid=t3.siteid and t2.tinvoiceapplyid=t3.tinvoiceapplyid and t2.tinvoiceapplyordid=t3.tinvoiceapplyordid\n" +
|
|
|
- "where t1.tinvoicebillid='" + getUniqueIDValue() + "' group by t3.saorderdetailid");
|
|
|
- PaoSetRemote saorderdetailSet = getPaoSet("$saorderdetail", "saorderdetail", "siteid='" + getString("siteid") + "' and saorderdetailid in " + rows.getInWhere("saorderdetailid"));
|
|
|
- int i = 0;
|
|
|
- while (saorderdetailSet.getPao(i) != null) {
|
|
|
- for (Row row : rows) {
|
|
|
- if (String.valueOf(saorderdetailSet.getPao(i).getUniqueIDValue()).equalsIgnoreCase(row.getString("saorderdetailid"))) {
|
|
|
- double foldinvoiceamount = saorderdetailSet.getPao(i).getDouble("finvoiceamount");
|
|
|
- saorderdetailSet.getPao(i).setValue("finvoiceamount", Math.add(foldinvoiceamount, row.getDouble("taxincludedamount")), 11L);
|
|
|
-
|
|
|
- double sainvoiceamount = -row.getDouble("taxincludedamount");
|
|
|
- /**
|
|
|
- * 更新发货单已开票金额
|
|
|
- */
|
|
|
- PaoSetRemote sainvoicedetailSet = saorderdetailSet.getPao(i).getPaoSet("sainvoicedetail");
|
|
|
- sainvoicedetailSet.setOrderBy("sainvoicedetailid");
|
|
|
- int n = 0;
|
|
|
- while (sainvoicedetailSet.getPao(n) != null) {
|
|
|
- if (sainvoicedetailSet.getPao(n).getPaoSet("SAINVOICE").getPao(0).getString("fstatus").equals("关闭")) {
|
|
|
- double finvoiceamount_sainvoice = sainvoicedetailSet.getPao(n).getDouble("finvoiceamount");//发货单已开票金额
|
|
|
- if (finvoiceamount_sainvoice > 0) {//表示已开票
|
|
|
- double fneedinvoiceamount_sainvoice = finvoiceamount_sainvoice;//发货单应减开票金额
|
|
|
- if (fneedinvoiceamount_sainvoice > sainvoiceamount) {
|
|
|
- fneedinvoiceamount_sainvoice = sainvoiceamount;
|
|
|
- }
|
|
|
- sainvoicedetailSet.getPao(n).setValue("finvoiceamount", baseclass.tools.Math.sub(finvoiceamount_sainvoice, fneedinvoiceamount_sainvoice), 11L);
|
|
|
- sainvoiceamount = baseclass.tools.Math.sub(sainvoiceamount, fneedinvoiceamount_sainvoice);
|
|
|
- }
|
|
|
- }
|
|
|
- n++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
- } else if ("红".equals(getString("frb")) && status.equals("3") && foldstatus.equals("2")) {
|
|
|
- //如果红字发票作废
|
|
|
- //红票查询成功后,更新订单已开票数量
|
|
|
- DBConnect dbConnect = new DBConnect();
|
|
|
- Rows rows = dbConnect.runSqlQuery("select t3.saorderdetailid,sum(t2.taxincludedamount)as taxincludedamount from tinvoicebill t1\n" +
|
|
|
- "inner join tinvoicebillitem t2 on t1.siteid=t2.siteid and t1.tinvoiceapplyid=t2.tinvoiceapplyid and t1.tinvoicebillid=t2.tinvoicebillid\n" +
|
|
|
- "inner join tinvoiceapplyorder t3 on t2.siteid=t3.siteid and t2.tinvoiceapplyid=t3.tinvoiceapplyid and t2.tinvoiceapplyordid=t3.tinvoiceapplyordid\n" +
|
|
|
- "where t1.tinvoicebillid='" + getUniqueIDValue() + "' group by t3.saorderdetailid");
|
|
|
- PaoSetRemote saorderdetailSet = getPaoSet("$saorderdetail", "saorderdetail", "siteid='" + getString("siteid") + "' and saorderdetailid in " + rows.getInWhere("saorderdetailid"));
|
|
|
- int i = 0;
|
|
|
- while (saorderdetailSet.getPao(i) != null) {
|
|
|
- for (Row row : rows) {
|
|
|
- if (String.valueOf(saorderdetailSet.getPao(i).getUniqueIDValue()).equalsIgnoreCase(row.getString("saorderdetailid"))) {
|
|
|
- double foldinvoiceamount = saorderdetailSet.getPao(i).getDouble("finvoiceamount");
|
|
|
- saorderdetailSet.getPao(i).setValue("finvoiceamount", Math.add(foldinvoiceamount, -row.getDouble("taxincludedamount")), 11L);
|
|
|
-
|
|
|
- double sainvoiceamount = -row.getDouble("taxincludedamount");
|
|
|
- /**
|
|
|
- * 更新发货单已开票金额
|
|
|
- */
|
|
|
- PaoSetRemote sainvoicedetailSet = saorderdetailSet.getPao(i).getPaoSet("sainvoicedetail");
|
|
|
- sainvoicedetailSet.setOrderBy("sainvoicedetailid");
|
|
|
- int n = 0;
|
|
|
- while (sainvoicedetailSet.getPao(n) != null) {
|
|
|
- if (sainvoicedetailSet.getPao(n).getPaoSet("SAINVOICE").getPao(0).getString("fstatus").equals("关闭")) {
|
|
|
- double famount_sainvoice = sainvoicedetailSet.getPao(n).getDouble("famount");//发货金额
|
|
|
- double finvoiceamount_sainvoice = sainvoicedetailSet.getPao(n).getDouble("finvoiceamount");//发货单已开票金额
|
|
|
- if (famount_sainvoice > finvoiceamount_sainvoice) {
|
|
|
- double fneedinvoiceamount_sainvoice = baseclass.tools.Math.sub(famount_sainvoice, finvoiceamount_sainvoice);//发货单应开票数
|
|
|
- if (fneedinvoiceamount_sainvoice > sainvoiceamount) {
|
|
|
- fneedinvoiceamount_sainvoice = sainvoiceamount;
|
|
|
- }
|
|
|
- sainvoicedetailSet.getPao(n).setValue("finvoiceamount", baseclass.tools.Math.add(finvoiceamount_sainvoice, fneedinvoiceamount_sainvoice), 11L);
|
|
|
- sainvoiceamount = baseclass.tools.Math.sub(sainvoiceamount, fneedinvoiceamount_sainvoice);
|
|
|
- }
|
|
|
- }
|
|
|
- n++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- setValue("result", object.toString(), 11L);
|
|
|
+// String finvoiceserialnum = getString("finvoiceserialnum");//发票流水号
|
|
|
+// String foldstatus = getString("status");//原状态
|
|
|
+//
|
|
|
+// JSONObject contentObject = new JSONObject();
|
|
|
+// contentObject.put("isOfferInvoiceDetail", "1");
|
|
|
+// JSONArray serialNosArray = new JSONArray();
|
|
|
+// serialNosArray.add(finvoiceserialnum);
|
|
|
+// contentObject.put("serialNos", serialNosArray);
|
|
|
+// JSONObject object = new OpenApi().requestApi("nuonuo.ElectronInvoice.queryInvoiceResult", contentObject.toString());
|
|
|
+// if (object.getString("code").equalsIgnoreCase("E0000")) {
|
|
|
+// JSONArray resultArray = object.getJSONArray("result");
|
|
|
+// for (Object o : resultArray) {
|
|
|
+// JSONObject resultObject = (JSONObject) o;
|
|
|
+// String status = resultObject.getString("status");
|
|
|
+// String statusMsg = resultObject.getString("statusMsg");
|
|
|
+// setValue("status", status, 11L);
|
|
|
+// setValue("msg", statusMsg, 11L);
|
|
|
+// if (status.equals("2")) {
|
|
|
+// if (resultObject.containsKey("pdfUrl")) {
|
|
|
+// String pdfUrl = resultObject.getString("pdfUrl");
|
|
|
+// if (getString("pdfUrl").equals("")) {
|
|
|
+// upLoadDocUrl(pdfUrl, "发票pdf地址");
|
|
|
+// }
|
|
|
+// setValue("pdfUrl", pdfUrl, 11L);
|
|
|
+// }
|
|
|
+// if (resultObject.containsKey("paperPdfUrl")) {
|
|
|
+// String paperPdfUrl = resultObject.getString("paperPdfUrl");
|
|
|
+// if (getString("paperPdfUrl").equals("")) {
|
|
|
+// upLoadDocUrl(paperPdfUrl, "纸票pdf地址");
|
|
|
+// }
|
|
|
+// setValue("paperPdfUrl", paperPdfUrl, 11L);
|
|
|
+// }
|
|
|
+// if (resultObject.containsKey("invoiceCode")) {
|
|
|
+// String invoiceCode = resultObject.getString("invoiceCode");
|
|
|
+// setValue("invoiceCode", invoiceCode, 11L);
|
|
|
+// }
|
|
|
+// if (resultObject.containsKey("invoiceNo")) {
|
|
|
+// String invoiceNo = resultObject.getString("invoiceNo");
|
|
|
+// setValue("invoiceNo", invoiceNo, 11L);
|
|
|
+// }
|
|
|
+// createPrintStr(getString("invoiceCode"), getString("invoiceNo"), Double.parseDouble(resultObject.getString("orderAmount")));
|
|
|
+// if ("红".equals(getString("frb")) && !foldstatus.equals("2")) {
|
|
|
+// //红票查询成功后,更新订单已开票数量
|
|
|
+// DBConnect dbConnect = new DBConnect();
|
|
|
+// Rows rows = dbConnect.runSqlQuery("select t3.saorderdetailid,sum(t2.taxincludedamount)as taxincludedamount from tinvoicebill t1\n" +
|
|
|
+// "inner join tinvoicebillitem t2 on t1.siteid=t2.siteid and t1.tinvoiceapplyid=t2.tinvoiceapplyid and t1.tinvoicebillid=t2.tinvoicebillid\n" +
|
|
|
+// "inner join tinvoiceapplyorder t3 on t2.siteid=t3.siteid and t2.tinvoiceapplyid=t3.tinvoiceapplyid and t2.tinvoiceapplyordid=t3.tinvoiceapplyordid\n" +
|
|
|
+// "where t1.tinvoicebillid='" + getUniqueIDValue() + "' group by t3.saorderdetailid");
|
|
|
+// PaoSetRemote saorderdetailSet = getPaoSet("$saorderdetail", "saorderdetail", "siteid='" + getString("siteid") + "' and saorderdetailid in " + rows.getInWhere("saorderdetailid"));
|
|
|
+// int i = 0;
|
|
|
+// while (saorderdetailSet.getPao(i) != null) {
|
|
|
+// for (Row row : rows) {
|
|
|
+// if (String.valueOf(saorderdetailSet.getPao(i).getUniqueIDValue()).equalsIgnoreCase(row.getString("saorderdetailid"))) {
|
|
|
+// double foldinvoiceamount = saorderdetailSet.getPao(i).getDouble("finvoiceamount");
|
|
|
+// saorderdetailSet.getPao(i).setValue("finvoiceamount", Math.add(foldinvoiceamount, row.getDouble("taxincludedamount")), 11L);
|
|
|
+//
|
|
|
+// double sainvoiceamount = -row.getDouble("taxincludedamount");
|
|
|
+// /**
|
|
|
+// * 更新发货单已开票金额
|
|
|
+// */
|
|
|
+// PaoSetRemote sainvoicedetailSet = saorderdetailSet.getPao(i).getPaoSet("sainvoicedetail");
|
|
|
+// sainvoicedetailSet.setOrderBy("sainvoicedetailid");
|
|
|
+// int n = 0;
|
|
|
+// while (sainvoicedetailSet.getPao(n) != null) {
|
|
|
+// if (sainvoicedetailSet.getPao(n).getPaoSet("SAINVOICE").getPao(0).getString("fstatus").equals("关闭")) {
|
|
|
+// double finvoiceamount_sainvoice = sainvoicedetailSet.getPao(n).getDouble("finvoiceamount");//发货单已开票金额
|
|
|
+// if (finvoiceamount_sainvoice > 0) {//表示已开票
|
|
|
+// double fneedinvoiceamount_sainvoice = finvoiceamount_sainvoice;//发货单应减开票金额
|
|
|
+// if (fneedinvoiceamount_sainvoice > sainvoiceamount) {
|
|
|
+// fneedinvoiceamount_sainvoice = sainvoiceamount;
|
|
|
+// }
|
|
|
+// sainvoicedetailSet.getPao(n).setValue("finvoiceamount", baseclass.tools.Math.sub(finvoiceamount_sainvoice, fneedinvoiceamount_sainvoice), 11L);
|
|
|
+// sainvoiceamount = baseclass.tools.Math.sub(sainvoiceamount, fneedinvoiceamount_sainvoice);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// n++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// i++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else if ("红".equals(getString("frb")) && status.equals("3") && foldstatus.equals("2")) {
|
|
|
+// //如果红字发票作废
|
|
|
+// //红票查询成功后,更新订单已开票数量
|
|
|
+// DBConnect dbConnect = new DBConnect();
|
|
|
+// Rows rows = dbConnect.runSqlQuery("select t3.saorderdetailid,sum(t2.taxincludedamount)as taxincludedamount from tinvoicebill t1\n" +
|
|
|
+// "inner join tinvoicebillitem t2 on t1.siteid=t2.siteid and t1.tinvoiceapplyid=t2.tinvoiceapplyid and t1.tinvoicebillid=t2.tinvoicebillid\n" +
|
|
|
+// "inner join tinvoiceapplyorder t3 on t2.siteid=t3.siteid and t2.tinvoiceapplyid=t3.tinvoiceapplyid and t2.tinvoiceapplyordid=t3.tinvoiceapplyordid\n" +
|
|
|
+// "where t1.tinvoicebillid='" + getUniqueIDValue() + "' group by t3.saorderdetailid");
|
|
|
+// PaoSetRemote saorderdetailSet = getPaoSet("$saorderdetail", "saorderdetail", "siteid='" + getString("siteid") + "' and saorderdetailid in " + rows.getInWhere("saorderdetailid"));
|
|
|
+// int i = 0;
|
|
|
+// while (saorderdetailSet.getPao(i) != null) {
|
|
|
+// for (Row row : rows) {
|
|
|
+// if (String.valueOf(saorderdetailSet.getPao(i).getUniqueIDValue()).equalsIgnoreCase(row.getString("saorderdetailid"))) {
|
|
|
+// double foldinvoiceamount = saorderdetailSet.getPao(i).getDouble("finvoiceamount");
|
|
|
+// saorderdetailSet.getPao(i).setValue("finvoiceamount", Math.add(foldinvoiceamount, -row.getDouble("taxincludedamount")), 11L);
|
|
|
+//
|
|
|
+// double sainvoiceamount = -row.getDouble("taxincludedamount");
|
|
|
+// /**
|
|
|
+// * 更新发货单已开票金额
|
|
|
+// */
|
|
|
+// PaoSetRemote sainvoicedetailSet = saorderdetailSet.getPao(i).getPaoSet("sainvoicedetail");
|
|
|
+// sainvoicedetailSet.setOrderBy("sainvoicedetailid");
|
|
|
+// int n = 0;
|
|
|
+// while (sainvoicedetailSet.getPao(n) != null) {
|
|
|
+// if (sainvoicedetailSet.getPao(n).getPaoSet("SAINVOICE").getPao(0).getString("fstatus").equals("关闭")) {
|
|
|
+// double famount_sainvoice = sainvoicedetailSet.getPao(n).getDouble("famount");//发货金额
|
|
|
+// double finvoiceamount_sainvoice = sainvoicedetailSet.getPao(n).getDouble("finvoiceamount");//发货单已开票金额
|
|
|
+// if (famount_sainvoice > finvoiceamount_sainvoice) {
|
|
|
+// double fneedinvoiceamount_sainvoice = baseclass.tools.Math.sub(famount_sainvoice, finvoiceamount_sainvoice);//发货单应开票数
|
|
|
+// if (fneedinvoiceamount_sainvoice > sainvoiceamount) {
|
|
|
+// fneedinvoiceamount_sainvoice = sainvoiceamount;
|
|
|
+// }
|
|
|
+// sainvoicedetailSet.getPao(n).setValue("finvoiceamount", baseclass.tools.Math.add(finvoiceamount_sainvoice, fneedinvoiceamount_sainvoice), 11L);
|
|
|
+// sainvoiceamount = baseclass.tools.Math.sub(sainvoiceamount, fneedinvoiceamount_sainvoice);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// n++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// i++;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ // setValue("result", object.toString(), 11L);
|
|
|
+ setValue("result", getDate_Str() + "as112221d", 11L);
|
|
|
}
|
|
|
|
|
|
/**
|