|
@@ -157,14 +157,26 @@ public class ElderlyTempOutServiceImpl implements ElderlyTempOutService {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- LocalDate outDate = outTime.toLocalDate();
|
|
|
|
|
- LocalDate monthEnd = billYm.atEndOfMonth();
|
|
|
|
|
- if (outDate.isAfter(monthEnd)) {
|
|
|
|
|
|
|
+ // 以当前遍历账单的账单月作为计算基准:离住当月从离住日起退至月末,离住之后的账单月整月退费
|
|
|
|
|
+ String currentBillingMonth = monthOrder.getBillingMonth();
|
|
|
|
|
+ if (currentBillingMonth == null) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- int refundDays = monthEnd.getDayOfMonth() - outDate.getDayOfMonth() + 1;
|
|
|
|
|
- int daysInMonth = billYm.lengthOfMonth();
|
|
|
|
|
|
|
+ YearMonth currentYm = YearMonth.parse(currentBillingMonth, DateTimeFormatter.ofPattern("yyyy-MM"));
|
|
|
|
|
+ if (currentYm.isBefore(billYm)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ LocalDate monthEnd = currentYm.atEndOfMonth();
|
|
|
|
|
+ LocalDate outDate;
|
|
|
|
|
+ int refundDays;
|
|
|
|
|
+ if (currentYm.equals(billYm)) {
|
|
|
|
|
+ outDate = outTime.toLocalDate();
|
|
|
|
|
+ refundDays = (int) (monthEnd.toEpochDay() - outDate.toEpochDay() + 1);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ outDate = currentYm.atDay(1);
|
|
|
|
|
+ refundDays = currentYm.lengthOfMonth();
|
|
|
|
|
+ }
|
|
|
|
|
+ int daysInMonth = currentYm.lengthOfMonth();
|
|
|
|
|
|
|
|
for (ExpenseOrderItemDO item : orderItems) {
|
|
for (ExpenseOrderItemDO item : orderItems) {
|
|
|
if (item.getType() == null) {
|
|
if (item.getType() == null) {
|
|
@@ -189,7 +201,7 @@ public class ElderlyTempOutServiceImpl implements ElderlyTempOutService {
|
|
|
// 账单已缴费、锁定、确认:生成日常费用记录(来源=离住)并写入已缴费账单明细
|
|
// 账单已缴费、锁定、确认:生成日常费用记录(来源=离住)并写入已缴费账单明细
|
|
|
if (Objects.equals(monthOrder.getPayStatus(), 1) || Boolean.TRUE.equals(monthOrder.getConfirmStatus()) || Boolean.TRUE.equals(monthOrder.getIsLock())) {
|
|
if (Objects.equals(monthOrder.getPayStatus(), 1) || Boolean.TRUE.equals(monthOrder.getConfirmStatus()) || Boolean.TRUE.equals(monthOrder.getIsLock())) {
|
|
|
DailyExpensesDO dailyExpenses = buildTempOutDailyExpense(elderId, tenantId, monthOrder.getBillOrderNumber(),
|
|
DailyExpensesDO dailyExpenses = buildTempOutDailyExpense(elderId, tenantId, monthOrder.getBillOrderNumber(),
|
|
|
- item, dayPrice, refundAmount, refundDays, outDate, monthEnd, billingMonth);
|
|
|
|
|
|
|
+ item, dayPrice, refundAmount, refundDays, outDate, monthEnd, currentBillingMonth);
|
|
|
dailyExpensesMapper.insert(dailyExpenses);
|
|
dailyExpensesMapper.insert(dailyExpenses);
|
|
|
|
|
|
|
|
ExpenseOrderItemDO orderItem = new ExpenseOrderItemDO();
|
|
ExpenseOrderItemDO orderItem = new ExpenseOrderItemDO();
|
|
@@ -470,6 +482,7 @@ public class ElderlyTempOutServiceImpl implements ElderlyTempOutService {
|
|
|
}
|
|
}
|
|
|
ElderlyRetreatRecordDO retreatRecordDO = elderlyRetreatRecordMapper.selectOne(new LambdaQueryWrapperX<ElderlyRetreatRecordDO>()
|
|
ElderlyRetreatRecordDO retreatRecordDO = elderlyRetreatRecordMapper.selectOne(new LambdaQueryWrapperX<ElderlyRetreatRecordDO>()
|
|
|
.eq(ElderlyRetreatRecordDO::getElderlyId, elderId)
|
|
.eq(ElderlyRetreatRecordDO::getElderlyId, elderId)
|
|
|
|
|
+ .eq(ElderlyRetreatRecordDO::getApplyType,1)
|
|
|
.orderByDesc(ElderlyRetreatRecordDO::getId)
|
|
.orderByDesc(ElderlyRetreatRecordDO::getId)
|
|
|
.last("LIMIT 1"));
|
|
.last("LIMIT 1"));
|
|
|
if (retreatRecordDO == null) {
|
|
if (retreatRecordDO == null) {
|