commit
1e454d9567
@ -0,0 +1,33 @@ |
|||||||
|
package com.jianshui.web.controller.platform; |
||||||
|
|
||||||
|
import com.jianshui.common.core.domain.AjaxResult; |
||||||
|
import com.jianshui.platform.dto.TaxCalculateDTO; |
||||||
|
import com.jianshui.platform.service.TaxCalculateService; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
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.RequestBody; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RestController; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author: kane |
||||||
|
* @Description: 税额税额计算控制类 |
||||||
|
* @CreateTime: 2023-06-07 17:41 |
||||||
|
* @Version: 1.0 |
||||||
|
**/ |
||||||
|
@Api(tags = "税额税额计算",value = "税额税额计算") |
||||||
|
@RestController |
||||||
|
@RequestMapping("/platForm/taxCalculate") |
||||||
|
public class TaxCalculateController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private TaxCalculateService taxCalculateService; |
||||||
|
|
||||||
|
@ApiOperation("税额税额计算") |
||||||
|
@PostMapping("/calculate") |
||||||
|
public AjaxResult taxCalculate(@RequestBody TaxCalculateDTO taxCalculateDTO){ |
||||||
|
return taxCalculateService.taxCalculate(taxCalculateDTO); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
package com.jianshui.platform.dto; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty; |
||||||
|
import javax.validation.constraints.NotNull; |
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author: kane |
||||||
|
* @Description: 金额税额计算类 |
||||||
|
* @CreateTime: 2023-06-07 17:36 |
||||||
|
* @Version: 1.0 |
||||||
|
**/ |
||||||
|
@ApiModel("金额税额计算") |
||||||
|
@Data |
||||||
|
public class TaxCalculateDTO { |
||||||
|
@NotNull |
||||||
|
@ApiModelProperty("发票id") |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
@NotNull |
||||||
|
@ApiModelProperty("数量") |
||||||
|
private BigDecimal number; |
||||||
|
@NotNull |
||||||
|
@ApiModelProperty("单价") |
||||||
|
private BigDecimal unitPrice; |
||||||
|
@NotNull |
||||||
|
@ApiModelProperty("税率") |
||||||
|
private BigDecimal taxRate; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
package com.jianshui.platform.service; |
||||||
|
|
||||||
|
import com.jianshui.common.core.domain.AjaxResult; |
||||||
|
import com.jianshui.platform.dto.TaxCalculateDTO; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author: kane |
||||||
|
* @Description: 金额税额计算业务类 |
||||||
|
* @CreateTime: 2023-06-07 17:42 |
||||||
|
* @Version: 1.0 |
||||||
|
**/ |
||||||
|
public interface TaxCalculateService { |
||||||
|
/** |
||||||
|
* 功能描述: 金额税额计算 |
||||||
|
* @param taxCalculateDTO |
||||||
|
* @return : com.jianshui.common.core.domain.AjaxResult |
||||||
|
*/ |
||||||
|
AjaxResult taxCalculate(TaxCalculateDTO taxCalculateDTO); |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
package com.jianshui.platform.service.impl; |
||||||
|
|
||||||
|
import com.jianshui.common.core.domain.AjaxResult; |
||||||
|
import com.jianshui.common.utils.ValidateUtils; |
||||||
|
import com.jianshui.platform.dto.TaxCalculateDTO; |
||||||
|
import com.jianshui.platform.service.TaxCalculateService; |
||||||
|
import com.jianshui.platform.vo.TaxCalculateVO; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.text.DecimalFormat; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author: kane |
||||||
|
* @Description: 金额税额计算业务层 |
||||||
|
* @CreateTime: 2023-06-07 17:43 |
||||||
|
* @Version: 1.0 |
||||||
|
**/ |
||||||
|
@Service |
||||||
|
public class TaxCalculateServiceImpl implements TaxCalculateService { |
||||||
|
/** |
||||||
|
* 功能描述: 金额税额计算 |
||||||
|
* @param taxCalculateDTO |
||||||
|
* @return : com.jianshui.common.core.domain.AjaxResult |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public AjaxResult taxCalculate(TaxCalculateDTO taxCalculateDTO) { |
||||||
|
//校验
|
||||||
|
ValidateUtils.validate(taxCalculateDTO); |
||||||
|
//含税金额
|
||||||
|
BigDecimal money = taxCalculateDTO.getNumber().multiply(taxCalculateDTO.getUnitPrice()); |
||||||
|
BigDecimal moneyResult = money.setScale(2); |
||||||
|
//税率计算
|
||||||
|
BigDecimal taxRate = taxCalculateDTO.getTaxRate().divide(new BigDecimal("100")); |
||||||
|
BigDecimal taxRateResult = taxRate.add(new BigDecimal("1")); |
||||||
|
//税额
|
||||||
|
BigDecimal taxMoney = money.multiply(taxRate).divide(taxRateResult,BigDecimal.ROUND_HALF_UP); |
||||||
|
BigDecimal taxMoneyResult = taxMoney.setScale(2,BigDecimal.ROUND_HALF_UP); |
||||||
|
//封装实体类
|
||||||
|
TaxCalculateVO taxCalculateVO = new TaxCalculateVO(); |
||||||
|
taxCalculateVO.setId(taxCalculateDTO.getId()); |
||||||
|
taxCalculateVO.setMoney(moneyResult); |
||||||
|
taxCalculateVO.setTaxMoney(taxMoneyResult); |
||||||
|
return AjaxResult.success(taxCalculateVO); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
package com.jianshui.platform.vo; |
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel; |
||||||
|
import io.swagger.annotations.ApiModelProperty; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull; |
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author: kane |
||||||
|
* @Description: 税额金额返回类 |
||||||
|
* @CreateTime: 2023-06-07 17:46 |
||||||
|
* @Version: 1.0 |
||||||
|
**/ |
||||||
|
@ApiModel("税额金额") |
||||||
|
@Data |
||||||
|
public class TaxCalculateVO { |
||||||
|
@NotNull |
||||||
|
@ApiModelProperty("发票id") |
||||||
|
private Integer id; |
||||||
|
|
||||||
|
@NotNull |
||||||
|
@ApiModelProperty("金额") |
||||||
|
private BigDecimal money; |
||||||
|
|
||||||
|
@NotNull |
||||||
|
@ApiModelProperty("税额") |
||||||
|
private BigDecimal taxMoney; |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue