From dd7f2d31b5b21d56d56f089d24506773fd90f271 Mon Sep 17 00:00:00 2001 From: cca Date: Sat, 9 May 2020 11:25:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E7=A8=8E=E8=AE=A1=E7=AE=97=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=A8=8E=E7=8E=87=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gszc/controller/CountController.java | 12 ++-- .../java/com/gszc/service/CountService.java | 62 +++++++++++-------- .../gszc/service/impl/InvoiceServiceImpl.java | 1 + 3 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/gszc/controller/CountController.java b/src/main/java/com/gszc/controller/CountController.java index 737d9e5..5ad652d 100644 --- a/src/main/java/com/gszc/controller/CountController.java +++ b/src/main/java/com/gszc/controller/CountController.java @@ -79,7 +79,8 @@ public class CountController { } } catch (Exception e) { - return ResultBuilder.error("参数错误",e).build(); + String msg = "".equals(e.getMessage()) ? "参数错误" : e.getMessage(); + return ResultBuilder.error(msg,e).build(); } return ResultBuilder.withPayload(jsonObject).build(); } @@ -97,13 +98,14 @@ public class CountController { @ApiImplicitParam(name = "money", value = "开票金额", dataType = "string", paramType = "query"), }) public Result PITCount(double money) { - BigDecimal bigDecimal = null; + JSONObject jsonObject = new JSONObject(); try { - bigDecimal = countService.PITCount(money); + jsonObject = countService.PITCount(money); } catch (Exception e) { - return ResultBuilder.error("参数错误",e).build(); + String msg = "".equals(e.getMessage()) ? "参数错误" : e.getMessage(); + return ResultBuilder.error(msg,e).build(); } - return ResultBuilder.withPayload(bigDecimal).build(); + return ResultBuilder.withPayload(jsonObject).build(); } } diff --git a/src/main/java/com/gszc/service/CountService.java b/src/main/java/com/gszc/service/CountService.java index fcb656f..24493fb 100644 --- a/src/main/java/com/gszc/service/CountService.java +++ b/src/main/java/com/gszc/service/CountService.java @@ -70,56 +70,59 @@ public class CountService { return jsonObject; } - public BigDecimal PITCount(double money) throws Exception{ + public JSONObject PITCount(double money) throws Exception{ if(money <= 0){ throw new Exception("金额须大于0"); } + JSONObject jsonObject = new JSONObject(); double result =0; + double rate = 0; if(money<=300000){ - result = money*0.005; + rate = 0.005; }else if(300000 impl public void addInvoice(Invoice invoice){ String id = Uuid8Utils.generateShortUUID(); invoice.setId(id); + invoice.setStatusCode("disable"); invoice.setCreateDate(new Date()); invoice.setModifyDate(new Date()); invoiceMapper.insert(invoice);