|
@@ -1,12 +1,17 @@
|
|
package com.jeeplus.business.borrow.service;
|
|
package com.jeeplus.business.borrow.service;
|
|
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.jeeplus.business.borrow.domain.BorrowMoney;
|
|
import com.jeeplus.business.borrow.domain.BorrowMoney;
|
|
import com.jeeplus.business.borrow.domain.Refund;
|
|
import com.jeeplus.business.borrow.domain.Refund;
|
|
|
|
+import com.jeeplus.business.borrow.domain.RefundHis;
|
|
import com.jeeplus.business.borrow.mapper.BorrowMapper;
|
|
import com.jeeplus.business.borrow.mapper.BorrowMapper;
|
|
|
|
+import com.jeeplus.business.borrow.mapper.RefundHisMapper;
|
|
import com.jeeplus.business.borrow.mapper.RefundMapper;
|
|
import com.jeeplus.business.borrow.mapper.RefundMapper;
|
|
import com.jeeplus.business.borrow.service.dto.BorrowDTO;
|
|
import com.jeeplus.business.borrow.service.dto.BorrowDTO;
|
|
import com.jeeplus.business.borrow.service.dto.RefundDTO;
|
|
import com.jeeplus.business.borrow.service.dto.RefundDTO;
|
|
@@ -37,6 +42,9 @@ public class BorrowService {
|
|
@Resource
|
|
@Resource
|
|
private JyReimbursementInfoBorrowMapper jyReimbursementInfoBorrowMapper;
|
|
private JyReimbursementInfoBorrowMapper jyReimbursementInfoBorrowMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private RefundHisMapper refundHisMapper;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 列表管理
|
|
* 列表管理
|
|
* @param borrowDTO
|
|
* @param borrowDTO
|
|
@@ -78,17 +86,50 @@ public class BorrowService {
|
|
IPage<BorrowDTO> pageList=borrowMapper.findPageList(queryWrapper,page);
|
|
IPage<BorrowDTO> pageList=borrowMapper.findPageList(queryWrapper,page);
|
|
//获取借款报销表中的信息
|
|
//获取借款报销表中的信息
|
|
List<JyReimbursementDetailInfoBorrow> borrowList=jyReimbursementInfoBorrowMapper.getList();
|
|
List<JyReimbursementDetailInfoBorrow> borrowList=jyReimbursementInfoBorrowMapper.getList();
|
|
- borrowList.stream().forEach(item->{
|
|
|
|
- pageList.getRecords().stream().forEach(data->{
|
|
|
|
- if (item.getProjectId().equals(data.getId())){
|
|
|
|
- Float moneyLower=Float.parseFloat(data.getMoneyLower());
|
|
|
|
- Float number=Float.parseFloat(item.getNumber());
|
|
|
|
- Float money=moneyLower-number;
|
|
|
|
- data.setFinalMoney(money.toString());
|
|
|
|
- data.setRefundLower(item.getNumber());
|
|
|
|
|
|
+
|
|
|
|
+ for (BorrowDTO item : pageList.getRecords()){
|
|
|
|
+ if (CollectionUtils.isNotEmpty(borrowList)){
|
|
|
|
+ for (JyReimbursementDetailInfoBorrow infoBorrow : borrowList) {
|
|
|
|
+ if (item.getId().equals(infoBorrow.getProjectId())){
|
|
|
|
+ if (StringUtils.isNotBlank(item.getFinalMoney())){
|
|
|
|
+ Float moneyLower=Float.parseFloat(item.getFinalMoney());
|
|
|
|
+ Float number=Float.parseFloat(infoBorrow.getNumber());
|
|
|
|
+ Float money=moneyLower-number;
|
|
|
|
+ item.setFinalMoney(money.toString());
|
|
|
|
+ Float refund=Float.parseFloat(item.getRefundLower());
|
|
|
|
+ Float lower=refund+number;
|
|
|
|
+ item.setRefundLower(lower.toString());
|
|
|
|
+ }else {
|
|
|
|
+ Float moneyLower=Float.parseFloat(item.getMoneyLower());
|
|
|
|
+ Float number=Float.parseFloat(infoBorrow.getNumber());
|
|
|
|
+ Float money=moneyLower-number;
|
|
|
|
+ item.setFinalMoney(money.toString());
|
|
|
|
+ item.setRefundLower(infoBorrow.getNumber());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// if (CollectionUtils.isNotEmpty(borrowList)){
|
|
|
|
+// for (JyReimbursementDetailInfoBorrow item : borrowList){
|
|
|
|
+// pageList.getRecords().stream().forEach(data->{
|
|
|
|
+// if (StringUtils.isNotBlank(item.getProjectId()) && StringUtils.isNotBlank(data.getId())){
|
|
|
|
+// if (item.getProjectId().equals(data.getId())){
|
|
|
|
+// Float moneyLower=Float.parseFloat(data.getFinalMoney());
|
|
|
|
+// Float number=Float.parseFloat(item.getNumber());
|
|
|
|
+// Float money=moneyLower-number;
|
|
|
|
+// data.setFinalMoney(money.toString());
|
|
|
|
+// data.setRefundLower(item.getNumber());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+// continue;
|
|
|
|
+// };
|
|
|
|
+// }
|
|
|
|
+
|
|
|
|
+
|
|
return pageList;
|
|
return pageList;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -209,6 +250,17 @@ public class BorrowService {
|
|
*/
|
|
*/
|
|
public void updateRefundById(RefundDTO refundDTO) {
|
|
public void updateRefundById(RefundDTO refundDTO) {
|
|
borrowMapper.updateRefundById(refundDTO.getId(),refundDTO.getStatus());
|
|
borrowMapper.updateRefundById(refundDTO.getId(),refundDTO.getStatus());
|
|
|
|
+ //如果审核同意,则往历史表中添加一条数据
|
|
|
|
+ if (refundDTO.getStatus().equals("5")){
|
|
|
|
+ //根据id找到当前还款信息
|
|
|
|
+ Refund refund = refundMapper.selectById(refundDTO.getId());
|
|
|
|
+ RefundHis refundHis = new RefundHis();
|
|
|
|
+ refundHis.setRefundMoney(refund.getRefundLower());
|
|
|
|
+ refundHis.setCreateById(refund.getCreateById());
|
|
|
|
+ refundHis.setRefundId(refund.getId());
|
|
|
|
+ refundHis.setCreateTime(new Date());
|
|
|
|
+ refundHisMapper.insert(refundHis);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -242,8 +294,53 @@ public class BorrowService {
|
|
UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getByToken(TokenProvider.getCurrentToken());
|
|
UserDTO userDTO = SpringUtil.getBean ( IUserApi.class ).getByToken(TokenProvider.getCurrentToken());
|
|
QueryWrapper<BorrowMoney> queryWrapper = QueryWrapperGenerator.buildQueryCondition(borrowMoney, BorrowMoney.class);
|
|
QueryWrapper<BorrowMoney> queryWrapper = QueryWrapperGenerator.buildQueryCondition(borrowMoney, BorrowMoney.class);
|
|
queryWrapper.eq("a.create_by_id",userDTO.getId());
|
|
queryWrapper.eq("a.create_by_id",userDTO.getId());
|
|
|
|
+ queryWrapper.eq("a.status","5");
|
|
queryWrapper.orderByDesc("a.update_time");
|
|
queryWrapper.orderByDesc("a.update_time");
|
|
IPage<BorrowMoney> moneyList = borrowMapper.listByUserId(queryWrapper,page);
|
|
IPage<BorrowMoney> moneyList = borrowMapper.listByUserId(queryWrapper,page);
|
|
return moneyList;
|
|
return moneyList;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据还款id查询还款历史数据
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<Refund> findByBorId(String id) {
|
|
|
|
+ List<Refund> refunds=borrowMapper.findByBorId(id);
|
|
|
|
+ return refunds;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 创建还款数据
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public String createReturnData(String id) {
|
|
|
|
+ Refund refund = refundMapper.selectOne(new LambdaQueryWrapper<Refund>().eq(Refund::getBorrowId, id));
|
|
|
|
+ if (ObjectUtils.isNotEmpty(refund)){
|
|
|
|
+ return refund.getId();
|
|
|
|
+ }else {
|
|
|
|
+ Refund refund1 = new Refund();
|
|
|
|
+ refund1.setBorrowId(id);
|
|
|
|
+ refund1.setStatus("0");
|
|
|
|
+ refundMapper.insert(refund1);
|
|
|
|
+ return refund1.getId();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据还款id查询还款数据
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public BorrowDTO findByRefundId(String id) {
|
|
|
|
+ Refund refund = refundMapper.selectOne(new LambdaQueryWrapper<Refund>().eq(Refund::getId, id));
|
|
|
|
+ if (ObjectUtils.isNotEmpty(refund) && StringUtils.isNotBlank(refund.getBorrowId())){
|
|
|
|
+ BorrowDTO byId = this.findById(refund.getBorrowId());
|
|
|
|
+ return byId;
|
|
|
|
+ }else {
|
|
|
|
+ return new BorrowDTO();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|