Commit d438fb0f by liyanlin

增加修改费用单接口

parent 291282f2
......@@ -31,6 +31,10 @@ public interface CostApi {
@PostMapping("/pushCost")
CostResult<Void> pushCost(@RequestBody CostInputDto input) throws Exception;
@ApiOperation("更新收付款单")
@PostMapping("/update/{costNo}")
CostResult<Void> updateCode(@RequestBody CostInputDto input, @PathVariable("costNo") String costNo) throws Exception;
@ApiOperation("提交费用单")
@PostMapping("submitAudit")
CostResult<Void> submitAudit(@RequestParam String costNo);
......
......@@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.websocket.server.PathParam;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
......@@ -80,6 +81,15 @@ public class CostApiController implements CostApi {
}
@LoginIgnore
@ApiOperation("更新收付款单")
@Override
@PostMapping("/update/{costNo}")
public CostResult<Void> updateCode(@RequestBody CostInputDto input, @PathVariable("costNo") String costNo) throws Exception {
String msg = costApiService.updateCost(input,costNo);
return CostResult.successMsg(msg);
}
@LoginIgnore
@Override
@ApiOperation("提交费用单")
@PostMapping("submitAudit")
......
......@@ -26,6 +26,14 @@ public interface CostApiService {
String generateCost(CostInputDto input) throws Exception;
/**
* 更新费用单
* @param input
* @return
* @throws Exception
*/
String updateCost(CostInputDto input,String costNo) throws Exception;
/**
* <p>
* 根据费用单号列表
* 查询原来传输到数据中心时为待支付状态 变成 已支付状态后的费用单
......
package com.blt.other.module.cost.service.impl;
import com.bailuntec.common.exception.BizException;
import com.bailuntec.cost.api.dto.*;
import com.bailuntec.cost.api.request.ManageCostListReq;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -215,6 +216,48 @@ public class CostApiServiceImpl implements CostApiService {
}
@Override
public String updateCost(CostInputDto input, String costNo) throws Exception{
CostDomain costDomain = costService.getCostByCostNo(costNo);
if(costDomain == null){
throw new Exception("不存在费用单"+costNo);
}
if(!costDomain.getCreateUserid().equals(input.getCreateUserid())){
throw new Exception("无权更改该费用单,该费用单不是您所创建");
}
if(!input.getCostForm().equals(costDomain.getCostForm())){
throw new Exception("不能更改费用单类型");
}
boolean sameTypeId = input.getTypeId().equals(costDomain.getTypeId());
BeanUtils.copyProperties(input,costDomain);
//costType , not set AccountingSubjectName
if(!sameTypeId) {
CostTypeDomain costTypeDomain = costTypeDao.selectById(input.getTypeId());
if (costTypeDomain == null) {
throw new Exception("费用系统中没有该费用类型");
}
costDomain.setTypeNo(costTypeDomain.getTypeNo());
costDomain.setTypeName(costTypeDomain.getTypeName());
costDomain.setAccountingSubjectId(costTypeDomain.getAccountingSubjectId());
costDomain.setAccountingSubjectNo(costTypeDomain.getAccountingSubjectNo());
costDomain.setNsAccountingSubjectId(costTypeDomain.getNsAccountingSubjectId());
//costDomain.setAccountingSubjectName()
}
//汇率
BigDecimal toRmbRate;
if ("CNY".equals(input.getDic())) {
toRmbRate = BigDecimal.ONE;
costDomain.setAmountRmb(input.getAmount());
} else {
toRmbRate = CurUtils.getCur(input.getDic(), "CNY");
costDomain.setAmountRmb(input.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP));
}
costDomain.setToRmbRate(toRmbRate);
costDao.update(costDomain, new LambdaQueryWrapper<CostDomain>()
.eq(CostDomain::getCostNo, costDomain.getCostNo()));
return "更新成功";
}
@Override
public List<CostDomain> getNoPayCost(List<String> costNoList) {
return costDao.selectList(new LambdaQueryWrapper<CostDomain>()
.eq(CostDomain::getCostForm, CostDomain.COST_FROM_1)
......
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