Commit 10bea416 by huluobin

update

parent 8165b5d1
package com.blt.other.module.cost.controller.costplan; package com.blt.other.module.cost.controller.costplan;
import com.blt.other.common.util.CurUtils;
import com.blt.other.module.cost.dto.CostPlanNewApiDto; import com.blt.other.module.cost.dto.CostPlanNewApiDto;
import com.blt.other.module.cost.service.CostPlanService; import com.blt.other.module.cost.service.CostPlanService;
import com.blt.other.module.cost.service.impl.costplan.CostPlanServiceFactory; import com.blt.other.module.cost.service.impl.costplan.CostPlanServiceFactory;
...@@ -7,8 +8,12 @@ import com.blt.other.module.database.model.CostPlanDomain; ...@@ -7,8 +8,12 @@ import com.blt.other.module.database.model.CostPlanDomain;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -22,6 +27,8 @@ import java.util.Map; ...@@ -22,6 +27,8 @@ import java.util.Map;
"/cost/plan/new/receipt"}) "/cost/plan/new/receipt"})
public class CostPlanNewController { public class CostPlanNewController {
@Value("${url.api.getExchangeRateApi}")
private String getExchangeRateApi;
@ApiOperation("获取新增费用计划编号") @ApiOperation("获取新增费用计划编号")
@GetMapping("/getNo") @GetMapping("/getNo")
...@@ -95,5 +102,49 @@ public class CostPlanNewController { ...@@ -95,5 +102,49 @@ public class CostPlanNewController {
return resp; return resp;
} }
@PostMapping("/changeDic")
public Map<String, Object> changeDic(HttpServletResponse response, HttpServletRequest request) {
Map<String, Object> result = new HashMap<>();
String fromDic = request.getParameter("fromDic");
String payCounteractStr = request.getParameter("payCounteract");
payCounteractStr = payCounteractStr.replace(" ", "");
BigDecimal payCounteract = null;
if (!payCounteractStr.isEmpty()) {
payCounteract = new BigDecimal(payCounteractStr);
} else {
// result.put("success",false);
// result.put("msg","请输入合法的冲销金额");
// return result;
payCounteract = new BigDecimal(0);
}
String payLendBalanceStr = request.getParameter("payLendBalance");
payLendBalanceStr = payLendBalanceStr.replace(" ", "");
BigDecimal payLendBalance = null;
if (!payLendBalanceStr.isEmpty()) {
payLendBalance = new BigDecimal(payLendBalanceStr);
} else {
// result.put("success",false);
// result.put("msg","请输入合法的余额");
// return result;
payLendBalance = new BigDecimal(0);
}
String toDic = request.getParameter("toDic");
BigDecimal cur = CurUtils.getCur(fromDic, toDic, getExchangeRateApi);
BigDecimal counteract = payCounteract.multiply(cur);
BigDecimal lendBalance = payLendBalance.multiply(cur);
BigDecimal planAmount = counteract.add(lendBalance);
BigDecimal payPlanAmount = payCounteract.add(payLendBalance);
result.put("success", true);
result.put("counteract", counteract.setScale(2, BigDecimal.ROUND_HALF_UP));
result.put("lendBalance", lendBalance);
result.put("planAmount", planAmount.setScale(2, BigDecimal.ROUND_HALF_UP));
result.put("payPlanAmount", payPlanAmount);
result.put("cur", cur);
return result;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment