You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
5.6 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.gszc.controller;
import com.alibaba.fastjson.JSONObject;
import com.gszc.build.Result;
import com.gszc.build.ResultBuilder;
import com.gszc.service.CountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
@Api(value = "工商注册 API", tags = {"计算api"})
@RestController
@RequestMapping("/count")
public class CountController {
@Autowired
CountService countService;
/**
* 增值税
* proprietorship 个人独资
* limit 有限责任公司
* partner 合伙人企业
* individual 个体工商户
*
* smallScale 小规模
* taxpayer 一般纳税人
* @return
*/
@PostMapping("/VATCount")
@ApiOperation(value = "增值税计算器", notes = "增值税计算器")
@ApiImplicitParams({
@ApiImplicitParam(name = "companyType", value = "公司类型limit-有限公司 proprietorship-个人独资企业 partner-合伙人企业 individual-个体工商户)", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "invoiceType", value = "开票类型1-普通发票 2-专用发票)", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "taxType", value = "纳税性质个体工商户不必填写1-小规模纳税人 2-一般纳税人服务业3-一般纳税人(商业)", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "oneMoney", value = "第一季度开票金额", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "twoMoney", value = "第二季度开票金额", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "threeMoney", value = "第三季度开票金额", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "fourMoney", value = "第四季度开票金额", dataType = "string", paramType = "query"),
})
public Result VATCount(String companyType,String invoiceType,String taxType,String oneMoney,String twoMoney,String threeMoney,String fourMoney) {
JSONObject oneBigDecimal = null;
JSONObject twoBigDecimal = null;
JSONObject threeBigDecimal = null;
JSONObject fourBigDecimal = null;
JSONObject jsonObject = new JSONObject();
try {
boolean isCounted = false;
if(!"".equals(oneMoney)){
oneBigDecimal = countService.VATCount(companyType,invoiceType,taxType,Double.parseDouble(oneMoney));
jsonObject.put("one",oneBigDecimal);
isCounted = true;
}
if(!"".equals(twoMoney)){
twoBigDecimal = countService.VATCount(companyType,invoiceType,taxType,Double.parseDouble(twoMoney));
jsonObject.put("two",twoBigDecimal);
isCounted = true;
}
if(!"".equals(threeMoney)){
threeBigDecimal = countService.VATCount(companyType,invoiceType,taxType,Double.parseDouble(threeMoney));
jsonObject.put("three",threeBigDecimal);
isCounted = true;
}
if(!"".equals(fourMoney)){
fourBigDecimal = countService.VATCount(companyType,invoiceType,taxType,Double.parseDouble(fourMoney));
jsonObject.put("four",fourBigDecimal);
isCounted = true;
}
if(!isCounted){
return ResultBuilder.error("至少需要计算一个季度").build();
}
} catch (Exception e) {
String msg = "".equals(e.getMessage()) ? "参数错误" : e.getMessage();
return ResultBuilder.error(msg,e).build();
}
return ResultBuilder.withPayload(jsonObject).build();
}
/**
* 个人所得税
*
* @return
*/
@PostMapping("/PITCount")
@ApiOperation(value = "个人所得税计算器", notes = "个人所得税计算器")
@ApiImplicitParams({
// @ApiImplicitParam(name = "type", value = "1-个税 2-生产经营个税)", dataType = "string", paramType = "query"),
// @ApiImplicitParam(name = "produceType", value = "生产经营方式1-核定征收 2-累进税率),不是生产经营不用填写", dataType = "string", paramType = "query"),
@ApiImplicitParam(name = "money", value = "开票金额", dataType = "string", paramType = "query"),
})
public Result PITCount(double money) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject = countService.PITCount(money);
} catch (Exception e) {
String msg = "".equals(e.getMessage()) ? "参数错误" : e.getMessage();
return ResultBuilder.error(msg,e).build();
}
return ResultBuilder.withPayload(jsonObject).build();
}
@PostMapping("/VATSurchargeCount")
@ApiOperation(value = "增值税附加税计算器", notes = "增值税计算器")
@ApiImplicitParams({
@ApiImplicitParam(name = "money", value = "开票金额", dataType = "string", paramType = "query"),
})
public Result VATSurchargeCount(String money) {
JSONObject jsonObject = countService.VATSurchargeCount(money);
return ResultBuilder.withPayload(jsonObject).build();
}
}