|
@@ -1,5 +1,6 @@
|
|
|
package com.idea.paymentManagement.service;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
@@ -16,8 +17,10 @@ import com.idea.paymentManagement.model.PayLog;
|
|
|
import com.idea.paymentManagement.model.PayLogExample;
|
|
|
import com.idea.util.DateUtils;
|
|
|
import com.rockstar.common.base.BaseService;
|
|
|
+import com.rockstar.frame.model.FrameUser;
|
|
|
import com.rockstar.frame.model.extend.DateTrans;
|
|
|
import com.rockstar.frame.model.extend.Tablepar;
|
|
|
+import com.rockstar.frame.service.FrameUserService;
|
|
|
import com.rockstar.shiro.util.ShiroUtils;
|
|
|
import com.rockstar.util.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -36,6 +39,8 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
|
|
|
private PayLogExtendMapper extendMapper;
|
|
|
@Autowired
|
|
|
private ContractManageMapper contractManageMapper;
|
|
|
+ @Autowired
|
|
|
+ private FrameUserService frameUserService;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -65,7 +70,7 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
|
|
|
|
|
|
@Override
|
|
|
public int updateByExampleSelective(PayLog PayLog, PayLogExample PayLogExample) {
|
|
|
- return modelMapper.updateByExampleSelective(PayLog,PayLogExample);
|
|
|
+ return modelMapper.updateByExampleSelective(PayLog, PayLogExample);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -99,45 +104,48 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
|
|
|
|
|
|
/**
|
|
|
* 新增
|
|
|
+ *
|
|
|
* @param model
|
|
|
* @return
|
|
|
*/
|
|
|
- public int add(PayLog model){
|
|
|
+ public int add(PayLog model) {
|
|
|
|
|
|
model.setCreatedBy(ShiroUtils.getUserId());
|
|
|
model.setCreatedAt(new Date());
|
|
|
+ model.setStatus(0);
|
|
|
int result = insertSelective(model);
|
|
|
// 更新合同 预收款 收款状态
|
|
|
ContractManage contractManage = contractManageMapper.selectByPrimaryKey(model.getContractId());
|
|
|
- if(model.getPayType() == 1){
|
|
|
- String receivedMoneyStr = extendMapper.getMoneyByContractId(model.getContractId(),model.getPayType());
|
|
|
+ if (model.getPayType() == 1) {
|
|
|
+ String receivedMoneyStr = extendMapper.getMoneyByContractId(model.getContractId(), model.getPayType());
|
|
|
BigDecimal totalPrice = contractManage.getTotalPrice();
|
|
|
BigDecimal receivedMoney = new BigDecimal(receivedMoneyStr);
|
|
|
- if(receivedMoney.doubleValue() < totalPrice.doubleValue()){
|
|
|
+ if (receivedMoney.doubleValue() < totalPrice.doubleValue()) {
|
|
|
// 部分收款
|
|
|
- contractManage.setContractStatus(1);
|
|
|
- }else {
|
|
|
+ contractManage.setCollectionStatus(1);
|
|
|
+ } else {
|
|
|
// 全部收款
|
|
|
- contractManage.setContractStatus(2);
|
|
|
+ contractManage.setCollectionStatus(2);
|
|
|
}
|
|
|
}
|
|
|
// 更新合同 资金 收款状态
|
|
|
- if(model.getPayType() == 2){
|
|
|
+ if (model.getPayType() == 2) {
|
|
|
// 已收款
|
|
|
contractManage.setFundCollectionStatus(2);
|
|
|
}
|
|
|
-
|
|
|
+ contractManageMapper.updateByPrimaryKeySelective(contractManage);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 收款信息
|
|
|
+ *
|
|
|
* @param model
|
|
|
* @param dt
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<PayLog> payListAll(PayLog model, DateTrans dt){
|
|
|
+ public List<PayLog> payListAll(PayLog model, DateTrans dt) {
|
|
|
return modelMapper.selectByExample(getCondition(model, dt));
|
|
|
}
|
|
|
|
|
@@ -145,7 +153,7 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
|
|
|
PayLogExample ex = new PayLogExample();
|
|
|
ex.setOrderByClause("created_at asc");
|
|
|
PayLogExample.Criteria criteria = ex.createCriteria();
|
|
|
- if(StringUtils.isNotEmpty(model.getContractId())){
|
|
|
+ if (StringUtils.isNotEmpty(model.getContractId())) {
|
|
|
criteria.andContractIdEqualTo(model.getContractId());
|
|
|
}
|
|
|
return ex;
|
|
@@ -153,10 +161,11 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
|
|
|
|
|
|
/**
|
|
|
* 查询合同部分的信息
|
|
|
+ *
|
|
|
* @param contractId
|
|
|
* @return
|
|
|
*/
|
|
|
- public PayLogDto getContractPart(String contractId){
|
|
|
+ public PayLogDto getContractPart(String contractId) {
|
|
|
|
|
|
ContractManage contractManage = contractManageMapper.selectByPrimaryKey(contractId);
|
|
|
PayLogDto payLogDto = new PayLogDto();
|
|
@@ -164,10 +173,10 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
|
|
|
payLogDto.setBuyerName(contractManage.getBuyerName());
|
|
|
payLogDto.setHouseName(contractManage.getHouseName());
|
|
|
payLogDto.setPaymentMethod(contractManage.getPaymentMethod());
|
|
|
- payLogDto.setDeadLine(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,contractManage.getDeadline()));
|
|
|
+ payLogDto.setDeadLine(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, contractManage.getDeadline()));
|
|
|
payLogDto.setReceivableMoney(contractManage.getTotalPrice());
|
|
|
// 查询已收房款
|
|
|
- String receivedMoneyStr = extendMapper.getMoneyByContractId(contractId,1);
|
|
|
+ String receivedMoneyStr = extendMapper.getMoneyByContractId(contractId, 1);
|
|
|
BigDecimal receivedMoney = new BigDecimal(receivedMoneyStr);
|
|
|
// 欠款
|
|
|
BigDecimal arrears = contractManage.getTotalPrice().subtract(receivedMoney);
|
|
@@ -176,7 +185,7 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
|
|
|
return payLogDto;
|
|
|
}
|
|
|
|
|
|
- public PayLog getByContractId(String contractId,Integer payType) {
|
|
|
+ public PayLog getByContractId(String contractId, Integer payType) {
|
|
|
|
|
|
PayLogExample payLogExample = new PayLogExample();
|
|
|
payLogExample.createCriteria().andContractIdEqualTo(contractId).andPayTypeEqualTo(payType);
|
|
@@ -185,8 +194,18 @@ public class PayLogService implements BaseService<PayLog, PayLogExample> {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ public PayLogDto getById(String id) {
|
|
|
+ PayLog payLog = selectByPrimaryKey(id);
|
|
|
+ String username = "";
|
|
|
+ if (StringUtils.isNotEmpty(payLog.getCreatedBy())) {
|
|
|
+ FrameUser frameUser = frameUserService.selectByPrimaryKey(payLog.getCreatedBy());
|
|
|
+ username = frameUser == null ? "" : frameUser.getTruename();
|
|
|
+ }
|
|
|
+ PayLogDto result = new PayLogDto();
|
|
|
+ result.setCreatedName(username);
|
|
|
+ BeanUtil.copyProperties(payLog, result);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|