demand: tms-客户账单管理-客户账单定制-批量生成账单时最后回款日算法调整 tms-客户账单管理-月结账单管理-修改账单时最后回款日算法调整
This commit is contained in:
parent
4ec6ef1a2d
commit
6d98cb17b6
@ -1608,6 +1608,63 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
|
||||
@Override
|
||||
public int updateEmisSettleBill(EmisSettleBill emisSettleBill)
|
||||
{
|
||||
// 如果修改了billMonth,需要重新计算最后回款日
|
||||
if (emisSettleBill.getId() != null && StringUtils.isNotEmpty(emisSettleBill.getBillMonth())) {
|
||||
EmisSettleBill oldBill = emisSettleBillMapper.selectEmisSettleBillById(emisSettleBill.getId());
|
||||
if (oldBill != null && !emisSettleBill.getBillMonth().equals(oldBill.getBillMonth())) {
|
||||
// billMonth发生变化,且是月结类型,需要重新计算最后回款日
|
||||
if ("2".equals(oldBill.getSettleType())) {
|
||||
EmisCustomerUser monthUser = getCustomerUserByMonthlyPayCode(oldBill.getCustNo());
|
||||
if (monthUser != null) {
|
||||
// 默认30天,从1号开始
|
||||
BigDecimal creditPeriod = BigDecimal.valueOf(30D);
|
||||
Integer settleDay = 1;
|
||||
|
||||
if (monthUser.getCreditPeriod() != null) {
|
||||
creditPeriod = monthUser.getCreditPeriod();
|
||||
}
|
||||
|
||||
if (monthUser.getSettleDay() != null) {
|
||||
settleDay = monthUser.getSettleDay();
|
||||
}
|
||||
|
||||
Date paymentDueDate = null;
|
||||
// 周结和半月结的特殊处理
|
||||
if (creditPeriod.intValue() == 7) {
|
||||
// // 获取今日零点 T+6,T为出账日
|
||||
// String currDayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date());
|
||||
// Date currDayDate = DateUtils.parseDate(currDayStr);
|
||||
// paymentDueDate = DateUtils.addDays(currDayDate, 7);
|
||||
} else if (creditPeriod.intValue() == 15) {
|
||||
// String currDayStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date());
|
||||
// Date currDayDate = DateUtils.parseDate(currDayStr);
|
||||
// paymentDueDate = DateUtils.addDays(currDayDate, 15);
|
||||
} else {
|
||||
Date billMonthDate = DateUtils.parseDate(emisSettleBill.getBillMonth() + "-" + settleDay);
|
||||
|
||||
// credit_period 为 30/60/90 且结算日为每月 1 号时,按对应月份月末作为最后付款日
|
||||
if ((creditPeriod.intValue() == 30 || creditPeriod.intValue() == 60 || creditPeriod.intValue() == 90)
|
||||
&& monthUser.getSettleDay() == 1) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(billMonthDate);
|
||||
// 30 -> 加 1 个月,60 -> 加 2 个月,90 -> 加 3 个月
|
||||
cal.add(Calendar.MONTH, creditPeriod.intValue() / 30);
|
||||
// 设置为该月的最后一天
|
||||
cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
paymentDueDate = cal.getTime();
|
||||
} else {
|
||||
paymentDueDate = DateUtils.addMonths(billMonthDate, 1);
|
||||
paymentDueDate = DateUtils.addDays(paymentDueDate, creditPeriod.intValue());
|
||||
}
|
||||
}
|
||||
|
||||
// 设置重新计算后的最后回款日
|
||||
emisSettleBill.setPaymentDueDate(paymentDueDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return emisSettleBillMapper.updateEmisSettleBill(emisSettleBill);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user