Commit 9c21f52c by kangxiaoshan

合同晚录

parent 5b8e2f16
......@@ -2,10 +2,13 @@ package common.service;
import common.model.Contract;
import common.model.User;
import org.joda.time.DateTime;
import java.util.List;
public interface ShareIncomeService {
List<Contract> shareIncomeList(User loginAccount, String startDate, String endDate, String platform, String bodyCode, String serchName);
boolean checkLateContract(DateTime dateTime, DateTime creatTime);
}
......@@ -4,10 +4,7 @@ import adi.model.ADIUser;
import adi.service.ADIAccountService;
import common.model.*;
import common.repository.*;
import common.service.AuthService;
import common.service.ContractService;
import common.service.TransactionUtils;
import common.service.UserService;
import common.service.*;
import dic.ContractStatusEnum;
import dic.ContractTypeEnum;
import dic.RoleEnum;
......@@ -201,6 +198,9 @@ public class ContractServiceImpl implements ContractService {
@Autowired
TransactionUtils transactionUtils;
@Autowired
ShareIncomeService shareIncomeService;
@Override
public Map<String, Object> checkAccount(String email, String platfrom) {
......@@ -494,6 +494,17 @@ public class ContractServiceImpl implements ContractService {
resource.setStatus(ContractStatusEnum.NFORMAL.getKey());
}
DateTime[] datePoints = new DateTime[]{
new DateTime(resource.getStartDate()),
new DateTime(new DateTime().toString("yyyy-MM-dd"))
};
if (shareIncomeService.checkLateContract(new DateTime(resource.getStartDate()),
new DateTime(new DateTime().toString("yyyy-MM-dd")))) {
resource.setStatus(ContractStatusEnum.LATE.getKey());
}
if (resource.getRelationContract() == null) {
resource.setRelationContract(-1L);
}
......@@ -808,9 +819,7 @@ public class ContractServiceImpl implements ContractService {
}
}
if (resource.getStatus() == null) {
resource.setStatus(ContractStatusEnum.NFORMAL.getKey());
}
resource.setStatus(contract.getStatus());
this.calculateShareIncome(resource);
......
......@@ -82,8 +82,8 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
}
}
//contracts = new ArrayList<>();
//contracts.add(contractRepository.findOne(1361L));
contracts = new ArrayList<>();
contracts.add(contractRepository.findOne(1355L));
List<ContractBody> bodies = contractBodyRepository.findAll();
Map<String, String> bodiesNameMap = bodies.stream().collect(
......@@ -150,7 +150,7 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
private void afterContract(Contract contract, int contractAllDay, Long dayShareIncome,
DateTime[] contractPart, DateTime[] usePart, DateTime[] selected, DateTime[] creatPoints) {
int aferDays = contractPart[0].monthOfYear().get() == 12 ? 29 : 9;
int betweenMonth = creatPoints[0].getMonthOfYear() - contractPart[0].getMonthOfYear();
//时间范围内用于计算分摊金额的天数
int daysIncom = getDayRange(usePart[0], usePart[1]) + 1;
......@@ -158,7 +158,9 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
contract.setIntervaIncomeShare(dayShareIncome * daysIncom);
Long adjustmentFund = 0L;//调整金
if (!contractPart[0].dayOfMonth().withMaximumValue().plusDays(aferDays).isBefore(creatPoints[0]) || betweenMonth < 1) {
int aferDays = contractPart[0].monthOfYear().get() == 12 ? 29 : 9;
if (!ContractStatusEnum.LATE.getKey().equals(contract.getStatus()) ||
!checkLateContract(contractPart[0], creatPoints[0]) || betweenMonth < 1) {
//非合同晚录
contract.setAdjustmentFund(0L);
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
......@@ -167,16 +169,20 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
//录入月1号之前 调整金为 0
contract.setIntervaIncomeShare(0L);
contract.setIncomeShareAll(contract.getIntervaIncomeShare());
contract.setStatus(ContractStatusEnum.LATE.getKey());
} else {
contract.setStatus(ContractStatusEnum.LATE.getKey());
//合同晚录
//所选时间范围内的分摊收入(录入月1号开始计算)
DateTime useStart = creatPoints[1].compareTo(selected[0]) >= 0 ? creatPoints[1] : selected[0];
daysIncom = getDayRange(useStart, usePart[1]) + 1;
contract.setIntervaIncomeShare(dayShareIncome * daysIncom);//时间范围内分摊金
adjustmentFund = new BigDecimal(((getDayRange(contractPart[0], creatPoints[1].plusDays(-1)) + 1)
/*adjustmentFund = new BigDecimal(((getDayRange(contractPart[0], creatPoints[1].plusDays(-1)) + 1)
* contract.getIncomeExcludingTax() * 1.0 / contractAllDay))
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue();*/
adjustmentFund = (getDayRange(contractPart[0], creatPoints[1].plusDays(-1)) + 1) * dayShareIncome;
if (checkTwoTime(selected[0], creatPoints[1]) && checkTwoTime(creatPoints[1], selected[1])) {
//所选时间范围包含 录入月 1 号 显示统计的调整金
......@@ -224,9 +230,11 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
if (checkTwoTime(suspendDate, cancelDate)) {
adjustmentFund = 0L;
} else {
adjustmentFund = new BigDecimal((getDayRange(cancelDate, suspendDate) + 1)
/* adjustmentFund = new BigDecimal((getDayRange(cancelDate, suspendDate) + 1)
* contract.getIncomeExcludingTax() * 1.0 / contractAllDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue() * -1;
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue() * -1;*/
adjustmentFund = (getDayRange(cancelDate, suspendDate) + 1) * dayShareIncome * (-1);
}
DateTime usedEnd = usePart[1].compareTo(cancelDate) <= 0 ? usePart[1] : cancelDate;
......@@ -265,11 +273,11 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
// 合同终止日 或 作废日
DateTime cancelDate = new DateTime(contractChange.getDs());
Long adjustmentFund = new BigDecimal((Days.daysBetween(contractPart[0], cancelDate).getDays() + 1)
* contract.getIncomeExcludingTax() * 1.0 / contractAllDay)
.setScale(0, BigDecimal.ROUND_HALF_UP).longValue() * -1;
Long adjustmentFund = (getDayRange(contractPart[0], cancelDate) + 1) * dayShareIncome * (-1);
DateTime usedEnd = usePart[1].compareTo(cancelDate) <= 0 ? usePart[1] : cancelDate;
int daysIncom = Days.daysBetween(usePart[0], usedEnd).getDays() + 1;
daysIncom = daysIncom < 0 ? 0 : daysIncom;
//区间分摊总收入
......@@ -290,6 +298,14 @@ public class ShareIncomeServiceImpl implements ShareIncomeService {
return contract;
}
@Override
public boolean checkLateContract(DateTime dateTime, DateTime creatTime) {
int aferDays = dateTime.monthOfYear().get() == 12 ? 29 : 9;
return dateTime.dayOfMonth().withMaximumValue().plusDays(aferDays).isBefore(creatTime);
}
private int getDayRange(DateTime range1, DateTime range2) {
return Days.daysBetween(range1, range2).getDays();
}
......
......@@ -21,7 +21,8 @@ public enum ContractStatusEnum {
MONEY_BACK_FIRST("backfirst", "先回款待录入"),
CANCEL("cancel", "作废"),
SUSPEND("suspend", "中止"),
NFORMAL("normal","常规"),
NFORMAL("normal", "常规"),
LATE("late", "晚录"),
DELETE("del", "已删除"),
FIRST_SIGNING("0", "首次签约"),
......
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