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

6 years ago
package com.gszc.controller;
6 years ago
import com.alibaba.fastjson.JSONObject;
6 years ago
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;
/**
*
6 years ago
* proprietorship
* limit
* partner
* individual
6 years ago
*
6 years ago
* smallScale
* taxpayer
6 years ago
* @return
*/
@PostMapping("/VATCount")
@ApiOperation(value = "增值税计算器", notes = "增值税计算器")
@ApiImplicitParams({
6 years ago
@ApiImplicitParam(name = "companyType", value = "公司类型limit-有限公司 proprietorship-个人独资企业 partner-合伙人企业 individual-个体工商户)", dataType = "string", paramType = "query"),
6 years ago
@ApiImplicitParam(name = "invoiceType", value = "开票类型1-普通发票 2-专用发票)", dataType = "string", paramType = "query"),
6 years ago
@ApiImplicitParam(name = "taxType", value = "纳税性质个体工商户不必填写1-小规模纳税人 2-一般纳税人服务业3-一般纳税人(商业)", dataType = "string", paramType = "query"),
6 years ago
@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"),
6 years ago
})
6 years ago
public Result VATCount(String companyType,String invoiceType,String taxType,String oneMoney,String twoMoney,String threeMoney,String fourMoney) {
6 years ago
JSONObject oneBigDecimal = null;
JSONObject twoBigDecimal = null;
JSONObject threeBigDecimal = null;
JSONObject fourBigDecimal = null;
6 years ago
JSONObject jsonObject = new JSONObject();
6 years ago
6 years ago
try {
6 years ago
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();
}
6 years ago
} catch (Exception e) {
String msg = "".equals(e.getMessage()) ? "参数错误" : e.getMessage();
return ResultBuilder.error(msg,e).build();
6 years ago
}
6 years ago
return ResultBuilder.withPayload(jsonObject).build();
6 years ago
}
/**
*
*
* @return
*/
@PostMapping("/PITCount")
6 years ago
@ApiOperation(value = "个人所得税计算器", notes = "个人所得税计算器")
6 years ago
@ApiImplicitParams({
6 years ago
// @ApiImplicitParam(name = "type", value = "1-个税 2-生产经营个税)", dataType = "string", paramType = "query"),
// @ApiImplicitParam(name = "produceType", value = "生产经营方式1-核定征收 2-累进税率),不是生产经营不用填写", dataType = "string", paramType = "query"),
6 years ago
@ApiImplicitParam(name = "money", value = "开票金额", dataType = "string", paramType = "query"),
})
6 years ago
public Result PITCount(double money) {
JSONObject jsonObject = new JSONObject();
6 years ago
try {
jsonObject = countService.PITCount(money);
6 years ago
} catch (Exception e) {
String msg = "".equals(e.getMessage()) ? "参数错误" : e.getMessage();
return ResultBuilder.error(msg,e).build();
6 years ago
}
return ResultBuilder.withPayload(jsonObject).build();
6 years ago
}
5 years ago
@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();
}
6 years ago
}