|
@@ -125,11 +125,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
try {
|
|
|
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
- List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部合同");
|
|
|
+ /*List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部合同");
|
|
|
if(functionContractList.size() <= 0){
|
|
|
httpRespMsg.setError(MessageUtils.message("access.viewError"));
|
|
|
return httpRespMsg;
|
|
|
- }
|
|
|
+ }*/
|
|
|
List<ContractType> types = contractTypeMapper.selectList(new QueryWrapper<ContractType>().eq("company_id", user.getCompanyId()));
|
|
|
if (types.size() == 0){
|
|
|
//String[] typeNames = {"买卖合同","赠与合同","租赁合同","借款合同","仓储合同","委托合同"};
|
|
@@ -163,7 +163,8 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
|
|
|
|
|
|
//首先获取所有合同的Id
|
|
|
- List<Integer> contractCollect = contracts.stream().map(c -> c.getId()).collect(Collectors.toList());
|
|
|
+ List<Integer> contractCollect = contracts.stream().map(Contract::getId).collect(Collectors.toList());
|
|
|
+ contractCollect.add(-1);
|
|
|
List<ContractPayment> contractPaymentList = contractPaymentMapper.selectList(new QueryWrapper<ContractPayment>().in("contract_id", contractCollect));
|
|
|
for (Contract contract : contracts) {
|
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
@@ -173,8 +174,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
BigDecimal decimal = contractPaymentList.stream().filter(c -> c.getContractId().equals(contract.getId()) && c.getIsBilled() == 1).map(ContractPayment::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
contract.setInvoicedAmount(decimal);
|
|
|
}
|
|
|
-
|
|
|
- contractCollect.add(-1);
|
|
|
//查询所有合同的所有附件
|
|
|
List<ContractDocument> fileList = contractDocumentMapper.selectList(new QueryWrapper<ContractDocument>().in("contract_id", contractCollect).eq("is_deleted",0));
|
|
|
//获取所有附件的上传者id
|
|
@@ -304,6 +303,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
// headList.add("创建时间");
|
|
|
// headList.add("备注");
|
|
|
headList.add(MessageUtils.message("entry.contractNo"));
|
|
|
+ headList.add("部门");
|
|
|
headList.add(MessageUtils.message("contract.name"));
|
|
|
headList.add(MessageUtils.message("Contract.startDate"));
|
|
|
headList.add(MessageUtils.message("Contract.endDate"));
|
|
@@ -318,6 +318,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
for (ContractPageVO contract : data) {
|
|
|
ArrayList<String> item = new ArrayList<>();
|
|
|
item.add(contract.getNumber()==null?"":contract.getNumber());
|
|
|
+ item.add(StringUtils.isEmpty(contract.getDepartmentName())?"":contract.getDepartmentName());
|
|
|
item.add(null == contract.getName()?"":contract.getName());
|
|
|
item.add(contract.getStartDate()==null?"":contract.getStartDate()+"");
|
|
|
item.add(contract.getEndDate()==null?"":contract.getEndDate()+"");
|
|
@@ -366,6 +367,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public HttpRespMsg addContract(HttpServletRequest request, Contract contract, ContractCustom custom, String paymentListStr) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
@@ -426,7 +428,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
for (ContractPayment contractPayment:contractPaymentList) {
|
|
|
contractPayment.setContractId(contract.getId());
|
|
|
contractPaymentMapper.insert(contractPayment);
|
|
|
- if (contractPayment.getIsPayed()) {
|
|
|
+ if (contractPayment.getIsPayed()!=null&&contractPayment.getIsPayed()) {
|
|
|
bg = bg.add(contractPayment.getAmount());
|
|
|
}
|
|
|
}
|
|
@@ -463,11 +465,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
public HttpRespMsg editContract(HttpServletRequest request, Contract contract, ContractCustom custom, String paymentListStr) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部合同");
|
|
|
+ /*List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部合同");
|
|
|
if(functionContractList.size() <= 0){
|
|
|
httpRespMsg.setError(MessageUtils.message("access.operationError"));
|
|
|
return httpRespMsg;
|
|
|
- }
|
|
|
+ }*/
|
|
|
try {
|
|
|
if (contract.getId() == null) {
|
|
|
httpRespMsg.setError(MessageUtils.message("name.idNullError"));
|
|
@@ -1574,6 +1576,8 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
try {
|
|
|
String token = request.getHeader("token");
|
|
|
User user = userMapper.selectById(token);
|
|
|
+ boolean isAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部合同");
|
|
|
+ boolean isNotAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看负责部门合同数据");
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
List<SysRichFunction> functionContractList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部合同");
|
|
|
// CompanyDingding dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
|
|
@@ -1583,10 +1587,6 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
// companyUserMap = companyUserList.stream().collect(Collectors.toMap(User::getId, t -> t));
|
|
|
// }
|
|
|
|
|
|
- if(functionContractList.size() <= 0){
|
|
|
- httpRespMsg.setError(MessageUtils.message("access.viewError"));
|
|
|
- return httpRespMsg;
|
|
|
- }
|
|
|
List<ContractType> types = contractTypeMapper.selectList(new QueryWrapper<ContractType>().eq("company_id", user.getCompanyId()));
|
|
|
if (types.size() == 0){
|
|
|
//String[] typeNames = {"买卖合同","赠与合同","租赁合同","借款合同","仓储合同","委托合同"};
|
|
@@ -1602,14 +1602,18 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
if (pageIndex!=null){
|
|
|
pageStart = (pageIndex -1) * pageSize;
|
|
|
}
|
|
|
-// if (StringUtils.isNotBlank(number)){
|
|
|
-// number = "%" + number + "%";
|
|
|
-// }
|
|
|
-// if (StringUtils.isNotBlank(name)){
|
|
|
-// name = "%" + name + "%";
|
|
|
-// }
|
|
|
- List<Contract> contracts = contractMapper.selectContractByPin(user.getCompanyId(), pageStart, pageSize, number, name , typeName , status, startDate,endDate, paymentStartDate, paymentEndDate, secTypeId,customerOrg,finishStatus);
|
|
|
- Long totalCnt = contractMapper.selectContractCnt(user.getCompanyId(), number, name, typeName, status, startDate, endDate, paymentStartDate, paymentEndDate, secTypeId,customerOrg,finishStatus);
|
|
|
+ int type=0;
|
|
|
+ Integer dept=user.getDepartmentId();
|
|
|
+ String userId=user.getId();
|
|
|
+ if (isAll){
|
|
|
+ type=1;//查看全部
|
|
|
+ }else if (isNotAll) {
|
|
|
+ type=2;//查看对应部门
|
|
|
+ }else {
|
|
|
+ type=3;//查看个人
|
|
|
+ }
|
|
|
+ List<Contract> contracts = contractMapper.selectContractByPinWithType(user.getCompanyId(), pageStart, pageSize, number, name , typeName , status, startDate,endDate, paymentStartDate, paymentEndDate, secTypeId,customerOrg,finishStatus,type,dept,userId);
|
|
|
+ Long totalCnt = contractMapper.selectContractContByPinWithType(user.getCompanyId(), number, name, typeName, status, startDate, endDate, paymentStartDate, paymentEndDate, secTypeId,customerOrg,finishStatus,type,dept,userId);
|
|
|
for (Contract contract : contracts) {
|
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
contract.setCreatorName(contract.getCreatorWxCorpId());
|
|
@@ -1749,6 +1753,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
public HttpRespMsg getContractDetail(HttpServletRequest request, Integer id) {
|
|
|
HttpRespMsg respMsg = new HttpRespMsg();
|
|
|
Contract contract = contractMapper.selectById(id);
|
|
|
+ if(contract.getDepartmentId()!=null){
|
|
|
+ contract.setDepartmentName(departmentService.getById(contract.getDepartmentId()).getDepartmentName());
|
|
|
+ }
|
|
|
if (contract.getTypeId()!=null){
|
|
|
SysDict dict = sysDictService.getById(contract.getTypeId());
|
|
|
if (dict!=null){
|
|
@@ -1764,6 +1771,10 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
contract.setNextPaymentAmount(contractPayment.getAmount());
|
|
|
}
|
|
|
}
|
|
|
+ List<ContractPayment> contractPaymentList = contractPaymentMapper.selectList(new QueryWrapper<ContractPayment>().eq("is_billed", 1).eq("contract_id",contract.getId()));
|
|
|
+ //已开票金额
|
|
|
+ BigDecimal decimal = contractPaymentList.stream().map(ContractPayment::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ contract.setInvoicedAmount(decimal);
|
|
|
List<ContractCustom> selectedList = contractCustomMapper.selectList(new QueryWrapper<ContractCustom>().eq("contract_id", contract.getId()));
|
|
|
if (selectedList != null && !selectedList.isEmpty()) {
|
|
|
contract.setCustomData(selectedList.get(0));
|
|
@@ -2046,7 +2057,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
|
|
|
paymentArrayList.add(payment);
|
|
|
BigDecimal paymented = contract.getPayment() == null ? BigDecimal.ZERO : contract.getPayment();
|
|
|
- contract.setPayment(paymented.add(BigDecimal.valueOf(vo.getReturnMoney())));
|
|
|
+ if(vo.getIsreturn().equals("是")) {
|
|
|
+ contract.setPayment(paymented.add(BigDecimal.valueOf(vo.getReturnMoney())));
|
|
|
+ }
|
|
|
}
|
|
|
contractPaymentService.saveBatch(paymentArrayList);
|
|
|
contractMapper.update(null,new UpdateWrapper<Contract>().set("payment",contract.getPayment()).eq("id",contract.getId()));
|
|
@@ -2124,7 +2137,9 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract> i
|
|
|
contractPaymentService.save(payment);
|
|
|
|
|
|
BigDecimal paymented = contract.getPayment() == null ? BigDecimal.ZERO : contract.getPayment();
|
|
|
- contract.setPayment(paymented.add(BigDecimal.valueOf(contractVo.getReturnMoney())));
|
|
|
+ if(contractVo.getIsreturn().equals("是")) {
|
|
|
+ contract.setPayment(paymented.add(BigDecimal.valueOf(contractVo.getReturnMoney())));
|
|
|
+ }
|
|
|
contractMapper.update(null,new UpdateWrapper<Contract>().set("payment",contract.getPayment()).eq("id",contract.getId()));
|
|
|
}
|
|
|
}
|