| @@ -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("账单滞纳金更新结束"); | |||
| } | |||
| @@ -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, Long> | |||
| WxBillProperty selectBillOne(WxBillProperty propertyQuery); | |||
| List<WxBillProperty> findLatePayBill(); | |||
| /** | |||
| * 累加每一天的滞纳金 | |||
| */ | |||
| void autoAddLatePayPrice(); | |||
| } | |||
| @@ -44,4 +44,9 @@ public interface WxBillRentMapper extends CommonMapper<WxBillRent, Long> { | |||
| WxBillRent selectBillOne(WxBillRent rentQuery); | |||
| List<WxBillRent> findLatePayBill(); | |||
| /** | |||
| * 累加每一天的滞纳金 | |||
| */ | |||
| void autoAddLatePayPrice(); | |||
| } | |||
| @@ -57,20 +57,6 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { | |||
| PageHelper.startPage(pageIndex, pageSize); | |||
| List<WxBillProperty> billRentList = wxBillPropertyMapper.queryBillPropertyList(record); | |||
| PageInfo<WxBillProperty> 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<WxBillProperty> 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<WxBillProperty> pageInfo = new PageInfo<>(billRentList); | |||
| return pageInfo; | |||
| } | |||
| @@ -303,24 +261,6 @@ public class WxBillPropertyServiceImpl implements WxBillPropertyService { | |||
| String billName = wxBillProperty.getRentShopType().equals(EnumRentShopType.SHOP.getCode()) ? "商铺物业账单" : "多经点位物业账单"; | |||
| List<WxBillProperty> 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<Long, List<WxBillProperty>> collect = billPropertyList.parallelStream() | |||
| .collect(Collectors.groupingBy(WxBillProperty::getMerchantId)); | |||
| Set<Map.Entry<Long, List<WxBillProperty>>> entries = collect.entrySet(); | |||
| @@ -56,20 +56,20 @@ public class WxBillRentServiceImpl implements WxBillRentService { | |||
| public PageInfo<WxBillRent> listAsPage(WxBillRent record, Integer pageIndex, Integer pageSize) { | |||
| PageHelper.startPage(pageIndex, pageSize); | |||
| List<WxBillRent> 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<WxBillRent> 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<WxBillRent> 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<WxBillRent> 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<WxBillRent> 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<Long, List<WxBillRent>> collect = billRentList.parallelStream() | |||
| .collect(Collectors.groupingBy(WxBillRent::getMerchantId)); | |||
| Set<Map.Entry<Long, List<WxBillRent>>> entries = collect.entrySet(); | |||
| @@ -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 @@ | |||
| <select id="findLatePayBill" resultMap="BaseResultMap"> | |||
| select r.id,r.owe,c.late_pay_ratio from wx_bill_property r left join wx_property_contract c on(r.`property_contract_id`=c.id) | |||
| where c.late_pay_ratio >0 and DATEDIFF(now(),receive_date) >= if(c.late_pay_day=0,1,c.late_pay_day) | |||
| where c.late_pay_ratio >0 | |||
| and DATEDIFF(now(), date_add(r.receive_date,interval(c.late_pay_day) day)) >0 | |||
| </select> | |||
| <update id="autoAddLatePayPrice"> | |||
| 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; | |||
| </update> | |||
| </mapper> | |||
| @@ -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 @@ | |||
| <select id="findLatePayBill" resultMap="BaseResultMap"> | |||
| select r.id,r.owe,c.late_pay_ratio from wx_bill_rent r left join wx_rent_contract c on(r.`rent_contract_id`=c.id) | |||
| where c.late_pay_ratio >0 and | |||
| DATEDIFF(now(),receive_date) >= if(c.late_pay_day=0,1,c.late_pay_day) | |||
| DATEDIFF(now(), date_add(r.receive_date,interval(c.late_pay_day) day)) >0 | |||
| </select> | |||
| <update id="autoAddLatePayPrice"> | |||
| 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; | |||
| </update> | |||
| </mapper> | |||