| @@ -56,39 +56,14 @@ public class WxRentContractController extends BaseController { | |||
| WxBillRentMapper wxBillRentMapper; | |||
| @Autowired | |||
| WxBillPropertyMapper wxBillPropertyMapper; | |||
| @Autowired | |||
| private WxBillActionMapper wxBillActionMapper; | |||
| @Autowired | |||
| private WxBillPropertyService wxBillPropertyService; | |||
| @GetMapping("autolatePay") | |||
| @SystemControllerLog(description = "autolatePay") | |||
| public ResultData autolatePay(String startDate, String endDate) throws Exception{ | |||
| try { | |||
| logger.info("账单滞纳金更新开始"); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| List<WxBillRent> billRentList = wxBillRentService.findLatePayBill(); | |||
| for (WxBillRent wxBillRent : billRentList) { | |||
| WxBillAction billAction = new WxBillAction(); | |||
| billAction.setId(idWorker.nextId()); | |||
| billAction.setUserName("系统端"); | |||
| billAction.setAction(EnumBillAction.UPDATE_LATE_PAY_MONEY.getCode()); | |||
| billAction.setBillId(wxBillRent.getId()); | |||
| BigDecimal divide = new BigDecimal(wxBillRent.getOwe()).multiply(new BigDecimal(wxBillRent.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); | |||
| billAction.setDetails("系统计入"+ divide.toString()+"元"); | |||
| wxBillActionMapper.insertSelective(billAction); | |||
| } | |||
| List<WxBillProperty> billPropertyList = wxBillPropertyService.findLatePayBill(); | |||
| for (WxBillProperty wxBillRent : billPropertyList) { | |||
| WxBillAction billAction = new WxBillAction(); | |||
| billAction.setId(idWorker.nextId()); | |||
| billAction.setUserName("系统端"); | |||
| billAction.setAction(EnumBillAction.UPDATE_LATE_PAY_MONEY.getCode()); | |||
| billAction.setBillId(wxBillRent.getId()); | |||
| BigDecimal divide = new BigDecimal(wxBillRent.getOwe()).multiply(new BigDecimal(wxBillRent.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); | |||
| billAction.setDetails("系统计入"+ divide.toString()+"元"); | |||
| wxBillActionMapper.insertSelective(billAction); | |||
| } | |||
| wxBillRentMapper.insertBillAction(); | |||
| wxBillPropertyMapper.insertBillAction(); | |||
| wxBillRentMapper.autoAddLatePayPrice(); | |||
| wxBillPropertyMapper.autoAddLatePayPrice(); | |||
| logger.info("账单滞纳金更新结束"); | |||
| @@ -0,0 +1,2 @@ | |||
| alter table wx_rent_contract modify `late_pay_day` INT(10) DEFAULT 0; | |||
| alter table wx_property_contract modify `late_pay_day` INT(10) DEFAULT 0; | |||
| @@ -106,8 +106,7 @@ public class WxCouponChannelController extends BaseController { | |||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||
| wxCouponChannel.setCouponStatus(EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()); | |||
| wxCouponChannel.setSortColumns(BaseEntity.SortField.UpdateDate_DESC, BaseEntity.SortField.Id_DESC); | |||
| WxCouponChannelVo vo = wxCouponChannelService.change(wxCouponChannel); | |||
| return new ResultData(vo); | |||
| return wxCouponChannelService.change(wxCouponChannel); | |||
| } | |||
| @@ -1,22 +1,12 @@ | |||
| package com.iformall.schedule; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.WxBillAction; | |||
| 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; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.scheduling.annotation.Scheduled; | |||
| import org.springframework.stereotype.Component; | |||
| import java.math.BigDecimal; | |||
| import java.util.List; | |||
| /** | |||
| * @author luozukai | |||
| @@ -24,13 +14,6 @@ import java.util.List; | |||
| @Component | |||
| public class LatePayBillActionSchedule { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxBillRentService wxBillRentService; | |||
| @Autowired | |||
| private WxBillPropertyService wxBillPropertyService; | |||
| @Autowired | |||
| private WxBillActionMapper wxBillActionMapper; | |||
| @Autowired | |||
| private WxBillRentMapper wxBillRentMapper; | |||
| @Autowired | |||
| @@ -42,30 +25,9 @@ public class LatePayBillActionSchedule { | |||
| public void updateBillStatus() { | |||
| try { | |||
| logger.info("账单滞纳金更新开始"); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| List<WxBillRent> billRentList = wxBillRentService.findLatePayBill(); | |||
| for (WxBillRent wxBillRent : billRentList) { | |||
| WxBillAction billAction = new WxBillAction(); | |||
| billAction.setId(idWorker.nextId()); | |||
| billAction.setUserName("系统端"); | |||
| billAction.setAction(EnumBillAction.UPDATE_LATE_PAY_MONEY.getCode()); | |||
| billAction.setBillId(wxBillRent.getId()); | |||
| BigDecimal divide = new BigDecimal(wxBillRent.getOwe()).multiply(new BigDecimal(wxBillRent.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); | |||
| billAction.setDetails("系统计入"+ divide.toString()+"元"); | |||
| wxBillActionMapper.insertSelective(billAction); | |||
| } | |||
| wxBillRentMapper.insertBillAction(); | |||
| wxBillPropertyMapper.insertBillAction(); | |||
| List<WxBillProperty> billPropertyList = wxBillPropertyService.findLatePayBill(); | |||
| for (WxBillProperty wxBillRent : billPropertyList) { | |||
| WxBillAction billAction = new WxBillAction(); | |||
| billAction.setId(idWorker.nextId()); | |||
| billAction.setUserName("系统端"); | |||
| billAction.setAction(EnumBillAction.UPDATE_LATE_PAY_MONEY.getCode()); | |||
| billAction.setBillId(wxBillRent.getId()); | |||
| BigDecimal divide = new BigDecimal(wxBillRent.getOwe()).multiply(new BigDecimal(wxBillRent.getLatePayRatio())).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_HALF_UP); | |||
| billAction.setDetails("系统计入"+ divide.toString()+"元"); | |||
| wxBillActionMapper.insertSelective(billAction); | |||
| } | |||
| wxBillRentMapper.autoAddLatePayPrice(); | |||
| wxBillPropertyMapper.autoAddLatePayPrice(); | |||
| logger.info("账单滞纳金更新结束"); | |||
| @@ -40,6 +40,7 @@ public class WxScoreRules extends BaseEntity { | |||
| " {\"businessId\":8,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":9,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":10,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":11,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":6,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}" + | |||
| "]}," + | |||
| "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + | |||
| @@ -62,6 +63,7 @@ public class WxScoreRules extends BaseEntity { | |||
| " {\"businessId\":8,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":9,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":10,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":11,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":6,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}" + | |||
| "]}," + | |||
| "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + | |||
| @@ -52,4 +52,9 @@ public interface WxBillPropertyMapper extends CommonMapper<WxBillProperty, Long> | |||
| * 累加每一天的滞纳金 | |||
| */ | |||
| void autoAddLatePayPrice(); | |||
| /** | |||
| * 保存billAction | |||
| */ | |||
| void insertBillAction(); | |||
| } | |||
| @@ -49,4 +49,9 @@ public interface WxBillRentMapper extends CommonMapper<WxBillRent, Long> { | |||
| * 累加每一天的滞纳金 | |||
| */ | |||
| void autoAddLatePayPrice(); | |||
| /** | |||
| * 保存billAction | |||
| */ | |||
| void insertBillAction(); | |||
| } | |||
| @@ -70,6 +70,6 @@ public interface WxCouponChannelService { | |||
| void updateStatusByCouponId(Long couponId,String tenantId,int status); | |||
| WxCouponChannelVo change(WxCouponChannel wxCouponChannel); | |||
| ResultData change(WxCouponChannel wxCouponChannel); | |||
| } | |||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| @@ -138,7 +139,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| } | |||
| @Override | |||
| public WxCouponChannelVo change(WxCouponChannel record) { | |||
| public ResultData change(WxCouponChannel record) { | |||
| Long couponId = 0L; | |||
| if (record.getCouponId() != null) { | |||
| couponId = record.getCouponId(); | |||
| @@ -146,10 +147,13 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| } | |||
| List<WxCouponChannelVo> voList = wxCouponChannelMapper.findVoList(record); | |||
| if (voList.isEmpty()) { | |||
| return null; | |||
| return new ResultData(Result.SUCCESS, "查询成功", null); | |||
| } | |||
| Map<String, Object> data = new HashMap<>(); | |||
| if (voList.size() == 1) { | |||
| return voList.get(0); | |||
| data.put("size", 1); | |||
| data.put("data", voList.get(0)); | |||
| return new ResultData(Result.SUCCESS, "查询成功", data); | |||
| } | |||
| Long finalCouponId = couponId; | |||
| voList = voList.stream() | |||
| @@ -157,7 +161,9 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| .collect(Collectors.toList()); | |||
| int size = voList.size(); | |||
| Random random = new Random(); | |||
| return voList.get(random.nextInt(size)); | |||
| data.put("size", size); | |||
| data.put("data", voList.get(random.nextInt(size))); | |||
| return new ResultData(Result.SUCCESS, "查询成功", data); | |||
| } | |||
| private boolean isCouponMerchantValid(Long couponId) { | |||
| @@ -1000,6 +1000,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| return shopInfoStr; | |||
| } | |||
| public Map<String, Object> buildRent(int receivePeriod, long[] priceArrs, List<Date> yearList, int dayType, WxRentContract wxRentContract, Long userId, int billcount, Integer isPreview, String shopInfoStr,boolean saveDb) { | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Map<String,Object> resultMap = new HashedMap(); | |||
| @@ -1050,8 +1051,12 @@ public class WxRentContractServiceImpl implements WxRentContractService { | |||
| if(sd.format(billTimeVo.getStartDate()).equals(sd.format(billTimeVo.getEndDate()))){ | |||
| needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb); | |||
| }else{ | |||
| needpayFront = getNeedPayMoney(wxRentContract,priceArrs[index-1],billTimeVo.getStartDate(),endDate,i,billTimeVoList.size(),saveDb); | |||
| needpayAfter = getNeedPayMoney(wxRentContract,priceArrs[index],endDate,billTimeVo.getEndDate(),i,billTimeVoList.size(),saveDb); | |||
| if(billTimeVo.getStartDate().before(endDate)){ | |||
| needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index - 1], billTimeVo.getStartDate(), endDate, i, billTimeVoList.size(), saveDb); | |||
| needpayAfter = getNeedPayMoney(wxRentContract, priceArrs[index], endDate, billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb); | |||
| }else{ | |||
| needpayFront = getNeedPayMoney(wxRentContract, priceArrs[index], billTimeVo.getStartDate(), billTimeVo.getEndDate(), i, billTimeVoList.size(), saveDb); | |||
| } | |||
| } | |||
| needpay = needpayFront+needpayAfter; | |||
| flag = true; | |||
| @@ -139,9 +139,9 @@ | |||
| <update id="updateNotPaidStatus" parameterType="hashmap"> | |||
| update wx_bill_property b set b.status=#{notPaid},b.expired_day= | |||
| DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`property_contract_id`) day)) | |||
| DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_property_contract where id = b.`property_contract_id`) day)) | |||
| where b.tenant_id=#{tenantId} and b.status!=#{paid} and b.status!=6 and | |||
| DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`property_contract_id`) day)) >0 | |||
| 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> | |||
| <update id="updateWaitPayStatus" parameterType="hashmap"> | |||
| @@ -226,17 +226,41 @@ | |||
| AND date_format(starttime,'%Y-%m-%d 00:00:00.0') = #{starttime} AND date_format(endtime,'%Y-%m-%d 00:00:00.0') = #{endtime} | |||
| </select> | |||
| <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) | |||
| <update id="insertBillAction"> | |||
| insert into wx_bill_action(id,user_name,`action`,bill_id,details) | |||
| select | |||
| (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id | |||
| ,'系统端' user_name,7 `action`,b.id bill_id, | |||
| CONCAT('系统计入', | |||
| if(b.late_pay_price is null, | |||
| round( | |||
| b.owe * c.late_pay_ratio * DATEDIFF(now(), date_add(b.receive_date,interval(c.late_pay_day) day)) /10000 | |||
| ,2) | |||
| , | |||
| round( | |||
| b.owe * (c.late_pay_ratio) /10000 | |||
| ,2) | |||
| ) | |||
| ,'元') details | |||
| from wx_bill_property b left join wx_property_contract c on(b.`property_contract_id`=c.id) | |||
| where c.late_pay_ratio >0 | |||
| and DATEDIFF(now(), date_add(r.receive_date,interval(c.late_pay_day) day)) >0 | |||
| </select> | |||
| and DATEDIFF(now(), date_add(b.receive_date,interval(c.late_pay_day) day)) >0 | |||
| and b.status!=3 and b.status!=6 | |||
| </update> | |||
| <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) | |||
| update wx_bill_property b set b.late_pay_price = | |||
| if(b.late_pay_price is null, | |||
| round( | |||
| b.owe * (select late_pay_ratio from wx_property_contract where id = b.`property_contract_id`) | |||
| * DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_property_contract where id = b.`property_contract_id`) day)) /100 | |||
| ,2) | |||
| , | |||
| b.late_pay_price + | |||
| round( | |||
| b.owe * (select late_pay_ratio from wx_property_contract where id = b.`property_contract_id`) /100 | |||
| ,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; | |||
| @@ -228,17 +228,41 @@ | |||
| AND date_format(starttime,'%Y-%m-%d 00:00:00.0') = #{starttime} AND date_format(endtime,'%Y-%m-%d 00:00:00.0') = #{endtime} | |||
| </select> | |||
| <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(), date_add(r.receive_date,interval(c.late_pay_day) day)) >0 | |||
| </select> | |||
| <update id="insertBillAction"> | |||
| insert into wx_bill_action(id,user_name,`action`,bill_id,details) | |||
| select | |||
| (select unix_timestamp(now()) + CEILING(RAND()*90000+10000)) id | |||
| ,'系统端' user_name,7 `action`,b.id bill_id, | |||
| CONCAT('系统计入', | |||
| if(b.late_pay_price is null, | |||
| round( | |||
| b.owe * c.late_pay_ratio * DATEDIFF(now(), date_add(b.receive_date,interval(c.late_pay_day) day)) /10000 | |||
| ,2) | |||
| , | |||
| round( | |||
| b.owe * (c.late_pay_ratio) /10000 | |||
| ,2) | |||
| ) | |||
| ,'元') details | |||
| from wx_bill_rent b left join wx_rent_contract c on(b.rent_contract_id=c.id) | |||
| where c.late_pay_ratio >0 | |||
| and DATEDIFF(now(), date_add(b.receive_date,interval(c.late_pay_day) day)) >0 | |||
| and b.status!=3 and b.status!=6 | |||
| </update> | |||
| <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) | |||
| update wx_bill_rent b set b.late_pay_price = | |||
| if(b.late_pay_price is null, | |||
| round( | |||
| b.owe * (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) | |||
| * DATEDIFF(now(), date_add(b.receive_date,interval(select late_pay_day from wx_rent_contract where id = b.`rent_contract_id`) day)) /100 | |||
| ,2) | |||
| , | |||
| b.late_pay_price + | |||
| round( | |||
| b.owe * (select late_pay_ratio from wx_rent_contract where id = b.`rent_contract_id`) /100 | |||
| ,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; | |||