ky 6 years ago
parent 895f7623c2
commit 8a52f89485

@ -40,10 +40,10 @@ public class CountController {
@ApiImplicitParam(name = "fourMoney", value = "第四季度开票金额", dataType = "string", paramType = "query"), @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) { public Result VATCount(String companyType,String invoiceType,String specialInvoiceType,double oneMoney,double twoMoney,double threeMoney,double fourMoney) {
BigDecimal oneBigDecimal = null; JSONObject oneBigDecimal = null;
BigDecimal twoBigDecimal = null; JSONObject twoBigDecimal = null;
BigDecimal threeBigDecimal = null; JSONObject threeBigDecimal = null;
BigDecimal fourBigDecimal = null; JSONObject fourBigDecimal = null;
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
try { try {
oneBigDecimal = countService.VATCount(companyType,invoiceType,specialInvoiceType,oneMoney); oneBigDecimal = countService.VATCount(companyType,invoiceType,specialInvoiceType,oneMoney);

@ -1,5 +1,6 @@
package com.gszc.service; package com.gszc.service;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -7,37 +8,43 @@ import java.math.BigDecimal;
@Service @Service
public class CountService { 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")){//有限公司 if(companyType.equals("1")){//有限公司
result = VATCountDetail(invoiceType, money, result, specialInvoiceType); result = VATCountDetail(invoiceType, money, specialInvoiceType);
}else if(companyType.equals("2")){//个独、合伙企业 }else if(companyType.equals("2")){//个独、合伙企业
result = VATCountDetail(invoiceType, money, result, specialInvoiceType); result = VATCountDetail(invoiceType, money, specialInvoiceType);
} else { } else {
throw new Exception("公司类型不正确"); throw new Exception("公司类型不正确");
} }
BigDecimal b = new BigDecimal(result); return result;
return b.setScale(2, BigDecimal.ROUND_HALF_UP);
} }
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")){//普票类型 if(invoiceType.equals("1")){//普票类型
result = money/1.03*0.03; result = money/1.03*0.03;
jsonObject.put("rate",3);
}else if(invoiceType.equals("2")){//专票类型 }else if(invoiceType.equals("2")){//专票类型
if(specialInvoiceType.equals("1")){ if(specialInvoiceType.equals("1")){
result = money/1.06*0.06; result = money/1.06*0.06;
jsonObject.put("rate",6);
}else if(specialInvoiceType.equals("2")){ }else if(specialInvoiceType.equals("2")){
result = money/1.13*0.13; result = money/1.13*0.13;
jsonObject.put("rate",13);
}else { }else {
throw new Exception("专票类型不正确"); throw new Exception("专票类型不正确");
} }
}else { }else {
throw new Exception("发票类型不正确"); 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{ public BigDecimal PITCount(String type,String produceType,double money) throws Exception{

@ -124,8 +124,7 @@ public class MiniAppService {
return jsonObject; return jsonObject;
} }
public MiniUser decryptPhoneNumber(String userId, String signature, public MiniUser decryptPhoneNumber(String userId,String encryptedData ,String ivStr,String signature,String rawData) {
String rawData, String encryptedData, String iv) {
//todo sessionKeyId 查出 sessionKey //todo sessionKeyId 查出 sessionKey
String sessionKey = getSessionKey(userId); 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(); String countryCode = phoneNoInfo.getCountryCode();

Loading…
Cancel
Save