From 8a52f894851f5b239b4aff26361a3421d64c183c Mon Sep 17 00:00:00 2001 From: ky <592468495@qq.com> Date: Thu, 7 May 2020 11:08:18 +0800 Subject: [PATCH] p --- .../com/gszc/controller/CountController.java | 8 +++--- .../java/com/gszc/service/CountService.java | 25 ++++++++++++------- .../java/com/gszc/service/MiniAppService.java | 5 ++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/gszc/controller/CountController.java b/src/main/java/com/gszc/controller/CountController.java index 3ce25ec..16d8ad3 100644 --- a/src/main/java/com/gszc/controller/CountController.java +++ b/src/main/java/com/gszc/controller/CountController.java @@ -40,10 +40,10 @@ public class CountController { @ApiImplicitParam(name = "fourMoney", value = "第四季度开票金额", dataType = "string", paramType = "query"), }) public Result VATCount(String companyType,String invoiceType,String specialInvoiceType,double oneMoney,double twoMoney,double threeMoney,double fourMoney) { - BigDecimal oneBigDecimal = null; - BigDecimal twoBigDecimal = null; - BigDecimal threeBigDecimal = null; - BigDecimal fourBigDecimal = null; + JSONObject oneBigDecimal = null; + JSONObject twoBigDecimal = null; + JSONObject threeBigDecimal = null; + JSONObject fourBigDecimal = null; JSONObject jsonObject = new JSONObject(); try { oneBigDecimal = countService.VATCount(companyType,invoiceType,specialInvoiceType,oneMoney); diff --git a/src/main/java/com/gszc/service/CountService.java b/src/main/java/com/gszc/service/CountService.java index e962004..805e4e8 100644 --- a/src/main/java/com/gszc/service/CountService.java +++ b/src/main/java/com/gszc/service/CountService.java @@ -1,5 +1,6 @@ package com.gszc.service; +import com.alibaba.fastjson.JSONObject; import org.springframework.stereotype.Service; import java.math.BigDecimal; @@ -7,37 +8,43 @@ import java.math.BigDecimal; @Service public class CountService { - public BigDecimal VATCount(String companyType,String invoiceType,String specialInvoiceType,double money) throws Exception{ + public JSONObject VATCount(String companyType,String invoiceType,String specialInvoiceType,double money) throws Exception{ - double result = 0; + JSONObject result = new JSONObject(); if(companyType.equals("1")){//有限公司 - result = VATCountDetail(invoiceType, money, result, specialInvoiceType); + result = VATCountDetail(invoiceType, money, specialInvoiceType); }else if(companyType.equals("2")){//个独、合伙企业 - result = VATCountDetail(invoiceType, money, result, specialInvoiceType); + result = VATCountDetail(invoiceType, money, specialInvoiceType); } else { throw new Exception("公司类型不正确"); } - BigDecimal b = new BigDecimal(result); - return b.setScale(2, BigDecimal.ROUND_HALF_UP); + return result; } - private double VATCountDetail(String invoiceType,double money,double result,String specialInvoiceType) throws Exception{ + private JSONObject VATCountDetail(String invoiceType,double money,String specialInvoiceType) throws Exception{ + JSONObject jsonObject = new JSONObject(); + double result = 0; if(invoiceType.equals("1")){//普票类型 result = money/1.03*0.03; - + jsonObject.put("rate",3); }else if(invoiceType.equals("2")){//专票类型 if(specialInvoiceType.equals("1")){ result = money/1.06*0.06; + jsonObject.put("rate",6); }else if(specialInvoiceType.equals("2")){ result = money/1.13*0.13; + jsonObject.put("rate",13); }else { throw new Exception("专票类型不正确"); } }else { throw new Exception("发票类型不正确"); } - return result; + BigDecimal b = new BigDecimal(result); + BigDecimal keep = b.setScale(2, BigDecimal.ROUND_HALF_UP); + jsonObject.put("money",keep); + return jsonObject; } public BigDecimal PITCount(String type,String produceType,double money) throws Exception{ diff --git a/src/main/java/com/gszc/service/MiniAppService.java b/src/main/java/com/gszc/service/MiniAppService.java index 44a3f5f..b3dc8ca 100644 --- a/src/main/java/com/gszc/service/MiniAppService.java +++ b/src/main/java/com/gszc/service/MiniAppService.java @@ -124,8 +124,7 @@ public class MiniAppService { return jsonObject; } - public MiniUser decryptPhoneNumber(String userId, String signature, - String rawData, String encryptedData, String iv) { + public MiniUser decryptPhoneNumber(String userId,String encryptedData ,String ivStr,String signature,String rawData) { //todo sessionKeyId 查出 sessionKey String sessionKey = getSessionKey(userId); @@ -136,7 +135,7 @@ public class MiniAppService { // } // 解密 - WxMaPhoneNumberInfo phoneNoInfo = wxService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv); + WxMaPhoneNumberInfo phoneNoInfo = wxService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, ivStr); //区号 String countryCode = phoneNoInfo.getCountryCode();