From 6bdcadb18519b3e2bed67a7fc09e0728d9d5d5ea Mon Sep 17 00:00:00 2001 From: luozukai Date: Thu, 1 Aug 2019 14:22:30 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=BB=9E=E7=BA=B3=E9=87=91][=E4=BF=AE?= =?UTF-8?q?=E6=94=B9][=E4=BF=AE=E6=94=B9=E6=BB=9E=E7=BA=B3=E9=87=91?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=B4=AF=E5=8A=A0=E9=80=BB=E8=BE=91]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/LatePayBillActionSchedule.java | 10 ++- .../iformall/mapper/WxBillPropertyMapper.java | 6 ++ .../com/iformall/mapper/WxBillRentMapper.java | 5 ++ .../impl/WxBillPropertyServiceImpl.java | 62 +-------------- .../service/impl/WxBillRentServiceImpl.java | 76 ++++--------------- .../resources/mapper/WxBillPropertyMapper.xml | 14 +++- .../resources/mapper/WxBillRentMapper.xml | 14 +++- 7 files changed, 60 insertions(+), 127 deletions(-) diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/LatePayBillActionSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/LatePayBillActionSchedule.java index 96025c06b..5be3ab989 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/LatePayBillActionSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/LatePayBillActionSchedule.java @@ -6,6 +6,8 @@ import com.iformall.domain.po.WxBillProperty; import com.iformall.domain.po.WxBillRent; import com.iformall.enums.EnumBillAction; import com.iformall.mapper.WxBillActionMapper; +import com.iformall.mapper.WxBillPropertyMapper; +import com.iformall.mapper.WxBillRentMapper; import com.iformall.service.WxBillPropertyService; import com.iformall.service.WxBillRentService; import org.slf4j.Logger; @@ -30,7 +32,10 @@ public class LatePayBillActionSchedule { private WxBillPropertyService wxBillPropertyService; @Autowired private WxBillActionMapper wxBillActionMapper; - + @Autowired + private WxBillRentMapper wxBillRentMapper; + @Autowired + private WxBillPropertyMapper wxBillPropertyMapper; /** * 每天凌晨1点执行 */ @@ -61,6 +66,9 @@ public class LatePayBillActionSchedule { billAction.setDetails("系统计入"+ divide.toString()+"元"); wxBillActionMapper.insertSelective(billAction); } + + wxBillRentMapper.autoAddLatePayPrice(); + wxBillPropertyMapper.autoAddLatePayPrice(); logger.info("账单滞纳金更新结束"); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java index d6d68c9fb..53ce3ae72 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillPropertyMapper.java @@ -2,6 +2,7 @@ package com.iformall.mapper; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxBillProperty; +import com.iformall.domain.po.WxBillRent; import com.iformall.domain.po.WxPropertyContract; import com.iformall.domain.po.WxRentContract; @@ -46,4 +47,9 @@ public interface WxBillPropertyMapper extends CommonMapper WxBillProperty selectBillOne(WxBillProperty propertyQuery); List findLatePayBill(); + + /** + * 累加每一天的滞纳金 + */ + void autoAddLatePayPrice(); } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java index f0bcf65b7..67f7bf2e4 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxBillRentMapper.java @@ -44,4 +44,9 @@ public interface WxBillRentMapper extends CommonMapper { WxBillRent selectBillOne(WxBillRent rentQuery); List findLatePayBill(); + + /** + * 累加每一天的滞纳金 + */ + void autoAddLatePayPrice(); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java index d5ecaf773..81474ccba 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillPropertyServiceImpl.java @@ -57,20 +57,6 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { PageHelper.startPage(pageIndex, pageSize); List billRentList = wxBillPropertyMapper.queryBillPropertyList(record); PageInfo pageInfo = new PageInfo<>(billRentList); - billRentList.stream().forEach(b -> { - if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ - int latePayDay = 0; //默认第次日开始交滞纳金 - if(b.getLatePayDay() != null){ - latePayDay = b.getLatePayDay(); - } - Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); - long dayCount = DateUtils.startToEnd(startPay,new Date()); - if(dayCount >0) { - BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - b.setLatePayPrice(divide.longValue()); - } - } - }); return pageInfo; } @@ -118,21 +104,7 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { public WxBillProperty getById(Long id) { WxBillProperty record = new WxBillProperty(); record.setId(id); - WxBillProperty b = wxBillPropertyMapper.queryBillPropertyList(record).get(0); - - if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ - int latePayDay = 0; //默认第次日开始交滞纳金 - if(b.getLatePayDay() != null){ - latePayDay = b.getLatePayDay(); - } - Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); - long dayCount = DateUtils.startToEnd(startPay,new Date()); - if(dayCount >0) { - BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - b.setLatePayPrice(divide.longValue()); - } - } - return b; + return wxBillPropertyMapper.queryBillPropertyList(record).get(0); } @Override @@ -228,20 +200,6 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { updateBillStatus(record); PageHelper.startPage(pageIndex, pageSize); List billRentList = wxBillPropertyMapper.queryBillPropertyList(record); - billRentList.stream().forEach(b -> { - if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ - int latePayDay = 0; //默认第次日开始交滞纳金 - if(b.getLatePayDay() != null){ - latePayDay = b.getLatePayDay(); - } - Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); - long dayCount = DateUtils.startToEnd(startPay,new Date()); - if(dayCount >0) { - BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - b.setLatePayPrice(divide.longValue()); - } - } - }); PageInfo pageInfo = new PageInfo<>(billRentList); return pageInfo; } @@ -303,24 +261,6 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { String billName = wxBillProperty.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) ? "商铺物业账单" : "多经点位物业账单"; List billPropertyList = wxBillPropertyMapper.queryBillPropertyList(wxBillProperty); - billPropertyList.stream().forEach(b -> { - if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ - int latePayDay = 0; //默认第次日开始交滞纳金 - if(b.getLatePayDay() != null){ - latePayDay = b.getLatePayDay(); - } - Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); - long dayCount = DateUtils.startToEnd(startPay,new Date()); - if(dayCount >0) { - BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - b.setLatePayPrice(divide.longValue()); - } - } - if (b.getDepositStatus() == null) { - b.setDepositStatus(0); - } - }); - Map> collect = billPropertyList.parallelStream() .collect(Collectors.groupingBy(WxBillProperty::getMerchantId)); Set>> entries = collect.entrySet(); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java index f5ff51333..882ce8b44 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxBillRentServiceImpl.java @@ -56,20 +56,20 @@ public class WxBillRentServiceImpl implements WxBillRentService { public PageInfo listAsPage(WxBillRent record, Integer pageIndex, Integer pageSize) { PageHelper.startPage(pageIndex, pageSize); List billRentList = wxBillRentMapper.queryBillRentList(record); - billRentList.stream().forEach(b -> { - if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ - int latePayDay = 0; //默认第次日开始交滞纳金 - if(b.getLatePayDay() != null){ - latePayDay = b.getLatePayDay(); - } - Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); - long dayCount = DateUtils.startToEnd(startPay,new Date()); - if(dayCount >0) { - BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - b.setLatePayPrice(divide.longValue()); - } - } - }); +// billRentList.stream().forEach(b -> { +// if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ +// int latePayDay = 0; //默认第次日开始交滞纳金 +// if(b.getLatePayDay() != null){ +// latePayDay = b.getLatePayDay(); +// } +// Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); +// long dayCount = DateUtils.startToEnd(startPay,new Date()); +// if(dayCount >0) { +// BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).multiply(new BigDecimal(dayCount)).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP); +// b.setLatePayPrice(divide.longValue()); +// } +// } +// }); PageInfo pageInfo = new PageInfo<>(billRentList); return pageInfo; } @@ -118,21 +118,7 @@ public class WxBillRentServiceImpl implements WxBillRentService { public WxBillRent getById(Long id) { WxBillRent record = new WxBillRent(); record.setId(id); - WxBillRent b = wxBillRentMapper.queryBillRentList(record).get(0); - - if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ - int latePayDay = 0; //默认第次日开始交滞纳金 - if(b.getLatePayDay() != null){ - latePayDay = b.getLatePayDay(); - } - Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); - long dayCount = DateUtils.startToEnd(startPay,new Date()); - if(dayCount >0) { - BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - b.setLatePayPrice(divide.longValue()); - } - } - return b; + return wxBillRentMapper.queryBillRentList(record).get(0); } @Override @@ -227,20 +213,6 @@ public class WxBillRentServiceImpl implements WxBillRentService { updateBillStatus(record); PageHelper.startPage(pageIndex, pageSize); List billRentList = wxBillRentMapper.queryBillRentList(record); - billRentList.stream().forEach(b -> { - if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ - int latePayDay = 0; //默认第次日开始交滞纳金 - if(b.getLatePayDay() != null){ - latePayDay = b.getLatePayDay(); - } - Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); - long dayCount = DateUtils.startToEnd(startPay,new Date()); - if(dayCount >0) { - BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - b.setLatePayPrice(divide.longValue()); - } - } - }); PageInfo pageInfo = new PageInfo<>(billRentList); return pageInfo; } @@ -338,24 +310,6 @@ public class WxBillRentServiceImpl implements WxBillRentService { public void exportBill(HttpServletRequest request, HttpServletResponse response, WxBillRent wxBillRent) { String billName = wxBillRent.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) ? "商铺租金账单" : "多经点位租金账单"; List billRentList = wxBillRentMapper.queryBillRentList(wxBillRent); - billRentList.stream().forEach(b -> { - if(b.getLatePayRatio() != null && b.getLatePayRatio() > 0){ - int latePayDay = 0; //默认第次日开始交滞纳金 - if(b.getLatePayDay() != null){ - latePayDay = b.getLatePayDay(); - } - Date startPay = DateUtils.getDaySet(b.getReceiveDate(),Calendar.DATE,latePayDay); - long dayCount = DateUtils.startToEnd(startPay,new Date()); - if(dayCount >0) { - BigDecimal divide = new BigDecimal(b.getOwe()).multiply(new BigDecimal(b.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); - b.setLatePayPrice(divide.longValue()); - } - } - if (b.getDepositStatus() == null) { - b.setDepositStatus(0); - } - }); - Map> collect = billRentList.parallelStream() .collect(Collectors.groupingBy(WxBillRent::getMerchantId)); Set>> entries = collect.entrySet(); diff --git a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml index d88036f06..ca7195c3d 100644 --- a/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillPropertyMapper.xml @@ -92,7 +92,7 @@ select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`, case when br.status=1 then br.owe else 0 end owe,br.`status`,br.`need_pay`,m.`name` merchant_name,s.shop_number,br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,br.`period`, - br.`revenue`,br.`late_pay_ratio`,br.`late_pay_time`,br.`property_contract_id`,d.receive_pay deposit, + br.`revenue`,r.`late_pay_ratio`,br.`late_pay_time`,br.`property_contract_id`,d.receive_pay deposit, br.late_pay_price,d.`status` deposit_status,br.`shop_info`,br.pay_way,br.late_pay_status, br.`comments`,br.starttime,br.endtime, @@ -228,8 +228,18 @@ + + update wx_bill_property b set b.late_pay_price = b.late_pay_price + + round( + b.owe * (select late_pay_ratio from wx_property_contract where id = b.`property_contract_id`) /10000 + ,2) + where b.status!=3 and b.status!=6 + and (select late_pay_ratio from wx_property_contract where id = b.`property_contract_id`) > 0 + and DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_property_contract where id = b.`property_contract_id`) day)) >0; + diff --git a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml index cd5307bad..f3fc95312 100644 --- a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml @@ -96,7 +96,7 @@ select br.`id`,br.`receive_pay`,br.`pay`,br.`receive_date`,br.`pay_date`,br.`createtime`,br.`expired_day`, case when br.status=1 then br.owe else 0 end owe,br.`status`,br.`need_pay`,r.merchant_name, s.shop_number,br.`updatetime`,br.`merchant_id`,br.`rent_shop_type`,r.type as rent_type, - r.pay_ratio,br.`revenue`,br.`late_pay_ratio`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`, + r.pay_ratio,br.`revenue`,r.`late_pay_ratio`,br.`late_pay_time`,br.`period`,br.`rent_contract_id`, d.receive_pay deposit,d.`status` deposit_status,br.late_pay_price,br.shop_info,br.pay_way,br.late_pay_status,br.`comments`,br.starttime,br.endtime, r.late_pay_day,r.late_pay_ratio @@ -231,7 +231,17 @@ + + + update wx_bill_rent b set b.late_pay_price = b.late_pay_price + + round( + b.owe * (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) /10000 + ,2) + where b.status!=3 and b.status!=6 + and (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) > 0 + and DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`rent_contract_id`) day)) >0; +